diff options
| author | Waiman Long <longman@redhat.com> | 2026-10-25 17:44:49 -0400 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2026-10-26 07:44:43 -1000 |
| commit | 518cec2def9992192291f5028edc077fb2e475e9 (patch) | |
| tree | afe0b22a8eafb4b957dfa46928797501db566fb1 /kernel | |
| parent | 43b9f826e7f6c8d2351000016dc07b24140756d8 (diff) | |
cgroup/cpuset: Integrate compute_partition_effective_cpumask() into compute_effective_cpumask()
Update compute_effective_cpumask() to call
compute_partition_effective_cpumask() directly if the given cpuset is
a valid remote or local partition root. This simplifies the call sites
where they are being involved. No functional change is expected.
Suggested-by: Ridong Chen <ridong.chen@linux.dev>
Signed-off-by: Waiman Long <longman@redhat.com>
Acked-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cgroup/cpuset.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index e5ffebb2e495..3219f927c35e 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1606,8 +1606,6 @@ static void compute_partition_effective_cpumask(struct cpuset *cs, struct cpuset *child; bool populated = partition_is_populated(cs, NULL); - WARN_ON_ONCE(!is_partition_valid(cs)); - /* * Check child partition roots to see if they should be invalidated * when all the effective_cpus will be used up and cs is populated. @@ -1668,6 +1666,10 @@ static void compute_effective_cpumask(struct cpumask *new_cpus, { bool has_cpus; + if (is_remote_partition(cs) || + (is_partition_valid(cs) && is_partition_valid(parent))) + return compute_partition_effective_cpumask(cs, new_cpus); + has_cpus = cpumask_and(new_cpus, cs->cpus_allowed, parent->effective_cpus); if (!has_cpus && is_in_v2_mode()) cpumask_copy(new_cpus, parent->effective_cpus); @@ -2268,10 +2270,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp, remote = (new_prs == old_prs); } - if (remote || (is_partition_valid(parent) && is_partition_valid(cp))) - compute_partition_effective_cpumask(cp, tmp->new_cpus); - else - compute_effective_cpumask(tmp->new_cpus, cp, parent); + compute_effective_cpumask(tmp->new_cpus, cp, parent); if (remote) goto get_css; /* Ready to update cpuset data */ @@ -2352,10 +2351,7 @@ get_css: */ new_prs = cp->partition_root_state; if (new_prs != old_prs) { - if (new_prs > 0) - compute_partition_effective_cpumask(cp, tmp->new_cpus); - else - compute_effective_cpumask(tmp->new_cpus, cp, parent); + compute_effective_cpumask(tmp->new_cpus, cp, parent); } } @@ -3987,7 +3983,6 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) static nodemask_t new_mems; bool cpus_updated; bool mems_updated; - bool remote; int partcmd = -1; struct cpuset *parent; @@ -3999,21 +3994,12 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) if (!tmp || !cs->partition_root_state) goto update_tasks; - /* - * Compute effective_cpus for valid partition root, may invalidate - * child partition roots if necessary. - */ - remote = is_remote_partition(cs); - if (remote || (is_partition_valid(cs) && is_partition_valid(parent))) - compute_partition_effective_cpumask(cs, &new_cpus); - - if (remote && (cpumask_empty(subpartitions_cpus) || - (cpumask_empty(&new_cpus) && - partition_is_populated(cs, NULL)))) { + if (is_remote_partition(cs) && (cpumask_empty(subpartitions_cpus) || + (cpumask_empty(&new_cpus) && + partition_is_populated(cs, NULL)))) { WRITE_ONCE(cs->prs_err, PERR_HOTPLUG); remote_partition_disable(cs, tmp); compute_effective_cpumask(&new_cpus, cs, parent); - remote = false; } /* @@ -4039,10 +4025,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) if (partcmd >= 0) { update_parent_effective_cpumask(cs, partcmd, NULL, tmp); - if (is_partition_valid(cs)) { - compute_partition_effective_cpumask(cs, &new_cpus); - cpuset_force_rebuild(); - } else if (partcmd == partcmd_invalidate) { + if (is_partition_valid(cs) || (partcmd == partcmd_invalidate)) { compute_effective_cpumask(&new_cpus, cs, parent); cpuset_force_rebuild(); } |
