* [PATCH net-next v2] net: skbuff: optimization of net_zcopy_get() call in pskb_carve helpers
@ 2026-07-08 5:54 Yun Lu
2026-07-09 1:26 ` Willem de Bruijn
0 siblings, 1 reply; 2+ messages in thread
From: Yun Lu @ 2026-07-08 5:54 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms, kerneljasonxing, kuniyu,
willemdebruijn.kernel
Cc: mhal, bjorn, jiayuan.chen, netdev
From: Yun Lu <luyun@kylinos.cn>
Commit 98d0912e9f84 ("net: skbuff: fix missing zerocopy reference in
pskb_carve helpers") introduced two calls of net_zcopy_get(skb_zcopy(skb)).
In fact, skb_zcopy() has already been executed once before. When calling
net_zcopy_get(), skb_zcopy() always returns skb_uarg(skb), which results
in adding some unnecessary instructions in skb_zcopy. So, change these
two calls to directly use skb_uarg(skb) instead of skb_zcopy.
In addition, also use net_zcopy_get() instead of refcount_inc() in
pskb_expand_head() for code consistency.
No functional change intended.
Signed-off-by: Yun Lu <luyun@kylinos.cn>
---
Changes in v2:
- Directly use skb_uarg(skb) instead of skb_zcopy.
Thanks: Willem de Bruijn
- Links to v1: https://lore.kernel.org/all/20260706100229.13812-1-luyun_611@163.com/
---
net/core/skbuff.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 18dabb4e9cfa..d798fbdc3da7 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2326,7 +2326,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
if (skb_orphan_frags(skb, gfp_mask))
goto nofrags;
if (skb_zcopy(skb))
- refcount_inc(&skb_uarg(skb)->refcnt);
+ net_zcopy_get(skb_uarg(skb));
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
skb_frag_ref(skb, i);
@@ -6842,7 +6842,7 @@ static int pskb_carve_inside_header(struct sk_buff *skb, const u32 off,
return -ENOMEM;
}
if (skb_zcopy(skb))
- net_zcopy_get(skb_zcopy(skb));
+ net_zcopy_get(skb_uarg(skb));
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
skb_frag_ref(skb, i);
if (skb_has_frag_list(skb))
@@ -6992,7 +6992,7 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
return -ENOMEM;
}
if (skb_zcopy(skb))
- net_zcopy_get(skb_zcopy(skb));
+ net_zcopy_get(skb_uarg(skb));
skb_release_data(skb, SKB_CONSUMED);
skb->head = data;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] net: skbuff: optimization of net_zcopy_get() call in pskb_carve helpers
2026-07-08 5:54 [PATCH net-next v2] net: skbuff: optimization of net_zcopy_get() call in pskb_carve helpers Yun Lu
@ 2026-07-09 1:26 ` Willem de Bruijn
0 siblings, 0 replies; 2+ messages in thread
From: Willem de Bruijn @ 2026-07-09 1:26 UTC (permalink / raw)
To: Yun Lu, davem, edumazet, kuba, pabeni, horms, kerneljasonxing,
kuniyu, willemdebruijn.kernel
Cc: mhal, bjorn, jiayuan.chen, netdev
Yun Lu wrote:
> From: Yun Lu <luyun@kylinos.cn>
>
> Commit 98d0912e9f84 ("net: skbuff: fix missing zerocopy reference in
> pskb_carve helpers") introduced two calls of net_zcopy_get(skb_zcopy(skb)).
> In fact, skb_zcopy() has already been executed once before. When calling
> net_zcopy_get(), skb_zcopy() always returns skb_uarg(skb), which results
> in adding some unnecessary instructions in skb_zcopy. So, change these
> two calls to directly use skb_uarg(skb) instead of skb_zcopy.
>
> In addition, also use net_zcopy_get() instead of refcount_inc() in
> pskb_expand_head() for code consistency.
>
> No functional change intended.
>
> Signed-off-by: Yun Lu <luyun@kylinos.cn>
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-09 1:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08 5:54 [PATCH net-next v2] net: skbuff: optimization of net_zcopy_get() call in pskb_carve helpers Yun Lu
2026-07-09 1:26 ` Willem de Bruijn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox