[RFC 13/19] page_pool: expand scope of is_pp_{netmem,page}() to global
From: Byungchul Park
Date: Fri May 09 2025 - 07:57:26 EST
Other than skbuff.c might need to check if a page or netmem is for page
pool, for example, page_alloc.c needs to check the page state, whether
it comes from page pool or not for their own purpose.
Expand the scope of is_pp_netmem() and introduce is_pp_page() newly, so
that those who want to check the source can achieve the checking without
accessing page pool member, page->pp_magic, directly.
Signed-off-by: Byungchul Park <byungchul@xxxxxx>
---
include/net/page_pool/types.h | 2 ++
net/core/page_pool.c | 10 ++++++++++
net/core/skbuff.c | 5 -----
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h
index 36eb57d73abc6..d3e1a52f01e09 100644
--- a/include/net/page_pool/types.h
+++ b/include/net/page_pool/types.h
@@ -299,4 +299,6 @@ static inline bool is_page_pool_compiled_in(void)
/* Caller must provide appropriate safe context, e.g. NAPI. */
void page_pool_update_nid(struct page_pool *pool, int new_nid);
+bool is_pp_netmem(netmem_ref netmem);
+bool is_pp_page(struct page *page);
#endif /* _NET_PAGE_POOL_H */
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index b61c1038f4c68..9c553e5a1b555 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -1225,3 +1225,13 @@ void net_mp_niov_clear_page_pool(struct netmem_desc *niov)
page_pool_clear_pp_info(netmem);
}
+
+bool is_pp_netmem(netmem_ref netmem)
+{
+ return (netmem_get_pp_magic(netmem) & ~0x3UL) == PP_SIGNATURE;
+}
+
+bool is_pp_page(struct page *page)
+{
+ return is_pp_netmem(page_to_netmem(page));
+}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 6cbf77bc61fce..11098c204fe3e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -893,11 +893,6 @@ static void skb_clone_fraglist(struct sk_buff *skb)
skb_get(list);
}
-static bool is_pp_netmem(netmem_ref netmem)
-{
- return (netmem_get_pp_magic(netmem) & ~0x3UL) == PP_SIGNATURE;
-}
-
int skb_pp_cow_data(struct page_pool *pool, struct sk_buff **pskb,
unsigned int headroom)
{
--
2.17.1