Commit 0f060deb authored by Tejun Heo's avatar Tejun Heo

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: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarZefan Li <lizefan@huawei.com>
parent cea74465
...@@ -1019,31 +1019,30 @@ static void cgroup_put(struct cgroup *cgrp) ...@@ -1019,31 +1019,30 @@ static void cgroup_put(struct cgroup *cgrp)
} }
/** /**
* cgroup_refresh_child_subsys_mask - update child_subsys_mask * cgroup_calc_child_subsys_mask - calculate child_subsys_mask
* @cgrp: the target cgroup * @cgrp: the target cgroup
* @subtree_control: the new subtree_control mask to consider
* *
* 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 determines which subsystems need to be enabled given the * This function calculates which subsystems need to be enabled if
* current @cgrp->subtree_control and records it in * @subtree_control is to be applied to @cgrp. The returned mask is always
* @cgrp->child_subsys_mask. The resulting mask is always a superset of * a superset of @subtree_control and follows the usual hierarchy rules.
* @cgrp->subtree_control and follows the usual hierarchy rules.
*/ */
static void cgroup_refresh_child_subsys_mask(struct cgroup *cgrp) static unsigned int cgroup_calc_child_subsys_mask(struct cgroup *cgrp,
unsigned int subtree_control)
{ {
struct cgroup *parent = cgroup_parent(cgrp); struct cgroup *parent = cgroup_parent(cgrp);
unsigned int cur_ss_mask = cgrp->subtree_control; unsigned int cur_ss_mask = subtree_control;
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
int ssid; int ssid;
lockdep_assert_held(&cgroup_mutex); lockdep_assert_held(&cgroup_mutex);
if (!cgroup_on_dfl(cgrp)) { if (!cgroup_on_dfl(cgrp))
cgrp->child_subsys_mask = cur_ss_mask; return cur_ss_mask;
return;
}
while (true) { while (true) {
unsigned int new_ss_mask = cur_ss_mask; unsigned int new_ss_mask = cur_ss_mask;
...@@ -1067,7 +1066,20 @@ static void cgroup_refresh_child_subsys_mask(struct cgroup *cgrp) ...@@ -1067,7 +1066,20 @@ static void cgroup_refresh_child_subsys_mask(struct cgroup *cgrp)
cur_ss_mask = new_ss_mask; cur_ss_mask = new_ss_mask;
} }
cgrp->child_subsys_mask = cur_ss_mask; return cur_ss_mask;
}
/**
* cgroup_refresh_child_subsys_mask - update child_subsys_mask
* @cgrp: the target cgroup
*
* Update @cgrp->child_subsys_mask according to the current
* @cgrp->subtree_control using cgroup_calc_child_subsys_mask().
*/
static void cgroup_refresh_child_subsys_mask(struct cgroup *cgrp)
{
cgrp->child_subsys_mask =
cgroup_calc_child_subsys_mask(cgrp, cgrp->subtree_control);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment