From: Eric Dumazet <eric.dumazet@gmail.com>
To: Tom Herbert <therbert@google.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, sridharr@google.com
Subject: Re: [PATCH v3] xmit_compl_seq: information to reclaim vmsplice buffers
Date: Fri, 24 Sep 2010 03:48:12 +0200 [thread overview]
Message-ID: <1285292892.2380.16.camel@edumazet-laptop> (raw)
In-Reply-To: <alpine.DEB.1.00.1009231426450.11579@pokey.mtv.corp.google.com>
Le jeudi 23 septembre 2010 à 14:35 -0700, Tom Herbert a écrit :
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 3e8a4db..3d8d33f 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1768,6 +1768,12 @@ skip_copy:
>
> TCP_CHECK_TIMER(sk);
> release_sock(sk);
> +
> + /* Copy the first unacked seq into the receive msg control part. */
> + if (sock_flag(sk, SOCK_XMIT_COMPL_SEQ))
> + put_cmsg(msg, SOL_SOCKET, SCM_XMIT_COMPL_SEQ,
> + sizeof(tp->snd_una), &tp->snd_una);
> +
> return copied;
>
> out:
Tom,
I took the time to suggest : copy tp->snd_una before release_sock().
Why do you try to avoid this copy and introduce a bug ?
Hint : put_cmsg() (and copy_to_user()) makes no guarantee the copy is
atomic.
It can be implemented by a 4 bytes copy, faut during this copy or being
interrupted, and application might get a garbled value, if tcp stack
modifies tp->snd_una during the copy.
If you want to optimize this (because release_sock() can process the
socket backlog, and update snd_una), please use :
/* Copy the first unacked seq into the receive msg control part.
* As put_cmsg() might sleep, we must copy snd_una in a private var.
* Integer reads are atomic on all arches, so this copy can be
* performed while socket is unlocked.
*/
if (sock_flag(sk, SOCK_XMIT_COMPL_SEQ)) {
u32 snd_una = tp->snd_una;
put_cmsg(msg, SOL_SOCKET, SCM_XMIT_COMPL_SEQ,
sizeof(snd_una), &snd_una);
}
Thanks !
next prev parent reply other threads:[~2010-09-24 1:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-23 21:35 [PATCH v3] xmit_compl_seq: information to reclaim vmsplice buffers Tom Herbert
2010-09-24 1:48 ` Eric Dumazet [this message]
2010-09-27 17:23 ` Michael S. Tsirkin
2010-09-27 18:38 ` Tom Herbert
2010-09-27 19:12 ` Eric Dumazet
2010-09-27 21:49 ` Tom Herbert
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=1285292892.2380.16.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=sridharr@google.com \
--cc=therbert@google.com \
/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