diff options
author | Vladimir Davydov <vdavydov@virtuozzo.com> | 2015-12-11 16:40:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-12-12 13:15:34 -0500 |
commit | 9516a18a9a253a94292e74f11f92083126c5a237 (patch) | |
tree | 4c8cf1212ce7cea038deaf01a82e7b09efc67ebd | |
parent | a88c769548047b21f76fd71e04b6a3300ff17160 (diff) |
memcg: fix memory.high target
When the memory.high threshold is exceeded, try_charge() schedules a
task_work to reclaim the excess. The reclaim target is set to the
number of pages requested by try_charge().
This is wrong, because try_charge() usually charges more pages than
requested (batch > nr_pages) in order to refill per cpu stocks. As a
result, a process in a cgroup can easily exceed memory.high
significantly when doing a lot of charges w/o returning to userspace
(e.g. reading a file in big chunks).
Fix this issue by assuring that when exceeding memory.high a process
reclaims as many pages as were actually charged (i.e. batch).
Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/memcontrol.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c92a65b2b4ab..32259e37a66b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2128,7 +2128,7 @@ done_restock: | |||
2128 | */ | 2128 | */ |
2129 | do { | 2129 | do { |
2130 | if (page_counter_read(&memcg->memory) > memcg->high) { | 2130 | if (page_counter_read(&memcg->memory) > memcg->high) { |
2131 | current->memcg_nr_pages_over_high += nr_pages; | 2131 | current->memcg_nr_pages_over_high += batch; |
2132 | set_notify_resume(current); | 2132 | set_notify_resume(current); |
2133 | break; | 2133 | break; |
2134 | } | 2134 | } |