diff options
author | Tejun Heo <tj@kernel.org> | 2015-09-18 17:54:23 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2015-09-18 17:54:23 -0400 |
commit | 1ada48387a31b437074aa8973ce81de6e8c60bde (patch) | |
tree | 8fc1fec61b2c5d0eb8d217e8c3a58971836a8f86 | |
parent | 6732ed853af942ba20ddbd091336acc7df569119 (diff) |
cgroup: cosmetic updates to rebind_subsystems()
* Use local variables @scgrp and @dcgrp for @src_root->cgrp and
@dst_root->cgrp respectively.
* Use initializers to set @src_root and @css in the inner bind loop.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
-rw-r--r-- | kernel/cgroup.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index f09bab1cf275..a4ff4965e53b 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1366,6 +1366,7 @@ err: | |||
1366 | static int rebind_subsystems(struct cgroup_root *dst_root, | 1366 | static int rebind_subsystems(struct cgroup_root *dst_root, |
1367 | unsigned long ss_mask) | 1367 | unsigned long ss_mask) |
1368 | { | 1368 | { |
1369 | struct cgroup *dcgrp = &dst_root->cgrp; | ||
1369 | struct cgroup_subsys *ss; | 1370 | struct cgroup_subsys *ss; |
1370 | unsigned long tmp_ss_mask; | 1371 | unsigned long tmp_ss_mask; |
1371 | int ssid, i, ret; | 1372 | int ssid, i, ret; |
@@ -1387,7 +1388,7 @@ static int rebind_subsystems(struct cgroup_root *dst_root, | |||
1387 | if (dst_root == &cgrp_dfl_root) | 1388 | if (dst_root == &cgrp_dfl_root) |
1388 | tmp_ss_mask &= ~cgrp_dfl_root_inhibit_ss_mask; | 1389 | tmp_ss_mask &= ~cgrp_dfl_root_inhibit_ss_mask; |
1389 | 1390 | ||
1390 | ret = cgroup_populate_dir(&dst_root->cgrp, tmp_ss_mask); | 1391 | ret = cgroup_populate_dir(dcgrp, tmp_ss_mask); |
1391 | if (ret) { | 1392 | if (ret) { |
1392 | if (dst_root != &cgrp_dfl_root) | 1393 | if (dst_root != &cgrp_dfl_root) |
1393 | return ret; | 1394 | return ret; |
@@ -1413,37 +1414,35 @@ static int rebind_subsystems(struct cgroup_root *dst_root, | |||
1413 | cgroup_clear_dir(&ss->root->cgrp, 1 << ssid); | 1414 | cgroup_clear_dir(&ss->root->cgrp, 1 << ssid); |
1414 | 1415 | ||
1415 | for_each_subsys_which(ss, ssid, &ss_mask) { | 1416 | for_each_subsys_which(ss, ssid, &ss_mask) { |
1416 | struct cgroup_root *src_root; | 1417 | struct cgroup_root *src_root = ss->root; |
1417 | struct cgroup_subsys_state *css; | 1418 | struct cgroup *scgrp = &src_root->cgrp; |
1419 | struct cgroup_subsys_state *css = cgroup_css(scgrp, ss); | ||
1418 | struct css_set *cset; | 1420 | struct css_set *cset; |
1419 | 1421 | ||
1420 | src_root = ss->root; | 1422 | WARN_ON(!css || cgroup_css(dcgrp, ss)); |
1421 | css = cgroup_css(&src_root->cgrp, ss); | ||
1422 | |||
1423 | WARN_ON(!css || cgroup_css(&dst_root->cgrp, ss)); | ||
1424 | 1423 | ||
1425 | RCU_INIT_POINTER(src_root->cgrp.subsys[ssid], NULL); | 1424 | RCU_INIT_POINTER(scgrp->subsys[ssid], NULL); |
1426 | rcu_assign_pointer(dst_root->cgrp.subsys[ssid], css); | 1425 | rcu_assign_pointer(dcgrp->subsys[ssid], css); |
1427 | ss->root = dst_root; | 1426 | ss->root = dst_root; |
1428 | css->cgroup = &dst_root->cgrp; | 1427 | css->cgroup = dcgrp; |
1429 | 1428 | ||
1430 | down_write(&css_set_rwsem); | 1429 | down_write(&css_set_rwsem); |
1431 | hash_for_each(css_set_table, i, cset, hlist) | 1430 | hash_for_each(css_set_table, i, cset, hlist) |
1432 | list_move_tail(&cset->e_cset_node[ss->id], | 1431 | list_move_tail(&cset->e_cset_node[ss->id], |
1433 | &dst_root->cgrp.e_csets[ss->id]); | 1432 | &dcgrp->e_csets[ss->id]); |
1434 | up_write(&css_set_rwsem); | 1433 | up_write(&css_set_rwsem); |
1435 | 1434 | ||
1436 | src_root->subsys_mask &= ~(1 << ssid); | 1435 | src_root->subsys_mask &= ~(1 << ssid); |
1437 | src_root->cgrp.subtree_control &= ~(1 << ssid); | 1436 | scgrp->subtree_control &= ~(1 << ssid); |
1438 | cgroup_refresh_child_subsys_mask(&src_root->cgrp); | 1437 | cgroup_refresh_child_subsys_mask(scgrp); |
1439 | 1438 | ||
1440 | /* default hierarchy doesn't enable controllers by default */ | 1439 | /* default hierarchy doesn't enable controllers by default */ |
1441 | dst_root->subsys_mask |= 1 << ssid; | 1440 | dst_root->subsys_mask |= 1 << ssid; |
1442 | if (dst_root == &cgrp_dfl_root) { | 1441 | if (dst_root == &cgrp_dfl_root) { |
1443 | static_branch_enable(cgroup_subsys_on_dfl_key[ssid]); | 1442 | static_branch_enable(cgroup_subsys_on_dfl_key[ssid]); |
1444 | } else { | 1443 | } else { |
1445 | dst_root->cgrp.subtree_control |= 1 << ssid; | 1444 | dcgrp->subtree_control |= 1 << ssid; |
1446 | cgroup_refresh_child_subsys_mask(&dst_root->cgrp); | 1445 | cgroup_refresh_child_subsys_mask(dcgrp); |
1447 | static_branch_disable(cgroup_subsys_on_dfl_key[ssid]); | 1446 | static_branch_disable(cgroup_subsys_on_dfl_key[ssid]); |
1448 | } | 1447 | } |
1449 | 1448 | ||
@@ -1451,7 +1450,7 @@ static int rebind_subsystems(struct cgroup_root *dst_root, | |||
1451 | ss->bind(css); | 1450 | ss->bind(css); |
1452 | } | 1451 | } |
1453 | 1452 | ||
1454 | kernfs_activate(dst_root->cgrp.kn); | 1453 | kernfs_activate(dcgrp->kn); |
1455 | return 0; | 1454 | return 0; |
1456 | } | 1455 | } |
1457 | 1456 | ||