From: Eric Dumazet <[email protected]>
To: David Ahern <[email protected]>
Cc: Pavel Begunkov <[email protected]>,
[email protected], [email protected],
[email protected], [email protected], [email protected]
Subject: Re: [PATCH net-next 2/2] net/tcp: optimise io_uring zc ubuf refcounting
Date: Mon, 15 May 2023 20:14:32 +0200 [thread overview]
Message-ID: <CANn89i+Bb7g9uDPVmomNDJivK7CZBYD1UXryxq2VEU77sajqEg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
On Mon, May 15, 2023 at 7:29 PM David Ahern <[email protected]> wrote:
>
> On 5/15/23 10:06 AM, Pavel Begunkov wrote:
> > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> > index 40f591f7fce1..3d18e295bb2f 100644
> > --- a/net/ipv4/tcp.c
> > +++ b/net/ipv4/tcp.c
> > @@ -1231,7 +1231,6 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> > if ((flags & MSG_ZEROCOPY) && size) {
> > if (msg->msg_ubuf) {
> > uarg = msg->msg_ubuf;
> > - net_zcopy_get(uarg);
> > zc = sk->sk_route_caps & NETIF_F_SG;
> > } else if (sock_flag(sk, SOCK_ZEROCOPY)) {
> > skb = tcp_write_queue_tail(sk);
> > @@ -1458,7 +1457,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> > tcp_push(sk, flags, mss_now, tp->nonagle, size_goal);
> > }
> > out_nopush:
> > - net_zcopy_put(uarg);
> > + /* msg->msg_ubuf is pinned by the caller so we don't take extra refs */
> > + if (uarg && !msg->msg_ubuf)
> > + net_zcopy_put(uarg);
> > return copied + copied_syn;
> >
> > do_error:
> > @@ -1467,7 +1468,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> > if (copied + copied_syn)
> > goto out;
> > out_err:
> > - net_zcopy_put_abort(uarg, true);
> > + /* msg->msg_ubuf is pinned by the caller so we don't take extra refs */
> > + if (uarg && !msg->msg_ubuf)
> > + net_zcopy_put_abort(uarg, true);
> > err = sk_stream_error(sk, flags, err);
> > /* make sure we wake any epoll edge trigger waiter */
> > if (unlikely(tcp_rtx_and_write_queues_empty(sk) && err == -EAGAIN)) {
>
> Both net_zcopy_put_abort and net_zcopy_put have an `if (uarg)` check.
Right, but here this might avoid a read of msg->msg_ubuf, which might
be more expensive to fetch.
Compiler will probably remove the second test (uarg) from net_zcopy_put()
Reviewed-by: Eric Dumazet <[email protected]>
next prev parent reply other threads:[~2023-05-15 18:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 16:06 [PATCH net-next 0/2] minor tcp io_uring zc optimisations Pavel Begunkov
2023-05-15 16:06 ` [PATCH net-next 1/2] net/tcp: don't peek at tail for io_uring zc Pavel Begunkov
2023-05-15 17:27 ` David Ahern
2023-05-15 18:11 ` Eric Dumazet
2023-05-15 16:06 ` [PATCH net-next 2/2] net/tcp: optimise io_uring zc ubuf refcounting Pavel Begunkov
2023-05-15 17:29 ` David Ahern
2023-05-15 18:14 ` Eric Dumazet [this message]
2023-05-15 18:40 ` David Ahern
2023-05-16 12:59 ` Pavel Begunkov
2023-05-16 14:37 ` David Ahern
2023-05-16 17:46 ` Pavel Begunkov
2023-05-17 7:40 ` [PATCH net-next 0/2] minor tcp io_uring zc optimisations patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CANn89i+Bb7g9uDPVmomNDJivK7CZBYD1UXryxq2VEU77sajqEg@mail.gmail.com \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox