Re: 3.13-rc breaks MEMCG_SWAP

From: Michal Hocko
Date: Tue Dec 17 2013 - 08:11:27 EST


On Mon 16-12-13 23:09:23, Hugh Dickins wrote:
> On Tue, 17 Dec 2013, Li Zefan wrote:
> > On 2013/12/17 9:41, Hugh Dickins wrote:
> > > On Mon, 16 Dec 2013, Tejun Heo wrote:
> > >> On Mon, Dec 16, 2013 at 06:19:37PM +0100, Michal Hocko wrote:
> > >>> I have to think about it some more (the brain is not working anymore
> > >>> today). But what we really need is that nobody gets the same id while
> > >>> the css is alive.
> >
> > That's what I meant to do in my last reply.
> >
> > But I'm confused by
> >
> > "How would this work? .. the swap will be there
> > after the last reference to css as well."
> >
> > >>> So css_from_id returning NULL doesn't seem to be
> > >>> enough.
> > >>
> > >> Oh, I meant whether it's necessary to keep css_from_id() working
> > >> (ie. doing successful lookups) between offline and release, because
> > >> that's where lifetimes are coupled. IOW, if it's enough for cgroup to
> > >> not recycle the ID until all css's are released && fail css_from_id()
> > >> lookup after the css is offlined, I can make a five liner quick fix.
> > >
> > > Don't take my word on it, I'm too fuzzy on this: but although it would
> > > be good to refrain from recycling the ID until all css's are released,
> > > I believe that it would not be good enough to fail css_from_id() once
> > > the css is offlined - mem_cgroup_uncharge_swap() needs to uncharge the
> > > hierarchy of the dead memcg (for example, when tmpfs file is removed).
> > >
> > > Uncharging the dead memcg itself is presumably irrelevant, but it does
> > > need to locate the right parent to uncharge, and NULL css_from_id()
> > > would make that impossible. It would be easy if we said those charges
> > > migrate to root rather than to parent, but that's inconsistent with
> > > what we have happily converged upon doing elsewhere (in the preferred
> > > use_hierarchy case), and it would be a change in behaviour.
> > >
> > > I'm not nearly as enthusiastic for my patch as Michal is: I really
> > > would prefer a five-liner from you or from Zefan.
> >
> > I've come up with a fix. Though it's more than five-line, it mostly moves
> > a few lines from one place to another. I've tested it with your script.
>
> It seems to be working very well for me. I'm inclined to forgive you for
> taking more than five lines, given that there are almost as many -s as +s ;)
>
> In my opinion, your patch is greatly preferable to mine - if there are
> good things in mine, memcg can incorporate them at leisure later on,
> but right now this seems a much better 3.13 solution. I'm guessing
> Tejun and Hannes will feel the same way: how about you, Michal?

OK, let's go with this for now but I would like swap accounting less
tricky and confusing and explicit reparenting should help there I
believe.

And sorry for distracting you from the css based approach. I have
totally misinterpreted the comment above idr_remove.
--
Michal Hocko
SUSE Labs
--
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/