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)
commit6ffe75eb53564953e75c051e1c28676e1e56f385
treedf3ded93cb68f3e739d1c490e8377dfee2fc028a
parent395eea6ccf2b253f81b4718ffbcae67d36fe2e69
net: avoid two atomic operations in fast clones

Commit ce1a4ea3f125 ("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