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) |
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, | |||
2613 | continue; | 2613 | continue; |
2614 | } | 2614 | } |
2615 | 2615 | ||
2616 | /* unavailable or not enabled on the parent? */ | ||
2617 | if (!(cgrp_dfl_root.subsys_mask & (1 << ssid)) || | ||
2618 | (cgroup_parent(cgrp) && | ||
2619 | !(cgroup_parent(cgrp)->child_subsys_mask & (1 << ssid)))) { | ||
2620 | ret = -ENOENT; | ||
2621 | goto out_unlock; | ||
2622 | } | ||
2623 | |||
2616 | /* | 2624 | /* |
2617 | * Because css offlining is asynchronous, userland | 2625 | * Because css offlining is asynchronous, userland |
2618 | * might try to re-enable the same controller while | 2626 | * 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, | |||
2635 | 2643 | ||
2636 | return restart_syscall(); | 2644 | return restart_syscall(); |
2637 | } | 2645 | } |
2638 | |||
2639 | /* unavailable or not enabled on the parent? */ | ||
2640 | if (!(cgrp_dfl_root.subsys_mask & (1 << ssid)) || | ||
2641 | (cgroup_parent(cgrp) && | ||
2642 | !(cgroup_parent(cgrp)->child_subsys_mask & (1 << ssid)))) { | ||
2643 | ret = -ENOENT; | ||
2644 | goto out_unlock; | ||
2645 | } | ||
2646 | } else if (disable & (1 << ssid)) { | 2646 | } else if (disable & (1 << ssid)) { |
2647 | if (!(cgrp->child_subsys_mask & (1 << ssid))) { | 2647 | if (!(cgrp->child_subsys_mask & (1 << ssid))) { |
2648 | disable &= ~(1 << ssid); | 2648 | disable &= ~(1 << ssid); |
@@ -2673,12 +2673,10 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of, | |||
2673 | goto out_unlock; | 2673 | goto out_unlock; |
2674 | } | 2674 | } |
2675 | 2675 | ||
2676 | /* | 2676 | cgrp->child_subsys_mask |= enable; |
2677 | * Create csses for enables and update child_subsys_mask. This | 2677 | cgrp->child_subsys_mask &= ~disable; |
2678 | * changes cgroup_e_css() results which in turn makes the | 2678 | |
2679 | * subsequent cgroup_update_dfl_csses() associate all tasks in the | 2679 | /* create new csses */ |
2680 | * subtree to the updated csses. | ||
2681 | */ | ||
2682 | for_each_subsys(ss, ssid) { | 2680 | for_each_subsys(ss, ssid) { |
2683 | if (!(enable & (1 << ssid))) | 2681 | if (!(enable & (1 << ssid))) |
2684 | continue; | 2682 | continue; |
@@ -2690,9 +2688,11 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of, | |||
2690 | } | 2688 | } |
2691 | } | 2689 | } |
2692 | 2690 | ||
2693 | cgrp->child_subsys_mask |= enable; | 2691 | /* |
2694 | cgrp->child_subsys_mask &= ~disable; | 2692 | * At this point, cgroup_e_css() results reflect the new csses |
2695 | 2693 | * making the following cgroup_update_dfl_csses() properly update | |
2694 | * css associations of all tasks in the subtree. | ||
2695 | */ | ||
2696 | ret = cgroup_update_dfl_csses(cgrp); | 2696 | ret = cgroup_update_dfl_csses(cgrp); |
2697 | if (ret) | 2697 | if (ret) |
2698 | goto err_undo_css; | 2698 | goto err_undo_css; |