2008-12-03 17:30:08     pagecache issue

Document created by Aaronwu Employee on Aug 8, 2013
Version 1Show Document
  • View in full screen mode

2008-12-03 17:30:08     pagecache issue

Andrew Didsbury (UNITED KINGDOM)

Message: 66257   

 

Hi,

 

I'm having some problems writing software to access the available memory on my blackfin.  There is 32 MB on the 537 and I'm running 2008R1.5.

 

I've written a simple c++ test program which attempts to allocate 16MB in 128k chunks at 1 sec intervals. It always fails at around 14MB, either failing to alloc or being oom_killed.

 

I would have expected the Cached memory to have automatically shrunk to allow that memory to be used by my process? This does not happen.

 

Before I start /proc/meminfo reports

 

MemTotal:        29432 kB

MemFree:         15292 kB

Cached:           7388 kB

Active:           3644 kB

Inactive:         3744 kB

 

Is there any way to limit the amount of RAM used by the pagecache on this version of uclinux? I know previous versions could set limits in the kernel config or through pagecache_ratio but these features seem to have been removed from 2008R1.5 and the automatic management of the pagecache does not seem to be doing what I would expect it to.

 

Any help gratefully received!

 

Andrew

QuoteReplyEditDelete

 

 

2008-12-03 17:34:43     Re: pagecache issue

Mike Frysinger (UNITED STATES)

Message: 66258   

 

page cache is for file systems, not memory.  when you say "16MB in 128k chunks", are you talking about malloc() or reading/writing files ?

QuoteReplyEditDelete

 

 

2008-12-03 17:48:20     Re: pagecache issue

Andrew Didsbury (UNITED KINGDOM)

Message: 66259   

 

yes I am using malloc to allocate 16MB in 128k chunks.

 

I know this test program is not using the page cache, but I would have expected the amount of memory that the page cache uses to have automatically been reduced as the system ran out of memory.  All through the time my process was running the page cache reported the same output in /proc/meminfo

 

Cached:           7388 kB

SwapCached:          0 kB

Active:           3644 kB

Inactive:         3744 kB

SwapTotal:           0 kB

SwapFree:            0 kB

 

 

This is the behaviour that is described as automatic reaping in this post:

 

blackfin.uclinux.org/gf/project/uclinux-dist/forum/

 

Andrew

QuoteReplyEditDelete

 

 

2008-12-03 18:00:29     Re: pagecache issue

Mike Frysinger (UNITED STATES)

Message: 66260   

 

then page cache really wont help you.  the cached memory shown is not just for file systems ... it is any and all kernel caches.  many are simply not freeable.

 

look at /proc/buddyinfo and /proc/slabinfo to see how memory is being used.  128k is a pretty big contigious chunk, and you simply may not have 128 of those ...

QuoteReplyEditDelete

 

 

2008-12-03 18:12:35     Re: pagecache issue

Andrew Didsbury (UNITED KINGDOM)

Message: 66263   

 

Thanks Mike,

 

I see what you are saying about 128k being a fairly big chunk and I believe that allocation is failing because there isnt a big enough contiguous block to give me.

 

I suppose my question really is, why does linux not reclaim the Inactive portion of the page cache as the system runs out of memory?

 

If this is not what is meant to happen then how can I reduce the amount of RAM that the kernel is allowed to use for the page cache?

 

Andrew

QuoteReplyEditDelete

 

 

2008-12-03 18:19:45     Re: pagecache issue

Mike Frysinger (UNITED STATES)

Message: 66264   

 

"page cache" generally refers to the pages the VFS has cached for file systems.  and the system should be reclaiming those when possible.  but as i said, when you see "cache", it represents a lot of caches, not just the VFS which is what all the previous threads you've read are talking about.

 

look at /proc/slabinfo for all the fun caches in use.

QuoteReplyEditDelete

 

 

2008-12-03 18:58:56     Re: pagecache issue

Andrew Didsbury (UNITED KINGDOM)

Message: 66265   

 

My understanding has always been that "Cached" in /proc/meminfo refers to the page cache.  The Slab is reported seperately in meminfo under "Slab"

 

Andrew

Attachments

    Outcomes