|
@@ -1992,6 +1992,7 @@ static int mem_cgroup_swappiness_write(struct cgroup *cgrp, struct cftype *cft,
|
|
|
{
|
|
|
struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
|
|
|
struct mem_cgroup *parent;
|
|
|
+
|
|
|
if (val > 100)
|
|
|
return -EINVAL;
|
|
|
|
|
@@ -1999,15 +2000,22 @@ static int mem_cgroup_swappiness_write(struct cgroup *cgrp, struct cftype *cft,
|
|
|
return -EINVAL;
|
|
|
|
|
|
parent = mem_cgroup_from_cont(cgrp->parent);
|
|
|
+
|
|
|
+ cgroup_lock();
|
|
|
+
|
|
|
/* If under hierarchy, only empty-root can set this value */
|
|
|
if ((parent->use_hierarchy) ||
|
|
|
- (memcg->use_hierarchy && !list_empty(&cgrp->children)))
|
|
|
+ (memcg->use_hierarchy && !list_empty(&cgrp->children))) {
|
|
|
+ cgroup_unlock();
|
|
|
return -EINVAL;
|
|
|
+ }
|
|
|
|
|
|
spin_lock(&memcg->reclaim_param_lock);
|
|
|
memcg->swappiness = val;
|
|
|
spin_unlock(&memcg->reclaim_param_lock);
|
|
|
|
|
|
+ cgroup_unlock();
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|