tech-userlevel archive

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

Re: poison mmap cache



On Tue, Aug 12, 2014 at 07:45:09PM -0400, James K. Lowden wrote:
> On Tue, 12 Aug 2014 12:15:38 +0930
> Brett Lymn <blymn%internode.on.net@localhost> wrote:
> 
> > > 
> > > Suggestions?  What would you do?  
> > > 
> > 
> > I would use msync(2) with the MS_INVALIDATE flag on your test file to
> > invalidate the cached pages.
> 
> Thanks, Brett.  I'm afraid that's a fine answer to the question I
> asked, instead of the one I should have asked....
> 
> Each test is a separate process, and tests are executed sequentially.
> My concern is that the kernel's pagemap cache (or whatever it's called)
> will still contain file pages from the input file when process N+1
> runs, and that the kernel will, rationally, take advantage of that
> fact to make mmap(2) as fast as possible.  
> 

I believe the pages are marked as invalid in the page cache which means
they will be pulled back in from disk on the next access.  I was using
MS_INVALIDATE on executable files, I had a small tool that would mmap
and invalidate the pages.  The next time the target executable file ran
the pages definitely came back from disk.  So, yes, if the pages are
shared then run N+1 would re-fetch the page.

-- 
Brett Lymn
Let go, or be dragged - Zen proverb.


Home | Main Index | Thread Index | Old Index