* [PATCH net-next] net: minor __alloc_skb() optimization
@ 2026-01-13 13:10 Eric Dumazet
2026-01-14 1:44 ` Jakub Kicinski
2026-01-16 4:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 6+ messages in thread
From: Eric Dumazet @ 2026-01-13 13:10 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet
We can directly call __finalize_skb_around()
instead of __build_skb_around() because @size is not zero.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/core/skbuff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4887099e8678352a62d805e1b0be2736dc985376..77508cf7c41e829a11a988d8de3d2673ff1ff121 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -714,7 +714,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
prefetchw(data + SKB_WITH_OVERHEAD(size));
skbuff_clear(skb);
- __build_skb_around(skb, data, size);
+ __finalize_skb_around(skb, data, size);
skb->pfmemalloc = pfmemalloc;
if (flags & SKB_ALLOC_FCLONE) {
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: minor __alloc_skb() optimization
2026-01-13 13:10 [PATCH net-next] net: minor __alloc_skb() optimization Eric Dumazet
@ 2026-01-14 1:44 ` Jakub Kicinski
2026-01-14 1:54 ` Eric Dumazet
2026-01-16 4:00 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2026-01-14 1:44 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Paolo Abeni, Simon Horman, netdev, eric.dumazet
On Tue, 13 Jan 2026 13:10:17 +0000 Eric Dumazet wrote:
> We can directly call __finalize_skb_around()
> instead of __build_skb_around() because @size is not zero.
FWIW I've been tempted to delete the zero check from
__build_skb_around() completely recently..
It's been a few years since we added slab_build_skb()
surely any buggy driver that's actually used would have
already hit that WARN_ONCE() and gotten reported?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: minor __alloc_skb() optimization
2026-01-14 1:44 ` Jakub Kicinski
@ 2026-01-14 1:54 ` Eric Dumazet
2026-01-14 2:01 ` Eric Dumazet
2026-01-14 2:30 ` Jakub Kicinski
0 siblings, 2 replies; 6+ messages in thread
From: Eric Dumazet @ 2026-01-14 1:54 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S . Miller, Paolo Abeni, Simon Horman, netdev, eric.dumazet
On Wed, Jan 14, 2026 at 2:44 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 13 Jan 2026 13:10:17 +0000 Eric Dumazet wrote:
> > We can directly call __finalize_skb_around()
> > instead of __build_skb_around() because @size is not zero.
>
> FWIW I've been tempted to delete the zero check from
> __build_skb_around() completely recently..
> It's been a few years since we added slab_build_skb()
> surely any buggy driver that's actually used would have
> already hit that WARN_ONCE() and gotten reported?
We could keep it for a while, WDYT of
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 77508cf7c41e829a11a988d8de3d2673ff1ff121..ccd287ff46e91c2548483c51fa32fc6167867940
100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -458,7 +458,8 @@ static void __build_skb_around(struct sk_buff
*skb, void *data,
/* frag_size == 0 is considered deprecated now. Callers
* using slab buffer should use slab_build_skb() instead.
*/
- if (WARN_ONCE(size == 0, "Use slab_build_skb() instead"))
+ if (IS_ENABLED(CONFIG_DEBUG_NET) &&
+ WARN_ONCE(size == 0, "Use slab_build_skb() instead"))
data = __slab_build_skb(data, &size);
__finalize_skb_around(skb, data, size);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: minor __alloc_skb() optimization
2026-01-14 1:54 ` Eric Dumazet
@ 2026-01-14 2:01 ` Eric Dumazet
2026-01-14 2:30 ` Jakub Kicinski
1 sibling, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2026-01-14 2:01 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S . Miller, Paolo Abeni, Simon Horman, netdev, eric.dumazet
On Wed, Jan 14, 2026 at 2:54 AM Eric Dumazet <edumazet@google.com> wrote:
>
> On Wed, Jan 14, 2026 at 2:44 AM Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > On Tue, 13 Jan 2026 13:10:17 +0000 Eric Dumazet wrote:
> > > We can directly call __finalize_skb_around()
> > > instead of __build_skb_around() because @size is not zero.
> >
> > FWIW I've been tempted to delete the zero check from
> > __build_skb_around() completely recently..
> > It's been a few years since we added slab_build_skb()
> > surely any buggy driver that's actually used would have
> > already hit that WARN_ONCE() and gotten reported?
>
> We could keep it for a while, WDYT of
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 77508cf7c41e829a11a988d8de3d2673ff1ff121..ccd287ff46e91c2548483c51fa32fc6167867940
> 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -458,7 +458,8 @@ static void __build_skb_around(struct sk_buff
> *skb, void *data,
> /* frag_size == 0 is considered deprecated now. Callers
> * using slab buffer should use slab_build_skb() instead.
> */
> - if (WARN_ONCE(size == 0, "Use slab_build_skb() instead"))
> + if (IS_ENABLED(CONFIG_DEBUG_NET) &&
> + WARN_ONCE(size == 0, "Use slab_build_skb() instead"))
> data = __slab_build_skb(data, &size);
>
> __finalize_skb_around(skb, data, size);
BTW, for folks using clang and not up to date kernels, backporting this commit
makes sure __build_skb_around() is at least inlined.
commit 242b872239f6a7deacbc20ab9406ea40cb738ec6
Author: Xie Yuanbin <qq570070308@gmail.com>
Date: Sun Nov 9 16:37:15 2025 +0800
include/linux/once_lite.h: fix judgment in WARN_ONCE with clang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: minor __alloc_skb() optimization
2026-01-14 1:54 ` Eric Dumazet
2026-01-14 2:01 ` Eric Dumazet
@ 2026-01-14 2:30 ` Jakub Kicinski
1 sibling, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2026-01-14 2:30 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Paolo Abeni, Simon Horman, netdev, eric.dumazet
On Wed, 14 Jan 2026 02:54:10 +0100 Eric Dumazet wrote:
> We could keep it for a while, WDYT of
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 77508cf7c41e829a11a988d8de3d2673ff1ff121..ccd287ff46e91c2548483c51fa32fc6167867940
> 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -458,7 +458,8 @@ static void __build_skb_around(struct sk_buff
> *skb, void *data,
> /* frag_size == 0 is considered deprecated now. Callers
> * using slab buffer should use slab_build_skb() instead.
> */
> - if (WARN_ONCE(size == 0, "Use slab_build_skb() instead"))
> + if (IS_ENABLED(CONFIG_DEBUG_NET) &&
> + WARN_ONCE(size == 0, "Use slab_build_skb() instead"))
> data = __slab_build_skb(data, &size);
Probably not worth it. People who use relevant HW + 3 year old kernels
(I just checked, we added the warning in Dec 2022) likely don't set
DEBUG_NET either. That said looks like the warning landed in 6.2,
narrowly missing the v6.1 LTS. I suppose v6.1 may still be used by some
"enterprise-ish" distroes. I guess we should wait another year :(
Sorry for the noise :(
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: minor __alloc_skb() optimization
2026-01-13 13:10 [PATCH net-next] net: minor __alloc_skb() optimization Eric Dumazet
2026-01-14 1:44 ` Jakub Kicinski
@ 2026-01-16 4:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-16 4:00 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, horms, netdev, eric.dumazet
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 13 Jan 2026 13:10:17 +0000 you wrote:
> We can directly call __finalize_skb_around()
> instead of __build_skb_around() because @size is not zero.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/core/skbuff.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Here is the summary with links:
- [net-next] net: minor __alloc_skb() optimization
https://git.kernel.org/netdev/net-next/c/2db009e4c8d6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-16 4:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 13:10 [PATCH net-next] net: minor __alloc_skb() optimization Eric Dumazet
2026-01-14 1:44 ` Jakub Kicinski
2026-01-14 1:54 ` Eric Dumazet
2026-01-14 2:01 ` Eric Dumazet
2026-01-14 2:30 ` Jakub Kicinski
2026-01-16 4:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox