lkml.org 
[lkml]   [2011]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [BUGFIX][PATCH] memcg: fix memory migration of shmem swapcache
From
On Wed, Jan 5, 2011 at 3:47 PM, Daisuke Nishimura
<nishimura@mxp.nes.nec.co.jp> wrote:
> On Wed, 5 Jan 2011 13:48:50 +0900
> Minchan Kim <minchan.kim@gmail.com> wrote:
>
>> Hi,
>>
>> On Wed, Jan 5, 2011 at 1:00 PM, Daisuke Nishimura
>> <nishimura@mxp.nes.nec.co.jp> wrote:
>> > Hi.
>> >
>> > This is a fix for a problem which has bothered me for a month.
>> >
>> > ===
>> > From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
>> >
>> > 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 <nishimura@mxp.nes.nec.co.jp>
>> Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
>>
>> Nice catch. I don't oppose the patch.
> Thank you for your review.
>
>> 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?
>>    ..
>> uncharge:
>>    if (!charge)    <-- why do we have to uncharge !charge?
>>       mem_group_end_migration(xxx);
>>    ..
>> }
>>
>> 'charge' local variable isn't good. How about changing "uncharge" or whatever?
> hmm, I agree that current code seems a bit confusing, but I can't think of
> better name to imply the result of 'charge'.
>
> And considering more, I can't understand why we need to check "if (!charge)"
> before mem_cgroup_end_migration() becase it must be always true and, IMHO,
> mem_cgroup_end_migration() should do all necesarry checks to avoid double uncharge.
> So, I think this local variable can be removed completely.

Agree.


--
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-01-05 08:21    [W:0.185 / U:0.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site