* [PATCH v3 net] net: skbuff: don't copy alloc_cpu in skb header copies
@ 2026-10-19 17:41 Carolina Jubran
2026-10-19 18:08 ` Eric Dumazet
2026-10-20 4:12 ` Kuniyuki Iwashima
0 siblings, 2 replies; 3+ messages in thread
From: Carolina Jubran @ 2026-10-19 17:41 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Jason Xing, Kuniyuki Iwashima, Jiayuan Chen,
netdev, linux-kernel, Carolina Jubran, Dragos Tatulea,
Björn Töpel
Commit 68822bdf76f1 ("net: generalize skb freeing deferral to
per-cpu lists") added alloc_cpu to struct sk_buff and placed it in the
headers group copied by __copy_skb_header().
This is wrong for newly allocated skbs. For example, skb_segment()
allocates a new skb and records the current CPU in alloc_cpu, but
__copy_skb_header() overwrites it with the value from the original skb.
If the original skb was allocated on another CPU, the segment may later
be treated as remotely allocated and unnecessarily deferred there when
it is freed.
Move alloc_cpu out of the headers group so it is preserved across
header copies. Copy it explicitly in skb_clone(), which allocates
the skb object directly instead of going through __alloc_skb().
This was discovered while investigating a throughput regression with
software IPsec. The load used 512 IPsec tunnels carrying traffic over
VXLAN, with 512 parallel iperf3 flows and an MTU of 4500.
Before the fix:
16.09% queued_spin_lock_slowpath
|
--15.90%--_raw_spin_lock_irqsave
|
--9.37%--__slab_free
kfree
skb_release_data
napi_consume_skb
mlx5e_poll_tx_cq
After the fix:
6.84% queued_spin_lock_slowpath
|
--6.57%--_raw_spin_lock_irqsave
|
--5.00%--__slab_free
kfree
skb_release_data
napi_consume_skb
mlx5e_poll_tx_cq
Fixes: 68822bdf76f1 ("net: generalize skb freeing deferral to per-cpu lists")
Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Björn Töpel <bjorn@kernel.org>
Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
---
include/linux/skbuff.h | 4 ++--
net/core/skbuff.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
---
V3 log:
- Add a blank line after alloc_cpu to separate it from the tail-end fields
comment. (Sashiko)
- Move the alloc_cpu copy in __skb_clone() next to the tail-end copies.
- Change "Initialize" to "Copy" in the commit message. (Jason Xing)
- Remove an extra blank line. (Sashiko, Jason Xing)
V2 log:
- Move alloc_cpu after the headers group and fix the indentation. (Eric Dumazet)
---
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a3ff380d43f01..d6894f463bf43 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1036,8 +1036,6 @@ struct sk_buff {
__u16 tc_index; /* traffic control index */
#endif
- u16 alloc_cpu;
-
union {
__wsum csum;
struct {
@@ -1088,6 +1086,8 @@ struct sk_buff {
); /* end headers group */
+ u16 alloc_cpu;
+
/* These elements must be at the end, see alloc_skb() for details. */
sk_buff_data_t tail;
sk_buff_data_t end;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 41beaf625421a..ab178af02a226 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1593,7 +1593,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
#ifdef CONFIG_NET_RX_BUSY_POLL
CHECK_SKB_FIELD(napi_id);
#endif
- CHECK_SKB_FIELD(alloc_cpu);
#ifdef CONFIG_XPS
CHECK_SKB_FIELD(sender_cpu);
#endif
@@ -1625,6 +1624,7 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
C(pfmemalloc);
C(pp_recycle);
n->destructor = NULL;
+ C(alloc_cpu);
C(tail);
C(end);
C(head);
--
2.38.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3 net] net: skbuff: don't copy alloc_cpu in skb header copies
2026-10-19 17:41 [PATCH v3 net] net: skbuff: don't copy alloc_cpu in skb header copies Carolina Jubran
@ 2026-10-19 18:08 ` Eric Dumazet
2026-10-20 4:12 ` Kuniyuki Iwashima
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-10-19 18:08 UTC (permalink / raw)
To: Carolina Jubran
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jason Xing, Kuniyuki Iwashima, Jiayuan Chen, netdev,
linux-kernel, Dragos Tatulea, Björn Töpel
Le lun. 19 oct. 2026 à 19:44, Carolina Jubran <cjubran@nvidia.com> a écrit :
>
> Commit 68822bdf76f1 ("net: generalize skb freeing deferral to
> per-cpu lists") added alloc_cpu to struct sk_buff and placed it in the
> headers group copied by __copy_skb_header().
>
> This is wrong for newly allocated skbs. For example, skb_segment()
> allocates a new skb and records the current CPU in alloc_cpu, but
> __copy_skb_header() overwrites it with the value from the original skb.
>
> If the original skb was allocated on another CPU, the segment may later
> be treated as remotely allocated and unnecessarily deferred there when
> it is freed.
>
> Move alloc_cpu out of the headers group so it is preserved across
> header copies. Copy it explicitly in skb_clone(), which allocates
> the skb object directly instead of going through __alloc_skb().
>
> This was discovered while investigating a throughput regression with
> software IPsec. The load used 512 IPsec tunnels carrying traffic over
> VXLAN, with 512 parallel iperf3 flows and an MTU of 4500.
>
> Before the fix:
>
> 16.09% queued_spin_lock_slowpath
> |
> --15.90%--_raw_spin_lock_irqsave
> |
> --9.37%--__slab_free
> kfree
> skb_release_data
> napi_consume_skb
> mlx5e_poll_tx_cq
>
> After the fix:
>
> 6.84% queued_spin_lock_slowpath
> |
> --6.57%--_raw_spin_lock_irqsave
> |
> --5.00%--__slab_free
> kfree
> skb_release_data
> napi_consume_skb
> mlx5e_poll_tx_cq
>
> Fixes: 68822bdf76f1 ("net: generalize skb freeing deferral to per-cpu lists")
> Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3 net] net: skbuff: don't copy alloc_cpu in skb header copies
2026-10-19 17:41 [PATCH v3 net] net: skbuff: don't copy alloc_cpu in skb header copies Carolina Jubran
2026-10-19 18:08 ` Eric Dumazet
@ 2026-10-20 4:12 ` Kuniyuki Iwashima
1 sibling, 0 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2026-10-20 4:12 UTC (permalink / raw)
To: Carolina Jubran
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Jason Xing, Jiayuan Chen, netdev, linux-kernel,
Dragos Tatulea, Björn Töpel
On Mon, 19 Oct 2026 20:41:52 +0300, Carolina Jubran wrote:
> Commit 68822bdf76f1 ("net: generalize skb freeing deferral to
> per-cpu lists") added alloc_cpu to struct sk_buff and placed it in the
> headers group copied by __copy_skb_header().
>
> This is wrong for newly allocated skbs. For example, skb_segment()
> allocates a new skb and records the current CPU in alloc_cpu, but
> __copy_skb_header() overwrites it with the value from the original skb.
>
> If the original skb was allocated on another CPU, the segment may later
> be treated as remotely allocated and unnecessarily deferred there when
> it is freed.
>
> Move alloc_cpu out of the headers group so it is preserved across
> header copies. Copy it explicitly in skb_clone(), which allocates
> the skb object directly instead of going through __alloc_skb().
>
> This was discovered while investigating a throughput regression with
> software IPsec. The load used 512 IPsec tunnels carrying traffic over
> VXLAN, with 512 parallel iperf3 flows and an MTU of 4500.
>
> Before the fix:
>
> 16.09% queued_spin_lock_slowpath
> |
> --15.90%--_raw_spin_lock_irqsave
> |
> --9.37%--__slab_free
> kfree
> skb_release_data
> napi_consume_skb
> mlx5e_poll_tx_cq
>
> After the fix:
>
> 6.84% queued_spin_lock_slowpath
> |
> --6.57%--_raw_spin_lock_irqsave
> |
> --5.00%--__slab_free
> kfree
> skb_release_data
> napi_consume_skb
> mlx5e_poll_tx_cq
>
> Fixes: 68822bdf76f1 ("net: generalize skb freeing deferral to per-cpu lists")
> Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> Reviewed-by: Björn Töpel <bjorn@kernel.org>
> Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-20 4:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-19 17:41 [PATCH v3 net] net: skbuff: don't copy alloc_cpu in skb header copies Carolina Jubran
2026-10-19 18:08 ` Eric Dumazet
2026-10-20 4:12 ` Kuniyuki Iwashima
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®