From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Zefan Subject: Re: [PATCH 04/17] cgroup: create directory before linking while creating a new cgroup Date: Fri, 16 Nov 2012 14:04:29 +0800 Message-ID: <50A5D76D.70805@huawei.com> References: <1352775704-9023-1-git-send-email-tj@kernel.org> <1352775704-9023-5-git-send-email-tj@kernel.org> <50A30E0F.7000408@huawei.com> <20121114190407.GI21185@mtj.dyndns.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20121114190407.GI21185-9pTldWuhBndy/B6EtB590w@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Tejun Heo Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, mhocko-AlSwsSmVLrQ@public.gmane.org, glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org On 2012/11/15 3:04, Tejun Heo wrote: > Hello, Li. > > On Wed, Nov 14, 2012 at 11:20:47AM +0800, Li Zefan wrote: >>> It also removes the need to check whether cgroup->dentry is %NULL in >>> cgroup_path. If a cgroup is visible, its dentry is guaranteed to be >>> visible too. >> >> I'm afraid this isn't safe. >> >> The cgroup is visible to a controller soon after ss->create(), and then >> the controller might call cgroup_path() while cgrp->dentry is still NULL. > > Hmmm... I can't find any case where ss->create() is calling > cgroup_path(). Do you remember which one that was? > I meant cgroup_create() may race with cgroup_path(). We used to have this race: (cpu0) (cpu1) mkdir cat /proc/sched_debug cgroup_create() cpu_cgroup_create() register_fair_sched_group() list_add_rcu(...) print_cfs_stats() for_each_leaf_cfs_rq() print_cfs_rq() cgroup_path() css->cgroup = cgroup; cgroup->dentry = dentry; In this case, cgroup_path() might access NULL cgroup or NULL dentry. But I've looked the current scheduler code, no race anymore, because now the cfs_rq won't be added to the gloal list until there's task in the cgroup. (in the old time it was added to the list when creating a cgroup)