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>
This commit is contained in:
parent
334c3679ec
commit
5ced2518bd
|
@ -1309,18 +1309,17 @@ static umode_t cgroup_file_mode(const struct cftype *cft)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cgroup_calc_subtree_ss_mask - calculate subtree_ss_mask
|
* cgroup_calc_subtree_ss_mask - calculate subtree_ss_mask
|
||||||
* @cgrp: the target cgroup
|
|
||||||
* @subtree_control: the new subtree_control mask to consider
|
* @subtree_control: the new subtree_control mask to consider
|
||||||
|
* @this_ss_mask: available subsystems
|
||||||
*
|
*
|
||||||
* On the default hierarchy, a subsystem may request other subsystems to be
|
* On the default hierarchy, a subsystem may request other subsystems to be
|
||||||
* enabled together through its ->depends_on mask. In such cases, more
|
* enabled together through its ->depends_on mask. In such cases, more
|
||||||
* subsystems than specified in "cgroup.subtree_control" may be enabled.
|
* subsystems than specified in "cgroup.subtree_control" may be enabled.
|
||||||
*
|
*
|
||||||
* This function calculates which subsystems need to be enabled if
|
* This function calculates which subsystems need to be enabled if
|
||||||
* @subtree_control is to be applied to @cgrp. The returned mask is always
|
* @subtree_control is to be applied while restricted to @this_ss_mask.
|
||||||
* a superset of @subtree_control and follows the usual hierarchy rules.
|
|
||||||
*/
|
*/
|
||||||
static u16 cgroup_calc_subtree_ss_mask(struct cgroup *cgrp, u16 subtree_control)
|
static u16 cgroup_calc_subtree_ss_mask(u16 subtree_control, u16 this_ss_mask)
|
||||||
{
|
{
|
||||||
u16 cur_ss_mask = subtree_control;
|
u16 cur_ss_mask = subtree_control;
|
||||||
struct cgroup_subsys *ss;
|
struct cgroup_subsys *ss;
|
||||||
|
@ -1328,9 +1327,6 @@ static u16 cgroup_calc_subtree_ss_mask(struct cgroup *cgrp, u16 subtree_control)
|
||||||
|
|
||||||
lockdep_assert_held(&cgroup_mutex);
|
lockdep_assert_held(&cgroup_mutex);
|
||||||
|
|
||||||
if (!cgroup_on_dfl(cgrp))
|
|
||||||
return cur_ss_mask;
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
u16 new_ss_mask = cur_ss_mask;
|
u16 new_ss_mask = cur_ss_mask;
|
||||||
|
|
||||||
|
@ -1343,7 +1339,7 @@ static u16 cgroup_calc_subtree_ss_mask(struct cgroup *cgrp, u16 subtree_control)
|
||||||
* happen only if some depended-upon subsystems were bound
|
* happen only if some depended-upon subsystems were bound
|
||||||
* to non-default hierarchies.
|
* to non-default hierarchies.
|
||||||
*/
|
*/
|
||||||
new_ss_mask &= cgroup_ss_mask(cgrp);
|
new_ss_mask &= this_ss_mask;
|
||||||
|
|
||||||
if (new_ss_mask == cur_ss_mask)
|
if (new_ss_mask == cur_ss_mask)
|
||||||
break;
|
break;
|
||||||
|
@ -3012,8 +3008,9 @@ static void cgroup_propagate_control(struct cgroup *cgrp)
|
||||||
|
|
||||||
cgroup_for_each_live_descendant_pre(dsct, d_css, cgrp) {
|
cgroup_for_each_live_descendant_pre(dsct, d_css, cgrp) {
|
||||||
dsct->subtree_control &= cgroup_control(dsct);
|
dsct->subtree_control &= cgroup_control(dsct);
|
||||||
dsct->subtree_ss_mask = cgroup_calc_subtree_ss_mask(dsct,
|
dsct->subtree_ss_mask =
|
||||||
dsct->subtree_control);
|
cgroup_calc_subtree_ss_mask(dsct->subtree_control,
|
||||||
|
cgroup_ss_mask(dsct));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue