[lkml]   [2011]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [BUGFIX][PATCH] memcg: fix memory migration of shmem swapcache

On Wed, Jan 5, 2011 at 1:00 PM, Daisuke Nishimura
<> wrote:
> Hi.
> This is a fix for a problem which has bothered me for a month.
> ===
> From: Daisuke Nishimura <>
> In current implimentation, mem_cgroup_end_migration() decides whether the page
> migration has succeeded or not by checking "oldpage->mapping".
> But if we are tring to migrate a shmem swapcache, the page->mapping of it is
> NULL from the begining, so the check would be invalid.
> As a result, mem_cgroup_end_migration() assumes the migration has succeeded
> even if it's not, so "newpage" would be freed while it's not uncharged.
> This patch fixes it by passing mem_cgroup_end_migration() the result of the
> page migration.
> Signed-off-by: Daisuke Nishimura <>
Reviewed-by: Minchan Kim <>

Nice catch. I don't oppose the patch.
But as looking the code in unmap_and_move, I feel part of mem cgroup
migrate is rather awkward.

int unmap_and_move()
charge = mem_cgroup_prepare_migration(xxx);
BUG_ON(charge); <-- BUG if it is charged?
if (!charge) <-- why do we have to uncharge !charge?

'charge' local variable isn't good. How about changing "uncharge" or whatever?
Of course, It would be another patch.
If you don't mind, I will send the patch or you may send the patch.


Kind regards,
Minchan Kim

 \ /
  Last update: 2011-01-05 05:51    [W:0.054 / U:0.692 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site