Re: [patch] mm: memcg: close race between charge and putback

From: Johannes Weiner
Date: Thu Sep 08 2011 - 04:54:26 EST


On Thu, Sep 08, 2011 at 05:30:42PM +0900, KAMEZAWA Hiroyuki wrote:
> On Thu, 8 Sep 2011 09:40:22 +0200
> Johannes Weiner <jweiner@xxxxxxxxxx> wrote:
>
> > There is a potential race between a thread charging a page and another
> > thread putting it back to the LRU list:
> >
> > charge: putback:
> > SetPageCgroupUsed SetPageLRU
> > PageLRU && add to memcg LRU PageCgroupUsed && add to memcg LRU
> >
>
> I assumed that all pages are charged before added to LRU.
> (i.e. event happens in charge->lru_lock->putback order.)
>
> But hmm, this assumption may be bad for maintainance.
> Do you find a code which adds pages to LRU before charge ?
>
> Hmm, if there are codes which recharge the page to other memcg,
> it will cause bug and my assumption may be harmful.

Swap slots are read optimistically into swapcache and put to the LRU,
then charged upon fault. Fuse apparently recharges uncharged LRU
pages. That's why we have the lrucare stuff in the first place, no?
Or did I misunderstand your question?
--
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/