aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-11-18 02:49:50 -0500
committerTejun Heo <tj@kernel.org>2014-11-18 02:49:50 -0500
commit0f060deb5c5107486c5dadd5c715b3693d381e0a (patch)
tree6e026e7b68546545bda4ca1d2cf89525e6b1c14a /kernel/cgroup.c
parentcea74465e27b1306a237087fca2f5f0befcf1daf (diff)
cgroup: separate out cgroup_calc_child_subsys_mask() from cgroup_refresh_child_subsys_mask()
cgroup_refresh_child_subsys_mask() calculates and updates the effective @cgrp->child_subsys_maks according to the current @cgrp->subtree_control. Separate out the calculation part into cgroup_calc_child_subsys_mask(). This will be used to fix a bug in the async css offline wait logic. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Zefan Li <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 136eceadeed1..1dda601ec337 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1019,31 +1019,30 @@ static void cgroup_put(struct cgroup *cgrp)
1019} 1019}
1020 1020
1021/** 1021/**
1022 * cgroup_refresh_child_subsys_mask - update child_subsys_mask 1022 * cgroup_calc_child_subsys_mask - calculate child_subsys_mask
1023 * @cgrp: the target cgroup 1023 * @cgrp: the target cgroup
1024 * @subtree_control: the new subtree_control mask to consider
1024 * 1025 *
1025 * On the default hierarchy, a subsystem may request other subsystems to be 1026 * On the default hierarchy, a subsystem may request other subsystems to be
1026 * enabled together through its ->depends_on mask. In such cases, more 1027 * enabled together through its ->depends_on mask. In such cases, more
1027 * subsystems than specified in "cgroup.subtree_control" may be enabled. 1028 * subsystems than specified in "cgroup.subtree_control" may be enabled.
1028 * 1029 *
1029 * This function determines which subsystems need to be enabled given the 1030 * This function calculates which subsystems need to be enabled if
1030 * current @cgrp->subtree_control and records it in 1031 * @subtree_control is to be applied to @cgrp. The returned mask is always
1031 * @cgrp->child_subsys_mask. The resulting mask is always a superset of 1032 * a superset of @subtree_control and follows the usual hierarchy rules.
1032 * @cgrp->subtree_control and follows the usual hierarchy rules.
1033 */ 1033 */
1034static void cgroup_refresh_child_subsys_mask(struct cgroup *cgrp) 1034static unsigned int cgroup_calc_child_subsys_mask(struct cgroup *cgrp,
1035 unsigned int subtree_control)
1035{ 1036{
1036 struct cgroup *parent = cgroup_parent(cgrp); 1037 struct cgroup *parent = cgroup_parent(cgrp);
1037 unsigned int cur_ss_mask = cgrp->subtree_control; 1038 unsigned int cur_ss_mask = subtree_control;
1038 struct cgroup_subsys *ss; 1039 struct cgroup_subsys *ss;
1039 int ssid; 1040 int ssid;
1040 1041
1041 lockdep_assert_held(&cgroup_mutex); 1042 lockdep_assert_held(&cgroup_mutex);
1042 1043
1043 if (!cgroup_on_dfl(cgrp)) { 1044 if (!cgroup_on_dfl(cgrp))
1044 cgrp->child_subsys_mask = cur_ss_mask; 1045 return cur_ss_mask;
1045 return;
1046 }
1047 1046
1048 while (true) { 1047 while (true) {
1049 unsigned int new_ss_mask = cur_ss_mask; 1048 unsigned int new_ss_mask = cur_ss_mask;
@@ -1067,7 +1066,20 @@ static void cgroup_refresh_child_subsys_mask(struct cgroup *cgrp)
1067 cur_ss_mask = new_ss_mask; 1066 cur_ss_mask = new_ss_mask;
1068 } 1067 }
1069 1068
1070 cgrp->child_subsys_mask = cur_ss_mask; 1069 return cur_ss_mask;
1070}
1071
1072/**
1073 * cgroup_refresh_child_subsys_mask - update child_subsys_mask
1074 * @cgrp: the target cgroup
1075 *
1076 * Update @cgrp->child_subsys_mask according to the current
1077 * @cgrp->subtree_control using cgroup_calc_child_subsys_mask().
1078 */
1079static void cgroup_refresh_child_subsys_mask(struct cgroup *cgrp)
1080{
1081 cgrp->child_subsys_mask =
1082 cgroup_calc_child_subsys_mask(cgrp, cgrp->subtree_control);
1071} 1083}
1072 1084
1073/** 1085/**