aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2014-06-04 19:07:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:53:58 -0400
commit3dae7fec5e884a4e72e5416db0894de66f586201 (patch)
tree7d23c8ad732b4a348d46972a2bff4421a602ef1c /mm/memcontrol.c
parent8bf8fcb07653fbaea74f96bba1e4ed0f851675ab (diff)
mm: memcontrol: remove hierarchy restrictions for swappiness and oom_control
Per-memcg swappiness and oom killing can currently not be tweaked on a memcg that is part of a hierarchy, but not the root of that hierarchy. Users have complained that they can't configure this when they turned on hierarchy mode. In fact, with hierarchy mode becoming the default, this restriction disables the tunables entirely. But there is no good reason for this restriction. The settings for swappiness and OOM killing are taken from whatever memcg whose limit triggered reclaim and OOM invocation, regardless of its position in the hierarchy tree. Allow setting swappiness on any group. The knob on the root memcg already reads the global VM swappiness, make it writable as well. Allow disabling the OOM killer on any non-root memcg. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Tejun Heo <tj@kernel.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7bab1de50f48..20f47d9cd8b2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5444,22 +5444,14 @@ static int mem_cgroup_swappiness_write(struct cgroup_subsys_state *css,
5444 struct cftype *cft, u64 val) 5444 struct cftype *cft, u64 val)
5445{ 5445{
5446 struct mem_cgroup *memcg = mem_cgroup_from_css(css); 5446 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
5447 struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(&memcg->css));
5448 5447
5449 if (val > 100 || !parent) 5448 if (val > 100)
5450 return -EINVAL; 5449 return -EINVAL;
5451 5450
5452 mutex_lock(&memcg_create_mutex); 5451 if (css_parent(css))
5453 5452 memcg->swappiness = val;
5454 /* If under hierarchy, only empty-root can set this value */ 5453 else
5455 if ((parent->use_hierarchy) || memcg_has_children(memcg)) { 5454 vm_swappiness = val;
5456 mutex_unlock(&memcg_create_mutex);
5457 return -EINVAL;
5458 }
5459
5460 memcg->swappiness = val;
5461
5462 mutex_unlock(&memcg_create_mutex);
5463 5455
5464 return 0; 5456 return 0;
5465} 5457}
@@ -5791,22 +5783,15 @@ static int mem_cgroup_oom_control_write(struct cgroup_subsys_state *css,
5791 struct cftype *cft, u64 val) 5783 struct cftype *cft, u64 val)
5792{ 5784{
5793 struct mem_cgroup *memcg = mem_cgroup_from_css(css); 5785 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
5794 struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(&memcg->css));
5795 5786
5796 /* cannot set to root cgroup and only 0 and 1 are allowed */ 5787 /* cannot set to root cgroup and only 0 and 1 are allowed */
5797 if (!parent || !((val == 0) || (val == 1))) 5788 if (!css_parent(css) || !((val == 0) || (val == 1)))
5798 return -EINVAL; 5789 return -EINVAL;
5799 5790
5800 mutex_lock(&memcg_create_mutex);
5801 /* oom-kill-disable is a flag for subhierarchy. */
5802 if ((parent->use_hierarchy) || memcg_has_children(memcg)) {
5803 mutex_unlock(&memcg_create_mutex);
5804 return -EINVAL;
5805 }
5806 memcg->oom_kill_disable = val; 5791 memcg->oom_kill_disable = val;
5807 if (!val) 5792 if (!val)
5808 memcg_oom_recover(memcg); 5793 memcg_oom_recover(memcg);
5809 mutex_unlock(&memcg_create_mutex); 5794
5810 return 0; 5795 return 0;
5811} 5796}
5812 5797