Re: A question about page aging in page frame reclaimation

Peter Zijlstra
2007-04-04T10:50:29Z

On Wed, 2007-04-04 at 18:33 +0800, Zhao Forrest wrote:
> Hi Riel,
>
> I'm studying the code of page frame reclaimation in 2.6 kernel. From
> my understanding, there should be kernel thread periodically scanning
> the active and inactive list and move the page frames between active
> and inactive list according to LRU rule.
>
> But I can't find the related code.....would you please point me to the
> code piece that implement this "page aging" functionality?
> Sorry for the stupid question, but I think I don't have a very strong
> code-reading ability.

There is no time related scanning; we only scan when we wake up kswapd
or in direct reclaim.

We wake kswapd when the free page count drops below the high watermark.
(look for callers of wakeup_kswapd()).

Direct reclaim is a per task reclaim, entered when the free page count
drops below the low watermark, this provides per task feedback when
under heavy pressure.

So reclaim is driven purely by page allocation.

The active -> inactive shuffling is a tad involved. But basically: we
scan the active list proportionally to its size to move active pages to
the inactive list, then scan the inactive list (proportional to its size
before the active->inactive move).

Pages on the inactive list that are referenced are moved to the active
list. Unreferenced pages in the active list are moved to the inactive
list. (Checking the reference bit also clears it).

And a gazillion exceptions and details...