From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1A1CC5ACD6 for ; Wed, 18 Mar 2020 09:47:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7CA6420767 for ; Wed, 18 Mar 2020 09:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727655AbgCRJrB (ORCPT ); Wed, 18 Mar 2020 05:47:01 -0400 Received: from smtp-rs2-vallila1.fe.helsinki.fi ([128.214.173.73]:53282 "EHLO smtp-rs2-vallila1.fe.helsinki.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727041AbgCRJq7 (ORCPT ); Wed, 18 Mar 2020 05:46:59 -0400 Received: from whs-18.cs.helsinki.fi (whs-18.cs.helsinki.fi [128.214.166.46]) by smtp-rs2.it.helsinki.fi (8.14.7/8.14.7) with ESMTP id 02I9cE9V006445; Wed, 18 Mar 2020 11:38:14 +0200 Received: by whs-18.cs.helsinki.fi (Postfix, from userid 1070048) id A8DFD360F5C; Wed, 18 Mar 2020 11:38:14 +0200 (EET) From: =?ISO-8859-1?Q?Ilpo_J=E4rvinen?= To: netdev@vger.kernel.org Cc: Yuchung Cheng , Neal Cardwell , Eric Dumazet , Olivier Tilmans Subject: [RFC PATCH 26/28] tcp: to prevent runaway AccECN cep/ACE deficit, limit GSO size Date: Wed, 18 Mar 2020 11:38:07 +0200 Message-Id: <1584524289-24187-26-git-send-email-ilpo.jarvinen@helsinki.fi> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584524289-24187-2-git-send-email-ilpo.jarvinen@helsinki.fi> References: <1584524289-24187-2-git-send-email-ilpo.jarvinen@helsinki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ilpo Järvinen It could occur that GSO sends segments in so large blocks that ACE deficit keeps growing because ACE field can only update in each super skb. Put some limit into sending large super skbs in case the ACE deficit is there and could go on indefinitely. Once the bool becomes false, it's no longer necessary to recheck it during further sending. Signed-off-by: Ilpo Järvinen --- net/ipv4/tcp_output.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 0aec2c57a9cc..4de6510532f2 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2124,6 +2124,23 @@ static bool tcp_snd_wnd_test(const struct tcp_sock *tp, return !after(end_seq, tcp_wnd_end(tp)); } +/* Runaway ACE deficit possible? */ +static bool tcp_accecn_deficit_runaway_test(const struct tcp_sock *tp, + int cwnd_quota) +{ + return (tcp_accecn_ace_deficit(tp) >= 2 * TCP_ACCECN_ACE_MAX_DELTA) && + (cwnd_quota > TCP_ACCECN_ACE_MAX_DELTA - 1); +} + +static u32 tcp_accecn_gso_limit(struct tcp_sock *tp, + const struct sk_buff *skb, int cwnd_quota) +{ + if (unlikely(tcp_accecn_deficit_runaway_test(tp, cwnd_quota))) + return TCP_ACCECN_ACE_MAX_DELTA - 1; + + return 0; +} + /* Trim TSO SKB to LEN bytes, put the remaining data into a new packet * which is put after SKB on the list. It is very much like * tcp_fragment() except that it may make several kinds of assumptions @@ -2623,6 +2640,8 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, int cwnd_quota; int result; bool is_cwnd_limited = false, is_rwnd_limited = false; + /* AccECN limit will be lifted below if not needed */ + bool accecn_gso_limit = tcp_ecn_mode_accecn(tp); u32 max_segs; sent_pkts = 0; @@ -2676,7 +2695,16 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, nonagle : TCP_NAGLE_PUSH)))) break; } else { - if (!push_one && + if (accecn_gso_limit) { + u32 limit = tcp_accecn_gso_limit(tp, skb, + cwnd_quota); + if (limit > 0) + cwnd_quota = limit; + else + accecn_gso_limit = false; + } + + if (!push_one && !accecn_gso_limit && tcp_tso_should_defer(sk, skb, &is_cwnd_limited, &is_rwnd_limited, max_segs)) break; -- 2.20.1