| From: David Hildenbrand <david@redhat.com> |
| Subject: mm/page-alloc: remove PageMappingFlags() |
| Date: Fri, 4 Jul 2025 12:25:17 +0200 |
| |
| As PageMappingFlags() now only indicates anon (incl. KSM) folios, we can |
| now simply check for PageAnon() and remove PageMappingFlags(). |
| |
| ... and while at it, use the folio instead and operate on folio->mapping. |
| |
| Link: https://lkml.kernel.org/r/20250704102524.326966-24-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> |
| --- |
| |
| include/linux/page-flags.h | 5 ----- |
| mm/page_alloc.c | 7 +++---- |
| 2 files changed, 3 insertions(+), 9 deletions(-) |
| |
| --- a/include/linux/page-flags.h~mm-page-alloc-remove-pagemappingflags |
| +++ a/include/linux/page-flags.h |
| @@ -723,11 +723,6 @@ static __always_inline bool folio_mappin |
| return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) != 0; |
| } |
| |
| -static __always_inline bool PageMappingFlags(const struct page *page) |
| -{ |
| - return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) != 0; |
| -} |
| - |
| static __always_inline bool folio_test_anon(const struct folio *folio) |
| { |
| return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0; |
| --- a/mm/page_alloc.c~mm-page-alloc-remove-pagemappingflags |
| +++ a/mm/page_alloc.c |
| @@ -1375,10 +1375,9 @@ __always_inline bool free_pages_prepare( |
| (page + i)->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; |
| } |
| } |
| - if (PageMappingFlags(page)) { |
| - if (PageAnon(page)) |
| - mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1); |
| - page->mapping = NULL; |
| + if (folio_test_anon(folio)) { |
| + mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1); |
| + folio->mapping = NULL; |
| } |
| if (unlikely(page_has_type(page))) |
| /* Reset the page_type (which overlays _mapcount) */ |
| _ |