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/migration: remove PageMovable()

Previously, if __ClearPageMovable() were invoked on a page, this would
cause __PageMovable() to return false, but due to the continued existence
of page movable ops, PageMovable() would have returned true.

With __ClearPageMovable() gone, the two are exactly equivalent.

So we can replace PageMovable() checks by __PageMovable(). In fact,
__PageMovable() cannot change until a page is freed, so we can turn some
PageMovable() into sanity checks for __PageMovable().

Link: https://lkml.kernel.org/r/20250704102524.326966-16-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
22d103ae 34727dee

+10 -25
-2
include/linux/migrate.h
··· 104 104 #endif /* CONFIG_MIGRATION */ 105 105 106 106 #ifdef CONFIG_COMPACTION 107 - bool PageMovable(struct page *page); 108 107 void __SetPageMovable(struct page *page, const struct movable_operations *ops); 109 108 #else 110 - static inline bool PageMovable(struct page *page) { return false; } 111 109 static inline void __SetPageMovable(struct page *page, 112 110 const struct movable_operations *ops) 113 111 {
-15
mm/compaction.c
··· 114 114 } 115 115 116 116 #ifdef CONFIG_COMPACTION 117 - bool PageMovable(struct page *page) 118 - { 119 - const struct movable_operations *mops; 120 - 121 - VM_BUG_ON_PAGE(!PageLocked(page), page); 122 - if (!__PageMovable(page)) 123 - return false; 124 - 125 - mops = page_movable_ops(page); 126 - if (mops) 127 - return true; 128 - 129 - return false; 130 - } 131 - 132 117 void __SetPageMovable(struct page *page, const struct movable_operations *mops) 133 118 { 134 119 VM_BUG_ON_PAGE(!PageLocked(page), page);
+10 -8
mm/migrate.c
··· 87 87 goto out; 88 88 89 89 /* 90 - * Check movable flag before taking the page lock because 90 + * Check for movable_ops pages before taking the page lock because 91 91 * we use non-atomic bitops on newly allocated page flags so 92 92 * unconditionally grabbing the lock ruins page's owner side. 93 + * 94 + * Note that once a page has movable_ops, it will stay that way 95 + * until the page was freed. 93 96 */ 94 97 if (unlikely(!__PageMovable(page))) 95 98 goto out_putfolio; ··· 111 108 if (unlikely(!folio_trylock(folio))) 112 109 goto out_putfolio; 113 110 114 - if (!PageMovable(page) || PageIsolated(page)) 111 + VM_WARN_ON_ONCE_PAGE(!__PageMovable(page), page); 112 + if (PageIsolated(page)) 115 113 goto out_no_isolated; 116 114 117 115 mops = page_movable_ops(page); ··· 153 149 */ 154 150 struct folio *folio = page_folio(page); 155 151 152 + VM_WARN_ON_ONCE_PAGE(!__PageMovable(page), page); 156 153 VM_WARN_ON_ONCE_PAGE(!PageIsolated(page), page); 157 154 folio_lock(folio); 158 - /* If the page was released by it's owner, there is nothing to do. */ 159 - if (PageMovable(page)) 160 - page_movable_ops(page)->putback_page(page); 155 + page_movable_ops(page)->putback_page(page); 161 156 ClearPageIsolated(page); 162 157 folio_unlock(folio); 163 158 folio_put(folio); ··· 194 191 { 195 192 int rc = MIGRATEPAGE_SUCCESS; 196 193 194 + VM_WARN_ON_ONCE_PAGE(!__PageMovable(src), src); 197 195 VM_WARN_ON_ONCE_PAGE(!PageIsolated(src), src); 198 - /* If the page was released by it's owner, there is nothing to do. */ 199 - if (PageMovable(src)) 200 - rc = page_movable_ops(src)->migrate_page(dst, src, mode); 196 + rc = page_movable_ops(src)->migrate_page(dst, src, mode); 201 197 if (rc == MIGRATEPAGE_SUCCESS) 202 198 ClearPageIsolated(src); 203 199 return rc;