On Thu, Jul 11, 2024 at 09:03:51PM +0800, Yajun Deng wrote: > +++ b/include/linux/page-flags.h > @@ -691,7 +691,8 @@ static __always_inline bool PageMappingFlags(const struct page *page) > > static __always_inline bool folio_test_anon(const struct folio *folio) > { > - return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0; > + return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) == > + PAGE_MAPPING_ANON; > } This is wrong. KSM pages are supposed to return true for folio_test_anon(). I haven't looked any further at this patch, since the premise appears to wrong and you clearly haven't tested.