[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20081210112348.3060f1d8.kamezawa.hiroyu@jp.fujitsu.com>
Date: Wed, 10 Dec 2008 11:23:48 +0900
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To: Li Zefan <lizf@...fujitsu.com>
Cc: "linux-mm@...ck.org" <linux-mm@...ck.org>,
"balbir@...ux.vnet.ibm.com" <balbir@...ux.vnet.ibm.com>,
"nishimura@....nes.nec.co.jp" <nishimura@....nes.nec.co.jp>,
"menage@...gle.com" <menage@...gle.com>,
"kosaki.motohiro@...fujitsu.com" <kosaki.motohiro@...fujitsu.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFC][PATCH 1/6] memcg: fix pre_destory handler
On Wed, 10 Dec 2008 10:19:35 +0800
Li Zefan <lizf@...fujitsu.com> wrote:
> > +static bool memcg_is_obsolete(struct mem_cgroup *mem)
> > +{
>
> Will this function be called with mem->css.refcnt == 0? If yes, then
> this function is racy.
>
> cg = mem->css.cgroup
> cgroup_diput()
> mem_cgroup_destroy()
> mem->css.cgroup = NULL;
> kfree(cg);
> if (!cg || cgroup_is_removed(cg)...)
>
> (accessing invalid cg)
>
Hmm. then we have to add flag to css itself, anyway.
> > + struct cgroup *cg = mem->css.cgroup;
> > + /*
> > + * "Being Removed" means pre_destroy() handler is called.
> > + * After "pre_destroy" handler is called, memcg should not
> > + * have any additional charges.
> > + * This means there are small races for mis-accounting. But this
> > + * mis-accounting should happen only under swap-in opration.
> > + * (Attachin new task will fail if cgroup is under rmdir()).
> > + */
> > +
> > + if (!cg || cgroup_is_removed(cg) || cgroup_is_being_removed(cg))
> > + return true;
> > + return false;
> > +}
> > +
>
> ...
>
> > static void mem_cgroup_destroy(struct cgroup_subsys *ss,
> > struct cgroup *cont)
> > {
> > - mem_cgroup_free(mem_cgroup_from_cont(cont));
> > + struct mem_cgroup *mem = mem_cgroup_from_cont(cont):
> > + mem_cgroup_free(mem);
> > + /* forget */
> > + mem->css.cgroup = NULL;
>
> mem might already be destroyed by mem_cgroup_free(mem).
>
Ah, maybe. will fix.
Thanks,
-Kame
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists