How can I shrink the Linux page cache from within kernel space?

Albino B Neto bino at riseup.net
Sat Aug 29 08:30:04 EDT 2015


2015-08-11 8:25 GMT-03:00 David Sorber <david.sorber at gmail.com>:
> For example, on the last failure that I captured the page cache filled 27 GB
> of the 32 GB of RAM on my system. I suspected that the page cache "fullness"
> was causing dma_alloc_coherent calls to fail. To test this theory I manually
> emptied the page cache using:
>
> # echo 1 > /proc/sys/vm/drop_caches
>
> This dropped the size of the cache from 27 GB to 94 MB and I was able to
> allocate 20+ 1 GB DMA buffers with no issues.
>
> Clearly the page cache is a beneficial thing so I would prefer not to have
> to completely empty it every time I run out of space when allocating DMA
> buffers. My questions is this: how can I dynamically shrink the page cache
> in kernel space such that if a call to dma_alloc_coherent fails I can
> recover just enough space so that I can retry the call and have it succeed?

> Any assistance with this would be greatly appreciated!

The Linux memory management is not very good yet. Was researching more
about the file system BTRFS is better.

-- 
Albino B Neto
www.bino.us
"Debian. Freedom to code. Code to freedom!" faw



More information about the Kernelnewbies mailing list