Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: stop storing migration_ops in page->mapping

... instead, look them up statically based on the page type. Maybe in
the future we want a registration interface? At least for now, it can be
easily handled using the two page types that actually support page
migration.

The remaining usage of page->mapping is to flag such pages as actually
being movable (having movable_ops), which we will change next.

Link: https://lkml.kernel.org/r/20250704102524.326966-20-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Eugenio Pé rez <eperezma@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Gregory Price <gourry@gourry.net>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Jerrin Shaji George <jerrin.shaji-george@broadcom.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mathew Brost <matthew.brost@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: xu xin <xu.xin16@zte.com.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand and committed by
Andrew Morton
84caf988 457d7b3a

+35 -25
+1 -1
include/linux/balloon_compaction.h
··· 92 92 struct page *page) 93 93 { 94 94 __SetPageOffline(page); 95 - __SetPageMovable(page, &balloon_mops); 95 + __SetPageMovable(page); 96 96 set_page_private(page, (unsigned long)balloon); 97 97 list_add(&page->lru, &balloon->pages); 98 98 }
+2 -12
include/linux/migrate.h
··· 104 104 #endif /* CONFIG_MIGRATION */ 105 105 106 106 #ifdef CONFIG_COMPACTION 107 - void __SetPageMovable(struct page *page, const struct movable_operations *ops); 107 + void __SetPageMovable(struct page *page); 108 108 #else 109 - static inline void __SetPageMovable(struct page *page, 110 - const struct movable_operations *ops) 109 + static inline void __SetPageMovable(struct page *page) 111 110 { 112 111 } 113 112 #endif 114 - 115 - static inline 116 - const struct movable_operations *page_movable_ops(struct page *page) 117 - { 118 - VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); 119 - 120 - return (const struct movable_operations *) 121 - ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE); 122 - } 123 113 124 114 #ifdef CONFIG_NUMA_BALANCING 125 115 int migrate_misplaced_folio_prepare(struct folio *folio,
+2
include/linux/zsmalloc.h
··· 46 46 void zs_obj_write(struct zs_pool *pool, unsigned long handle, 47 47 void *handle_mem, size_t mem_len); 48 48 49 + extern const struct movable_operations zsmalloc_mops; 50 + 49 51 #endif
-1
mm/balloon_compaction.c
··· 253 253 .isolate_page = balloon_page_isolate, 254 254 .putback_page = balloon_page_putback, 255 255 }; 256 - EXPORT_SYMBOL_GPL(balloon_mops); 257 256 258 257 #endif /* CONFIG_BALLOON_COMPACTION */
+2 -3
mm/compaction.c
··· 114 114 } 115 115 116 116 #ifdef CONFIG_COMPACTION 117 - void __SetPageMovable(struct page *page, const struct movable_operations *mops) 117 + void __SetPageMovable(struct page *page) 118 118 { 119 119 VM_BUG_ON_PAGE(!PageLocked(page), page); 120 - VM_BUG_ON_PAGE((unsigned long)mops & PAGE_MAPPING_MOVABLE, page); 121 - page->mapping = (void *)((unsigned long)mops | PAGE_MAPPING_MOVABLE); 120 + page->mapping = (void *)(PAGE_MAPPING_MOVABLE); 122 121 } 123 122 EXPORT_SYMBOL(__SetPageMovable); 124 123
+23
mm/migrate.c
··· 43 43 #include <linux/sched/sysctl.h> 44 44 #include <linux/memory-tiers.h> 45 45 #include <linux/pagewalk.h> 46 + #include <linux/balloon_compaction.h> 47 + #include <linux/zsmalloc.h> 46 48 47 49 #include <asm/tlbflush.h> 48 50 ··· 52 50 53 51 #include "internal.h" 54 52 #include "swap.h" 53 + 54 + static const struct movable_operations *page_movable_ops(struct page *page) 55 + { 56 + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); 57 + 58 + /* 59 + * If we enable page migration for a page of a certain type by marking 60 + * it as movable, the page type must be sticky until the page gets freed 61 + * back to the buddy. 62 + */ 63 + #ifdef CONFIG_BALLOON_COMPACTION 64 + if (PageOffline(page)) 65 + /* Only balloon compaction sets PageOffline pages movable. */ 66 + return &balloon_mops; 67 + #endif /* CONFIG_BALLOON_COMPACTION */ 68 + #if defined(CONFIG_ZSMALLOC) && defined(CONFIG_COMPACTION) 69 + if (PageZsmalloc(page)) 70 + return &zsmalloc_mops; 71 + #endif /* defined(CONFIG_ZSMALLOC) && defined(CONFIG_COMPACTION) */ 72 + return NULL; 73 + } 55 74 56 75 /** 57 76 * isolate_movable_ops_page - isolate a movable_ops page for migration
+2 -3
mm/zpdesc.h
··· 152 152 return page_zpdesc(pfn_to_page(pfn)); 153 153 } 154 154 155 - static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, 156 - const struct movable_operations *mops) 155 + static inline void __zpdesc_set_movable(struct zpdesc *zpdesc) 157 156 { 158 - __SetPageMovable(zpdesc_page(zpdesc), mops); 157 + __SetPageMovable(zpdesc_page(zpdesc)); 159 158 } 160 159 161 160 static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc)
+3 -5
mm/zsmalloc.c
··· 1685 1685 1686 1686 #ifdef CONFIG_COMPACTION 1687 1687 1688 - static const struct movable_operations zsmalloc_mops; 1689 - 1690 1688 static void replace_sub_page(struct size_class *class, struct zspage *zspage, 1691 1689 struct zpdesc *newzpdesc, struct zpdesc *oldzpdesc) 1692 1690 { ··· 1707 1709 set_first_obj_offset(newzpdesc, first_obj_offset); 1708 1710 if (unlikely(ZsHugePage(zspage))) 1709 1711 newzpdesc->handle = oldzpdesc->handle; 1710 - __zpdesc_set_movable(newzpdesc, &zsmalloc_mops); 1712 + __zpdesc_set_movable(newzpdesc); 1711 1713 } 1712 1714 1713 1715 static bool zs_page_isolate(struct page *page, isolate_mode_t mode) ··· 1817 1819 { 1818 1820 } 1819 1821 1820 - static const struct movable_operations zsmalloc_mops = { 1822 + const struct movable_operations zsmalloc_mops = { 1821 1823 .isolate_page = zs_page_isolate, 1822 1824 .migrate_page = zs_page_migrate, 1823 1825 .putback_page = zs_page_putback, ··· 1880 1882 1881 1883 do { 1882 1884 WARN_ON(!zpdesc_trylock(zpdesc)); 1883 - __zpdesc_set_movable(zpdesc, &zsmalloc_mops); 1885 + __zpdesc_set_movable(zpdesc); 1884 1886 zpdesc_unlock(zpdesc); 1885 1887 } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); 1886 1888 }