Re: missing madvise functionality

Rik van Riel
2007-04-03T16:55:42Z

Ulrich Drepper wrote:

> That's it. The current MADV_DONTNEED doesn't cut it because it zaps the
> pages, causing *all* future reuses to create page faults. This is what
> I guess happens in the mysql test case where the pages where unused and
> freed but then almost immediately reused. The page faults erased all
> the benefits of using one mprotect() call vs a pair of mmap()/mprotect()
> calls.

I already started looking into implementing this.

Basically:

1) on MADV_DONTNEED, mark pages clean, not accessed and move them
to some "dontneed" LRU list.

2) when the VM needs pages, the pages are first removed from that
list, before the VM goes elsewhere - or maybe we'll want to
balance this list with reclaim from the inactive list at some
point based on size, reuse rate, etc...?

3) if an application reuses a DONTNEED page before the VM reclaims
it, the accessed and dirty bits will get set by hardware

4) in the reclaiming of the DONTNEED pages we simply move accessed
pages back to the active list, instead of reclaiming them

5) if the system hsa lots of free memory, pages can go through
multiple free/malloc cycles while sitting on the "dontneed"
list, very lazily with no lock contention :)

What do you think?

--
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is. Each group
calls the other unpatriotic.