From: Thomas Jarosch <thomas.jarosch@intra2net.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: netdev@vger.kernel.org, edumazet@google.com,
Steffen Klassert <steffen.klassert@secunet.com>,
Ben Hutchings <bhutchings@solarflare.com>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: tcp: Do not apply TSO segment limit to non-TSO packets
Date: Fri, 16 Jan 2015 11:45:44 +0100 [thread overview]
Message-ID: <74814478.Xs0dcijNdd@storm> (raw)
In-Reply-To: <20141231133923.GA30248@gondor.apana.org.au>
On Thursday, 1. January 2015 00:39:23 Herbert Xu wrote:
> On Mon, Dec 01, 2014 at 06:25:22PM +0800, Herbert Xu wrote:
> > Thomas Jarosch <thomas.jarosch@intra2net.com> wrote:
> > > When I revert it, even kernel v3.18-rc6 starts working.
> > > But I doubt this is the root problem, may be just hiding another
> > > issue.
> >
> > Can you do a tcpdump with this patch reverted? I would like to
> > see the size of the packets that are sent out vs. the ICMP message
> > that came back.
>
> Thanks for providing the data. Here is a patch that should fix
> the problem.
Thanks for the fix, Herbert! I've verified the patch is working fine
and the tcpdump looks good, too. In fact the PMTU discovery
only takes 0.001s, you can barely notice it ;)
For backporting to -stable: Kernel 3.14 lacks tcp_tso_autosize().
So I've borrowed that from 3.19-rc4+ and also added the max_segs variable.
The final and tested code looks like this:
-- >8 --
Thomas Jarosch reported IPsec TCP stalls when a PMTU event occurs.
In fact the problem was completely unrelated to IPsec. The bug is
also reproducible if you just disable TSO/GSO.
The problem is that when the MSS goes down, existing queued packet
on the TX queue that have not been transmitted yet all look like
TSO packets and get treated as such.
This then triggers a bug where tcp_mss_split_point tells us to
generate a zero-sized packet on the TX queue. Once that happens
we're screwed because the zero-sized packet can never be removed
by ACKs.
Fixes: 1485348d242 ("tcp: Apply device TSO segment limit earlier")
Reported-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 17a11e6..a109032 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1432,6 +1432,27 @@ static bool tcp_nagle_check(bool partial, const struct tcp_sock *tp,
((nonagle & TCP_NAGLE_CORK) ||
(!nonagle && tp->packets_out && tcp_minshall_check(tp)));
}
+
+/* Return how many segs we'd like on a TSO packet,
+ * to send one TSO packet per ms
+ */
+static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now)
+{
+ u32 bytes, segs;
+
+ bytes = min(sk->sk_pacing_rate >> 10,
+ sk->sk_gso_max_size - 1 - MAX_TCP_HEADER);
+
+ /* Goal is to send at least one packet per ms,
+ * not one big TSO packet every 100 ms.
+ * This preserves ACK clocking and is consistent
+ * with tcp_tso_should_defer() heuristic.
+ */
+ segs = max_t(u32, bytes / mss_now, sysctl_tcp_min_tso_segs);
+
+ return min_t(u32, segs, sk->sk_gso_max_segs);
+}
+
/* Returns the portion of skb which can be sent right away */
static unsigned int tcp_mss_split_point(const struct sock *sk,
const struct sk_buff *skb,
@@ -1857,6 +1878,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
unsigned int tso_segs, sent_pkts;
int cwnd_quota;
int result;
+ u32 max_segs;
sent_pkts = 0;
@@ -1870,6 +1892,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
}
}
+ max_segs = tcp_tso_autosize(sk, mss_now);
while ((skb = tcp_send_head(sk))) {
unsigned int limit;
@@ -1891,7 +1914,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now)))
break;
- if (tso_segs == 1) {
+ if (tso_segs == 1 || !max_segs) {
if (unlikely(!tcp_nagle_test(tp, skb, mss_now,
(tcp_skb_is_last(sk, skb) ?
nonagle : TCP_NAGLE_PUSH))))
@@ -1928,7 +1951,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
}
limit = mss_now;
- if (tso_segs > 1 && !tcp_urg_mode(tp))
+ if (tso_segs > 1 && max_segs && !tcp_urg_mode(tp))
limit = tcp_mss_split_point(sk, skb, mss_now,
min_t(unsigned int,
cwnd_quota,
--
1.9.3
next prev parent reply other threads:[~2015-01-16 10:45 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-29 11:44 [bisected] xfrm: TCP connection initiating PMTU discovery stalls on v3.12+ Thomas Jarosch
2014-12-01 10:25 ` Herbert Xu
2014-12-01 11:20 ` Thomas Jarosch
2014-12-31 13:39 ` tcp: Do not apply TSO segment limit to non-TSO packets Herbert Xu
2014-12-31 13:42 ` Herbert Xu
2015-01-02 18:24 ` Eric Dumazet
2015-01-02 20:36 ` David Miller
2015-01-02 22:01 ` Herbert Xu
2015-01-02 22:06 ` David Miller
2015-01-02 22:09 ` Herbert Xu
2015-01-02 21:13 ` David Miller
2015-01-16 10:45 ` Thomas Jarosch [this message]
2015-01-16 10:50 ` Herbert Xu
2015-01-16 11:03 ` Thomas Jarosch
2015-01-19 13:39 ` Thomas Jarosch
[not found] ` <CANn89i+U-PFbuUrp08s3Ec8BmjPFq1zj8Aj2=vPVO4-iiLkTuw@mail.gmail.com>
2015-01-19 22:36 ` Herbert Xu
2015-01-19 22:38 ` Eric Dumazet
2015-01-19 22:40 ` Herbert Xu
2014-12-01 13:17 ` [bisected] xfrm: TCP connection initiating PMTU discovery stalls on v3.12+ Wolfgang Walter
2014-12-01 16:41 ` Wolfgang Walter
2014-12-05 12:09 ` Wolfgang Walter
2014-12-05 13:26 ` Eric Dumazet
2014-12-08 22:20 ` Wolfgang Walter
2014-12-09 8:54 ` Thomas Jarosch
2014-12-09 14:26 ` [bisected] xfrm: TCP connection initiating PMTU discovery stalls on v3 Eric Dumazet
2014-12-09 14:49 ` Thomas Jarosch
2014-12-09 20:36 ` Wolfgang Walter
2014-12-09 21:40 ` Eric Dumazet
2014-12-10 18:34 ` Wolfgang Walter
2014-12-10 19:10 ` Eric Dumazet
2014-12-11 0:36 ` Wolfgang Walter
2014-12-12 16:58 ` Wolfgang Walter
2014-12-12 17:27 ` Eric Dumazet
2014-12-12 20:31 ` Wolfgang Walter
2014-12-12 21:30 ` Thomas Jarosch
2014-12-12 22:31 ` Eric Dumazet
2014-12-12 23:47 ` Wolfgang Walter
2014-12-13 0:15 ` Eric Dumazet
2014-12-13 0:43 ` Wolfgang Walter
2014-12-15 18:04 ` Wolfgang Walter
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=74814478.Xs0dcijNdd@storm \
--to=thomas.jarosch@intra2net.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.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