Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cgroup/cpuset: Consistently compute effective_xcpus in update_cpumasks_hier()

Since commit f62a5d39368e ("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 86bbbd1f33ab ("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>

authored by

Waiman Long and committed by
Tejun Heo
a1a01793 18bc2425

+5 -9
+5 -9
kernel/cgroup/cpuset.c
··· 2168 2168 spin_lock_irq(&callback_lock); 2169 2169 cpumask_copy(cp->effective_cpus, tmp->new_cpus); 2170 2170 cp->partition_root_state = new_prs; 2171 - if (!cpumask_empty(cp->exclusive_cpus) && (cp != cs)) 2172 - compute_excpus(cp, cp->effective_xcpus); 2173 - 2174 2171 /* 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. 2177 2174 */ 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) 2182 2178 reset_partition_data(cp); 2183 2179 spin_unlock_irq(&callback_lock); 2184 2180