On Mon, Sep 19, 2022 at 09:57:08PM +0900, Hyeonggon Yoo wrote: > For now, only SLAB uses _mapcount field as a number of active objects in > a slab, and other slab allocators do not use it. As 16 bits are enough > for that, use remaining 16 bits of _mapcount as page_type even when > SLAB is used. And then move PG_slab flag to page_type! > > Note that page_type is always placed in upper 16 bits of _mapcount to > avoid confusing normal _mapcount as page_type. As underflow (actually > I mean, yeah, overflow) is not a concern anymore, use more lower bits > except bit zero. > > Add more folio helpers for PAGE_TYPE_OPS() not to break existing > slab implementations. > > Remove PG_slab check from PAGE_FLAGS_CHECK_AT_FREE. buddy will still > check if _mapcount is properly set at free. > > Exclude PG_slab from hwpoison and show_page_flags() for now. > > Note that with this patch, page_mapped() and folio_mapped() always return > false for slab page. > [...] Hi. a silly mistake: > > include/linux/mm_types.h | 22 +++++++-- > include/linux/page-flags.h | 83 ++++++++++++++++++++++++++-------- > include/trace/events/mmflags.h | 1 - > mm/memory-failure.c | 8 ---- > mm/slab.h | 11 ++++- > 5 files changed, 92 insertions(+), 33 deletions(-) > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index cf97f3884fda..4b217c6fbe1f 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -193,12 +193,24 @@ struct page { > atomic_t _mapcount; > > /* > - * If the page is neither PageSlab nor mappable to userspace, > - * the value stored here may help determine what this page > - * is used for. See page-flags.h for a list of page types > - * which are currently stored here. > + * If the page is not mappable to userspace, the value > + * stored here may help determine what this page is used for. > + * See page-flags.h for a list of page types which are currently > + * stored here. > */ > - unsigned int page_type; > + struct { > + /* > + * Always place page_type in > + * upper 16 bits of _mapcount > + */ > +#ifdef CPU_BIG_ENDIAN s/CPU_BIG_ENDIAN/CONFIG_CPU_BIG_ENDIAN/g > + __u16 page_type; > + __u16 active; > +#else > + __u16 active; > + __u16 page_type; > +#endif > + }; > }; > > /* Usage count. *DO NOT USE DIRECTLY*. See page_ref.h */ [...] > diff --git a/mm/slab.h b/mm/slab.h > index 985820b9069b..a5273e189265 100644 > --- a/mm/slab.h > +++ b/mm/slab.h > @@ -20,7 +20,16 @@ struct slab { > }; > struct rcu_head rcu_head; > }; > - unsigned int active; > + struct { > + /* always place page_type in upper 16 bits of _mapcount */ > +#ifdef CPU_BIG_ENDIAN same here. > + __u16 page_type; > + __u16 active; > +#else > + __u16 active; > + __u16 page_type; > +#endif > + }; > > #elif defined(CONFIG_SLUB) > > -- > 2.32.0 > -- Thanks, Hyeonggon