Re: [PATCH 02/10] slab: Rename slab->__page_flags to slab->flags

Matthew Wilcox
2025-06-09T12:45:58Z

On Mon, Jun 09, 2025 at 11:15:07AM +0900, Harry Yoo wrote:
> > +/**
> > + * enum slab_flags - How the slab flags bits are used.
> > + * @SL_locked: Is locked with slab_lock()
> > + *
> > + * The slab flags share space with the page flags but some bits have
> > + * different interpretations. The high bits are used for information
> > + * like zone/node/section.
> > + */
> > +enum slab_flags {
> > + SL_locked,
> > +};
>
> I think we need to make sure SL_locked use the same bit as PG_locked
> at least for now?
>
> I'm not sure what prevents the MM code from checking page flags on a slab
> and getting confused by the SL_locked bit is set.

The lock bit is actually used very differently between page lock and
slab lock. If there is any code inadvertently checking one when it's
looking for the other, it's already broken. I can't think of anywhere
which would look for it; we're pretty fastidious about checking for
is_slab() before going anywhere near the lock bit.

> Or the other way around—a slab might have a page flag (e.g., PG_head) set
> and mistakenly interpret it as SL_locked.

PG_head is a good one, but I don't think we're going to run into it
before we finish the page diet.