memcg: cleanup root memcg checks
Subsystems (3)
PATCH 1/1 memcg: cleanup root memcg checks
Replace the implicit checking of root memcg with explicit root memcg checking i.e. !css->parent with mem_cgroup_is_root().
Signed-off-by Shakeel Butt <[email protected]>
--- mm/memcontrol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
@@ -4141,7 +4141,7 @@ static int mem_cgroup_swappiness_write(struct cgroup_subsys_state *css,if (val >100 )return -EINVAL ; -if (css->parent) +if (!mem_cgroup_is_root (memcg)) memcg->swappiness = val;else vm_swappiness = val;
@@ -4491,7 +4491,7 @@ static int mem_cgroup_oom_control_write(struct cgroup_subsys_state *css,struct mem_cgroup *memcg =mem_cgroup_from_css (css);/* cannot set to root cgroup and only 0 and 1 are allowed */ -if (!css->parent || !((val ==0 ) || (val ==1 ))) +if (mem_cgroup_is_root (memcg) || !((val ==0 ) || (val ==1 )))return -EINVAL ; memcg->oom_kill_disable = val;
Signature · 1 line
2.30.0.617.g56c4b15f3c-goog
Quoted 4 lines · Shakeel Butt
Replace the implicit checking of root memcg with explicit root memcg checking i.e. !css->parent with
mem_cgroup_is_root().Signed-off-by Shakeel Butt <[email protected]>
Thanks!
Quoted 28 lines
--- mm/memcontrol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/memcontrol.c +2
-2@@ -4141,7 +4141,7 @@ static int mem_cgroup_swappiness_write(struct cgroup_subsys_state *css,if (val >100 )return -EINVAL ; -if (css->parent) +if (!mem_cgroup_is_root (memcg)) memcg->swappiness = val;else vm_swappiness = val;@@ -4491,7 +4491,7 @@ static int mem_cgroup_oom_control_write(struct cgroup_subsys_state *css,struct mem_cgroup *memcg =mem_cgroup_from_css (css);/* cannot set to root cgroup and only 0 and 1 are allowed */ -if (!css->parent || !((val ==0 ) || (val ==1 ))) +if (mem_cgroup_is_root (memcg) || !((val ==0 ) || (val ==1 )))return -EINVAL ; memcg->oom_kill_disable = val;Signature · 1 line
2.30.0.617.g56c4b15f3c-goog
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 4 lines · Shakeel Butt
Replace the implicit checking of root memcg with explicit root memcg checking i.e. !css->parent with
mem_cgroup_is_root().Signed-off-by Shakeel Butt <[email protected]>
Acked-by Johannes Weiner <[email protected]>