Commit 2378d8b8 authored by Tejun Heo's avatar Tejun Heo

cgroup: re-hash init_css_set after subsystems are initialized

css_sets are hashed by their subsys[] contents and in cgroup_init()
init_css_set is hashed early, before subsystem inits, when all entries
in its subsys[] are NULL, so that cgroup_dfl_root initialization can
find and link to it.  As subsystems are initialized,
init_css_set.subsys[] is filled up but the hashing is never updated
making init_css_set hashed in the wrong place.  While incorrect, this
doesn't cause a critical failure as css_set management code would
create an identical css_set dynamically.

Fix it by rehashing init_css_set after subsystems are initialized.
While at it, drop unnecessary @key local variable.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarZefan Li <lizefan@huawei.com>
parent fa06235b
...@@ -5266,7 +5266,6 @@ static u16 cgroup_disable_mask __initdata; ...@@ -5266,7 +5266,6 @@ static u16 cgroup_disable_mask __initdata;
int __init cgroup_init(void) int __init cgroup_init(void)
{ {
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
unsigned long key;
int ssid; int ssid;
BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 16); BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 16);
...@@ -5276,9 +5275,12 @@ int __init cgroup_init(void) ...@@ -5276,9 +5275,12 @@ int __init cgroup_init(void)
mutex_lock(&cgroup_mutex); mutex_lock(&cgroup_mutex);
/* Add init_css_set to the hash table */ /*
key = css_set_hash(init_css_set.subsys); * Add init_css_set to the hash table so that dfl_root can link to
hash_add(css_set_table, &init_css_set.hlist, key); * it during init.
*/
hash_add(css_set_table, &init_css_set.hlist,
css_set_hash(init_css_set.subsys));
BUG_ON(cgroup_setup_root(&cgrp_dfl_root, 0)); BUG_ON(cgroup_setup_root(&cgrp_dfl_root, 0));
...@@ -5331,6 +5333,11 @@ int __init cgroup_init(void) ...@@ -5331,6 +5333,11 @@ int __init cgroup_init(void)
ss->bind(init_css_set.subsys[ssid]); ss->bind(init_css_set.subsys[ssid]);
} }
/* init_css_set.subsys[] has been updated, re-hash */
hash_del(&init_css_set.hlist);
hash_add(css_set_table, &init_css_set.hlist,
css_set_hash(init_css_set.subsys));
WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup")); WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup"));
WARN_ON(register_filesystem(&cgroup_fs_type)); WARN_ON(register_filesystem(&cgroup_fs_type));
WARN_ON(register_filesystem(&cgroup2_fs_type)); WARN_ON(register_filesystem(&cgroup2_fs_type));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment