[Devel] [PATCH rh7 2/3] memcg: use CFTYPE_NOT_ON_ROOT for memory.low and memory.oom_guarantee

Vladimir Davydov vdavydov at parallels.com
Mon May 25 07:05:47 PDT 2015


This is neater than checking if the root is passed to the write method
and this is how it works upstream (for memory.low).

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 mm/memcontrol.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 0ca9cdff8c83..144a2720b604 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5192,9 +5192,6 @@ static int mem_cgroup_low_write(struct cgroup *cont, struct cftype *cft,
 	unsigned long long val;
 	int ret;
 
-	if (mem_cgroup_is_root(memcg))
-		return -EINVAL;
-
 	ret = res_counter_memparse_write_strategy(buffer, &val);
 	if (ret)
 		return ret;
@@ -5222,9 +5219,6 @@ static int mem_cgroup_oom_guarantee_write(struct cgroup *cont,
 	unsigned long long val;
 	int ret;
 
-	if (mem_cgroup_is_root(memcg))
-		return -EINVAL;
-
 	ret = res_counter_memparse_write_strategy(buffer, &val);
 	if (ret)
 		return ret;
@@ -6118,6 +6112,7 @@ static struct cftype mem_cgroup_files[] = {
 	},
 	{
 		.name = "low",
+		.flags = CFTYPE_NOT_ON_ROOT,
 		.write_string = mem_cgroup_low_write,
 		.read = mem_cgroup_low_read,
 	},
@@ -6161,6 +6156,7 @@ static struct cftype mem_cgroup_files[] = {
 	},
 	{
 		.name = "oom_guarantee",
+		.flags = CFTYPE_NOT_ON_ROOT,
 		.write_string = mem_cgroup_oom_guarantee_write,
 		.read = mem_cgroup_oom_guarantee_read,
 	},
-- 
2.1.4




More information about the Devel mailing list