提交 692e7c45 编写于 作者: J Johannes Weiner 提交者: Linus Torvalds

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: NJohannes Weiner <hannes@cmpxchg.org>
Acked-by: NMichal 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9476db97
...@@ -6401,6 +6401,10 @@ static int mem_cgroup_do_precharge(unsigned long count) ...@@ -6401,6 +6401,10 @@ static int mem_cgroup_do_precharge(unsigned long count)
mc.precharge += count; mc.precharge += count;
return ret; return ret;
} }
if (ret == -EINTR) {
__mem_cgroup_cancel_charge(root_mem_cgroup, count);
return ret;
}
/* Try charges one by one with reclaim */ /* Try charges one by one with reclaim */
while (count--) { while (count--) {
...@@ -6409,8 +6413,11 @@ static int mem_cgroup_do_precharge(unsigned long count) ...@@ -6409,8 +6413,11 @@ static int mem_cgroup_do_precharge(unsigned long count)
/* /*
* In case of failure, any residual charges against * In case of failure, any residual charges against
* mc.to will be dropped by mem_cgroup_clear_mc() * mc.to will be dropped by mem_cgroup_clear_mc()
* later on. * later on. However, cancel any charges that are
* bypassed to root right away or they'll be lost.
*/ */
if (ret == -EINTR)
__mem_cgroup_cancel_charge(root_mem_cgroup, 1);
if (ret) if (ret)
return ret; return ret;
mc.precharge++; mc.precharge++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册