Skip to content

Commit 648bb56

Browse files
committed
cgroup: lock cgroup_mutex in cgroup_init_subsys()
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>
1 parent b48c6a8 commit 648bb56

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/cgroup.c

+4
Original file line numberDiff line numberDiff line change
@@ -4317,6 +4317,8 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
43174317

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

4320+
mutex_lock(&cgroup_mutex);
4321+
43204322
/* init base cftset */
43214323
cgroup_init_cftsets(ss);
43224324

@@ -4346,6 +4348,8 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
43464348
if (ss->post_create)
43474349
ss->post_create(dummytop);
43484350

4351+
mutex_unlock(&cgroup_mutex);
4352+
43494353
/* this function shouldn't be used with modular subsystems, since they
43504354
* need to register a subsys_id, among other things */
43514355
BUG_ON(ss->module);

0 commit comments

Comments
 (0)