* [PATCH net-next] net: inline napi_skb_cache_get()
@ 2026-01-12 13:15 Eric Dumazet
2026-01-15 11:29 ` Paolo Abeni
2026-01-15 11:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-01-12 13:15 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet
clang is inlining it already, gcc (14.2) does not.
Small space cost (215 bytes on x86_64) but faster sk_buff allocations.
$ scripts/bloat-o-meter -t net/core/skbuff.gcc.before.o net/core/skbuff.gcc.after.o
add/remove: 0/1 grow/shrink: 4/1 up/down: 359/-144 (215)
Function old new delta
__alloc_skb 471 611 +140
napi_build_skb 245 363 +118
napi_alloc_skb 331 416 +85
skb_copy_ubufs 1869 1885 +16
skb_shift 1445 1413 -32
napi_skb_cache_get 112 - -112
Total: Before=59941, After=60156, chg +0.36%
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 a56133902c0d9c47b45a4a19b228b151456e5051..9e94590914b7f9b1cc748262c73eb5aa4f9d2df8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -280,7 +280,7 @@ EXPORT_SYMBOL(__netdev_alloc_frag_align);
*/
static u32 skbuff_cache_size __read_mostly;
-static struct sk_buff *napi_skb_cache_get(bool alloc)
+static inline struct sk_buff *napi_skb_cache_get(bool alloc)
{
struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
struct sk_buff *skb;
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net-next] net: inline napi_skb_cache_get()
2026-01-12 13:15 [PATCH net-next] net: inline napi_skb_cache_get() Eric Dumazet
@ 2026-01-15 11:29 ` Paolo Abeni
2026-01-15 11:35 ` Eric Dumazet
2026-01-15 11:40 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Paolo Abeni @ 2026-01-15 11:29 UTC (permalink / raw)
To: Eric Dumazet
Cc: Simon Horman, netdev, eric.dumazet, David S . Miller,
Jakub Kicinski
On 1/12/26 2:15 PM, Eric Dumazet wrote:
> clang is inlining it already, gcc (14.2) does not.
>
> Small space cost (215 bytes on x86_64) but faster sk_buff allocations.
>
> $ scripts/bloat-o-meter -t net/core/skbuff.gcc.before.o net/core/skbuff.gcc.after.o
> add/remove: 0/1 grow/shrink: 4/1 up/down: 359/-144 (215)
> Function old new delta
> __alloc_skb 471 611 +140
> napi_build_skb 245 363 +118
> napi_alloc_skb 331 416 +85
> skb_copy_ubufs 1869 1885 +16
> skb_shift 1445 1413 -32
> napi_skb_cache_get 112 - -112
> Total: Before=59941, After=60156, chg +0.36%
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Not blocking this patch, but I'm wondering if we should consider
defining an 'inline_for_performance' macro for both documentation
purpose and to allow no inline for size-sensitive build.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: inline napi_skb_cache_get()
2026-01-15 11:29 ` Paolo Abeni
@ 2026-01-15 11:35 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-01-15 11:35 UTC (permalink / raw)
To: Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, David S . Miller,
Jakub Kicinski
On Thu, Jan 15, 2026 at 12:29 PM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On 1/12/26 2:15 PM, Eric Dumazet wrote:
> > clang is inlining it already, gcc (14.2) does not.
> >
> > Small space cost (215 bytes on x86_64) but faster sk_buff allocations.
> >
> > $ scripts/bloat-o-meter -t net/core/skbuff.gcc.before.o net/core/skbuff.gcc.after.o
> > add/remove: 0/1 grow/shrink: 4/1 up/down: 359/-144 (215)
> > Function old new delta
> > __alloc_skb 471 611 +140
> > napi_build_skb 245 363 +118
> > napi_alloc_skb 331 416 +85
> > skb_copy_ubufs 1869 1885 +16
> > skb_shift 1445 1413 -32
> > napi_skb_cache_get 112 - -112
> > Total: Before=59941, After=60156, chg +0.36%
> >
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
>
> Not blocking this patch, but I'm wondering if we should consider
> defining an 'inline_for_performance' macro for both documentation
> purpose and to allow no inline for size-sensitive build.
Yes, I saw mm/slub.c was using __fastpath_inline, but conditional to
CONFIG_SLUB_TINY,
and forcing __always_inline
#ifndef CONFIG_SLUB_TINY
#define __fastpath_inline __always_inline
#else
#define __fastpath_inline
#endif
(For some reason clang is not very smart at compiling mm/slub.c, I am
preparing a series to help with that)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: inline napi_skb_cache_get()
2026-01-12 13:15 [PATCH net-next] net: inline napi_skb_cache_get() Eric Dumazet
2026-01-15 11:29 ` Paolo Abeni
@ 2026-01-15 11:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-15 11:40 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 Paolo Abeni <pabeni@redhat.com>:
On Mon, 12 Jan 2026 13:15:15 +0000 you wrote:
> clang is inlining it already, gcc (14.2) does not.
>
> Small space cost (215 bytes on x86_64) but faster sk_buff allocations.
>
> $ scripts/bloat-o-meter -t net/core/skbuff.gcc.before.o net/core/skbuff.gcc.after.o
> add/remove: 0/1 grow/shrink: 4/1 up/down: 359/-144 (215)
> Function old new delta
> __alloc_skb 471 611 +140
> napi_build_skb 245 363 +118
> napi_alloc_skb 331 416 +85
> skb_copy_ubufs 1869 1885 +16
> skb_shift 1445 1413 -32
> napi_skb_cache_get 112 - -112
> Total: Before=59941, After=60156, chg +0.36%
>
> [...]
Here is the summary with links:
- [net-next] net: inline napi_skb_cache_get()
https://git.kernel.org/netdev/net-next/c/d4596891e72c
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] 4+ messages in thread
end of thread, other threads:[~2026-01-15 11:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12 13:15 [PATCH net-next] net: inline napi_skb_cache_get() Eric Dumazet
2026-01-15 11:29 ` Paolo Abeni
2026-01-15 11:35 ` Eric Dumazet
2026-01-15 11:40 ` 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