Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1599738rwb; Fri, 12 Aug 2022 03:55:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR7R3VzUnEp0KT6NxAL3GAjvIIA7lMUftMIVbJJnq/aA+EoOD9s0NGA+Fsr1ptYtVoz7FRQf X-Received: by 2002:a05:6402:4414:b0:434:f58c:ee2e with SMTP id y20-20020a056402441400b00434f58cee2emr3019059eda.362.1660301748248; Fri, 12 Aug 2022 03:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660301748; cv=none; d=google.com; s=arc-20160816; b=HBkaVZkQ8ToOyNSu9YzQSQgUbzryQNyAnAomV3u8YwpLMOyl8V90ooSH7hSNK9+DGe wwErWwf83YCHXr+RIMT9WJTi3hjc563razNeQXJACdbzlfUc4VdQnh0ughBk6UQNN+z9 xxnUZ6PdyCRRIGR+hNtm1WSB7wNGE/5X4sjBX+mIhx+ECAk3D8EGYkyO3h7Da+6l+4UI bHyVbUEmDJDOIFeRbqxS/W3TgH10GUGkKqJN7pWWC9AXyDHF2Wpc3oKVMGXiLn8Fi4Yx 2GxgXuRBxx47zsBb5VtPUweEHRZiYYL7rTb8yH0d0nMWZxojRFadklW9RgDqzyytoLn3 MvAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=dW2G0qJWSdOJR/KsBHIn9eNKEZuLbI9RFjDHcUIfJU4=; b=G1p/8cRd9mkjk4Sfzq2CTiEVxbF5OruLZ8ZZuVmTfUecqgiZ9fqJNjkzTj3bwKjc5c uKi7+4uPCjIkmpEUvM7cYX9dfmcNO2UZrs0wpr3GbaE4an2r9wa9d6DbwUjmImQuNtXX i0sixtqgMxnRAQNgw2Vh7DWs5yNSabAaIRGz9+JO4N9CshLY3XwcLHjhARTmvfO9sFcK /RT9y9+EhMfOXcQZnxgW5X0A3ZD5yUSGHN7lyxev/dikpoBJR3j7KhyeDMyPAY6u3F6q uDTQaeIFdhAhJQlt4VhLOSBCm1hJSiDj+aBhgHYjAjQn5KZLDolNdaKBnJuf5a8pSsvX CebQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kt27-20020a170906aadb00b00732f74db44dsi1444823ejb.17.2022.08.12.03.55.19; Fri, 12 Aug 2022 03:55:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231408AbiHLKKl (ORCPT + 99 others); Fri, 12 Aug 2022 06:10:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbiHLKKg (ORCPT ); Fri, 12 Aug 2022 06:10:36 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1338DF0; Fri, 12 Aug 2022 03:10:33 -0700 (PDT) Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTPS id 27CA9VAe044276 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Fri, 12 Aug 2022 18:09:31 +0800 (CST) (envelope-from zhaoyang.huang@unisoc.com) Received: from bj03382pcu.spreadtrum.com (10.0.74.65) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 12 Aug 2022 18:09:31 +0800 From: "zhaoyang.huang" To: Johannes Weiner , Michal Hocko , Zhaoyang Huang , , , , Tejun Heo , Zefan Li Subject: [RFC PATCH] cgroup: use root_mem_cgroup as css when current is not enabled Date: Fri, 12 Aug 2022 18:09:26 +0800 Message-ID: <1660298966-11493-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.74.65] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 27CA9VAe044276 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 From: Zhaoyang Huang Memory charged on group B abserved on belowing v2 hierarchy where we just would like to only have group E's memory be controlled and B's descendants compete freely for memory. This should be the consequences of unified hierarchy. Solve this by have the cgroup without valid memory css alloced use root_mem_cgroup instead of its ancestor's. A(subtree_control = memory) - B(subtree_control = NULL) - C() \ D() - E(subtree_control = memory) - F() \ G() Signed-off-by: Zhaoyang Huang --- kernel/cgroup/cgroup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 1779ccd..b29b3f6 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -533,6 +533,14 @@ static struct cgroup_subsys_state *cgroup_e_css_by_mask(struct cgroup *cgrp, * can't test the csses directly. Test ss_mask. */ while (!(cgroup_ss_mask(cgrp) & (1 << ss->id))) { + /* + * charging to the parent cgroup which hasn't distribute + * memory control to its descendants doesn't make sense + * especially on cgroup v2, where the parent could be configured + * to use memory controller as its sibling want to use it + */ + if (memory_cgrp_id == ss->id) + return &root_mem_cgroup->css; cgrp = cgroup_parent(cgrp); if (!cgrp) return NULL; -- 1.9.1