Re: 'disposable' dirty pages [was: Out Of Memory in v. 2.1]

Kenneth Albanowski (kjahds@kjahds.com)
Fri, 9 Oct 1998 12:50:03 -0400 (EDT)


On Fri, 9 Oct 1998, Jamie Lokier wrote:

> > As for the pixmap cache idea: I thought for a moment that there would be
> > race conditions, but since the first touch will clear the discardable
> > flag, this doesn't feel like a problem. Some non-zero data in the page
> > will be sufficient to recognize that the page is still present. The only
> > issue is whether a pixmap (or whatever) cache is any use if individual
> > pages can drop out.
>
> Sounds like that would need a VMA all its own, such that if the kernel
> discards any pages in the VMA it has to discard all of them (or
> optimally just the first one, etc.; all quite yucky).

Yes, uniformly yucky. It feels like disappearing 4K pages could be of use
in some contexts (places where either the cached data fits easily in a 4K
page, or the data is continuous, and 4K chunks can be recalculated as
needed.) but not especially easy to use -- and also not portable. Just
move over to an Alpha, and you're working with 8K pages all of a sudden...

Certainly it's possible to use these semantics with larger data sizes
(just keep a set of flags at the beginning of each page, and before
accessing the cached item, check every flag) but it becomes a real pain.
Some mechanism of linking discardable pages would be more useful.

A separate VMA seems like a bit more overhead then we should need...
Hmm... Contiguous discardability: if page X is discarded and has the
DISCARDABLE_CONTIGUOUS_PREV flag, then page X-1 must also be discarded if
it is discardable. The same for DISCARDABLE_CONTIGUOUS_NEXT, and page X+1.
Apply recursively (well, iteratively :-).

That makes the kernel get rid of the lot in one go, but the same thing has
to be applied in reverse during the touch-trap, so that all of the pages
in the block have their DISCARDABLE flags reset in the same manner.
Otherwise race-conditions abound.

What are we up to, three page flag bits and an O(n*epsilon) page fault
handler?

> Aging will still work as usual.
>
> Marking a page discardable doesn't make it any older, and it stays
> mapped -- touching is detected in the usual processor-specific way. So
> the mechanism is quite efficient in the case that the page is not
> discarded or when you repeatedly mark a page used but then touch it
> quite soon afterwards.

Yes, the only overhead is the extra (internal) trap to turn off the
discardable flag, and then the syscall to turn the bit back on (if you are
using the memory as a cache). That should be a miniscule overhead, though.

-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/