Skip to content

Commit

Permalink
memcg: cleanup root memcg checks
Browse files Browse the repository at this point in the history
Replace the implicit checking of root memcg with explicit root memcg
checking i.e.  !css->parent with mem_cgroup_is_root().

Link: https://lkml.kernel.org/r/20210223205625.2792891-1-shakeelb@google.com
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Roman Gushchin <guro@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Shakeel Butt authored and Linus Torvalds committed Apr 30, 2021
1 parent 27faca8 commit a479203
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -4123,7 +4123,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;
Expand Down Expand Up @@ -4473,7 +4473,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;
Expand Down

0 comments on commit a479203

Please sign in to comment.