Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5820938rwp; Mon, 17 Jul 2023 09:56:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlGT+2kzbVgblrJdih1T5cx8f4lY27Sy3i7oJVpqgdyCDvcp8Ou0zcL/6mZnVOZ06Vm3xQmo X-Received: by 2002:a05:6a00:15d1:b0:67f:6226:58ac with SMTP id o17-20020a056a0015d100b0067f622658acmr14263523pfu.14.1689613005425; Mon, 17 Jul 2023 09:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689613005; cv=none; d=google.com; s=arc-20160816; b=X0FRgRg1CKVwIY5N0agkEkoir7rbSbY2FUyXShXytEeqHcPP6yoMIeqhOh/0gC5TWK CPj3bzP1fogj80h/U8mZCqO6+KJrsbKS0J+j9qbXptBrTf0peVGyjyNH8lwqixyDoYaX P5ObfbqyMVOxZlSr9Xcyk29VYIiwHfeBmS3Nsw/M1CbNoYhIazSdf25cnO5UatkEXGW1 A7w8+tWAtCx7XVLUiKfkQ7plJNRFB0f5fx/J8KFtVfzKHkmDcFmKYFWzeUIrC1PLSu63 N4VJDqBx0lDMc6TYxs6g+OAg6ysHGj63MSZXNrp+EnOrkI0YACYQ2Eo2QAnIuQkL396m AZEA== 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=3+e3D526DKZcQ2/LAze/ywkjnh9HvcdhsT43CIzyhYY=; fh=x68O4gjZ52faEZjFStbaZBjd9MosxF51UOsMEhGzgfE=; b=f+PvSxC2be3N2ui+ku0BamucadXCpy/LlhvHCnuoZri33KPD9G4lDf16PBbJbxvrJq wiwB3VGx9j6dOj91vkBS8hTOLBSC09YVRigwsOeCsXBhwEi964PjC+fhGLZ0Y9VtPKjX 2PBTRgzL3F5/nno2/iADTb04962uYtJwpoCJL3xHyyX7qVED+56KAsAgtCfmERHEwfFg YeNTLAxnPNYu68Suw+1wx4WmAJ9Der71odlJOZTbTJa6MsKoy40k1PjBZIkhivm7g2In SS+4FDP2APVENsRhoFL6x00gTpjm8bSCPa9js94kD/ckSA109yrNZVaA893zNxFRDrTJ hgLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=7e7AHSmK; 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 cq8-20020a056a00330800b00666e42caa20si46685pfb.203.2023.07.17.09.56.32; Mon, 17 Jul 2023 09:56:45 -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=7e7AHSmK; 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 S230317AbjGQQrL (ORCPT + 99 others); Mon, 17 Jul 2023 12:47:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjGQQrK (ORCPT ); Mon, 17 Jul 2023 12:47:10 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7053CB3 for ; Mon, 17 Jul 2023 09:47:09 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-40371070eb7so3231cf.1 for ; Mon, 17 Jul 2023 09:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689612428; x=1692204428; 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=3+e3D526DKZcQ2/LAze/ywkjnh9HvcdhsT43CIzyhYY=; b=7e7AHSmKQjlPgGKaHQMt+n0aS+VVfmzs90QReaDQ30pWE3QbgvP4dlI/Eq6qWlom3Q tgsW7dq6VqsVnuMLzpC8HXpF6wS+Il45ekw6QnKdbZGn73Q7eC8/Yh5eD4nvIwav25k0 YwOK6reB2bI0Y0MYUtSJ/3wNBcYbxZjtYl77R6rmYbgESIxXVNYbIJp4/9xZco/ph3Z3 1xDkRJ7QPr6Fa+6zMY8s8mkIcRogUQTKMcJ07Y8d5d7u/ReENB0jfz9bAFol9ZrdAaHu 0buWWeiD1Cvhwv2tcdjUP+4ZnYf/SgoRf9Rv7C8mTDJ9tYZGgzFtOaxKX7CzP9FWFygB 24gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689612428; x=1692204428; 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=3+e3D526DKZcQ2/LAze/ywkjnh9HvcdhsT43CIzyhYY=; b=QEFRfGvIdo++/y9mN9x9F1fOKRYgD1JHd67MHFDWllQaL/hejJAuOMuYKhgvbuEv7l oLuLqtnL9ckpxqZao5QL5OXmdYJRVFt2c9VXwAQz7uX+UrLLK59XBOP1LUH50ULHqLa9 Gpe4KvXVe8CriK+T9SYS1p0WT/nDYzuvpWCDkSznBce0fW6gIhdbA297cSyl2aSVeMAT eo9iKx6GavL7ruqFpzdl+sTQQcqQrstai/g93bsIVu01oVL6M8wOG0H/S8+71C2/brb7 WqdpUD1DwUQsJ48uFR9np3I0zBvyTkFWMLI9xkif4hgEhAIQ9tKqPQ5EOszBg53O5U+T nV/w== X-Gm-Message-State: ABy/qLbtXlnLHLCch7s61dxdDpiQ+CCZ6/MjthfSxsx0ztPBD7KCYoKn STP02tzgkPJGi2g6wq2cfi+lX5VUclMHwDoe7jgQ8Q== X-Received: by 2002:ac8:5b44:0:b0:403:96e3:4745 with SMTP id n4-20020ac85b44000000b0040396e34745mr1459522qtw.20.1689612428412; Mon, 17 Jul 2023 09:47:08 -0700 (PDT) MIME-Version: 1.0 References: <20230713112404.2022373-1-imagedong@tencent.com> In-Reply-To: <20230713112404.2022373-1-imagedong@tencent.com> From: Eric Dumazet Date: Mon, 17 Jul 2023 18:46:57 +0200 Message-ID: Subject: Re: [PATCH net-next v2] net: tcp: support to probe tcp receiver OOM To: menglong8.dong@gmail.com Cc: ncardwell@google.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, corbet@lwn.net, dsahern@kernel.org, kuniyu@amazon.com, morleyd@google.com, imagedong@tencent.com, mfreemon@cloudflare.com, mubashirq@google.com, netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org 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_BLOCKED,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 13, 2023 at 1:24=E2=80=AFPM wrote: > > From: Menglong Dong > > For now, skb will be dropped directly if rmem schedule fails, which means > tcp_try_rmem_schedule() returns an error. This can happen on following > cases: > > 1. The total memory allocated for TCP protocol is up to tcp_mem[2], and > the receive queue of the tcp socket is not empty. > 2. The receive buffer of the tcp socket is full, which can happen on smal= l > packet cases. > > If the user hangs and doesn't take away the packet in the receive queue > with recv() or read() for a long time, the sender will keep > retransmitting until timeout, and the tcp connection will break. > > In order to handle such case, we introduce the tcp protocol OOM detection > in following steps, as Neal Cardwell suggested: > For the record, I dislike this patch. I am not sure what Neal had in mind. I suggested instead to send an ACK RWIN 0, whenever we were under extreme memory pressure, and we only could queue one skb in the receive queue. For details, look at the points we call sk_forced_mem_schedule(). This would be a matter of refactoring code around it, in tcp_data_queue() The patch would be much simpler. Nothing changed at the sender side :/