From patchwork Thu Dec 6 17:58:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 1008952 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="k58RezqN"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 439jyJ1FCkz9s3q for ; Fri, 7 Dec 2018 04:58:32 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725936AbeLFR6a (ORCPT ); Thu, 6 Dec 2018 12:58:30 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:39018 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbeLFR6a (ORCPT ); Thu, 6 Dec 2018 12:58:30 -0500 Received: by mail-pg1-f194.google.com with SMTP id w6so473003pgl.6 for ; Thu, 06 Dec 2018 09:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4p69pAwHQhrFZC3EHrRMRKL6u6hZSbbTkWV9s/V+PzI=; b=k58RezqNVAmJWq0kOzvwO9rGUHCv4k2Dg7G+8HpDiq4ZXtHtn+u6N22mGnYBVreDBi HKYwSGqjTLhcSIAw0uvLnAUMxAaCu+j4a4fj2bGqf5OcZBpqoopOIJj/g+sBZ8XDD7Uc zqHxuUTAOF1ApRfofZS5aw4tnVtbFAKFqAmAJKpjrtAiC7QI+PRHlxXEKS+wxwp6PKUv jHD7MtV5mXoEIQQ4MwmmBLGhSFoJIsehTQh2G/O9WkrHQrY+H4HdoSBgkumA8tl7YoE0 EBrZohGOetgpdfdlk9hVryJ+hKA/3b0maAKiu5Pm26JRDauUlGTzvRjrdnjTdKq1lWrU C+Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4p69pAwHQhrFZC3EHrRMRKL6u6hZSbbTkWV9s/V+PzI=; b=S7DQ5ouRFvCkhPf9aktNaShGVlES6Ri3smSUycU2qYsSomLh9PgVZi8MdMIAg7hXAO Yoj4PDanG1O7cQPlYjovNgAr34kStxozrO+wjkT/Maf3rn63cnFnDupNZPwxNEGN0U+D Eyb+4Dzb5+Fpqdt0Gm3LHA7RbU/DY4WdVb/dl+UDH9EVMA2wJpLANr0b+4/gzSQX7Q40 x1kXewGFbCXWpGmKVG8m3p8ZtDBH8p3AwPa1gE/8gKo+acExShjUOciN4ZN7FHbzzW5A 88DbXPecRCz3TM7fvmNke2BQIhye+BcPggxnL1Hg9cWgfAAELQkglE9yuN4HES7mxyH1 P4og== X-Gm-Message-State: AA+aEWaw2JAFu4bZ8shZ9E8MPxxh584/rs5gCkI4CZRedAXInKz5oZEi CmD5HejMzAedlEvog2V5J4zRkw== X-Google-Smtp-Source: AFSGD/V8XnZhQ1mbWAXhJg2hG8EoTLH/VLnnVtJRRgOJaSJL10SYj9N47uNnczDg7/hfkR02bo8c1A== X-Received: by 2002:a65:41c2:: with SMTP id b2mr24624221pgq.67.1544119108731; Thu, 06 Dec 2018 09:58:28 -0800 (PST) Received: from localhost ([2620:15c:2c4:201:f5a:7eca:440a:3ead]) by smtp.gmail.com with ESMTPSA id o1sm1554014pgn.63.2018.12.06.09.58.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 09:58:27 -0800 (PST) From: Eric Dumazet To: "David S . Miller" Cc: netdev , Eric Dumazet , Neal Cardwell , Soheil Hassas Yeganeh , Yuchung Cheng , Eric Dumazet Subject: [PATCH net] tcp: lack of available data can also cause TSO defer Date: Thu, 6 Dec 2018 09:58:24 -0800 Message-Id: <20181206175824.103521-1-edumazet@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org tcp_tso_should_defer() can return true in three different cases : 1) We are cwnd-limited 2) We are rwnd-limited 3) We are application limited. Neal pointed out that my recent fix went too far, since it assumed that if we were not in 1) case, we must be rwnd-limited Fix this by properly populating the is_cwnd_limited and is_rwnd_limited booleans. After this change, we can finally move the silly check for FIN flag only for the application-limited case. The same move for EOR bit will be handled in net-next, since commit 1c09f7d073b1 ("tcp: do not try to defer skbs with eor mark (MSG_EOR)") is scheduled for linux-4.21 Tested by running 200 concurrent netperf -t TCP_RR -- -r 60000,100 and checking none of them was rwnd_limited in the chrono_stat output from "ss -ti" command. Fixes: 41727549de3e ("tcp: Do not underestimate rwnd_limited") Signed-off-by: Eric Dumazet Suggested-by: Neal Cardwell Reviewed-by: Neal Cardwell Acked-by: Soheil Hassas Yeganeh Reviewed-by: Yuchung Cheng --- net/ipv4/tcp_output.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 5aa600900695666aa8b55f1e4b11ba5129509958..d1676d8a6ed70fbe050709a16a650df35a1f4d87 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1904,7 +1904,9 @@ static int tso_fragment(struct sock *sk, enum tcp_queue tcp_queue, * This algorithm is from John Heffner. */ static bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb, - bool *is_cwnd_limited, u32 max_segs) + bool *is_cwnd_limited, + bool *is_rwnd_limited, + u32 max_segs) { const struct inet_connection_sock *icsk = inet_csk(sk); u32 age, send_win, cong_win, limit, in_flight; @@ -1912,9 +1914,6 @@ static bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb, struct sk_buff *head; int win_divisor; - if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) - goto send_now; - if (icsk->icsk_ca_state >= TCP_CA_Recovery) goto send_now; @@ -1973,10 +1972,27 @@ static bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb, if (age < (tp->srtt_us >> 4)) goto send_now; - /* Ok, it looks like it is advisable to defer. */ + /* Ok, it looks like it is advisable to defer. + * Three cases are tracked : + * 1) We are cwnd-limited + * 2) We are rwnd-limited + * 3) We are application limited. + */ + if (cong_win < send_win) { + if (cong_win <= skb->len) { + *is_cwnd_limited = true; + return true; + } + } else { + if (send_win <= skb->len) { + *is_rwnd_limited = true; + return true; + } + } - if (cong_win < send_win && cong_win <= skb->len) - *is_cwnd_limited = true; + /* If this packet won't get more data, do not wait. */ + if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) + goto send_now; return true; @@ -2356,11 +2372,8 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, } else { if (!push_one && tcp_tso_should_defer(sk, skb, &is_cwnd_limited, - max_segs)) { - if (!is_cwnd_limited) - is_rwnd_limited = true; + &is_rwnd_limited, max_segs)) break; - } } limit = mss_now;