diff options
| -rw-r--r-- | Documentation/cgroups/memory.txt | 11 | ||||
| -rw-r--r-- | mm/memcontrol.c | 29 |
2 files changed, 11 insertions, 29 deletions
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index 2622115276aa..1829c65f8371 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt | |||
| @@ -535,17 +535,15 @@ Note: | |||
| 535 | 535 | ||
| 536 | 5.3 swappiness | 536 | 5.3 swappiness |
| 537 | 537 | ||
| 538 | Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only. | 538 | Similar to /proc/sys/vm/swappiness, but only affecting reclaim that is |
| 539 | triggered by this cgroup's hard limit. The tunable in the root cgroup | ||
| 540 | corresponds to the global swappiness setting. | ||
| 541 | |||
| 539 | Please note that unlike the global swappiness, memcg knob set to 0 | 542 | Please note that unlike the global swappiness, memcg knob set to 0 |
| 540 | really prevents from any swapping even if there is a swap storage | 543 | really prevents from any swapping even if there is a swap storage |
| 541 | available. This might lead to memcg OOM killer if there are no file | 544 | available. This might lead to memcg OOM killer if there are no file |
| 542 | pages to reclaim. | 545 | pages to reclaim. |
| 543 | 546 | ||
| 544 | Following cgroups' swappiness can't be changed. | ||
| 545 | - root cgroup (uses /proc/sys/vm/swappiness). | ||
| 546 | - a cgroup which uses hierarchy and it has other cgroup(s) below it. | ||
| 547 | - a cgroup which uses hierarchy and not the root of hierarchy. | ||
| 548 | |||
| 549 | 5.4 failcnt | 547 | 5.4 failcnt |
| 550 | 548 | ||
| 551 | A memory cgroup provides memory.failcnt and memory.memsw.failcnt files. | 549 | A memory cgroup provides memory.failcnt and memory.memsw.failcnt files. |
| @@ -754,7 +752,6 @@ You can disable the OOM-killer by writing "1" to memory.oom_control file, as: | |||
| 754 | 752 | ||
| 755 | #echo 1 > memory.oom_control | 753 | #echo 1 > memory.oom_control |
| 756 | 754 | ||
| 757 | This operation is only allowed to the top cgroup of a sub-hierarchy. | ||
| 758 | If OOM-killer is disabled, tasks under cgroup will hang/sleep | 755 | If OOM-killer is disabled, tasks under cgroup will hang/sleep |
| 759 | in memory cgroup's OOM-waitqueue when they request accountable memory. | 756 | in memory cgroup's OOM-waitqueue when they request accountable memory. |
| 760 | 757 | ||
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 | ||
