From: Soheil Hassas Yeganeh <soheil@google.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>,
David Miller <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>, Alexei Starovoitov <ast@fb.com>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Subject: Re: [PATCH net-next] tcp: guarantee forward progress in tcp_sendmsg()
Date: Tue, 3 May 2016 00:53:09 -0400 [thread overview]
Message-ID: <CACSApvY_eRfr4ukOha6ebxz1VHiSYQGAhP9hRJApbL3zHsAzUw@mail.gmail.com> (raw)
In-Reply-To: <1462250965.5535.286.camel@edumazet-glaptop3.roam.corp.google.com>
On Tue, May 3, 2016 at 12:49 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> Under high rx pressure, it is possible tcp_sendmsg() never has a
> chance to allocate an skb and loop forever as sk_flush_backlog()
> would always return true.
>
> Fix this by calling sk_flush_backlog() only if one skb had been
> allocated and filled before last backlog check.
>
> Fixes: d41a69f1d390 ("tcp: make tcp_sendmsg() aware of socket backlog")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
> ---
> net/ipv4/tcp.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index b945c2b046c5ead5503505f250c3c67761b284ae..5c7ed147449c1b7ba029b12e033ad779a631460a 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1084,6 +1084,7 @@ int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
> struct sockcm_cookie sockc;
> int flags, err, copied = 0;
> int mss_now = 0, size_goal, copied_syn = 0;
> + bool process_backlog = false;
> bool sg;
> long timeo;
>
> @@ -1167,9 +1168,10 @@ new_segment:
> if (!sk_stream_memory_free(sk))
> goto wait_for_sndbuf;
>
> - if (sk_flush_backlog(sk))
> + if (process_backlog && sk_flush_backlog(sk)) {
> + process_backlog = false;
> goto restart;
> -
> + }
> skb = sk_stream_alloc_skb(sk,
> select_size(sk, sg),
> sk->sk_allocation,
> @@ -1177,6 +1179,7 @@ new_segment:
> if (!skb)
> goto wait_for_memory;
>
> + process_backlog = true;
> /*
> * Check whether we can use HW checksum.
> */
>
>
Nice catch! Thanks.
next prev parent reply other threads:[~2016-05-03 4:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 21:16 [PATCH v2 net-next 0/7] net: make TCP preemptible Eric Dumazet
2016-04-29 21:16 ` [PATCH v3 net-next 1/7] tcp: do not assume TCP code is non preemptible Eric Dumazet
2016-04-29 21:16 ` [PATCH v3 net-next 2/7] tcp: do not block bh during prequeue processing Eric Dumazet
2016-04-29 21:47 ` Alexei Starovoitov
2016-04-29 21:16 ` [PATCH v3 net-next 3/7] dccp: do not assume DCCP code is non preemptible Eric Dumazet
2016-04-29 21:16 ` [PATCH v3 net-next 4/7] udp: prepare for non BH masking at backlog processing Eric Dumazet
2016-04-29 21:16 ` [PATCH v3 net-next 5/7] sctp: prepare for socket backlog behavior change Eric Dumazet
2016-04-29 22:01 ` Marcelo Ricardo Leitner
2016-04-29 21:16 ` [PATCH v3 net-next 6/7] net: do not block BH while processing socket backlog Eric Dumazet
2016-04-29 21:47 ` Alexei Starovoitov
2016-04-29 21:16 ` [PATCH v3 net-next 7/7] tcp: make tcp_sendmsg() aware of " Eric Dumazet
2016-05-03 4:49 ` [PATCH net-next] tcp: guarantee forward progress in tcp_sendmsg() Eric Dumazet
2016-05-03 4:53 ` Soheil Hassas Yeganeh [this message]
2016-05-03 20:20 ` David Miller
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=CACSApvY_eRfr4ukOha6ebxz1VHiSYQGAhP9hRJApbL3zHsAzUw@mail.gmail.com \
--to=soheil@google.com \
--cc=ast@fb.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).