[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1660298966-11493-1-git-send-email-zhaoyang.huang@unisoc.com>
Date: Fri, 12 Aug 2022 18:09:26 +0800
From: "zhaoyang.huang" <zhaoyang.huang@...soc.com>
To: Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Zhaoyang Huang <huangzhaoyang@...il.com>,
<linux-kernel@...r.kernel.org>, <cgroups@...r.kernel.org>,
<ke.wang@...soc.com>, Tejun Heo <tj@...nel.org>,
Zefan Li <lizefan.x@...edance.com>
Subject: [RFC PATCH] cgroup: use root_mem_cgroup as css when current is not enabled
From: Zhaoyang Huang <zhaoyang.huang@...soc.com>
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 <zhaoyang.huang@...soc.com>
---
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
Powered by blists - more mailing lists