From: Matthew Wilcox (Oracle) Date: Mon, 17 Mar 2025 17:38:19 +0000 (-0400) Subject: mm: Rename page->mapping to page->__folio_mapping X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fshrunk-page;p=users%2Fwilly%2Fpagecache.git mm: Rename page->mapping to page->__folio_mapping All users of page->mapping except page migration have been converted to not refer to it any more. Prevent new users from appearing (or at least make them easy to grep for). That lets us delete the TAIL_MAPPING poison as there's no way to see it any more. Signed-off-by: Matthew Wilcox (Oracle) --- diff --git a/include/linux/migrate.h b/include/linux/migrate.h index aaa2114498d6d..8f1261d0e75a8 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -138,7 +138,7 @@ const struct movable_operations *page_movable_ops(struct page *page) VM_BUG_ON(!__PageMovable(page)); return (const struct movable_operations *) - ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE); + ((unsigned long)page->__folio_mapping - PAGE_MAPPING_MOVABLE); } #ifdef CONFIG_NUMA_BALANCING diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 86db7fc40021e..3ed24519a16b5 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -106,7 +106,7 @@ struct page { }; }; /* See page-flags.h for PAGE_MAPPING_FLAGS */ - struct address_space *mapping; + struct address_space *__folio_mapping; union { pgoff_t __folio_index; /* Our offset within mapping. */ unsigned long share; /* share count for fsdax */ @@ -487,7 +487,7 @@ struct folio { static_assert(offsetof(struct page, pg) == offsetof(struct folio, fl)) FOLIO_MATCH(flags, flags); FOLIO_MATCH(lru, lru); -FOLIO_MATCH(mapping, mapping); +FOLIO_MATCH(__folio_mapping, mapping); FOLIO_MATCH(compound_head, lru); FOLIO_MATCH(__folio_index, index); FOLIO_MATCH(private, private); @@ -533,14 +533,14 @@ FOLIO_MATCH(compound_head, _head_3); * pgds. * @_pt_pad_1: Padding that aliases with page's compound head. * @pmd_huge_pte: Protected by ptdesc->ptl, used for THPs. - * @__page_mapping: Aliases with page->mapping. Unused for page tables. + * @__folio_mapping: Aliases with folio->mapping. Unused for page tables. * @pt_index: Used for s390 gmap. * @pt_mm: Used for x86 pgds. * @pt_frag_refcount: For fragmented page table tracking. Powerpc only. * @pt_share_count: Used for HugeTLB PMD page table share count. * @_pt_pad_2: Padding to ensure proper alignment. * @ptl: Lock for the page table. - * @__page_type: Same as page->page_type. Unused for page tables. + * @__page_type: Set to PGTY_table. Bottom 24 bits unused. * @__page_refcount: Same as page refcount. * @pt_memcg_data: Memcg data. Tracked for page tables here. * @@ -558,7 +558,7 @@ struct ptdesc { pgtable_t pmd_huge_pte; }; }; - unsigned long __page_mapping; + unsigned long __folio_mapping; union { pgoff_t pt_index; @@ -589,7 +589,7 @@ struct ptdesc { TABLE_MATCH(flags, __page_flags); TABLE_MATCH(compound_head, pt_list); TABLE_MATCH(compound_head, _pt_pad_1); -TABLE_MATCH(mapping, __page_mapping); +TABLE_MATCH(__folio_mapping, __folio_mapping); TABLE_MATCH(__folio_index, pt_index); TABLE_MATCH(rcu_head, pt_rcu_head); TABLE_MATCH(page_type, __page_type); diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 31d2575d178b5..2091f44bc5afe 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -740,7 +740,7 @@ static __always_inline bool __folio_test_movable(const struct folio *folio) static __always_inline bool __PageMovable(const struct page *page) { - return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) == + return ((unsigned long)page->__folio_mapping & PAGE_MAPPING_FLAGS) == PAGE_MAPPING_MOVABLE; } diff --git a/include/linux/poison.h b/include/linux/poison.h index 331a9a996fa87..c6682e38d1fc5 100644 --- a/include/linux/poison.h +++ b/include/linux/poison.h @@ -29,10 +29,6 @@ /********** mm/page_poison.c **********/ #define PAGE_POISON 0xaa -/********** mm/page_alloc.c ************/ - -#define TAIL_MAPPING ((void *) 0x400 + POISON_POINTER_DELTA) - /********** mm/slab.c **********/ /* * Magic nums for obj red zoning. diff --git a/include/trace/events/page_ref.h b/include/trace/events/page_ref.h index fe33a255b7d09..c14494d5cd3b5 100644 --- a/include/trace/events/page_ref.h +++ b/include/trace/events/page_ref.h @@ -31,7 +31,7 @@ DECLARE_EVENT_CLASS(page_ref_mod_template, __entry->flags = page->flags; __entry->count = page_ref_count(page); __entry->mapcount = atomic_read(&page->_mapcount); - __entry->mapping = page->mapping; + __entry->mapping = page->__folio_mapping; __entry->mt = get_pageblock_migratetype(page); __entry->val = v; ), @@ -80,7 +80,7 @@ DECLARE_EVENT_CLASS(page_ref_mod_and_test_template, __entry->flags = page->flags; __entry->count = page_ref_count(page); __entry->mapcount = atomic_read(&page->_mapcount); - __entry->mapping = page->mapping; + __entry->mapping = page->__folio_mapping; __entry->mt = get_pageblock_migratetype(page); __entry->val = v; __entry->ret = ret; diff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c index 1fec61603ef32..30e5d9e3769a7 100644 --- a/kernel/vmcore_info.c +++ b/kernel/vmcore_info.c @@ -171,7 +171,7 @@ static int __init crash_save_vmcoreinfo_init(void) VMCOREINFO_SIZE(nodemask_t); VMCOREINFO_OFFSET(page, flags); VMCOREINFO_OFFSET(page, _refcount); - VMCOREINFO_OFFSET(page, mapping); + VMCOREINFO_OFFSET(folio, mapping); VMCOREINFO_OFFSET(page, lru); VMCOREINFO_OFFSET(page, _mapcount); VMCOREINFO_OFFSET(page, private); diff --git a/mm/compaction.c b/mm/compaction.c index 4a2ccb82d0b27..b472aa9f8e541 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -133,7 +133,7 @@ void __SetPageMovable(struct page *page, const struct movable_operations *mops) { VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE((unsigned long)mops & PAGE_MAPPING_MOVABLE, page); - page->mapping = (void *)((unsigned long)mops | PAGE_MAPPING_MOVABLE); + page->__folio_mapping = (void *)((unsigned long)mops | PAGE_MAPPING_MOVABLE); } EXPORT_SYMBOL(__SetPageMovable); @@ -144,7 +144,7 @@ void __ClearPageMovable(struct page *page) * This page still has the type of a movable page, but it's * actually not movable any more. */ - page->mapping = (void *)PAGE_MAPPING_MOVABLE; + page->__folio_mapping = (void *)PAGE_MAPPING_MOVABLE; } EXPORT_SYMBOL(__ClearPageMovable); diff --git a/mm/internal.h b/mm/internal.h index 6869c8ceea348..52c64b19a501a 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -784,7 +784,6 @@ static inline void prep_compound_tail(struct page *head, int tail_idx) { struct page *p = head + tail_idx; - p->mapping = TAIL_MAPPING; set_compound_head(p, head); set_page_private(p, 0); } diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 3158afe7eb230..f3f900663e9a9 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -176,7 +176,7 @@ again: } /* FIXME support THP */ - if (!page || !page->mapping || PageTransCompound(page)) { + if (!page || !page->__folio_mapping || PageTransCompound(page)) { mpfn = 0; goto next; } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5c1a0f0cf26f7..37a6c0a241a48 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -892,7 +892,7 @@ static inline bool page_expected_state(struct page *page, if (unlikely(atomic_read(&page->_mapcount) != -1)) return false; - if (unlikely((unsigned long)page->mapping | + if (unlikely((unsigned long)page->__folio_mapping | page_ref_count(page) | #ifdef CONFIG_MEMCG page->memcg_data | @@ -912,7 +912,7 @@ static const char *page_bad_reason(struct page *page, unsigned long flags) if (unlikely(atomic_read(&page->_mapcount) != -1)) bad_reason = "nonzero mapcount"; - if (unlikely(page->mapping != NULL)) + if (unlikely(page->__folio_mapping != NULL)) bad_reason = "non-NULL mapping"; if (unlikely(page_ref_count(page) != 0)) bad_reason = "nonzero _refcount"; @@ -970,8 +970,7 @@ static int free_tail_page_prepare(struct page *head_page, struct page *page) goto out; } switch (page - head_page) { - case 1: - /* the first tail page: these may be in place of ->mapping */ + case 1: /* the first tail page */ if (unlikely(folio_large_mapcount(folio))) { bad_page(page, "nonzero large_mapcount"); goto out; @@ -1002,8 +1001,7 @@ static int free_tail_page_prepare(struct page *head_page, struct page *page) } } break; - case 2: - /* the second tail page: deferred_list overlaps ->mapping */ + case 2: /* the second tail page */ if (unlikely(!list_empty(&folio->_deferred_list))) { bad_page(page, "on deferred list"); goto out; @@ -1019,16 +1017,7 @@ static int free_tail_page_prepare(struct page *head_page, struct page *page) } } break; - case 3: - /* the third tail page: hugetlb specifics overlap ->mappings */ - if (IS_ENABLED(CONFIG_HUGETLB_PAGE)) - break; - fallthrough; default: - if (page->mapping != TAIL_MAPPING) { - bad_page(page, "corrupted mapping in tail page"); - goto out; - } break; } if (unlikely(!PageTail(page))) { @@ -1041,7 +1030,7 @@ static int free_tail_page_prepare(struct page *head_page, struct page *page) } ret = 0; out: - page->mapping = NULL; + page->__folio_mapping = NULL; clear_compound_head(page); return ret; } diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 506eec5d98fe1..fccb173da971e 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -50,7 +50,7 @@ struct zpdesc { ZPDESC_MATCH(flags, flags); ZPDESC_MATCH(lru, lru); -ZPDESC_MATCH(mapping, movable_ops); +ZPDESC_MATCH(__folio_mapping, movable_ops); ZPDESC_MATCH(__folio_index, next); ZPDESC_MATCH(__folio_index, handle); ZPDESC_MATCH(private, zspage); diff --git a/tools/include/linux/poison.h b/tools/include/linux/poison.h index e530e54046c9b..b4b804af8d43c 100644 --- a/tools/include/linux/poison.h +++ b/tools/include/linux/poison.h @@ -38,10 +38,6 @@ /********** mm/page_poison.c **********/ #define PAGE_POISON 0xaa -/********** mm/page_alloc.c ************/ - -#define TAIL_MAPPING ((void *) 0x400 + POISON_POINTER_DELTA) - /********** mm/slab.c **********/ /* * Magic nums for obj red zoning.