[RFC 14/19] mm: page_alloc: do not directly access page->pp_magic but use is_pp_page()

From
Byungchul Park <byungchul@sk.com>
Date
2025-05-09 11:51:45
Also in
linux-mm, lkml
Reply to
Byungchul Park, 2025-05-09
To simplify struct page, the effort to seperate its own descriptor from
struct page is required and the work for page pool is on going.

To achieve that, all the code should avoid accessing page pool members
of struct page directly, but use safe API for the corresponding purpose,
that is is_pp_page() in this case.

Use is_pp_page() instead of accessing the members directly, when
checking if a page comes from page pool or not.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 mm/page_alloc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a6fe1e9b95941..cf672b9ab7086 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -55,6 +55,7 @@
 #include <linux/delayacct.h>
 #include <linux/cacheinfo.h>
 #include <linux/pgalloc_tag.h>
+#include <net/page_pool/types.h> /* for page pool checking */
 #include <asm/div64.h>
 #include "internal.h"
 #include "shuffle.h"
@@ -899,7 +900,7 @@ static inline bool page_expected_state(struct page *page,
 			page->memcg_data |
 #endif
 #ifdef CONFIG_PAGE_POOL
-			((page->pp_magic & ~0x3UL) == PP_SIGNATURE) |
+			(is_pp_page(page)) |
 #endif
 			(page->flags & check_flags)))
 		return false;
@@ -928,7 +929,7 @@ static const char *page_bad_reason(struct page *page, unsigned long flags)
 		bad_reason = "page still charged to cgroup";
 #endif
 #ifdef CONFIG_PAGE_POOL
-	if (unlikely((page->pp_magic & ~0x3UL) == PP_SIGNATURE))
+	if (unlikely(is_pp_page(page)))
 		bad_reason = "page_pool leak";
 #endif
 	return bad_reason;
-- 
2.17.1
Thread (53 messages) 53 messages, 6 authors, last reply 2025-05-14
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help