]> git.baikalelectronics.ru Git - kernel.git/commit
net: avoid two atomic operations in fast clones
authorEric Dumazet <edumazet@google.com>
Thu, 4 Dec 2014 01:04:39 +0000 (17:04 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 9 Dec 2014 18:40:20 +0000 (13:40 -0500)
commit50ca075ae2d368053fb33f71b8ee724c4c4dcbfd
treedf3ded93cb68f3e739d1c490e8377dfee2fc028a
parent58eb7c1de383b440c092f909c27db36f5288d96a
net: avoid two atomic operations in fast clones

Commit da46d5679934 ("net: avoid one atomic operation in skb_clone()")
took the wrong way to save one atomic operation.

It is actually possible to avoid two atomic operations, if we
do not change skb->fclone values, and only rely on clone_ref
content to signal if the clone is available or not.

skb_clone() can simply use the fast clone if clone_ref is 1.

kfree_skbmem() can avoid the atomic_dec_and_test() if clone_ref is 1.

Note that because we usually free the clone before the original skb,
this particular attempt is only done for the original skb to have better
branch prediction.

SKB_FCLONE_FREE is removed.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Chris Mason <clm@fb.com>
Cc: Sabrina Dubroca <sd@queasysnail.net>
Cc: Vijay Subramanian <subramanian.vijay@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/core/skbuff.c