On Fri, Feb 14, 2025 at 10:42:12AM -0500, Zi Yan wrote: > During page isolation, the original migratetype is overwritten, since > MIGRATE_* are enums. Change MIGRATE_ISOLATE to be a standalone bit like > PB_migrate_skip. pageblock bits needs to be word aligned, so expand > the number of pageblock bits from 4 to 8 and make migrate isolate bit 7. > > Signed-off-by: Zi Yan <ziy@xxxxxxxxxx> > --- > include/linux/mmzone.h | 18 +++++++++++++----- > include/linux/page-isolation.h | 2 +- > include/linux/pageblock-flags.h | 33 ++++++++++++++++++++++++++++++++- > mm/page_alloc.c | 21 +++++++++++++++++++-- > 4 files changed, 65 insertions(+), 9 deletions(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index 8aecbbb0b685..3c7d3f22ccb2 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -106,14 +106,22 @@ static inline bool migratetype_is_mergeable(int mt) > > extern int page_group_by_mobility_disabled; > > -#define MIGRATETYPE_MASK ((1UL << PB_migratetype_bits) - 1) > +#ifdef CONFIG_MEMORY_ISOLATION > +#define MIGRATETYPE_NO_ISO_MASK (BIT(PB_migratetype_bits) - 1) > +#define MIGRATETYPE_MASK (MIGRATETYPE_NO_ISO_MASK | PB_migrate_isolate_bit) > +#else > +#define MIGRATETYPE_NO_ISO_MASK (BIT(PB_migratetype_bits) - 1) > +#define MIGRATETYPE_MASK (BIT(PB_migratetype_bits) - 1) > +#endif There is no user of the NO_ISO_MASK until the last patch. Can you please defer introduction until then? > -#define get_pageblock_migratetype(page) \ > - get_pfnblock_flags_mask(page, page_to_pfn(page), MIGRATETYPE_MASK) > +#define get_pageblock_migratetype(page) \ > + get_pfnblock_flags_mask(page, page_to_pfn(page), \ > + MIGRATETYPE_MASK) > > -#define folio_migratetype(folio) \ > - get_pfnblock_flags_mask(&folio->page, folio_pfn(folio), \ > +#define folio_migratetype(folio) \ > + get_pfnblock_flags_mask(&folio->page, folio_pfn(folio), \ > MIGRATETYPE_MASK) That's a spurious change currently. I assume you tweaked the MIGRATETYPE_MASK parameter during development, but I can't see a functional difference now. > @@ -373,7 +374,13 @@ unsigned long get_pfnblock_flags_mask(const struct page *page, > * racy, are not corrupted. > */ > word = READ_ONCE(bitmap[word_bitidx]); > - return (word >> bitidx) & mask; > + flags = (word >> bitidx) & mask; > + > +#ifdef CONFIG_MEMORY_ISOLATION > + if (flags & PB_migrate_isolate_bit) > + return MIGRATE_ISOLATE; > +#endif > + return flags; > } > > static __always_inline int get_pfnblock_migratetype(const struct page *page, > @@ -397,8 +404,18 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags, > unsigned long bitidx, word_bitidx; > unsigned long word; > > +#ifdef CONFIG_MEMORY_ISOLATION > + BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 8); > + /* keep other migratetype bits if MIGRATE_ISOLATE is set */ > + if (flags == MIGRATE_ISOLATE) { > + mask &= ~((1UL << PB_migratetype_bits) - 1); > + flags = PB_migrate_isolate_bit; > + } Please change the callers in both cases to pass the appropriate masks of interest instead. That's likely a bit of churn in the allocator code, but adding caller specifics to this function violates abstraction layering rules.