cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Cgroups <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH cgroup/for-3.14-fixes] cgroup: protect modifications to cgroup_idr with cgroup_mutex
Date: Wed, 12 Feb 2014 10:32:11 +0800	[thread overview]
Message-ID: <52FADD2B.3080401@huawei.com> (raw)
In-Reply-To: <52FAD958.6020505-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

On 2014/2/12 10:15, Li Zefan wrote:
> On 2014/2/12 0:26, Michal Hocko wrote:
>> On Tue 11-02-14 10:41:05, Tejun Heo wrote:
>> [...]
>>> @@ -4254,12 +4256,12 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
>>>  
>>>  	return 0;
>>>  
>>> -err_unlock:
>>> -	mutex_unlock(&cgroup_mutex);
>>> -	/* Release the reference count that we took on the superblock */
>>> -	deactivate_super(sb);
>>>  err_free_id:
>>>  	idr_remove(&root->cgroup_idr, cgrp->id);
>>> +	/* Release the reference count that we took on the superblock */
>>> +	deactivate_super(sb);
>>> +err_unlock:
>>> +	mutex_unlock(&cgroup_mutex);
>>>  err_free_name:
>>>  	kfree(rcu_dereference_raw(cgrp->name));
>>>  err_free_cgrp:
>>
>> Do I have to change deactivate_super vs. mutex_unlock ordering in my
>> backport for 3.12 as well?
>>
> 
> Your change is wrong that you shouldn't drop sb refcnt in err_unlock path.
> 
> But you made me think if it's OK to hold cgroup_mutex while calling deactivate_super(),
> and the answer is NO! deactive_super() may call cgroup_kill_sb() which will
> acquire cgroup_mutex.
> 
> I'll update the patch.
> 
> Thank Tejun we won't be entangled with vfs internal anymore after coverting
> to kernfs.
> 

On second thought, it should be safe to call deactivate_super() before
releasing cgroup_mutex, as cgroup_create() is called through vfs, so vfs
should guanrantee the superblock won't disapear, so this deactivate_super()
won't drop sb refcnt to 0.

Still this is just my guess without diving into vfs code, and we'd better
not depend on it even my guess is correct.

      parent reply	other threads:[~2014-02-12  2:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11  8:05 [PATCH] cgroup: protect modifications to cgroup_idr with cgroup_mutex Li Zefan
     [not found] ` <52F9D9DA.7040108-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-02-11 10:20   ` Michal Hocko
     [not found]     ` <20140211102032.GA11946-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2014-02-12  1:50       ` Li Zefan
2014-02-12  9:12     ` Michal Hocko
2014-02-12  9:26       ` Li Zefan
     [not found]         ` <52FB3E50.8020809-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-02-12  9:38           ` Michal Hocko
2014-02-11 15:36   ` Tejun Heo
2014-02-11 15:41   ` [PATCH cgroup/for-3.14-fixes] " Tejun Heo
2014-02-11 16:26     ` Michal Hocko
     [not found]       ` <20140211162625.GP11946-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2014-02-12  2:15         ` Li Zefan
     [not found]           ` <52FAD958.6020505-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-02-12  2:32             ` Li Zefan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52FADD2B.3080401@huawei.com \
    --to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mhocko-AlSwsSmVLrQ@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).