aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2016-03-03 09:58:01 -0500
committerTejun Heo <tj@kernel.org>2016-03-03 09:58:01 -0500
commit5ced2518bd3e3a4f01e2122122211f217cd99f4f (patch)
treefefeccfceacfb805672d3007db8e3e76e51ca744
parent334c3679ec4b2b113c35ebe37d2018b112dd5013 (diff)
cgroup: make cgroup_calc_subtree_ss_mask() take @this_ss_mask
cgroup_calc_subtree_ss_mask() currently takes @cgrp and @subtree_control. @cgrp is used for two purposes - to decide whether it's for default hierarchy and the mask of available subsystems. The former doesn't matter as the results are the same regardless. The latter can be specified directly through a subsystem mask. This patch makes cgroup_calc_subtree_ss_mask() perform the same calculations for both default and legacy hierarchies and take @this_ss_mask for available subsystems. @cgrp is no longer used and dropped. This is to allow using the function in contexts where available controllers can't be decided from the cgroup. v2: cgroup_refres_subtree_ss_mask() is removed by a previous patch. Updated accordingly. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Zefan Li <lizefan@huawei.com>
-rw-r--r--kernel/cgroup.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 98e644b0a532..58e02e9aa970 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1309,18 +1309,17 @@ static umode_t cgroup_file_mode(const struct cftype *cft)
1309 1309
1310/** 1310/**
1311 * cgroup_calc_subtree_ss_mask - calculate subtree_ss_mask 1311 * cgroup_calc_subtree_ss_mask - calculate subtree_ss_mask
1312 * @cgrp: the target cgroup
1313 * @subtree_control: the new subtree_control mask to consider 1312 * @subtree_control: the new subtree_control mask to consider
1313 * @this_ss_mask: available subsystems
1314 * 1314 *
1315 * On the default hierarchy, a subsystem may request other subsystems to be 1315 * On the default hierarchy, a subsystem may request other subsystems to be
1316 * enabled together through its ->depends_on mask. In such cases, more 1316 * enabled together through its ->depends_on mask. In such cases, more
1317 * subsystems than specified in "cgroup.subtree_control" may be enabled. 1317 * subsystems than specified in "cgroup.subtree_control" may be enabled.
1318 * 1318 *
1319 * This function calculates which subsystems need to be enabled if 1319 * This function calculates which subsystems need to be enabled if
1320 * @subtree_control is to be applied to @cgrp. The returned mask is always 1320 * @subtree_control is to be applied while restricted to @this_ss_mask.
1321 * a superset of @subtree_control and follows the usual hierarchy rules.
1322 */ 1321 */
1323static u16 cgroup_calc_subtree_ss_mask(struct cgroup *cgrp, u16 subtree_control) 1322static u16 cgroup_calc_subtree_ss_mask(u16 subtree_control, u16 this_ss_mask)
1324{ 1323{
1325 u16 cur_ss_mask = subtree_control; 1324 u16 cur_ss_mask = subtree_control;
1326 struct cgroup_subsys *ss; 1325 struct cgroup_subsys *ss;
@@ -1328,9 +1327,6 @@ static u16 cgroup_calc_subtree_ss_mask(struct cgroup *cgrp, u16 subtree_control)
1328 1327
1329 lockdep_assert_held(&cgroup_mutex); 1328 lockdep_assert_held(&cgroup_mutex);
1330 1329
1331 if (!cgroup_on_dfl(cgrp))
1332 return cur_ss_mask;
1333
1334 while (true) { 1330 while (true) {
1335 u16 new_ss_mask = cur_ss_mask; 1331 u16 new_ss_mask = cur_ss_mask;
1336 1332
@@ -1343,7 +1339,7 @@ static u16 cgroup_calc_subtree_ss_mask(struct cgroup *cgrp, u16 subtree_control)
1343 * happen only if some depended-upon subsystems were bound 1339 * happen only if some depended-upon subsystems were bound
1344 * to non-default hierarchies. 1340 * to non-default hierarchies.
1345 */ 1341 */
1346 new_ss_mask &= cgroup_ss_mask(cgrp); 1342 new_ss_mask &= this_ss_mask;
1347 1343
1348 if (new_ss_mask == cur_ss_mask) 1344 if (new_ss_mask == cur_ss_mask)
1349 break; 1345 break;
@@ -3012,8 +3008,9 @@ static void cgroup_propagate_control(struct cgroup *cgrp)
3012 3008
3013 cgroup_for_each_live_descendant_pre(dsct, d_css, cgrp) { 3009 cgroup_for_each_live_descendant_pre(dsct, d_css, cgrp) {
3014 dsct->subtree_control &= cgroup_control(dsct); 3010 dsct->subtree_control &= cgroup_control(dsct);
3015 dsct->subtree_ss_mask = cgroup_calc_subtree_ss_mask(dsct, 3011 dsct->subtree_ss_mask =
3016 dsct->subtree_control); 3012 cgroup_calc_subtree_ss_mask(dsct->subtree_control,
3013 cgroup_ss_mask(dsct));
3017 } 3014 }
3018} 3015}
3019 3016