Skip to content

Commit 81cf1ad

Browse files
committed
Merge branch 'tcp-io_uring-zc-opts'
Merge branch 'tcp-io_uring-zc-opts' Pavel Begunkov says: ==================== minor tcp io_uring zc optimisations Patch 1 is a simple cleanup, patch 2 gives removes 2 atomics from the io_uring zc TCP submission path, which yielded extra 0.5% for my throughput CPU bound tests based on liburing/examples/send-zerocopy.c ==================== Reviewed-by: David Ahern <dsahern@kernel.org> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 833e24a + a753358 commit 81cf1ad

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

net/ipv4/tcp.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,13 +1229,11 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
12291229
flags = msg->msg_flags;
12301230

12311231
if ((flags & MSG_ZEROCOPY) && size) {
1232-
skb = tcp_write_queue_tail(sk);
1233-
12341232
if (msg->msg_ubuf) {
12351233
uarg = msg->msg_ubuf;
1236-
net_zcopy_get(uarg);
12371234
zc = sk->sk_route_caps & NETIF_F_SG;
12381235
} else if (sock_flag(sk, SOCK_ZEROCOPY)) {
1236+
skb = tcp_write_queue_tail(sk);
12391237
uarg = msg_zerocopy_realloc(sk, size, skb_zcopy(skb));
12401238
if (!uarg) {
12411239
err = -ENOBUFS;
@@ -1459,7 +1457,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
14591457
tcp_push(sk, flags, mss_now, tp->nonagle, size_goal);
14601458
}
14611459
out_nopush:
1462-
net_zcopy_put(uarg);
1460+
/* msg->msg_ubuf is pinned by the caller so we don't take extra refs */
1461+
if (uarg && !msg->msg_ubuf)
1462+
net_zcopy_put(uarg);
14631463
return copied + copied_syn;
14641464

14651465
do_error:
@@ -1468,7 +1468,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
14681468
if (copied + copied_syn)
14691469
goto out;
14701470
out_err:
1471-
net_zcopy_put_abort(uarg, true);
1471+
/* msg->msg_ubuf is pinned by the caller so we don't take extra refs */
1472+
if (uarg && !msg->msg_ubuf)
1473+
net_zcopy_put_abort(uarg, true);
14721474
err = sk_stream_error(sk, flags, err);
14731475
/* make sure we wake any epoll edge trigger waiter */
14741476
if (unlikely(tcp_rtx_and_write_queues_empty(sk) && err == -EAGAIN)) {

0 commit comments

Comments
 (0)