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. > > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Cc: Christoph Lameter <cl@xxxxxxxxx> > Cc: Pekka Enberg <penberg@xxxxxxxxxx> > Cc: David Rientjes <rientjes@xxxxxxxxxx> > Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> > Cc: Vlastimil Babka <vbabka@xxxxxxx> > Cc: Roman Gushchin <roman.gushchin@xxxxxxxxx> > Cc: Naoya Horiguchi <naoya.horiguchi@xxxxxxx> > Cc: Miaohe Lin <linmiaohe@xxxxxxxxxx> > Cc: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> > Cc: Minchan Kim <minchan@xxxxxxxxxx> > Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> > Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> > Cc: Dan Williams <dan.j.williams@xxxxxxxxx> > Cc: Hugh Dickins <hughd@xxxxxxxxxx> > Cc: Muchun Song <songmuchun@xxxxxxxxxxxxx> > Cc: David Hildenbrand <david@xxxxxxxxxx> > Cc: Andrey Konovalov <andreyknvl@xxxxxxxxx> > Cc: Marco Elver <elver@xxxxxxxxxx> > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx> > --- > > I think this gives us two benefits: > - it frees a bit in flags field > - it makes it simpler to distinguish user-mapped pages and > not-user-mapped pages. > > Plus I'm writing a bit more of code including: > 0) a few cleanup for code that checks > !PageSlab() && page_mapped() or that does similar thing > 1) provide human-readale string of page_type in dump_page > 2) add show_page_types() for tracepoint > 3) fix hwpoison ...etc. > > Anyway This is an early RFC, I will very appreciate feedbacks! Looks like I forgot to add RFC in subject :)