From nobody Mon Apr 13 12:02:39 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71209C00140 for ; Fri, 12 Aug 2022 10:10:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237381AbiHLKKm (ORCPT ); Fri, 12 Aug 2022 06:10:42 -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 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhaoyang Huang Memory charged on group B abserved on belowing v2 hierarchy where we just w= ould like to only have group E's memory be controlled and B's descendants compet= e freely for memory. This should be the consequences of unified hierarchy. Solve thi= s by have the cgroup without valid memory css alloced use root_mem_cgroup instea= d of its ancestor's. A(subtree_control =3D memory) - B(subtree_control =3D NULL) - C() \ D() - E(subtree_control =3D 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_mas= k(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 =3D=3D ss->id) + return &root_mem_cgroup->css; cgrp =3D cgroup_parent(cgrp); if (!cgrp) return NULL; --=20 1.9.1