Skip to content

Commit 3e24591

Browse files
Alexander Duyckdavem330
authored andcommitted
skb: Drop "fastpath" variable for skb_cloned check in pskb_expand_head
Since there is now only one spot that actually uses "fastpath" there isn't much point in carrying it. Instead we can just use a check for skb_cloned to verify if we can perform the fast-path free for the head or not. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9202e31 commit 3e24591

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

net/core/skbuff.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,6 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
932932
u8 *data;
933933
int size = nhead + (skb_end_pointer(skb) - skb->head) + ntail;
934934
long off;
935-
bool fastpath;
936935

937936
BUG_ON(nhead < 0);
938937

@@ -941,16 +940,6 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
941940

942941
size = SKB_DATA_ALIGN(size);
943942

944-
/* Check if we can avoid taking references on fragments if we own
945-
* the last reference on skb->head. (see skb_release_data())
946-
*/
947-
if (!skb->cloned)
948-
fastpath = true;
949-
else {
950-
int delta = skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1;
951-
fastpath = atomic_read(&skb_shinfo(skb)->dataref) == delta;
952-
}
953-
954943
data = kmalloc(size + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
955944
gfp_mask);
956945
if (!data)
@@ -966,9 +955,12 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
966955
skb_shinfo(skb),
967956
offsetof(struct skb_shared_info, frags[skb_shinfo(skb)->nr_frags]));
968957

969-
if (fastpath) {
970-
skb_free_head(skb);
971-
} else {
958+
/*
959+
* if shinfo is shared we must drop the old head gracefully, but if it
960+
* is not we can just drop the old head and let the existing refcount
961+
* be since all we did is relocate the values
962+
*/
963+
if (skb_cloned(skb)) {
972964
/* copy this zero copy skb frags */
973965
if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
974966
if (skb_copy_ubufs(skb, gfp_mask))
@@ -981,6 +973,8 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
981973
skb_clone_fraglist(skb);
982974

983975
skb_release_data(skb);
976+
} else {
977+
skb_free_head(skb);
984978
}
985979
off = (data + nhead) - skb->head;
986980

0 commit comments

Comments
 (0)