]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cgroup: Inline cgroup_has_tasks() in cgroup.h
authorTejun Heo <tj@kernel.org>
Tue, 5 May 2026 00:51:17 +0000 (14:51 -1000)
committerTejun Heo <tj@kernel.org>
Fri, 15 May 2026 17:24:12 +0000 (07:24 -1000)
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>
include/linux/cgroup.h
kernel/cgroup/cgroup.c
kernel/cgroup/cpuset-v1.c
kernel/cgroup/cpuset.c

index e52160e85af4b5ba8b3540733aca20a2250fffee..ceb87507667e3a26de9af52e6d621c42a1f06449 100644 (file)
@@ -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)
 {
index bd10a7e2f9c550564e50d498dde2b2ff1508004b..7a94c2ea1036acb8975b7772f22e399ec61eb77d 100644 (file)
@@ -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;
index 7308e9b024951ee709c6ed1ec96fcb592fdf6e16..3e9968dd91e9f56b49f1b249048ae130cd66a56d 100644 (file)
@@ -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;
 
index 74d5c494d6aec16e9100e033ad5c00e9a10d0485..8500e4341c6035605f622875592383d3a7dbbbc5 100644 (file)
@@ -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;