Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp671925rwb; Thu, 27 Jul 2023 20:22:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlGsYjuOX7ncj9miPiCfnJ2hrQ4MN9IUFXMaVljIp7YmgPuZw/LtK7SDOrerbSpY25P0Fd9+ X-Received: by 2002:a17:907:78d7:b0:99b:e428:b93c with SMTP id kv23-20020a17090778d700b0099be428b93cmr1106886ejc.68.1690514522699; Thu, 27 Jul 2023 20:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690514522; cv=none; d=google.com; s=arc-20160816; b=jgO1dQAb6A91/fLFZ41+x1dk+fJZBXm86IdAKt81RhJJVoDNtu0nNrD+CZcuHYPY+/ MwZ16/M5ePVH8FEIHmzfeSXuPCNgopFx5DRDB31yjC8MposFJWzezRXwC1cEbsL3VRDd PMC1qFmy4GKRrbHQvKyY4XS4pIKYzUyVF91s/ahRQ49vNG55njXt9KD/+WdPZPkOBhsF yA4dM9LeDJXM+8VKxI3coV4Cgyz3d8Omi7dpEnHIzGVO0spEuTxN0qnAFMlqxDYmwri2 YfGRtTx2JTy2Yk2DRtXcjndzPr3GJUuKXnTC7dKFxztaQIkfUt2mcqS6zfzMEGYcPkq2 DZfA== 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=4b3n4ix0PVCID/H1AF/PSs6xMKgdCeQOhECeB9MZXrY=; fh=AA1FTwGpJjHmZ9fEmTdh7cYVAESGUxzR6F5k9iXS/ew=; b=sWC+4neQcwLAjm6yo2GppI75MJ2erJz42064CPi/bVvdhvOzCjahJb0xr6YyoydBkm hZgPiKQwT1VmBTQ+OrasT+r4iyUPdh+yDxsPCKPXdktgYMLu5Oy5d7ihcTwuWn0d/ivt /NB9V8Smj3eCbup9x+zpATF8T4HRcWYcRJ3rWK1aSRzHwhfoJb66nSQYKktbiPZMPKgh m9sCqLrHS8VQGOEwsnj4GOKkvuHKx4AOidFnjiWcqqsuOjUWo7NtuIdJllsIBBCYRKiF 8jjigxM1A5e1m8kkmcTrCDCoeTBnYTPRpX/eKAEAH1jVJJUIqV1yP+XYYwHmAjB0NQTJ xl7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=hIEE8deF; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a17090685c900b0099b422f9c93si1851383ejy.524.2023.07.27.20.21.38; Thu, 27 Jul 2023 20:22:02 -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=@gmail.com header.s=20221208 header.b=hIEE8deF; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232653AbjG1CiL (ORCPT + 99 others); Thu, 27 Jul 2023 22:38:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232336AbjG1CiK (ORCPT ); Thu, 27 Jul 2023 22:38:10 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11B2530E0; Thu, 27 Jul 2023 19:38:08 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id 3f1490d57ef6-c5f98fc4237so1438165276.2; Thu, 27 Jul 2023 19:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690511887; x=1691116687; 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=4b3n4ix0PVCID/H1AF/PSs6xMKgdCeQOhECeB9MZXrY=; b=hIEE8deFlO6a9hQYyGPt90EuEo57RSABAUGdR6qZzuOqVuRxjthPsgH17pu2HDmCB7 nlPeaz4YDPJs/q4s6baeiysbsJF8RxONzgHyOn4XH+pQQ2ONxcJZip2sP4QND5tmCCbu bTwBkjRhnvKgioiqTc8Q7XDDC/zYAlpm1Qe0nadneHd+qBUnuGF+G6tMbGTalJEPxq4f jqC+1p/FEsDYbcBGIS0BJZlmx7zbA1VNMRiYKNonZNrTpPVri74nzQL751NiLQ3cG7v4 2VbGGa8N59pdEMZgw31ButQ7Q49PeI4Pvr3UFsWYqW6s4lKN3bVsYYygK2H7nBDxbT9m 69fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690511887; x=1691116687; 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=4b3n4ix0PVCID/H1AF/PSs6xMKgdCeQOhECeB9MZXrY=; b=bH4anYWbwMD+5C/+GFakQTeeWJ/kxRTUIiuNzc3I1mBX/iUSQ8sIw3HHCX6eTfupPq trVRIFdalH1XZbLoU968yoiVSstzF+wfJ7YtZbhA8jQ+/neQ/5ue32Vd9cienjC2nKjq bD69WthyK5r0ZyueotQO1FmhaTDr9VvcUug7ZcCT4gJWt08QOeBKQDCPFjgbOAmeOHBZ DyoaxZesBStrk4TBafsLT/BEgHrlum4pzPHNRr4vZBurcaR4E75hgIc8k2yy9yzw0Q2p xIKUX8/KjWtOsmJ0pzrF1ZT5Es9wg0VPsXlc1GZycXpd/vOdMZTtubF+KLDuB5b+kJdu 7sOQ== X-Gm-Message-State: ABy/qLa5R3/+nk9R9bezHNf0hzuBB3NTl5l01Sg7auVk8rHTJET5HF2K z9WztPSlFB2IehCE6QYHdWpX4ORaJfNNOi6M5H4= X-Received: by 2002:a0d:d453:0:b0:582:5527:ddc with SMTP id w80-20020a0dd453000000b0058255270ddcmr510035ywd.34.1690511887183; Thu, 27 Jul 2023 19:38:07 -0700 (PDT) MIME-Version: 1.0 References: <20230727125125.1194376-1-imagedong@tencent.com> <20230727125125.1194376-2-imagedong@tencent.com> In-Reply-To: From: Menglong Dong Date: Fri, 28 Jul 2023 10:37:55 +0800 Message-ID: Subject: Re: [PATCH net-next 1/3] net: tcp: send zero-window ACK when no memory To: Eric Dumazet Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Menglong Dong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Fri, Jul 28, 2023 at 3:17=E2=80=AFAM Eric Dumazet = wrote: > > On Thu, Jul 27, 2023 at 2:51=E2=80=AFPM wrote: > > > > From: Menglong Dong > > > > For now, skb will be dropped when no memory, which makes client keep > > retrans util timeout and it's not friendly to the users. > > > > In this patch, we reply an ACK with zero-window in this case to update > > the snd_wnd of the sender to 0. Therefore, the sender won't timeout the > > connection and will probe the zero-window with the retransmits. > > > > Signed-off-by: Menglong Dong > > --- > > include/net/inet_connection_sock.h | 3 ++- > > net/ipv4/tcp_input.c | 4 ++-- > > net/ipv4/tcp_output.c | 14 +++++++++++--- > > 3 files changed, 15 insertions(+), 6 deletions(-) > > > > diff --git a/include/net/inet_connection_sock.h b/include/net/inet_conn= ection_sock.h > > index c2b15f7e5516..be3c858a2ebb 100644 > > --- a/include/net/inet_connection_sock.h > > +++ b/include/net/inet_connection_sock.h > > @@ -164,7 +164,8 @@ enum inet_csk_ack_state_t { > > ICSK_ACK_TIMER =3D 2, > > ICSK_ACK_PUSHED =3D 4, > > ICSK_ACK_PUSHED2 =3D 8, > > - ICSK_ACK_NOW =3D 16 /* Send the next ACK immediately (onc= e) */ > > + ICSK_ACK_NOW =3D 16, /* Send the next ACK immediately (onc= e) */ > > + ICSK_ACK_NOMEM =3D 32, > > }; > > > > void inet_csk_init_xmit_timers(struct sock *sk, > > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > > index 3cd92035e090..03111af6115d 100644 > > --- a/net/ipv4/tcp_input.c > > +++ b/net/ipv4/tcp_input.c > > @@ -5061,7 +5061,8 @@ static void tcp_data_queue(struct sock *sk, struc= t sk_buff *skb) > > reason =3D SKB_DROP_REASON_PROTO_MEM; > > NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDR= OP); > > sk->sk_data_ready(sk); > > - goto drop; > > + inet_csk(sk)->icsk_ack.pending |=3D ICSK_ACK_NO= MEM; > > Also set ICSK_ACK_NOW ? > > We also need to make sure to send an immediate ACK WIN 0 in the case we q= ueued > the skb in an empty receive queue and we were under pressure. > > We do not want to have a delayed ACK sending a normal RWIN, > then wait for another packet that we will probably drop. > > Look at the code : > > if (skb_queue_len(&sk->sk_receive_queue) =3D=3D 0) > sk_forced_mem_schedule(sk, skb->truesize); > else if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) { > > and refactor it to make sure to set ICSK_ACK_NOMEM even on the first pac= ket > that bypassed the rmem_schedule(). > Ok, that makes sense. > > > > + goto out_of_window; > > Why forcing quickack mode ? Please leave the "goto drop;" > Hmm...because I want to make it send an immediate ACK. Obviously, a ICSK_ACK_NOW flag should be the better choice here. > > } > > > > eaten =3D tcp_queue_rcv(sk, skb, &fragstolen); > > @@ -5102,7 +5103,6 @@ static void tcp_data_queue(struct sock *sk, struc= t sk_buff *skb) > > out_of_window: > > tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS); > > inet_csk_schedule_ack(sk); > > -drop: > > tcp_drop_reason(sk, skb, reason); > > return; > > } > >