Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp291761rwb; Thu, 27 Jul 2023 12:49:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlHvthclPiqR+moKi2viwRJRp0nL+g+CmKUBmkBU65/adjJI7K5rqo7ApQ4acYEj4FD9h0kR X-Received: by 2002:a17:907:8a21:b0:98e:1c4b:10e2 with SMTP id sc33-20020a1709078a2100b0098e1c4b10e2mr3163065ejc.20.1690487386817; Thu, 27 Jul 2023 12:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690487386; cv=none; d=google.com; s=arc-20160816; b=MYTKipQgSJfLB/8MsuSq/JuKK8aQ1enoMwgGgHsPNBlsF/hGCOp+6A8I8g4vFwmRlU Y4/cKRGCq6bfkBIokzBMc0y0q6/amlBQ+NkorSh2udmsvfTRUbax8iASX4f2Lp7tBiie SuPeQkQCZBi72k2+NjB07GEtZvzobQ1qQr/MEtgRs4HtBRHO4k+08LK3RYxvjIwAdzHj w6YSDdBLe+7ZjwneH7EQlYMoqr0ZigDUNKtO1D49vRU6318B3+gOxV46KCzRmmyzqdaQ cx79arAiIh5czpWp2r7MmXcHghG4wOMQtJnB7iEtp7EsJkIOtjGzZA3pmtgZt4z+umbq GGcw== 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=vjaICTqH+cZvfMDigfbOcA5yUI6vz5+/jEk/szdxuyE=; fh=NCRQiMHg3gSYewWiMq7ysI3CbE0w0I9HaTX9KLwifSs=; b=e2hlY5mp0UlyULVqGZXsySK5LccfSwxWrP7ppPLpdv72OIHXRWxuElClnIFs2q4Qos t9pBKrYGxcVi4tFNHXN56uADIHGozQIaSvZ3rBKOcATX6TL8kSYzKZ+Pk1krHAxBqcPj L73duiYNezVAFNh34mqBh0GVqQtKHPZQ649pThs0tOPar8XNte6DgbvMgZRSx/nJXY7r dy1ToaUgSVkZK0zIAubEmGSg53tD5o7X6379EkWYVRrsw0wUE7WmS61OCrrDCaIE3JKc QT623hxkuutmQUR3+SZxwxmIjJtu3MFb9G5WzKsxgsoXLp4wj4iIWsCAoBeHij9DIZW2 0wtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3eURap2j; 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 g16-20020a17090613d000b009930d9d6b4csi1376341ejc.888.2023.07.27.12.49.22; Thu, 27 Jul 2023 12:49:46 -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=3eURap2j; 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 S232051AbjG0TSA (ORCPT + 99 others); Thu, 27 Jul 2023 15:18:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbjG0TRy (ORCPT ); Thu, 27 Jul 2023 15:17:54 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4C54FA for ; Thu, 27 Jul 2023 12:17:53 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-40540a8a3bbso47871cf.1 for ; Thu, 27 Jul 2023 12:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690485473; x=1691090273; 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=vjaICTqH+cZvfMDigfbOcA5yUI6vz5+/jEk/szdxuyE=; b=3eURap2jCy1X1+Y0vpp99Mf1wqN21k7CprGG94jUm0nCmOjDF5YmGVGfUOv7brl3v6 yTrRE0UHjwn8xaokwm7gwwYqB7mhKwshXo9H9hHInqnBjTGdpF7vidjAkfFZjRNjodJr iVYhsBFSc7+2wDnAKPGZhe6BOkhWHZGxfZtfogeDDk7D7TB8WHAI3+oWw2u4NIcsqRYg fC9/VCW9K4aDiFWUwO5K7gKzaPBSQsoU0SVOQKfijMUKnj4TpPEKy6/zX2cf2mzVXhev uQnvvLny6Pu9737cnCfbDRG+Is7ydcHSc97wTjSYtdEUpt04GFFzPzk2BPpbyirW3Lcu qrFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690485473; x=1691090273; 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=vjaICTqH+cZvfMDigfbOcA5yUI6vz5+/jEk/szdxuyE=; b=VsQu6TiIkPmD/KxaYhPMj5VuRNsbMTj+xYpDJkBArFbraTzBFly6L63nBg7sqRpKhG 9nclsw5yy0MLaE1ob41zl0C2CAmNi1yYHxD8LhbofaaVVm4BWZ/BTU+mhWEUFr2fysUX I3Gt20yt8Ru4m0SzuJ4vlCFXrTZMUwzqeUEvWLdLE3Loqfk6jYP4DI9jt7NIi/jLl//x S9ogpCzaIxiB5ZyOxOPJyNPS2XB04owek7Uy6vEtGpCjGfDWCnDwcFk9YrC9TmDCgAgN /wx56x+X0MaSX8ueGXkzsRFHHjgJoBju1JV0Otf5LWR3VR+INbi7WIWpHbNQktX20BZQ LQag== X-Gm-Message-State: ABy/qLZ++hu+nc4x9JZGniYB2VGRAfx6O7whm740OU+dokdzvAR4y37n 4niR3NDKVVPWA5CvI+swZB+eODh2NviYxVkYtmPRNA== X-Received: by 2002:ac8:58d5:0:b0:403:b1e5:bcae with SMTP id u21-20020ac858d5000000b00403b1e5bcaemr62160qta.10.1690485472810; Thu, 27 Jul 2023 12:17:52 -0700 (PDT) MIME-Version: 1.0 References: <20230727125125.1194376-1-imagedong@tencent.com> <20230727125125.1194376-2-imagedong@tencent.com> In-Reply-To: <20230727125125.1194376-2-imagedong@tencent.com> From: Eric Dumazet Date: Thu, 27 Jul 2023 21:17:41 +0200 Message-ID: Subject: Re: [PATCH net-next 1/3] net: tcp: send zero-window ACK when no memory To: menglong8.dong@gmail.com 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=-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 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_connec= tion_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 (once)= */ > + ICSK_ACK_NOW =3D 16, /* Send the next ACK immediately (once)= */ > + 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, struct = sk_buff *skb) > reason =3D SKB_DROP_REASON_PROTO_MEM; > NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP= ); > sk->sk_data_ready(sk); > - goto drop; > + inet_csk(sk)->icsk_ack.pending |=3D ICSK_ACK_NOME= M; Also set ICSK_ACK_NOW ? We also need to make sure to send an immediate ACK WIN 0 in the case we que= ued 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 packe= t that bypassed the rmem_schedule(). > + goto out_of_window; Why forcing quickack mode ? Please leave the "goto drop;" > } > > eaten =3D tcp_queue_rcv(sk, skb, &fragstolen); > @@ -5102,7 +5103,6 @@ static void tcp_data_queue(struct sock *sk, struct = 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; > } >