mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
cgroup: Inline cgroup_has_tasks() in cgroup.h
cpuset reads cs->css.cgroup->nr_populated_csets directly in two places to test whether a cgroup has tasks. cgroup.c already has a matching helper, cgroup_has_tasks(). Move it to cgroup.h as static inline and use that instead. This is to prepare for relocation of cgroup->nr_populated_csets. No semantic change. Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
@@ -639,6 +639,11 @@ static inline bool task_under_cgroup_hierarchy(struct task_struct *task,
|
||||
return cgroup_is_descendant(cset->dfl_cgrp, ancestor);
|
||||
}
|
||||
|
||||
static inline bool cgroup_has_tasks(struct cgroup *cgrp)
|
||||
{
|
||||
return cgrp->nr_populated_csets;
|
||||
}
|
||||
|
||||
/* no synchronization, the result can only be used as a hint */
|
||||
static inline bool cgroup_is_populated(struct cgroup *cgrp)
|
||||
{
|
||||
|
||||
@@ -376,11 +376,6 @@ static void cgroup_idr_remove(struct idr *idr, int id)
|
||||
spin_unlock_bh(&cgroup_idr_lock);
|
||||
}
|
||||
|
||||
static bool cgroup_has_tasks(struct cgroup *cgrp)
|
||||
{
|
||||
return cgrp->nr_populated_csets;
|
||||
}
|
||||
|
||||
static bool cgroup_is_threaded(struct cgroup *cgrp)
|
||||
{
|
||||
return cgrp->dom_cgrp != cgrp;
|
||||
|
||||
@@ -312,7 +312,7 @@ void cpuset1_hotplug_update_tasks(struct cpuset *cs,
|
||||
* This is full cgroup operation which will also call back into
|
||||
* cpuset. Execute it asynchronously using workqueue.
|
||||
*/
|
||||
if (is_empty && cs->css.cgroup->nr_populated_csets &&
|
||||
if (is_empty && cgroup_has_tasks(cs->css.cgroup) &&
|
||||
css_tryget_online(&cs->css)) {
|
||||
struct cpuset_remove_tasks_struct *s;
|
||||
|
||||
|
||||
@@ -432,7 +432,7 @@ static inline bool partition_is_populated(struct cpuset *cs,
|
||||
* nr_populated_domain_children may include populated
|
||||
* csets from descendants that are partitions.
|
||||
*/
|
||||
if (cs->css.cgroup->nr_populated_csets ||
|
||||
if (cgroup_has_tasks(cs->css.cgroup) ||
|
||||
cs->attach_in_progress)
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user