public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] cgroup: use root_mem_cgroup as css when current is not enabled
@ 2022-08-12 10:09 zhaoyang.huang
       [not found] ` <1660298966-11493-1-git-send-email-zhaoyang.huang-1tVvrHeaX6nQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: zhaoyang.huang @ 2022-08-12 10:09 UTC (permalink / raw)
  To: Johannes Weiner, Michal Hocko, Zhaoyang Huang,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	cgroups-u79uwXL29TY76Z2rM5mHXA, ke.wang-1tVvrHeaX6nQT0dZR+AlfA,
	Tejun Heo, Zefan Li

From: Zhaoyang Huang <zhaoyang.huang-1tVvrHeaX6nQT0dZR+AlfA@public.gmane.org>

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-1tVvrHeaX6nQT0dZR+AlfA@public.gmane.org>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-15 20:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12 10:09 [RFC PATCH] cgroup: use root_mem_cgroup as css when current is not enabled zhaoyang.huang
     [not found] ` <1660298966-11493-1-git-send-email-zhaoyang.huang-1tVvrHeaX6nQT0dZR+AlfA@public.gmane.org>
2022-08-12 19:06   ` Tejun Heo
     [not found]     ` <YvakpukeF9d35Bc8-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2022-08-14  6:40       ` Zhaoyang Huang
     [not found]         ` <CAGWkznG6n=+v7hUKR8Rmg8VEF=BTDegk8bh6aHfvOU5TbmeXDw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-15  1:38           ` Zhaoyang Huang
     [not found]             ` <CAGWkznHa9WTV2oK=HB1OVEdKeMZ1V2omDDiNrRdyBdyYd=q5Fg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-15  9:17               ` Zhaoyang Huang
     [not found]                 ` <CAGWkznEQ_njmNt8usr-DyaiYDAHJE-niC2QxoXPQkDqY7v_Mqg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-15 20:12                   ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox