Re: [patch 2/13] remove pages from the LRU in __free_pages_ok()

Linus Torvalds
2002-07-29T04:47:01Z

On Sun, 28 Jul 2002, Andrew Morton wrote:
>
> Problem is that the rmap VM doesn't perform swapout via pagetables.
> It performs it via the LRU.
>
> If someone is sleeping on a pagefault against a mmapped file, and a
> truncate happens meanwhile, that page comes back as an anonymous
> page. It's not on the LRU any more so it has become unswappable.

Note that there is nothing fundamentally wrong with keeping the anonymous
page on the LRU either.

Some of th e2.4.x kernels kept _all_ anonymous pages on the LRU. That
added a lot of LRU overhead, but there could be a fairly simple
workaround: don't add anon pages to the LRU normally, but if a LRU page is
turned into an anonymous page _and_ it is still mapped, keep it on the LRU
list as an anonymous page.

Then, when it is unmapped, the last unmapper (even if it isn't necessarily
the last count) removes it from the LRU list.

This wouldn't have worked in 2.4.x - because without rmap you can't know
whether a count comes from mapping or not. But with rmap you can know, and
you can also notice the "last unmapper" thing.

Linus