aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2014-08-06 19:05:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 21:01:17 -0400
commit692e7c45d95ad1064b6911800e2cfec7fc0236db (patch)
tree2ff6a6787fd84f067c6d7bfb8790d725700eb726 /mm
parent9476db974d9e18885123fcebc09f4596bb922e5f (diff)
mm: memcontrol: catch root bypass in move precharge
When mem_cgroup_try_charge() returns -EINTR, it bypassed the charge to the root memcg. But move precharging does not catch this and treats this case as if no charge had happened, thus leaking a charge against root. Because of an old optimization, the root memcg's res_counter is not actually charged right now, but it's still an imbalance and subsequent patches will charge the root memcg again. Catch those bypasses to the root memcg and properly cancel them before giving up the move. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: Hugh Dickins <hughd@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Vladimir Davydov <vdavydov@parallels.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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8a4159efa3c0..e0ac636315f8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6401,6 +6401,10 @@ static int mem_cgroup_do_precharge(unsigned long count)
6401 mc.precharge += count; 6401 mc.precharge += count;
6402 return ret; 6402 return ret;
6403 } 6403 }
6404 if (ret == -EINTR) {
6405 __mem_cgroup_cancel_charge(root_mem_cgroup, count);
6406 return ret;
6407 }
6404 6408
6405 /* Try charges one by one with reclaim */ 6409 /* Try charges one by one with reclaim */
6406 while (count--) { 6410 while (count--) {
@@ -6409,8 +6413,11 @@ static int mem_cgroup_do_precharge(unsigned long count)
6409 /* 6413 /*
6410 * In case of failure, any residual charges against 6414 * In case of failure, any residual charges against
6411 * mc.to will be dropped by mem_cgroup_clear_mc() 6415 * mc.to will be dropped by mem_cgroup_clear_mc()
6412 * later on. 6416 * later on. However, cancel any charges that are
6417 * bypassed to root right away or they'll be lost.
6413 */ 6418 */
6419 if (ret == -EINTR)
6420 __mem_cgroup_cancel_charge(root_mem_cgroup, 1);
6414 if (ret) 6421 if (ret)
6415 return ret; 6422 return ret;
6416 mc.precharge++; 6423 mc.precharge++;