Skip to content

Commit a1a0179

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Consistently compute effective_xcpus in update_cpumasks_hier()
Since commit f62a5d3 ("cgroup/cpuset: Remove remote_partition_check() & make update_cpumasks_hier() handle remote partition"), the compute_effective_exclusive_cpumask() helper was extended to strip exclusive CPUs from siblings when computing effective_xcpus (cpuset.cpus.exclusive.effective). This helper was later renamed to compute_excpus() in commit 86bbbd1 ("cpuset: Refactor exclusive CPU mask computation logic"). This helper is supposed to be used consistently to compute effective_xcpus. However, there is an exception within the callback critical section in update_cpumasks_hier() when exclusive_cpus of a valid partition root is empty. This can cause effective_xcpus value to differ depending on where exactly it is last computed. Fix this by using compute_excpus() in this case to give a consistent result. Signed-off-by: Waiman Long <longman@redhat.com> Reviewed-by: Chen Ridong <chenridong@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 18bc242 commit a1a0179

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

kernel/cgroup/cpuset.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,17 +2168,13 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
21682168
spin_lock_irq(&callback_lock);
21692169
cpumask_copy(cp->effective_cpus, tmp->new_cpus);
21702170
cp->partition_root_state = new_prs;
2171-
if (!cpumask_empty(cp->exclusive_cpus) && (cp != cs))
2172-
compute_excpus(cp, cp->effective_xcpus);
2173-
21742171
/*
2175-
* Make sure effective_xcpus is properly set for a valid
2176-
* partition root.
2172+
* Need to compute effective_xcpus if either exclusive_cpus
2173+
* is non-empty or it is a valid partition root.
21772174
*/
2178-
if ((new_prs > 0) && cpumask_empty(cp->exclusive_cpus))
2179-
cpumask_and(cp->effective_xcpus,
2180-
cp->cpus_allowed, parent->effective_xcpus);
2181-
else if (new_prs < 0)
2175+
if ((new_prs > 0) || !cpumask_empty(cp->exclusive_cpus))
2176+
compute_excpus(cp, cp->effective_xcpus);
2177+
if (new_prs <= 0)
21822178
reset_partition_data(cp);
21832179
spin_unlock_irq(&callback_lock);
21842180

0 commit comments

Comments
 (0)