Re: [PATCH 9/12] memcg allocate all page_cgroup at boot

From: KAMEZAWA Hiroyuki
Date: Thu Sep 25 2008 - 21:59:20 EST


On Fri, 26 Sep 2008 10:43:36 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
> > > - /*
> > > - * Check if our page_cgroup is valid
> > > - */
> > > - lock_page_cgroup(page);
> > > - pc = page_get_page_cgroup(page);
> > > - if (unlikely(!pc))
> > > - goto unlock;
> > > -
> > > - VM_BUG_ON(pc->page != page);
> > > + pc = lookup_page_cgroup(page);
> > > + if (unlikely(!pc || !PageCgroupUsed(pc)))
> > > + return;
> > > + preempt_disable();
> > > + lock_page_cgroup(pc);
> > > + if (unlikely(page_mapped(page))) {
> > > + unlock_page_cgroup(pc);
> > > + preempt_enable();
> > > + return;
> > > + }
> > Just for clarification, in what sequence will the page be mapped here?
> > mem_cgroup_uncharge_page checks whether the page is mapped.
> >
> Please think about folloing situation.
>
> There is a SwapCache which is referred from 2 process, A, B.
> A maps it.
> B doesn't maps it.
>
> And now, process A exits.
>
> CPU0(process A) CPU1 (process B)
>
> zap_pte_range()
> => page remove from rmap => charge() (do_swap_page)
> => set page->mapcount->0
> => uncharge() => set page->mapcount=1
>
> This race is what patch 12/12 is fixed.
> This only happens on cursed SwapCache.
>
Sorry, my brain seems to be sleeping.. above page_mapped() check doesn't
help this situation. Maybe this page_mapped() check is not necessary
because it's of no use.

I think this kind of problem will not be fixed until we handle SwapCache.


Thanks,
-Kame












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