Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp849706iog; Fri, 24 Jun 2022 16:04:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1udg1jatZttUpVdvemcfVqQ0s0QPwcraU2LKBEdmtD4u+Y8UTdOgdfEFTBEGdXmkIcpw40Q X-Received: by 2002:a05:6402:4496:b0:435:d605:6ff8 with SMTP id er22-20020a056402449600b00435d6056ff8mr1741908edb.357.1656111892469; Fri, 24 Jun 2022 16:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656111892; cv=none; d=google.com; s=arc-20160816; b=DFh/MddqzQBEJCFhlowMzWTqN09myKdTegjhOPhdJakVRpZ7usP7dMAa9YS3lwFiZG YJCBJhWjT6H/mvRGljUHGiZuZKnm2wcwV9ljH15IYwUIDfgyXHl920j5P9qIuKFMRGq/ TkPYw4ZByXcFpeZTASOdvShHe0eyc05zc7J6cr6E4d2LWSLjjlRsG7JP9Mdlo8g3DXZ2 0b2VdFFVGFCTbhSUBImNspVOW/Lm7LOZnURP4WGCYeD8GrMlqLHFgTkDsynIb9aPdg47 ODVk9xcA7yWqBsR5mGWJvY6lePZ+QHlbeGElK3JEI7bAnNTqB06d7PlclIe3lOFQGL5c dGBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PB2ou5T9HchfcMcQw7R0zS+RgHm7z0GH0PzcwmCwOgA=; b=GBT+2W9ETsS7LvhWTmc9JOnUYGa0smrm/tNAwO9bbQVffqdGURaBCSPPD/CEFEogvP NJoD0RPtIYQn9kCTN13N1SwLkZdUZEacsNm3n1+0s7aotEZjZgAaO+e0Pi4NbDR+ZyOZ ZKl2VfSJniLQl+uqZmszDUkal+Nx8RkafyRsdkqJbLVsrgUk8QToRaE0OzDB4OR6jHT9 H+Pa3fYJBGMyDmQbo7QMUPUDHF0L/CwOSjMhAlQmiCCKHjUVL7rNG0usEqF71bwlNs4d +cbVUYNRyxM4q3o3Z/cj1tph1ezkYVAqzzMLKStk/gQICb4tH9L3NhFTshkGXXtWq3z3 BfIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=XQE4jOFc; 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 cw9-20020a170906478900b00711ca15cd52si2249903ejc.230.2022.06.24.16.04.27; Fri, 24 Jun 2022 16:04:52 -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=20210112 header.b=XQE4jOFc; 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 S231312AbiFXWlk (ORCPT + 99 others); Fri, 24 Jun 2022 18:41:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbiFXWlj (ORCPT ); Fri, 24 Jun 2022 18:41:39 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91FA287D60 for ; Fri, 24 Jun 2022 15:41:38 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id p136so632590ybg.4 for ; Fri, 24 Jun 2022 15:41:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PB2ou5T9HchfcMcQw7R0zS+RgHm7z0GH0PzcwmCwOgA=; b=XQE4jOFcM4OBioX8gNb6neMZZtMx9ApUxsfIs+HvbW74PPckXr9kwQl3EPOlYYez6B hJlk4uLOgUGW8gdUDBG9YVqB17VvMyYEkPvFl8nRwuScUFY362IVVVdErTsLlScS3cfY ykm30jXlcihAE8MKVVS2Kq3xjw4J7+r8yi+0+KvlXisgFGvjb3ntL+P8eTwYho4AMSgC mdBMrFgW0cc8jdW0r4MWZRBhiDZHNsQ2PizaT4z9wDWW1HHhjl16Jm0swyyHkDDQrq7f j5e6kCtnNYFwpaFURhhxhidnhV9TKrtFD2f9Emuxk0b7CnGAlvswguw3CxV2lYtXDK+7 qo3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PB2ou5T9HchfcMcQw7R0zS+RgHm7z0GH0PzcwmCwOgA=; b=cU6L9ECJnSQh7z6UR8qKZzx1lZbU0hTFpw+T1wpWHiL0KEn3MYJhJRTEKXlcrlwxKK JFDJFaqgJqhPOCOufct7+42UeFbOh3EjS6yruRR0X2KcTBbXPvfa9DXRE0Wo6OnUa5xb 7yYDI9VEsScZTBh8a8M+jx0xkKM2WNQL325LcrGRh0UbewA5g9De7rQGrhQMUVv1wNrA /iHJeZGtwikOPJ3+u/mXvIL4VQE582PPqEUIkaT6HzHR2zD7thNQuS9HmeoG41b2od4k Z7iY8sg//cfkvvvHRIlwwm2fkwWp0MQYK3bDg+p1eAIQtw91mcCcL5JZSiTUQjO3+F7x /FIQ== X-Gm-Message-State: AJIora/HUdfaqH1aYd1jumthOf+JFU18A+pvywQENiJy9SAvu6to+h43 7zTgRoeptAdDYYSb6xNq2NyBtk3X9/xHF7XiSDkiwg== X-Received: by 2002:a25:888a:0:b0:669:9661:912 with SMTP id d10-20020a25888a000000b0066996610912mr1468060ybl.348.1656110497625; Fri, 24 Jun 2022 15:41:37 -0700 (PDT) MIME-Version: 1.0 References: <20220623000530.1194226-1-yosryahmed@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 24 Jun 2022 15:41:26 -0700 Message-ID: Subject: Re: [PATCH] mm: vmpressure: don't count userspace-induced reclaim as memory pressure To: Yosry Ahmed Cc: Michal Hocko , Shakeel Butt , Johannes Weiner , Roman Gushchin , Muchun Song , Andrew Morton , Matthew Wilcox , Vlastimil Babka , David Hildenbrand , Miaohe Lin , NeilBrown , Alistair Popple , Peter Xu , Linux Kernel Mailing List , Cgroups , Linux-MM Content-Type: text/plain; charset="UTF-8" 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 Fri, Jun 24, 2022 at 3:14 PM Yosry Ahmed wrote: > > On Fri, Jun 24, 2022 at 3:10 PM Suren Baghdasaryan wrote: > > > > On Thu, Jun 23, 2022 at 10:26 AM Yosry Ahmed wrote: > > > > > > On Thu, Jun 23, 2022 at 10:04 AM Michal Hocko wrote: > > > > > > > > On Thu 23-06-22 09:42:43, Shakeel Butt wrote: > > > > > On Thu, Jun 23, 2022 at 9:37 AM Michal Hocko wrote: > > > > > > > > > > > > On Thu 23-06-22 09:22:35, Yosry Ahmed wrote: > > > > > > > On Thu, Jun 23, 2022 at 2:43 AM Michal Hocko wrote: > > > > > > > > > > > > > > > > On Thu 23-06-22 01:35:59, Yosry Ahmed wrote: > > > > > > [...] > > > > > > > > > In our internal version of memory.reclaim that we recently upstreamed, > > > > > > > > > we do not account vmpressure during proactive reclaim (similar to how > > > > > > > > > psi is handled upstream). We want to make sure this behavior also > > > > > > > > > exists in the upstream version so that consolidating them does not > > > > > > > > > break our users who rely on vmpressure and will start seeing increased > > > > > > > > > pressure due to proactive reclaim. > > > > > > > > > > > > > > > > These are good reasons to have this patch in your tree. But why is this > > > > > > > > patch benefitial for the upstream kernel? It clearly adds some code and > > > > > > > > some special casing which will add a maintenance overhead. > > > > > > > > > > > > > > It is not just Google, any existing vmpressure users will start seeing > > > > > > > false pressure notifications with memory.reclaim. The main goal of the > > > > > > > patch is to make sure memory.reclaim does not break pre-existing users > > > > > > > of vmpressure, and doing it in a way that is consistent with psi makes > > > > > > > sense. > > > > > > > > > > > > memory.reclaim is v2 only feature which doesn't have vmpressure > > > > > > interface. So I do not see how pre-existing users of the upstream kernel > > > > > > can see any breakage. > > > > > > > > > > > > > > > > Please note that vmpressure is still being used in v2 by the > > > > > networking layer (see mem_cgroup_under_socket_pressure()) for > > > > > detecting memory pressure. > > > > > > > > I have missed this. It is hidden quite good. I thought that v2 is > > > > completely vmpressure free. I have to admit that the effect of > > > > mem_cgroup_under_socket_pressure is not really clear to me. Not to > > > > mention whether it should or shouldn't be triggered for the user > > > > triggered memory reclaim. So this would really need some explanation. > > > > > > vmpressure was tied into socket pressure by 8e8ae645249b ("mm: > > > memcontrol: hook up vmpressure to socket pressure"). A quick look at > > > the commit log and the code suggests that this is used all over the > > > socket and tcp code to throttles the memory consumption of the > > > networking layer if we are under pressure. > > > > > > However, for proactive reclaim like memory.reclaim, the target is to > > > probe the memcg for cold memory. Reclaiming such memory should not > > > have a visible effect on the workload performance. I don't think that > > > any network throttling side effects are correct here. > > > > IIUC, this change is fixing two mechanisms during userspace-induced > > memory pressure: > > 1. psi accounting, which I think is not controversial and makes sense to me; > > 2. vmpressure signal, which is a "kinda" obsolete interface and might > > be viewed as controversial. > > I would suggest splitting the patch into two, first to fix psi > > accounting and second to fix vmpressure signal. This way the first one > > (probably the bigger of the two) can be reviewed and accepted easily > > while debates continue on the second one. > > This change should be NOP for psi. psi was already fixed by > e22c6ed90aa9 ("mm: memcontrol: don't count limit-setting reclaim > as memory pressure") by Johannes a while ago. This patch does the same > for vmpressure, but in a different way, as the same approach of > e22c6ed90aa9 cannot be used. > > The changes you are seeing in this patch for psi are basically > reverting e22c6ed90aa9 and using the newly introduced flag that > handles vmpressure to handle psi as well, to avoid having two separate > ways to address accounting memory pressure during userspace-induced > reclaim. Ah, I see. Thanks for clarifying that. > > > > > > > > > > > > > > > Though IMO we should deprecate vmpressure altogether. > > > > > > > > Yes it should be really limited to v1. But as I've said the effect on > > > > mem_cgroup_under_socket_pressure is not really clear to me. It really > > > > seems the v2 support has been introduced deliberately. > > > > > > > > -- > > > > Michal Hocko > > > > SUSE Labs