Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3538098pxb; Mon, 4 Apr 2022 20:25:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFX7HxDGxJq3yrvGSGrac5pJzCd1hE1KqwUI0N5WIlgYvS56hfkAy4YvJD/AT6scyTxExS X-Received: by 2002:a63:656:0:b0:385:f723:5245 with SMTP id 83-20020a630656000000b00385f7235245mr1135072pgg.496.1649129115783; Mon, 04 Apr 2022 20:25:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649129115; cv=none; d=google.com; s=arc-20160816; b=aQLxq9FJFiesvwPPT+dAn9d0cW4IKHuGxIGBTecyGZXBdPUjSPZjYKTYQ9SEywRYES 0SlVix4um6v9eqi1gTpt6/eC5sE/BklbUJuHp6gPcN8phYM+5tr4Lfk09mE3oem4C41x uMSha993KDzSmvnT3LgY23KksrUPVRjjLjVSx0Ev4robhoHFrLsMxU+KjaXE7uKpOYYa WAEAgwGgNWjOZwsKGx7P/MC3a9nfAn9IOG0UuPwkfpUs1UryDwZnfU9fREX5EmaFUCHo v+f/UaP9ihLK/XoziwKoy4FOrKMjd94v58EHA62xuTgwBeZS1KaEskAXatEtO2OsKqsS LyuA== 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=qm48wnLSa24puHCxxJ0e1Qe5gtn6QPwMgY9+Vycw7ig=; b=DycwM5GzIpp4S9SHS+KtlYELm8T0b2bFVpf9ywWMRzeeUP7z7OdVNyXjcqFYGGNoiz xIPdWAA4Rbejuos4oi0dji96QUiNkCYrsv4/wLHaS+2y8nrr59uaaVRiRA1D4ANLi9b8 uLaOmOws1R8wsFuZTWbztv4bM+tqaAVWCHCB3X1uGwukocgcKFbiAI4xLagspKZp/9If B/HZ03S7TyGHFVZOzpGh3DGoynFPNJpRK4zPQs4GOvHjzQT7ki5iTTAUaL+FUx8EZ3bZ YsdQ51TA649zkDAicHJuKnS9YILm82GzJbPsnhMANgjYeZ9eNJvqW4+nTGExxeGS2Yjh OSmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ki+gCYwb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c6-20020a056a00248600b004fa3a8dff4dsi9959441pfv.4.2022.04.04.20.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:25:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ki+gCYwb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 827CB2AEE3E; Mon, 4 Apr 2022 18:24:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359634AbiDDLhO (ORCPT + 99 others); Mon, 4 Apr 2022 07:37:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233165AbiDDLhN (ORCPT ); Mon, 4 Apr 2022 07:37:13 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7217A3D1D5; Mon, 4 Apr 2022 04:35:17 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id 1so7331867qke.1; Mon, 04 Apr 2022 04:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qm48wnLSa24puHCxxJ0e1Qe5gtn6QPwMgY9+Vycw7ig=; b=Ki+gCYwbS0XnQ5UhlqPCCi5C/H/hPmbA8WTAV8iHSC/oPkMxbbfr5ufUIJQvh9nj1i XCN/Wi+j7sh1PrPInyPGbJu5zCIY80Gfriv7q+IdRApbUkvSPn3aMNravOLC5GIKRUwl OfNTazXCkloY2UyAgYCq8ZwIAPfaWXToSKqA/3S7pjhQWgbTkqX3HSyVTknG9lMnugFJ HRpB4d4IwoyNiYzqewo/s4PVA6Ort+cs8Oj2H7qox2hHXoC9rVGnaFu5bXYDUzitT99z 3DrHOw0r8yWErgJQ/g+1Mb6g86bvmWYMS6GC7TYvlvgWEQG17Z2FeElDO8q6TZ0HTvgE hH0A== 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=qm48wnLSa24puHCxxJ0e1Qe5gtn6QPwMgY9+Vycw7ig=; b=KAgTtQWtU4604vUHJDBdgeRvtDKZo+UeGw7uw3Hf0Pa3Ex0ZaCKHnL/tNj0CR1QX2a +A9HcSL1MG3d0/gLhrm+Gm+nT48tSu4CwLhDjOk8tGgvaicb7gU/E2zophtWmSnP0nQ7 XIgFU7NX8e+J/X+MMeoVRPMzCAkExgcCWys9zV2+cCyQlunTIdL1EBu+xdWvfV7v7Ih3 aoZfzM4qRGeg+N8zMsYzliIU6nedAN1GRzJ05qDdga7zmaO0DfAKM22P7XWxVwddnWMA WnvzN+xOj+ZD6QLfQj2p4AWJvWP8zsqv+P6iCiOeTegVp6CQ28i03jnyvrltQjaS9BHm eROA== X-Gm-Message-State: AOAM533inRr4ySkfQ/EmvwNruqj/hJ9fZ38+UNhbBW3IAHkwctVFB1Vz hcw7TzZxPKDXVFtEH+E3Q62MyWea7fj9FwzAx6k= X-Received: by 2002:a05:620a:4586:b0:67e:d240:ed1d with SMTP id bp6-20020a05620a458600b0067ed240ed1dmr13123222qkb.630.1649072116559; Mon, 04 Apr 2022 04:35:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Zhaoyang Huang Date: Mon, 4 Apr 2022 19:35:05 +0800 Message-ID: Subject: Re: [RFC PATCH] cgroup: introduce dynamic protection for memcg To: Michal Hocko Cc: Suren Baghdasaryan , "zhaoyang.huang" , Andrew Morton , Johannes Weiner , Vladimir Davydov , "open list:MEMORY MANAGEMENT" , LKML , cgroups mailinglist , Ke Wang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Mon, Apr 4, 2022 at 5:36 PM Michal Hocko wrote: > > On Mon 04-04-22 11:32:28, Michal Hocko wrote: > > On Mon 04-04-22 17:23:43, Zhaoyang Huang wrote: > > > On Mon, Apr 4, 2022 at 5:07 PM Zhaoyang Huang wrote: > > > > > > > > On Mon, Apr 4, 2022 at 4:51 PM Michal Hocko wrote: > > > > > > > > > > On Mon 04-04-22 10:33:58, Zhaoyang Huang wrote: > > > > > [...] > > > > > > > One thing that I don't understand in this approach is: why memory.low > > > > > > > should depend on the system's memory pressure. It seems you want to > > > > > > > allow a process to allocate more when memory pressure is high. That is > > > > > > > very counter-intuitive to me. Could you please explain the underlying > > > > > > > logic of why this is the right thing to do, without going into > > > > > > > technical details? > > > > > > What I want to achieve is make memory.low be positive correlation with > > > > > > timing and negative to memory pressure, which means the protected > > > > > > memcg should lower its protection(via lower memcg.low) for helping > > > > > > system's memory pressure when it's high. > > > > > > > > > > I have to say this is still very confusing to me. The low limit is a > > > > > protection against external (e.g. global) memory pressure. Decreasing > > > > > the protection based on the external pressure sounds like it goes right > > > > > against the purpose of the knob. I can see reasons to update protection > > > > > based on refaults or other metrics from the userspace but I still do not > > > > > see how this is a good auto-magic tuning done by the kernel. > > > > > > > > > > > The concept behind is memcg's > > > > > > fault back of dropped memory is less important than system's latency > > > > > > on high memory pressure. > > > > > > > > > > Can you give some specific examples? > > > > For both of the above two comments, please refer to the latest test > > > > result in Patchv2 I have sent. I prefer to name my change as focus > > > > transfer under pressure as protected memcg is the focus when system's > > > > memory pressure is low which will reclaim from root, this is not > > > > against current design. However, when global memory pressure is high, > > > > then the focus has to be changed to the whole system, because it > > > > doesn't make sense to let the protected memcg out of everybody, it > > > > can't > > > > do anything when the system is trapped in the kernel with reclaiming work. > > > Does it make more sense if I describe the change as memcg will be > > > protect long as system pressure is under the threshold(partially > > > coherent with current design) and will sacrifice the memcg if pressure > > > is over the threshold(added change) > > > > No, not really. For one it is still really unclear why there should be any > > difference in the semantic between global and external memory pressure > > in general. The low limit is always a protection from the external > > pressure. And what should be the actual threshold? Amount of the reclaim > > performed, effectivness of the reclaim or what? > > Btw. you might want to have a look at http://lkml.kernel.org/r/20220331084151.2600229-1-yosryahmed@google.com > where a new interface to allow pro-active memory reclaim is discussed. > I think that this might turn out to be a better fit then an automagic > kernel manipulation with a low limit. It will require a user agent to > drive the reclaim though. Ok. But AFAIK, there are some of this kinds of method working as out of tree code now. such as PPR in android etc. As I have replied to Suren, there is always latency issue on this scheme as the agent should poll the event/read current status/write to launch the action. This patch is aiming at solve part of these issues. > -- > Michal Hocko > SUSE Labs