summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2018-06-08 02:09:21 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-08 02:34:37 +0200
commitbe09102b4190561b67e3809b07a7fd29c9774152 (patch)
treefe377c3140a10db766473986b0fec1e1dbd59008 /mm
parentmm/shmem.c: use new return type vm_fault_t (diff)
downloadlinux-be09102b4190561b67e3809b07a7fd29c9774152.tar.xz
linux-be09102b4190561b67e3809b07a7fd29c9774152.zip
mm: memcg: allow lowering memory.swap.max below the current usage
Currently an attempt to set swap.max into a value lower than the actual swap usage fails, which causes configuration problems as there's no way of lowering the configuration below the current usage short of turning off swap entirely. This makes swap.max difficult to use and allows delegatees to lock the delegator out of reducing swap allocation. This patch updates swap_max_write() so that the limit can be lowered below the current usage. It doesn't implement active reclaiming of swap entries for the following reasons. * mem_cgroup_swap_full() already tells the swap machinary to aggressively reclaim swap entries if the usage is above 50% of limit, so simply lowering the limit automatically triggers gradual reclaim. * Forcing back swapped out pages is likely to heavily impact the workload and mess up the working set. Given that swap usually is a lot less valuable and less scarce, letting the existing usage dissipate over time through the above gradual reclaim and as they're falted back in is likely the better behavior. Link: http://lkml.kernel.org/r/20180523185041.GR1718769@devbig577.frc2.facebook.com Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Roman Gushchin <guro@fb.com> Acked-by: Rik van Riel <riel@surriel.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Shaohua Li <shli@fb.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e3d56927a724..c1e64d60ed02 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6280,11 +6280,7 @@ static ssize_t swap_max_write(struct kernfs_open_file *of,
if (err)
return err;
- mutex_lock(&memcg_max_mutex);
- err = page_counter_set_max(&memcg->swap, max);
- mutex_unlock(&memcg_max_mutex);
- if (err)
- return err;
+ xchg(&memcg->swap.max, max);
return nbytes;
}