Skip to content

Commit

Permalink
cgroup: lock cgroup_mutex in cgroup_init_subsys()
Browse files Browse the repository at this point in the history
Make cgroup_init_subsys() grab cgroup_mutex while initializing a
subsystem so that all helpers and callbacks are called under the
context they expect.  This isn't strictly necessary as
cgroup_init_subsys() doesn't race with anybody but will allow adding
lockdep assertions.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
  • Loading branch information
htejun committed Nov 19, 2012
1 parent b48c6a8 commit 648bb56
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/cgroup.c
Expand Up @@ -4317,6 +4317,8 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)

printk(KERN_INFO "Initializing cgroup subsys %s\n", ss->name);

mutex_lock(&cgroup_mutex);

/* init base cftset */
cgroup_init_cftsets(ss);

Expand Down Expand Up @@ -4346,6 +4348,8 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
if (ss->post_create)
ss->post_create(dummytop);

mutex_unlock(&cgroup_mutex);

/* this function shouldn't be used with modular subsystems, since they
* need to register a subsys_id, among other things */
BUG_ON(ss->module);
Expand Down

0 comments on commit 648bb56

Please sign in to comment.