]> git.baikalelectronics.ru Git - kernel.git/commit
memcg: fix destination cgroup leak on task charges migration
authorVladimir Davydov <vdavydov@parallels.com>
Thu, 8 Jan 2015 22:32:37 +0000 (14:32 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 8 Jan 2015 23:10:52 +0000 (15:10 -0800)
commitad6d23ab372fcc2c09d69d7518328ff74cd33ebd
tree83451949e0afdfe0f2456977ac3d90b861ddfc6e
parentf8731ad37c674dbcd32ff75c54462de4852673d0
memcg: fix destination cgroup leak on task charges migration

We are supposed to take one css reference per each memory page and per
each swap entry accounted to a memory cgroup.  However, during task
charges migration we take a reference to the destination cgroup twice
per each swap entry: first in mem_cgroup_do_precharge()->try_charge()
and then in mem_cgroup_move_swap_account(), permanently leaking the
destination cgroup.

The hunk taking the second reference seems to be a leftover from the
pre-7b5e9dd291f76 ("mm: memcontrol: rewrite charge API") era.  Remove it
to fix the leak.

Fixes: 589e82bfa400 (mm: memcontrol: take a css reference for each charged page)
Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memcontrol.c