net: minor optimization in __alloc_skb()
Subsystems (2)
PATCH 1/1 net: minor optimization in __alloc_skb()
TCP allocates 'fast clones' skbs for packets in tx queues.
Currently, __alloc_skb() initializes the companion fclone field to SKB_FCLONE_CLONE, and leaves other fields untouched.
It makes sense to defer this init much later in skb_clone(), because all fclone fields are copied and hot in cpu caches at that time.
This removes one cache line miss in __alloc_skb(), cost seen on an host with 256 cpus all competing on memory accesses.
--- net/core/skbuff.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/core/skbuff.c +1 -2
@@ -454,8 +454,6 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, skb->fclone =SKB_FCLONE_ORIG ;refcount_set (&fclones->fclone_ref,1 ); - - fclones->skb2.fclone =SKB_FCLONE_CLONE ; }return skb;
@@ -1513,6 +1511,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask) refcount_read(&fclones->fclone_ref) == 1) { n = &fclones->skb2; refcount_set(&fclones->fclone_ref, 2); + n->fclone = SKB_FCLONE_CLONE; } else {if (skb_pfmemalloc (skb)) gfp_mask |= __GFP_MEMALLOC;
Signature · 1 line
2.37.0.rc0.161.g10f37bed90-goog
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 10 lines · On Thu, 7 Jul 2022 19:18:46 +0000 you wrote:
TCP allocates 'fast clones' skbs for packets in tx queues.
Currently,
__alloc_skb()initializes the companion fclone field toSKB_FCLONE_CLONE, and leaves other fields untouched.It makes sense to defer this init much later in
skb_clone(), because all fclone fields are copied and hot in cpu caches at that time.[...]
Here is the summary with links:
- [net-next] net: minor optimization in __alloc_skb()
https://git.kernel.org/netdev/net-next/c/c2dd4059dc31
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html