Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: fclone allocation small optimization

After skb allocation, initial skb->fclone value is 0 (SKB_FCLONE_UNAVAILABLE)

We can replace one RMW sequence with a single OR instruction.

movzbl 0x7e(%r13),%eax // skb->fclone = SKB_FCLONE_ORIG;
and $0xf3,%al
or $0x4,%al
mov %al,0x7e(%r13)
->
or $0x4,0x7e(%r13) // skb->fclone |= SKB_FCLONE_ORIG;

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

authored by

Eric Dumazet and committed by
Jakub Kicinski
79bfa5fb ee7be82f

+8 -1
+8 -1
net/core/skbuff.c
··· 723 723 724 724 fclones = container_of(skb, struct sk_buff_fclones, skb1); 725 725 726 - skb->fclone = SKB_FCLONE_ORIG; 726 + /* skb->fclone is a 2bits field. 727 + * Replace expensive RMW (skb->fclone = SKB_FCLONE_ORIG) 728 + * with a single OR. 729 + */ 730 + BUILD_BUG_ON(SKB_FCLONE_UNAVAILABLE != 0); 731 + DEBUG_NET_WARN_ON_ONCE(skb->fclone != SKB_FCLONE_UNAVAILABLE); 732 + skb->fclone |= SKB_FCLONE_ORIG; 733 + 727 734 refcount_set(&fclones->fclone_ref, 1); 728 735 } 729 736