On Fri, Dec 01, 2017 at 02:31:45PM +0100, Michal Hocko wrote:
> On Fri 01-12-17 13:15:38, Roman Gushchin wrote:
> [...]
> > So, maybe we just need to return -EAGAIN (or may be -ENOTSUP) on any 
> > read/write
> > attempt if option is not enabled?
> 
> Yes, that would work as well. ENOTSUP sounds better to me.
> -- 
> Michal Hocko
> SUSE Labs

>From 78bf2c00abf450bcd993d02a7dc1783144005fbd Mon Sep 17 00:00:00 2001
From: Roman Gushchin <g...@fb.com>
Date: Fri, 1 Dec 2017 14:30:14 +0000
Subject: [PATCH] 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

Signed-off-by: Roman Gushchin <g...@fb.com>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: Johannes Weiner <han...@cmpxchg.org>
Cc: Michal Hocko <mho...@suse.com>
Cc: Vladimir Davydov <vdavydov....@gmail.com>
Cc: Tejun Heo <t...@kernel.org>
Cc: kernel-t...@fb.com
Cc: linux...@kvack.org
Cc: linux-ker...@vger.kernel.org
---
 mm/memcontrol.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c76d5fb55c5c..b709ee4f914b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5482,6 +5482,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;
@@ -5495,6 +5498,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;
-- 
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to