Re: [RFC 13/19] page_pool: expand scope of is_pp_{netmem,page}() to global

From
Toke Høiland-Jørgensen <hidden>
Date
2025-05-14 11:17:27
Also in
linux-mm, lkml
Reply to
Byungchul Park, 2025-05-14
Byungchul Park [off-list ref] writes:
On Mon, May 12, 2025 at 02:46:36PM +0200, Toke Høiland-Jørgensen wrote:
quoted
Byungchul Park [off-list ref] writes:
quoted
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@sk.com>
---
 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;
-}
-
This has already been moved to mm.h (and the check changed) by commit:

cd3c93167da0 ("page_pool: Move pp_magic check into helper functions")

You should definitely rebase this series on top of that (and the
subsequent ee62ce7a1d90 ("page_pool: Track DMA-mapped pages and unmap
them when destroying the pool")), as these change the semantics of how
page_pool interacts with struct page.

Both of these are in net-next, which Mina already asked you to rebase
Is this net-next you are mentioning?  I will rebase on this if so.

   https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/
Yup :)

-Toke
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