Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp479125rwe; Thu, 25 Aug 2022 04:04:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5DTmri2r5z1QHphKkMU0/xB03nAcRLQuBbTGp9fytzNzc2XnbCBwwTrpoLfWLokEvsmSyu X-Received: by 2002:a05:6402:270c:b0:446:f754:371a with SMTP id y12-20020a056402270c00b00446f754371amr2769858edd.388.1661425462092; Thu, 25 Aug 2022 04:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661425462; cv=none; d=google.com; s=arc-20160816; b=MNWBpSQOP8BMQQOiqGHLRc7MbrptXDISzVJ/3WDAmPizFvGK+22RIw7bPojWt8LjeS wUm2vJow6WyZDc+xbiDaqamaXG2qs5UgKPs5FC7LE99CtIer66LCYxkBAjzSI8GREYNh gb6o6/46McV0L/WLxa0aotCZ1Er+2sLDNABrwx0FLc9gPjf6DCxEnwna9/yVKo0RHiqO QKP5le90zhg/4M9YUROC2Z5HCgKxFhuZ6DBjotiFWAYUZuZUhFTmsqKeNcOOe5W3KiXz 5XlHNw78ElfWBAkeXu0WRSLSqNM/+1tEXU+Sv+CC6p0rAPYEdf3mSvU/iXk5ZZaPAFtk b8rg== 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=vnEJEeMF2AE4KxAkE8pFWCq29ZFBba+mEDUrxnkbubM=; b=To6ZMPRF0oANc9KLHNDxKhoFJVdCwKoFqlewRQIYEFq7BemFxwjkXEOgp0wgjrFNQg wCgL0GFZ7jFlw2HbdxRfByPgG8hkmplCzAlWrCqBjoCFouVAdeaDYBH3qU6m6l3QWFtG 6MAdA2RSyxtJikEPHs2GsMhdEJNnVll6iqxkgixgUXdYL57Nk02uH0+ZLnK6zeFNQ+mo Ws+/0jIM2qQjZgd992TTlci05pF2WSwMz1qKu4FcaLnKbqMCujWTwdEUMu+u5eyUGeLA Mgc9N09dpakmBd8lGjqmLnEMzv+hxvj710TGn7mwnncHatyxhCg9DtZJ8Ead5x6WKcX1 Dvng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mxRAvOKh; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020a1709060ac300b007316ac034a5si3351840ejf.844.2022.08.25.04.03.37; Thu, 25 Aug 2022 04:04:22 -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=@gmail.com header.s=20210112 header.b=mxRAvOKh; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240976AbiHYKLq (ORCPT + 99 others); Thu, 25 Aug 2022 06:11:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240983AbiHYKLk (ORCPT ); Thu, 25 Aug 2022 06:11:40 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 567699A695; Thu, 25 Aug 2022 03:11:39 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id s6so16339596lfo.11; Thu, 25 Aug 2022 03:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=vnEJEeMF2AE4KxAkE8pFWCq29ZFBba+mEDUrxnkbubM=; b=mxRAvOKhdn8T9NwgbWp0p3+x7XpqNID2pV90xgRQeuY9cXpHX8jpfcu515trEPmGIk yXpm6WKMG2ujC33kXZlEbt7CFaCFh2qqB2KO+AHFU8Z8NQDWGNqLDBsM+X5i0DnkGX2K dr7liyUGjF4cymJwj1hyeZsoVXLqownOuwKrgcStuLIlTIY/bGCjk7I1DpT1RuA6dQs4 soXomcu2m/MrFqNhsPUFwGIFxOVpa+GANbCZ75+y/TBD/U5JunxlxfAkWtHfFnLaNo/p SU+aK56MqrnU18R7CLczUwjBW7rYEdtcdvgtKogZzNkAQeSKd32wCBNkEOZzQzGioN3t C+WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=vnEJEeMF2AE4KxAkE8pFWCq29ZFBba+mEDUrxnkbubM=; b=wzw89k5ZmUvs/uHNwKySf77Mtz165Rk5gQkffaC32DZk912E7cFl57FyZjMo3XWoA9 IuAhJ3wHJOeXke1mn2aWRUoZUtlgmA+RPvttrmxUSRLtzrPmeGprDzSodMCu2MF68Nsm qyZFVoYXnQRvksBtFjcJNFAPwY6ssvRlnaK7SA685GtGY5gPVZ8mrdPJAFAJ1qkz8ZV6 04hco2bGnzBerToP7sUltSZ1pgcn2WpyP1tPfqJArc01l20u+jEvPngpoNu3z6kEh4ip bCEVkCX1pYDlhm2QY3Y9jeHjLeD0ikAw0Rd2ASNkDHdCga7g5ROswReeM5oVC51vxaFj zjqg== X-Gm-Message-State: ACgBeo00PFr88JaaFcDfdGjUmJ1j0Mv/m/bmVWr5mU1p/kjS5zpOmCE+ euJQQgxDx/frn+UqIo+4T+NpHhLVDH6Lfe/V5QcHrx2MxlkxbQ== X-Received: by 2002:a05:6512:3049:b0:492:f394:11cd with SMTP id b9-20020a056512304900b00492f39411cdmr998982lfb.165.1661422297676; Thu, 25 Aug 2022 03:11:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Zhaoyang Huang Date: Thu, 25 Aug 2022 18:11:09 +0800 Message-ID: Subject: Re: [RFC PATCH] memcg: use root_mem_cgroup when css is inherited To: Michal Hocko Cc: Suren Baghdasaryan , Tejun Heo , Shakeel Butt , "zhaoyang.huang" , Johannes Weiner , Linux MM , LKML , Cgroups , Ke Wang , Zefan Li , Roman Gushchin , Muchun Song Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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, Aug 25, 2022 at 4:50 PM Michal Hocko wrote: > > On Thu 25-08-22 16:34:04, Zhaoyang Huang wrote: > > On Thu, Aug 25, 2022 at 2:40 PM Michal Hocko wrote: > > > > > > On Thu 25-08-22 08:43:52, Zhaoyang Huang wrote: > > > > On Wed, Aug 24, 2022 at 6:27 PM Michal Hocko wrote: > > > > > > > > > > On Wed 24-08-22 17:34:42, Zhaoyang Huang wrote: > > > [...] > > > > > > IMHO, charging the pages which out of explicitly memory > > > > > > enabled group to root could solve all of the above constraints with no > > > > > > harm. > > > > > > > > > > This would break the hierarchical property of the controller. So a > > > > > strong no no. Consider the following example > > > > > > > > > > root > > > > > | > > > > > A > > > > > controllers="memory" > > > > > memory.max = 1G > > > > > subtree_control="" > > > > > | | | > > > > > A1 A2 A3 > > > > > > > > > > althought A1,2,3 do not have their memory controller enabled explicitly > > > > > they are still constrained by the A memcg limit. If you just charge to > > > > > the root because it doesn't have memory controller enabled explicitly > > > > > then you just evade that constrain. I hope you understand why that is a > > > > > problem. > > > > IMO, A1-A3 should be explicitly enabled via echo "+memory" > > > > > A/subtree_control since memory.max has been set. > > > > > > You seem to be missing the point I've triedy to make here. It is not > > > about how the respective subtree should or shouldn't be configured. It > > > is about the hierarchical behavior. Configuration at a higher level should be > > > enforced under subtree no matter how that subtree decides to > > > enabled/disable controllers. Such subtree might have beeb delegated > > > and configured differently yet the constrain should be still applied. > > > See the point? > > > > > > What you seem to be proposing is similar to cgroup v1 use_hierarchy > > > configuration. It has been decided that this is undesirable very early > > > in the cgroup v2 development because it make delegation impossible > > > (among other reasons). > > Ok, I would like to know how AA3 achieve the goal of competing with A1 > > and A2 for cpu but keep memory out of control under current policy? > > root > > | > > A > > controllers="memory,cpu" > > memory.max = 1G > > subtree_control="memory,cpu" > > | | | > > A1 A2 A3 subtree_control="cpu" > > | | > > AA3 AA4 controllers="cpu" > > I cannot really give you configuration you want without understanding > what you are trying to achieve and why do you need it that way. Really, > you can construct arbitrary hierarchies and only a very small subset of > them actually makes sense. So far you have been very terse at your goals > and intentions but rather demanding on the underlying mechanisms. This > doesn't really makes the discussion productive. > > I hope you have at least understood that hierarchical property of the > cgroup v2 is a must and it won't change. If you need a help to construct > hierarchy for your specific workload I would recommend to clearly state > your final goal and reasoning behind. Maybe you will get a more specific > help that way. Good luck! Sorry for any misunderstanding among the discussion. My purpose is real and simple as I have stated from the very beginning that I would like to have per-app cgroup hierarchy to charge memory to root if it is not enabled explicitly for memory. The reason has also been stated like reclaim and workingset regression in suren's report. I don't think my proposal will do any harm to current v2's mechanism besides asking for the admin echo "+memory" to their desire group. > -- > Michal Hocko > SUSE Labs