]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: split kmalloc_reserve() to allow inlining
authorEric Dumazet <edumazet@google.com>
Fri, 16 Jan 2026 04:13:59 +0000 (04:13 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 21 Jan 2026 02:19:18 +0000 (18:19 -0800)
commit3fbb5395c7303582757d5090ab8f7ec70dbe2c10
tree3313205c6667c4c908a320e3101fbf4573f48efb
parent7333299be4e5cc0d9ccbe9d13c9cd954a00f94d9
net: split kmalloc_reserve() to allow inlining

kmalloc_reserve() is too big to be inlined.

Put the slow path in a new out-of-line function : kmalloc_pfmemalloc()

Then let kmalloc_reserve() set skb->pfmemalloc only when/if
the slow path is taken.

This makes __alloc_skb() faster :

- kmalloc_reserve() is now automatically inlined by both gcc and clang.
- No more expensive RMW (skb->pfmemalloc = pfmemalloc).
- No more expensive stack canary (for CONFIG_STACKPROTECTOR_STRONG=y).
- Removal of two prefetches that were coming too late for modern cpus.

Text size increase is quite small compared to the cpu savings (~0.7 %)

$ size net/core/skbuff.clang.before.o net/core/skbuff.clang.after.o
   text    data     bss     dec     hex filename
  72507    5897       0   78404   13244 net/core/skbuff.clang.before.o
  72681    5897       0   78578   132f2 net/core/skbuff.clang.after.o

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260116041359.181104-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/skbuff.c