[RFC] Free up a page flag

From: Matthew Wilcox
Date: Wed Mar 09 2022 - 15:50:45 EST


We're always running out of page flags. Here's an attempt to free one
up for the next time somebody wants one.

It's based on the idea that neither PageReserved nor PageSlab need
(most) other flags in the flags word. So instead of encoding PG_slab and
PG_reserved as their own flags, we can use a magic flag (tentatively named
xyzzy because I suck at naming) to indicate that it's one of these two,
and then reuse some other flags to specify which one it is.

Here's patch 1/2 which just converts PG_slab. There should be another
one which converts PG_reserved, but it's a bit of work and I thought it
best to get feedback on this before spending more time on it.

It's "wrong" in a number of ways, including the fact that slab doesn't
actually need the atomic versions of Set and Clear; it always uses
__folio_set_slab() and __folio_clear_slab(), but I thought it was a good
idea to illustrate how one could do the atomic flag updates if necessary.
I'm tempted to say "Oh, you shouldn't", but PG_reserved is set in an
atomic manner today, even though it probably doesn't need to be.

I don't think there are any other existing flags that we can reclaim
using this technique, but maybe there are others who would love their
own flag that can be used in this manner.

It compiles, but I didn't boot it.