[PATCH 12/18] page_pool: use netmem APIs to access page->pp_magic in page_pool_page_is_pp()

From
Byungchul Park <byungchul@sk.com>
Date
2025-05-23 03:26:27
Also in
bpf, linux-mm, linux-rdma, lkml
Reply to
Byungchul Park, 2025-05-23
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 APIs for the purpose.

Use netmem_is_pp() instead of directly accessing page->pp_magic in
page_pool_page_is_pp().

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 include/linux/mm.h   | 5 +----
 net/core/page_pool.c | 5 +++++
 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 8dc012e84033..3f7c80fb73ce 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4312,10 +4312,7 @@ int arch_lock_shadow_stack_status(struct task_struct *t, unsigned long status);
 #define PP_MAGIC_MASK ~(PP_DMA_INDEX_MASK | 0x3UL)
 
 #ifdef CONFIG_PAGE_POOL
-static inline bool page_pool_page_is_pp(struct page *page)
-{
-	return (page->pp_magic & PP_MAGIC_MASK) == PP_SIGNATURE;
-}
+bool page_pool_page_is_pp(struct page *page);
 #else
 static inline bool page_pool_page_is_pp(struct page *page)
 {
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 1071cb3d63e5..37e667e6ca33 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -1284,3 +1284,8 @@ void net_mp_niov_clear_page_pool(struct net_iov *niov)
 
 	page_pool_clear_pp_info(netmem);
 }
+
+bool page_pool_page_is_pp(struct page *page)
+{
+	return netmem_is_pp(page_to_netmem(page));
+}
-- 
2.17.1
Thread (72 messages) 72 messages, 7 authors, last reply 2025-05-28
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