[PATCH net-next v1 5/6] net: skbuff: use skb_frag_ref() in skb_try_coalesce()

From: Mina Almasry

Date: Sat Oct 10 2026 - 04:47:15 EST


skb_pp_frag_ref() was introduced solely to work around skb_frag_ref()
ignoring skb->pp_recycle and incrementing the non-pp backing refcount.
Now that skb_frag_ref() handles both pp_recycle=1 and pp_recycle=0
symmetrically, call skb_frag_ref() directly in skb_try_coalesce() and
remove skb_pp_frag_ref().

Signed-off-by: Mina Almasry <almasrymina@xxxxxxxxxx>
---
net/core/skbuff.c | 37 ++-----------------------------------
1 file changed, 2 insertions(+), 35 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f03ce8d5ae585..554af794bd7cd 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1078,37 +1078,6 @@ static bool skb_pp_recycle(struct sk_buff *skb, void *data)
return napi_pp_put_page(page_to_netmem(virt_to_page(data)));
}

-/**
- * skb_pp_frag_ref() - Increase fragment references of a page pool aware skb
- * @skb: page pool aware skb
- *
- * Increase the fragment reference count (pp_ref_count) of a skb. This is
- * intended to gain fragment references only for page pool aware skbs,
- * i.e. when skb->pp_recycle is true, and not for fragments in a
- * non-pp-recycling skb. It has a fallback to increase references on normal
- * pages, as page pool aware skbs may also have normal page fragments.
- */
-static int skb_pp_frag_ref(struct sk_buff *skb)
-{
- struct skb_shared_info *shinfo;
- netmem_ref head_netmem;
- int i;
-
- if (!skb->pp_recycle)
- return -EINVAL;
-
- shinfo = skb_shinfo(skb);
-
- for (i = 0; i < shinfo->nr_frags; i++) {
- head_netmem = netmem_compound_head(shinfo->frags[i].netmem);
- if (likely(netmem_is_pp(head_netmem)))
- page_pool_ref_netmem(head_netmem);
- else
- page_ref_inc(netmem_to_page(head_netmem));
- }
- return 0;
-}
-
static void skb_kfree_head(void *head)
{
kfree(head);
@@ -6295,10 +6264,8 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
/* if the skb is not cloned this does nothing
* since we set nr_frags to 0.
*/
- if (skb_pp_frag_ref(from)) {
- for (i = 0; i < from_shinfo->nr_frags; i++)
- get_netmem(skb_frag_netmem(&from_shinfo->frags[i]));
- }
+ for (i = 0; i < from_shinfo->nr_frags; i++)
+ skb_frag_ref(from, i);

to->truesize += delta;
to->len += len;
--
2.56.0.385.gd3acb90ef8-goog