kernel page caching questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks,

I'm developing a kernel module (sorry under nda till product release so
no code available) which is currently allocating ~6MB of buffers (3 x
2MB buffers) with pci_alloc_consistent for dma usage, it will be less
later on but for now the hardware requires this. Anyway the target
system has 256MB of ram and the problem is that our test program does a
lot of streaming of data, this causes the page cache to fill up pretty
much all available memory. This isn't really a problem until I make
changes to the module and I need to reload it. At which point despite it
freeing up all memory that had been allocated to the module, the kernel fails to be able to allocate enough memory to my module.

I have found several ways around this, first of all if I tell the kernel
to drop all cache with "echo 3 > /proc/sys/vm/drop_caches" then I can
now load my driver. Alternatively and this is the way that I now prefer
as it doesn't involve me doing anything each time I reload the driver, I have set the min_free_kbytes value to a rather excessively high value of 20MB which seems to work great.

Is this really the correct way to go about this though? I'd like to
avoid my application doing any caching at all, from looking over
previous discussions on LKML it seems that opening files with O_DIRECT
is not the correct way to do this and that using posix_fadvise would be
the correct way. The problem with posix_fadvise though is that from what I gather, the option which I should use, POSIX_FADV_NOREUSE is not implemented in Linux (see $kernel/mm/fadvise.c) and that the alternative POSIX_FADV_DONTNEED is less favourable. Are there any other alternatives or should I implement fadvise with _DONTNEED.

What I'm also wondering though, is if this is the correct way for linux
to behave, should it be prioritising page cache over requests for memory
allocations from drivers?

Philip Downer

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux