diff options
author | Tejun Heo <tj@kernel.org> | 2014-07-08 18:02:56 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-07-08 18:02:56 -0400 |
commit | c29adf24e0c443fb4433efb6a62bd91fdb739c34 (patch) | |
tree | 99a57e738ef088cbadbb6073601361a8d46ebc82 /kernel/cgroup.c | |
parent | a497c3ba1d97fc69c1e78e7b96435ba8c2cb42ee (diff) | |
download | linux-c29adf24e0c443fb4433efb6a62bd91fdb739c34.tar.gz linux-c29adf24e0c443fb4433efb6a62bd91fdb739c34.tar.bz2 linux-c29adf24e0c443fb4433efb6a62bd91fdb739c34.zip |
cgroup: reorganize cgroup_subtree_control_write()
Make the following two reorganizations to
cgroup_subtree_control_write(). These are to prepare for future
changes and shouldn't cause any functional difference.
* Move availability above css offlining wait.
* Move cgrp->child_subsys_mask update above new css creation.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 7868fc3c0bc5..a46d7e2012b4 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2613,6 +2613,14 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of, continue; } + /* unavailable or not enabled on the parent? */ + if (!(cgrp_dfl_root.subsys_mask & (1 << ssid)) || + (cgroup_parent(cgrp) && + !(cgroup_parent(cgrp)->child_subsys_mask & (1 << ssid)))) { + ret = -ENOENT; + goto out_unlock; + } + /* * Because css offlining is asynchronous, userland * might try to re-enable the same controller while @@ -2635,14 +2643,6 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of, return restart_syscall(); } - - /* unavailable or not enabled on the parent? */ - if (!(cgrp_dfl_root.subsys_mask & (1 << ssid)) || - (cgroup_parent(cgrp) && - !(cgroup_parent(cgrp)->child_subsys_mask & (1 << ssid)))) { - ret = -ENOENT; - goto out_unlock; - } } else if (disable & (1 << ssid)) { if (!(cgrp->child_subsys_mask & (1 << ssid))) { disable &= ~(1 << ssid); @@ -2673,12 +2673,10 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of, goto out_unlock; } - /* - * Create csses for enables and update child_subsys_mask. This - * changes cgroup_e_css() results which in turn makes the - * subsequent cgroup_update_dfl_csses() associate all tasks in the - * subtree to the updated csses. - */ + cgrp->child_subsys_mask |= enable; + cgrp->child_subsys_mask &= ~disable; + + /* create new csses */ for_each_subsys(ss, ssid) { if (!(enable & (1 << ssid))) continue; @@ -2690,9 +2688,11 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of, } } - cgrp->child_subsys_mask |= enable; - cgrp->child_subsys_mask &= ~disable; - + /* + * At this point, cgroup_e_css() results reflect the new csses + * making the following cgroup_update_dfl_csses() properly update + * css associations of all tasks in the subtree. + */ ret = cgroup_update_dfl_csses(cgrp); if (ret) goto err_undo_css; |