Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5780957imw; Wed, 20 Jul 2022 12:23:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ucFo9+D/iSQC3HixjM1uy0dmhBZpPv1/nUbZHIqY7muLKaU1iwO7ttoUfsKTGV4CwVzAwF X-Received: by 2002:a17:907:7fa7:b0:72e:f88c:db16 with SMTP id qk39-20020a1709077fa700b0072ef88cdb16mr26369613ejc.366.1658345016488; Wed, 20 Jul 2022 12:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658345016; cv=none; d=google.com; s=arc-20160816; b=q67Qz5IAGCmSE20DYrqDWl7D3AHG1OzCuCO3pHrWKddnolMSrJF2wqYzY3U1R0i3wU KHPnaAVEIMI7hcTUMHza6ytN0eKU9AXr0ig/MJJhOm7wTA/vkhPDm6Ba275kR/pfT4tj 7qRHitE5Pa8V60h2PG+1kyxaM+IQMncUbmZU3RBWNEjtxKiyLPhiKQg5hDprEJDYAO4w 0bbey7MnFJWuyOKEKTaNY2PT+nxoQgBV2s2/MjgLS64gN8Fot2whzAUQqjo0mr+kcOOM aQFPagZN8Vk6zTriecZ0Bu3ck+F+DWBvHqBId8dft20Xtad/uhLUUmiZ+68ZSUH+K/yX bcSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ewHdJY+0XilkP+ABNbGfVEqdZY0AHgVgsfEbax1I1nI=; b=kL7AA17KlZkm71CfcITYGH79Pvk13NgGdSQiqQe87m+5C/mafQBgWW06bCkxJY3csV Rm/InrBdKeHzCOwoIin1RUYb2O5n22OLzhugWuyzPN1Kp8XzJY9MP/zdFe/6HTSmtAkd Hss8QXOG4mcrk4WMJ/e4UlOTMaIO979IzJdGiI836StJpIGaOY1sElrjtfjpmAoDMs1r oLAPb4NVegci8ooaRZcYr3exKdjzE7oWLbX9oapTSZTgY+ZtgIajk1QDBNd6ZckBSmr3 wDRu0aJAxyDgvO9TVB0sQk659VbWaFmkoirjjDTIoqsZm208tMrXOnXydL8+jrP15qZ3 qfQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=F9x0Fxkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go39-20020a1709070da700b0071578ad44a1si23553872ejc.986.2022.07.20.12.23.10; Wed, 20 Jul 2022 12:23:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=F9x0Fxkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbiGTStz (ORCPT + 99 others); Wed, 20 Jul 2022 14:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbiGTSty (ORCPT ); Wed, 20 Jul 2022 14:49:54 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C725C735BF for ; Wed, 20 Jul 2022 11:49:52 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id l3so12205501qkl.3 for ; Wed, 20 Jul 2022 11:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ewHdJY+0XilkP+ABNbGfVEqdZY0AHgVgsfEbax1I1nI=; b=F9x0Fxkpa/jLnmDbMPmLXofXV5EW8/x22/stbIqW17hDUGzcswbmPx8laZD4o0MXEe QgFAOVkYEm8Sy0tRQuY4GSDH38giuxoBxr0sfhk0FmCorNZEcYMG3CTwu15AmTtozpou iNB0wrjDTkzANtZedl75sd8B6sUswAHZw7B/lmwpp0YxEHObCkPB2/tFcqtLkldT1UzG vTvW7/C8LqJs5441VJ/2VGsceX+3SKG63JX62X9nMZUVW/aw/87DHTNY1SgAMtqE9pYQ NFcOdWo1b95yqvZlWWswFqEiGZJsVvU9qqRgPfkRyYeTK4a0S28tbSYqlMzVLXL+vhZP FlCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ewHdJY+0XilkP+ABNbGfVEqdZY0AHgVgsfEbax1I1nI=; b=CC5hl0eDVOP2hMw5KDaSDYeYxMYC3h5oC31HyCB1jAuSOgKk4jIIcnnwusi1E6NN5E 1bJuQo/bXk4BOyXTd5OkitXIaYJG0hx0iUhIQ4TpcbamU98t80sxj2WS8Gll6+voLU58 9fLPpkPYMj99rKF85jSd10xlaPNLUx5lvY3LkMd9vVnw1ZpJx3NciQMQjh2gCaAaHbl8 4ca7OhQ3kyfMa5R13+eA3dZtVqTcrCBf4zjRSVbT2EngCi3yR3T1LQo5nmSuw2AoYSZM bcNYQgz7nOaSpVg8KqKyV0Wq7mcMnR6RVYnjCmKmMPD4BwDUU3GbOLddZGaHF1gtQex+ Adww== X-Gm-Message-State: AJIora95XELtoEqEUSCMpAx9+Ra/wDh2ETD1jrQwM4I+FoJcCuCxMV9a sv4DM5oefpAFcV4WkqiTAGzLj/jydH5Aq6rJiK/7XcJivW0= X-Received: by 2002:a05:620a:410c:b0:6b2:82d8:dcae with SMTP id j12-20020a05620a410c00b006b282d8dcaemr25452157qko.259.1658342991816; Wed, 20 Jul 2022 11:49:51 -0700 (PDT) MIME-Version: 1.0 References: <20220720072404.16708-1-hlm3280@163.com> In-Reply-To: <20220720072404.16708-1-hlm3280@163.com> From: Neal Cardwell Date: Wed, 20 Jul 2022 14:49:35 -0400 Message-ID: Subject: Re: [PATCH net-next v2] tcp: fix condition for increasing pingpong count To: LemmyHuang Cc: edumazet@google.com, davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Wei Wang , Yuchung Cheng , Soheil Hassas Yeganeh Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 20, 2022 at 3:25 AM LemmyHuang wrote: > > When CONFIG_HZ defaults to 1000Hz and the network transmission time is > less than 1ms, lsndtime and lrcvtime are likely to be equal, which will > lead to hundreds of interactions before entering pingpong mode. > > Fixes: 4a41f453bedf ("tcp: change pingpong threshold to 3") > Suggested-by: Jakub Kicinski > Signed-off-by: LemmyHuang > --- > v2: > * Use !after() wrapping the values. (Jakub Kicinski) > > v1: https://lore.kernel.org/netdev/20220719130136.11907-1-hlm3280@163.com/ > --- > net/ipv4/tcp_output.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c > index 858a15cc2..c1c95dc40 100644 > --- a/net/ipv4/tcp_output.c > +++ b/net/ipv4/tcp_output.c > @@ -172,7 +172,7 @@ static void tcp_event_data_sent(struct tcp_sock *tp, > * and it is a reply for ato after last received packet, > * increase pingpong count. > */ > - if (before(tp->lsndtime, icsk->icsk_ack.lrcvtime) && > + if (!after(tp->lsndtime, icsk->icsk_ack.lrcvtime) && > (u32)(now - icsk->icsk_ack.lrcvtime) < icsk->icsk_ack.ato) > inet_csk_inc_pingpong_cnt(sk); > > -- Thanks for pointing out this problem! AFAICT this patch would result in incorrect behavior. With this patch, we could have cases where tp->lsndtime == icsk->icsk_ack.lrcvtime and (u32)(now - icsk->icsk_ack.lrcvtime) < icsk->icsk_ack.ato and yet we do not really have a ping-pong exchange. For example, with this patch we could have: T1: jiffies=J1; host B receives RPC request from host A T2: jiffies=J1; host B sends first RPC response data packet to host A; -> calls inet_csk_inc_pingpong_cnt() T3: jiffies=J1; host B sends second RPC response data packet to host A; -> calls inet_csk_inc_pingpong_cnt() In this scenario there is only one ping-pong exchange but the code calls inet_csk_inc_pingpong_cnt() twice. So I'm hoping we can come up with a better fix. A simpler approach might be to simplify the model and go back to having a single ping-pong interaction cause delayed ACKs to be enabled on a connection endpoint. Our team has been seeing good results for a while with the simpler approach. What do folks think? neal