Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4279092rwd; Tue, 30 May 2023 03:10:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62okmAT6fVvuIRclaIlq5CafICUyLvBOtl8QWWWIL/eSz3dgrn4jSjTb8WWgwwPb/gZIf6 X-Received: by 2002:a05:6a00:3905:b0:63b:5501:6795 with SMTP id fh5-20020a056a00390500b0063b55016795mr2222816pfb.24.1685441400699; Tue, 30 May 2023 03:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685441400; cv=none; d=google.com; s=arc-20160816; b=IANDsyJRSdOMe8CQGsR9NpWxyJxgLHoBvnyzOj05LgZ6EcNXIQOrCR+tjPXuqMQm01 gzGiZao+HdxFaiqll/ywesdoAzNrmpwBbAttNXo35FItOALxZ+tQ/v3asiQVKhzoKKkU HP2wrHO91ALRG2rK9xqxqamBc+fKkebvqEX0eEfwundRXt4mOBqiqQSYmmDwsFz5BLUw +efTknejcO0NXFdRcaiySt03M/Khm30yBYR+uWnPqVJ9IwuKQyh7b3AZJkiOPyTWiqiJ TJ2LJz7tSGLA966p1LsjaqzavyDsfG8pDYrYDiAsOkaO7aET0P5XlJnN5HyGtHBGvkt1 Weiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=wfzfeMtirG5QHJLiHd4JBm4644BE/2DpR8F2CXOzA6E=; b=abeF5JC582+t7MTDYEpSAGeHYMOYHzV0Y9ebSHn6k6r/8xP3U7TpHruTpvt4/S9YP4 TeY57cuYCcXy3G6M1K0IzATR4Yd+Y+/kXuXV1P1kDW92Z+UankZjd3gZ/pN2DyvT6MHY AVEhvQtl+3DNRbyAM2yuu6PlM9DvE1mGVEE8Q7CRJUqmxzMQtkr5F5pbX8NYkFut71ud RWLsY2NJ+todHl6Kn0tGCg5iCEnq7kTodjjdjnHcbgpJaCp3657jMvmkoaXpgl0ty/Fq ixCHIheGlhwnn9plwUYwJamnn9QqQBNc0z9msyW8vUwv8YZ4wL54LvFemT3sgTsk1i9E +1Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qCFFn90B; 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 a19-20020a637053000000b0053efe1af2d0si3721443pgn.224.2023.05.30.03.09.47; Tue, 30 May 2023 03:10:00 -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=20221208 header.b=qCFFn90B; 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 S231295AbjE3KBS (ORCPT + 99 others); Tue, 30 May 2023 06:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbjE3KBN (ORCPT ); Tue, 30 May 2023 06:01:13 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11EAA9C for ; Tue, 30 May 2023 03:01:11 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-51400fa347dso11391a12.0 for ; Tue, 30 May 2023 03:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685440869; x=1688032869; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wfzfeMtirG5QHJLiHd4JBm4644BE/2DpR8F2CXOzA6E=; b=qCFFn90BdrsPrk3a85q++FOBXx412EpZvXib9VRrAyNla0ozGWXyQWe0uzw5vclo00 4wu4kw4bZGVZMPYqXhNbBabc8fLnCSrGrNTWjYFNSYk3F6YLH/NCfJ/VM4dRI7/jJSny 4wt42UBxMO0y8pRkyqWBcT/CEuNUeOHyW567nAse3OF5RNJCrMy519pAbhX+n6+8y8C0 9bq5A5vJMOeW6vk+N7FKfrRkChXWft5hD+tnOEUFK1ah4bAql8pMzhjdqlT19g6WzxMx M47VXij8bmhGiC8E6MaF/UTdQ3qHemoOfAYqIw4opgNoMV3ePZO13w5OoDe1XZK8PlLO NrYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685440869; x=1688032869; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wfzfeMtirG5QHJLiHd4JBm4644BE/2DpR8F2CXOzA6E=; b=Fz4vG6KimqFF4kQYD9f0ktnUT0jpHXz1/GgLSXeWEXLoglQIhpbfm+YMz/SmC5+1Yr PhqBQ7TO/mML34JlN+ADYaMSeMhCNNgfUeOlcs1VpAlSq6TZ3XgBPdzNollJ2/Sk3g/6 qOs9qZOF3QuefZJ4dcG4nzgl/awG6OlPMItDDKPe1HMv2pHEeecfc+pao5m70WR9QB6l 2HgPm8DOhhIT/jHEUrvpN83bc7ywrGrGlEPFuQZN/pd/tv5OJ/h7s9X/GrMJgUpaz+Sj kxrg8DLZ5tmngv3qP0/C4ij3YOPjU0IO1TGCUtCJ/m+PPVZ8On+7nsShuxZqaxZdvRqa n6Bw== X-Gm-Message-State: AC+VfDwKzn1zYUz2VLtvjh+UXYopyaiNXj5VbMTmmNZVclR6xXHKdl0t FKBBVkFurL1G8fZos6Kl45ZNeUzxSbEAXzcYGKvojw== X-Received: by 2002:a50:c059:0:b0:506:c207:c979 with SMTP id u25-20020a50c059000000b00506c207c979mr75079edd.0.1685440869312; Tue, 30 May 2023 03:01:09 -0700 (PDT) MIME-Version: 1.0 References: <20230529113804.GA20300@didi-ThinkCentre-M920t-N000> In-Reply-To: From: Eric Dumazet Date: Tue, 30 May 2023 12:00:57 +0200 Message-ID: Subject: Re: [PATCH net] tcp: introduce a compack timer handler in sack compression To: Jason Xing Cc: toke@toke.dk, Yuchung Cheng , "David S. Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Neal Cardwell , netdev@vger.kernel.org, zhangweiping , tiozhang , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, fuyuanli@didiglobal.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Tue, May 30, 2023 at 9:45=E2=80=AFAM Jason Xing wrote: > > On Tue, May 30, 2023 at 3:12=E2=80=AFPM Eric Dumazet wrote: > > > > On Mon, May 29, 2023 at 1:38=E2=80=AFPM fuyuanli wrote: > > > > > > We've got some issues when sending a compressed ack is deferred to > > > release phrase due to the socket owned by another user: > > > 1. a compressed ack would not be sent because of lack of ICSK_ACK_TIM= ER > > > flag. > > > > Are you sure ? Just add it then, your patch will be a one-liner > > instead of a complex one adding > > more code in a fast path. > > Honestly, at the very beginning, we just added one line[1] to fix > this. After I digged more into this part, I started to doubt if we > should reuse the delayed ack logic. > > Because in the sack compression logic there is no need to do more > things as delayed ack does in the tcp_delack_timer_handler() function. > > Besides, here are some things extra to be done if we defer to send an > ack in sack compression: > 1) decrease tp->compressed_ack. The same as "tp->compressed_ack--;" in > tcp_compressed_ack_kick(). > 2) initialize icsk->icsk_ack.timeout. Actually we don't need to do > this because we don't modify the expiration time in the sack > compression hrtimer. Yes, we do not need this, see my following comment. > 3) don't need to count the LINUX_MIB_DELAYEDACKS counter. > 4) I wonder even if those checks about the ack schedule or ping pong > mode in tcp_delack_timer_handler() for sack compression? I'm not sure > about it. > > So one line cannot solve it perfectly. That's the reason why we > introduce a new logic which can be clearer. > > I'm wondering if adding one check in the fast path is really that > unacceptable (it may hurt performance?) because a new logic would be > clearer for the whole sack compression. We definitely can solve the minor issue by not polluting the fast path. We also want simple/localised fixes, not something invasive (and risky). > > [1] > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > index cc072d2cfcd8..d9e76d761cc6 100644 > --- a/net/ipv4/tcp_input.c > +++ b/net/ipv4/tcp_input.c > @@ -5568,6 +5568,7 @@ static void __tcp_ack_snd_check(struct sock *sk, > int ofo_possible) > > READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_comp_sack_delay_ns), > rtt * (NSEC_PER_USEC >> 3)/20); > sock_hold(sk); > + inet_csk(sk)->icsk_ack.pending |=3D ICSK_ACK_TIMER; Why not simply use existing storage/variables (tp->compressed_ack), instead of trying to reuse something else or add another bit, then complain that this does not work well ? Again, just fix tcp_delack_timer_handler(), it already can fetch existing s= tate. As a bonus, no need to send one patch for net, and another in net-next, trying to 'fix' issues that should have been fixed cleanly in a single patc= h. Something like: diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index b839c2f91292f7346f33d6dcbf597594473a5aca..16bc4cedceb8a5e88f61f9abc2c= 0a8cc9322676a 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -290,10 +290,20 @@ static int tcp_write_timeout(struct sock *sk) void tcp_delack_timer_handler(struct sock *sk) { struct inet_connection_sock *icsk =3D inet_csk(sk); + struct tcp_sock *tp =3D tcp_sk(sk); - if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) || - !(icsk->icsk_ack.pending & ICSK_ACK_TIMER)) + if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) + return; + + if (!(icsk->icsk_ack.pending & ICSK_ACK_TIMER) && + !tp->compressed_ack) + return; + + if (tp->compressed_ack) { + tcp_mstamp_refresh(tp); + tcp_sack_compress_send_ack(sk); return; + } if (time_after(icsk->icsk_ack.timeout, jiffies)) { sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout); @@ -312,7 +322,7 @@ void tcp_delack_timer_handler(struct sock *sk) inet_csk_exit_pingpong_mode(sk); icsk->icsk_ack.ato =3D TCP_ATO_MIN; } - tcp_mstamp_refresh(tcp_sk(sk)); + tcp_mstamp_refresh(tp); tcp_send_ack(sk); __NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKS); }