Messages in this thread | | | Date | Tue, 03 Apr 2007 12:55:36 -0400 | From | Rik van Riel <> | Subject | Re: missing madvise functionality |
| |
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. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |