summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Gushchin <guro@fb.com>2018-04-23 08:20:29 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2018-04-23 08:23:48 +1000
commit759183beffa88f9fbcb7248f023a8da11a51eafa (patch)
treeba2b706ca8103025d4de00c29fdeb9be6952e9c6
parent82bce23c515d9d6614f2c4e2b044796e9a70fde7 (diff)
downloadlinux-759183beffa88f9fbcb7248f023a8da11a51eafa.tar.gz
linux-759183beffa88f9fbcb7248f023a8da11a51eafa.tar.xz
mm, oom: return error on access to memory.oom_group if groupoom is disabled
Cgroup-aware OOM killer depends on cgroup mount option and is turned off by default, despite the user interface (memory.oom_group file) is always present. As it might be confusing to a user, let's return -ENOTSUPP on an attempt to access to memory.oom_group if groupoom is not enabled globally. Example: $ cd /sys/fs/cgroup/user.slice/ $ cat memory.oom_group cat: memory.oom_group: Unknown error 524 $ echo 1 > memory.oom_group -bash: echo: write error: Unknown error 524 $ mount -o remount,groupoom /sys/fs/cgroup $ echo 1 > memory.oom_group $ cat memory.oom_group 1 Link: http://lkml.kernel.org/r/20171201170004.GA27436@castle.DHCP.thefacebook.com Signed-off-by: Roman Gushchin <guro@fb.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Cc: Tejun Heo <tj@kernel.org> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-rw-r--r--mm/memcontrol.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index dfd763c3ec71..c35c8d650c44 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5430,6 +5430,9 @@ static int memory_oom_group_show(struct seq_file *m, void *v)
struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
bool oom_group = memcg->oom_group;
+ if (!(cgrp_dfl_root.flags & CGRP_GROUP_OOM))
+ return -ENOTSUPP;
+
seq_printf(m, "%d\n", oom_group);
return 0;
@@ -5443,6 +5446,9 @@ static ssize_t memory_oom_group_write(struct kernfs_open_file *of,
int oom_group;
int err;
+ if (!(cgrp_dfl_root.flags & CGRP_GROUP_OOM))
+ return -ENOTSUPP;
+
err = kstrtoint(strstrip(buf), 0, &oom_group);
if (err)
return err;