Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3665593rwd; Mon, 29 May 2023 14:47:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ncaFORrrO81XmNlbYrk/ziciaJwWI4fSEG+aObHs88FmPzUegPsCdTy8ZkHlrCO4iwdss X-Received: by 2002:a05:6a20:7346:b0:10a:f8d3:2cf3 with SMTP id v6-20020a056a20734600b0010af8d32cf3mr356938pzc.7.1685396832265; Mon, 29 May 2023 14:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685396832; cv=none; d=google.com; s=arc-20160816; b=hniTZ6lgiNPrKzb2xFpq9rqjb3FzIubVDLMsatW61ru7ghbJ6CJ8tK8DOqt9kPFXGV 6DHvvosE+gy6CdwdcitAf+j8C4EjKrL9pYLKBg6wBmALJQhpAMs3nPDadtGuumdM2bKa Bf/Ud9rBUUZag6cHUOwvQPLiwDGNKu1sNywOg2qlk6XjrEWzTH61COhA+853EaeF886x OBbYEr8TMcfzsIv9+8Wa0Vo8WpMnCHJpx4iSpVjx5Rouc1eZGnRStUII4oX/fsDJVod8 cIU1rMPlyAc+a4PnWSZSed9s84TBT/d083ixKaiQbUz8hhCqZiitz0LQs9UAPbU2Rt0/ jU5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=SNIbMRRuukreAZUC2GpTXXJapIJH6ZTqRY6eETcu5do=; b=wM0qorRL5smbt8FSg+b3Hs78bnQL5PSZvP6eLB7jeUaJL5ToevM/VV+7xOOFcJI/zj Q+YJT/hebjPH6O/q58jrIbTpiIh/7qWCFcpUfeHsXO40zt+akhMmfwKX4LMQxUMxkHea igVK+R3ehFCcmqcTv/HVOKWOets5wKwto5nZ8WS4Bsf6DKk67YhxBX1b5LjdyKJf6/Im Tc7wQQeHit7fkOunQq3KlomSrUavgla2uOb6MkE0PdYWHTbzmo4dFxLkvsehql+ftNr+ syVSLXU6VjtW3GXopfiiCCMED2aQ8cLHp9hlQEVOMmL7uEYS2CpFrKlhJb1ko4R0XkiS YFSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=a58aF0ye; 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 g9-20020a63fa49000000b00524eef20da6si2879578pgk.642.2023.05.29.14.46.59; Mon, 29 May 2023 14:47:12 -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=a58aF0ye; 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 S229455AbjE2VMN (ORCPT + 99 others); Mon, 29 May 2023 17:12:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbjE2VMM (ORCPT ); Mon, 29 May 2023 17:12:12 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80122D9 for ; Mon, 29 May 2023 14:12:08 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5659c7dad06so82694237b3.0 for ; Mon, 29 May 2023 14:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685394727; x=1687986727; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SNIbMRRuukreAZUC2GpTXXJapIJH6ZTqRY6eETcu5do=; b=a58aF0yeP61zDhlUOfNZLdoceiGGu26FxV3w360cVEX5mXHSCikCT9QZERrFOn+Wgg PQV3rmSuBZyWY7RJpxGCaweRtPtOGXNtJcQhRUc2Iiihmavwag/sytmxBLigXGwWZ5lk MLQoJyIYLb64f3BZPnDxbbiLlxkUMoohc9b/lJFrsKSBEmQDa4uuUXrKl0lWOYjJlass Vm9R7gNJl0aoBHuFj+eLnN5KovJ8X9KpPljEMIAznmET2jGKoJR2W7ks9R7Zl7Kw+ity mkmUkdCwuo7zJwvR5vpEgDRs5datWM1md9+4+SU5d4GrZlIohZop23cGF+rwOMxEyoPR NYUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685394727; x=1687986727; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SNIbMRRuukreAZUC2GpTXXJapIJH6ZTqRY6eETcu5do=; b=UCSdXWgWP8esSYrG6PO0EPvNdTsi0NkmpQjra0C7pqLdO1z2tTPubHKVn6DOZvEifg rbYjDxiuW5HuDLe55mgYvnR9EVvU+7ei44vk6kBCgwG37e2FOGomKlj7rH+4EmatVSpA ANNfAzJ+k8JDYNGHaiZ4E6fOb2dTsgtoJ2J6nU8hCGjdWLR5Cy+SV01QOFnKB5QrxiWn RdRzIP46KRxcrM9gKnZLIAlFBFPrFzfofdNYHuwAV0sQ5gAsMHglr9gYuOASatElm1Hq 2nxggUMOp996RPR+wfCzu9Udphb+pUnOLRHX4cbn1OUoUZhjSjUgOgUiH/SQ9cI/QAtw NBGQ== X-Gm-Message-State: AC+VfDx5GG/WIgVOUpUyZanS2RlHGbcRxrwTZ8K5Wr2TPbNhiB1Pj0Jc 941W2BHnUEHdDaJ3XhU0QYaKjJ6pjUgvcw== X-Received: from shakeelb.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:262e]) (user=shakeelb job=sendgmr) by 2002:a81:b619:0:b0:561:bf07:ee28 with SMTP id u25-20020a81b619000000b00561bf07ee28mr54893ywh.5.1685394727672; Mon, 29 May 2023 14:12:07 -0700 (PDT) Date: Mon, 29 May 2023 21:12:05 +0000 In-Reply-To: <73b1381e-6a59-26fe-c0b6-51ea3ebf60f8@bytedance.com> Mime-Version: 1.0 References: <20230522070122.6727-1-wuyun.abel@bytedance.com> <20230522070122.6727-4-wuyun.abel@bytedance.com> <20230525012259.qd6i6rtqvvae3or7@google.com> <73b1381e-6a59-26fe-c0b6-51ea3ebf60f8@bytedance.com> Message-ID: <20230529211205.6clthjyt37c4opju@google.com> Subject: Re: [PATCH v2 3/4] sock: Consider memcg pressure when raising sockmem From: Shakeel Butt To: Abel Wu Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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 +linux-mm and cgroups On Mon, May 29, 2023 at 07:58:45PM +0800, Abel Wu wrote: > Hi Shakeel, thanks for reviewing! And sorry for replying so late, > I was on a vocation :) > > On 5/25/23 9:22 AM, Shakeel Butt wrote: > > On Mon, May 22, 2023 at 03:01:21PM +0800, Abel Wu wrote: > > > For now __sk_mem_raise_allocated() mainly considers global socket > > > memory pressure and allows to raise if no global pressure observed, > > > including the sockets whose memcgs are in pressure, which might > > > result in longer memcg memstall. > > > > > > So take net-memcg's pressure into consideration when allocating > > > socket memory to alleviate long tail latencies. > > > > > > Signed-off-by: Abel Wu > > > > Hi Abel, > > > > Have you seen any real world production issue which is fixed by this > > patch or is it more of a fix after reading code? > > The latter. But we do observe one common case in the production env > that p2p service, which mainly downloads container images, running > inside a container with tight memory limit can easily be throttled and > keep memstalled for a long period of time and sometimes even be OOM- > killed. This service shows burst usage of TCP memory and I think it > indeed needs suppressing sockmem allocation if memcg is already under > pressure. The memcg pressure is usually caused by too many page caches > and the dirty ones starting to be wrote back to slow backends. So it > is insane to continuously receive net data to consume more memory. > We actually made an intentional decision to not throttle the incoming traffic under memory pressure. See 720ca52bcef22 ("net-memcg: avoid stalls when under memory pressure"). If you think the throttling behavior is preferred for your application, please propose the patch separately and we can work on how to enable flexible policy here. > > > > This code is quite subtle and small changes can cause unintended > > behavior changes. At the moment the tcp memory accounting and memcg > > accounting is intermingled and I think we should decouple them. > > My original intention to post this patchset is to clarify that: > > - proto pressure only considers sysctl_mem[] (patch 2) > - memcg pressure only indicates the pressure inside itself > - consider both whenever needs allocation or reclaim (patch 1,3) > > In this way, the two kinds of pressure maintain purer semantics, and > socket core can react on both of them properly and consistently. Can you please resend you patch series (without patch 3) and Cc to linux-mm, cgroups list and memcg maintainers as well?