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: rename __PageMovable() to page_has_movable_ops()

Let's make it clearer that we are talking about movable_ops pages.

While at it, convert a VM_BUG_ON to a VM_WARN_ON_ONCE_PAGE.

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

+20 -25
+1 -1
include/linux/migrate.h
··· 115 115 static inline 116 116 const struct movable_operations *page_movable_ops(struct page *page) 117 117 { 118 - VM_BUG_ON(!__PageMovable(page)); 118 + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); 119 119 120 120 return (const struct movable_operations *) 121 121 ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE);
+1 -1
include/linux/page-flags.h
··· 750 750 PAGE_MAPPING_MOVABLE; 751 751 } 752 752 753 - static __always_inline bool __PageMovable(const struct page *page) 753 + static __always_inline bool page_has_movable_ops(const struct page *page) 754 754 { 755 755 return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) == 756 756 PAGE_MAPPING_MOVABLE;
+2 -5
mm/compaction.c
··· 1056 1056 * Skip any other type of page 1057 1057 */ 1058 1058 if (!PageLRU(page)) { 1059 - /* 1060 - * __PageMovable can return false positive so we need 1061 - * to verify it under page_lock. 1062 - */ 1063 - if (unlikely(__PageMovable(page)) && 1059 + /* Isolation code will deal with any races. */ 1060 + if (unlikely(page_has_movable_ops(page)) && 1064 1061 !PageIsolated(page)) { 1065 1062 if (locked) { 1066 1063 unlock_page_lruvec_irqrestore(locked, flags);
+2 -2
mm/memory-failure.c
··· 1388 1388 if (PageSlab(page)) 1389 1389 return false; 1390 1390 1391 - /* Soft offline could migrate non-LRU movable pages */ 1392 - if ((flags & MF_SOFT_OFFLINE) && __PageMovable(page)) 1391 + /* Soft offline could migrate movable_ops pages */ 1392 + if ((flags & MF_SOFT_OFFLINE) && page_has_movable_ops(page)) 1393 1393 return true; 1394 1394 1395 1395 return PageLRU(page) || is_free_buddy_page(page);
+4 -6
mm/memory_hotplug.c
··· 1739 1739 1740 1740 #ifdef CONFIG_MEMORY_HOTREMOVE 1741 1741 /* 1742 - * Scan pfn range [start,end) to find movable/migratable pages (LRU pages, 1743 - * non-lru movable pages and hugepages). Will skip over most unmovable 1742 + * Scan pfn range [start,end) to find movable/migratable pages (LRU and 1743 + * hugetlb folio, movable_ops pages). Will skip over most unmovable 1744 1744 * pages (esp., pages that can be skipped when offlining), but bail out on 1745 1745 * definitely unmovable pages. 1746 1746 * ··· 1759 1759 struct folio *folio; 1760 1760 1761 1761 page = pfn_to_page(pfn); 1762 - if (PageLRU(page)) 1763 - goto found; 1764 - if (__PageMovable(page)) 1762 + if (PageLRU(page) || page_has_movable_ops(page)) 1765 1763 goto found; 1766 1764 1767 1765 /* 1768 - * PageOffline() pages that are not marked __PageMovable() and 1766 + * PageOffline() pages that do not have movable_ops and 1769 1767 * have a reference count > 0 (after MEM_GOING_OFFLINE) are 1770 1768 * definitely unmovable. If their reference count would be 0, 1771 1769 * they could at least be skipped when offlining memory.
+4 -4
mm/migrate.c
··· 94 94 * Note that once a page has movable_ops, it will stay that way 95 95 * until the page was freed. 96 96 */ 97 - if (unlikely(!__PageMovable(page))) 97 + if (unlikely(!page_has_movable_ops(page))) 98 98 goto out_putfolio; 99 99 100 100 /* ··· 111 111 if (unlikely(!folio_trylock(folio))) 112 112 goto out_putfolio; 113 113 114 - VM_WARN_ON_ONCE_PAGE(!__PageMovable(page), page); 114 + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); 115 115 if (PageIsolated(page)) 116 116 goto out_no_isolated; 117 117 ··· 153 153 */ 154 154 struct folio *folio = page_folio(page); 155 155 156 - VM_WARN_ON_ONCE_PAGE(!__PageMovable(page), page); 156 + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); 157 157 VM_WARN_ON_ONCE_PAGE(!PageIsolated(page), page); 158 158 folio_lock(folio); 159 159 page_movable_ops(page)->putback_page(page); ··· 194 194 { 195 195 int rc = MIGRATEPAGE_SUCCESS; 196 196 197 - VM_WARN_ON_ONCE_PAGE(!__PageMovable(src), src); 197 + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(src), src); 198 198 VM_WARN_ON_ONCE_PAGE(!PageIsolated(src), src); 199 199 rc = page_movable_ops(src)->migrate_page(dst, src, mode); 200 200 if (rc == MIGRATEPAGE_SUCCESS)
+1 -1
mm/page_alloc.c
··· 2006 2006 * migration are movable. But we don't actually try 2007 2007 * isolating, as that would be expensive. 2008 2008 */ 2009 - if (PageLRU(page) || __PageMovable(page)) 2009 + if (PageLRU(page) || page_has_movable_ops(page)) 2010 2010 (*num_movable)++; 2011 2011 pfn++; 2012 2012 }
+5 -5
mm/page_isolation.c
··· 21 21 * consequently belong to a single zone. 22 22 * 23 23 * PageLRU check without isolation or lru_lock could race so that 24 - * MIGRATE_MOVABLE block might include unmovable pages. And __PageMovable 25 - * check without lock_page also may miss some movable non-lru pages at 26 - * race condition. So you can't expect this function should be exact. 24 + * MIGRATE_MOVABLE block might include unmovable pages. Similarly, pages 25 + * with movable_ops can only be identified some time after they were 26 + * allocated. So you can't expect this function should be exact. 27 27 * 28 28 * Returns a page without holding a reference. If the caller wants to 29 29 * dereference that page (e.g., dumping), it has to make sure that it ··· 133 133 if ((mode == PB_ISOLATE_MODE_MEM_OFFLINE) && PageOffline(page)) 134 134 continue; 135 135 136 - if (__PageMovable(page) || PageLRU(page)) 136 + if (PageLRU(page) || page_has_movable_ops(page)) 137 137 continue; 138 138 139 139 /* ··· 421 421 * proper free and split handling for them. 422 422 */ 423 423 VM_WARN_ON_ONCE_PAGE(PageLRU(page), page); 424 - VM_WARN_ON_ONCE_PAGE(__PageMovable(page), page); 424 + VM_WARN_ON_ONCE_PAGE(page_has_movable_ops(page), page); 425 425 426 426 goto failed; 427 427 }