aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
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