summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2017-08-31 16:48:21 -0700
committerDavid S. Miller <davem@davemloft.net>2017-09-01 20:22:03 -0700
commitdb5bce32fbe19f0c7482fb5a40a33178bbe7b11b (patch)
treeda0171aec6a48e32f1c9c140cf04e984cd979f5c /net/core
parent487234cc1954a1c09115a82b45ebcc2086657572 (diff)
downloadlinux-stable-db5bce32fbe19f0c7482fb5a40a33178bbe7b11b.tar.gz
linux-stable-db5bce32fbe19f0c7482fb5a40a33178bbe7b11b.tar.bz2
linux-stable-db5bce32fbe19f0c7482fb5a40a33178bbe7b11b.zip
net: prepare (struct ubuf_info)->refcnt conversion
In order to convert this atomic_t refcnt to refcount_t, we need to init the refcount to one to not trigger a 0 -> 1 transition. This also removes one atomic operation in fast path. v2: removed dead code in sock_zerocopy_put_abort() as suggested by Willem. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/skbuff.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 246ca1c81715..a003f953a0a6 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -963,7 +963,7 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
uarg->len = 1;
uarg->bytelen = size;
uarg->zerocopy = 1;
- atomic_set(&uarg->refcnt, 0);
+ atomic_set(&uarg->refcnt, 1);
sock_hold(sk);
return uarg;
@@ -1005,6 +1005,7 @@ struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
uarg->len++;
uarg->bytelen = bytelen;
atomic_set(&sk->sk_zckey, ++next);
+ sock_zerocopy_get(uarg);
return uarg;
}
}
@@ -1102,13 +1103,6 @@ void sock_zerocopy_put_abort(struct ubuf_info *uarg)
atomic_dec(&sk->sk_zckey);
uarg->len--;
- /* sock_zerocopy_put expects a ref. Most sockets take one per
- * skb, which is zero on abort. tcp_sendmsg holds one extra, to
- * avoid an skb send inside the main loop triggering uarg free.
- */
- if (sk->sk_type != SOCK_STREAM)
- atomic_inc(&uarg->refcnt);
-
sock_zerocopy_put(uarg);
}
}