Re: make swappiness safer to use

Andrew Morton
2007-07-31T23:49:38Z

On Tue, 31 Jul 2007 16:32:06 -0700
Martin Bligh <mbligh@mbligh.org> wrote:

> > Anyway, we can say more if we see the patch (or, more accurately, the
> > analysis which comes with that patch).
>
> I must say, I don't see what's wrong with killing it and having it
> local. We're rotating the list all the time, IIRC ... so if we start
> off with only 1/2^12th of the list ... does it matter? we'll just
> crank it up higher fairly quickly. Not sure why we want to start
> with the same chunk size we did last time.

This scenario:

- a thread goes into shrink_active_list(), does scan, scan, scan, finding
only mapped pages.

- eventually, we reach a sufficiently high priority to flip into
reclaim-mapped mode.

- now, we quickly move SWAP_CLUSTER_MAX pages onto the inactive list, and
we're done.

So we scanned a few thousand pages, then moved 32-odd down to the inactive
list.

Now, someone else comes in and does some reclaim. It would be bad to scan
another few thousand pages and to then move 32-odd pages down to the
inactive list. Think what that pattern looks like: lumps of 32-pages with a
few thousand pages between them getting deactivated.

To fix this, we attempt to start scanning out in the state which it was
originally in: ie, the state which this caller to shrink_active_list()
would have discovered for himself _anyway_. After enough pages have been
pointlessly recirculated.

Can the current implemetnation make mistakes? Sure. But I'd suggest that
it will make far less than (thousands/32) mistakes.