Skip to content

Commit 2452483

Browse files
committed
Revert "lib: Restrict cpumask_local_spread to houskeeping CPUs"
This reverts commit 1abdfe7. This change is broken and not solving any problem it claims to solve. Robin reported that cpumask_local_spread() now returns any cpu out of cpu_possible_mask in case that NOHZ_FULL is disabled (runtime or compile time). It can also return any offline or not-present CPU in the housekeeping mask. Before that it was returning a CPU out of online_cpu_mask. While the function is racy against CPU hotplug if the caller does not protect against it, the actual use cases are not caring much about it as they use it mostly as hint for: - the user space affinity hint which is unused by the kernel - memory node selection which is just suboptimal - network queue affinity which might fail but is handled gracefully But the occasional fail vs. hotplug is very different from returning anything from possible_cpu_mask which can have a large amount of offline CPUs obviously. The changelog of the commit claims: "The current implementation of cpumask_local_spread() does not respect the isolated CPUs, i.e., even if a CPU has been isolated for Real-Time task, it will return it to the caller for pinning of its IRQ threads. Having these unwanted IRQ threads on an isolated CPU adds up to a latency overhead." The only correct part of this changelog is: "The current implementation of cpumask_local_spread() does not respect the isolated CPUs." Everything else is just disjunct from reality. Reported-by: Robin Murphy <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Nitesh Narayan Lal <[email protected]> Cc: Marcelo Tosatti <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 1048ba8 commit 2452483

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/cpumask.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <linux/export.h>
77
#include <linux/memblock.h>
88
#include <linux/numa.h>
9-
#include <linux/sched/isolation.h>
109

1110
/**
1211
* cpumask_next - get the next cpu in a cpumask
@@ -206,27 +205,22 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask)
206205
*/
207206
unsigned int cpumask_local_spread(unsigned int i, int node)
208207
{
209-
int cpu, hk_flags;
210-
const struct cpumask *mask;
208+
int cpu;
211209

212-
hk_flags = HK_FLAG_DOMAIN | HK_FLAG_MANAGED_IRQ;
213-
mask = housekeeping_cpumask(hk_flags);
214210
/* Wrap: we always want a cpu. */
215-
i %= cpumask_weight(mask);
211+
i %= num_online_cpus();
216212

217213
if (node == NUMA_NO_NODE) {
218-
for_each_cpu(cpu, mask) {
214+
for_each_cpu(cpu, cpu_online_mask)
219215
if (i-- == 0)
220216
return cpu;
221-
}
222217
} else {
223218
/* NUMA first. */
224-
for_each_cpu_and(cpu, cpumask_of_node(node), mask) {
219+
for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask)
225220
if (i-- == 0)
226221
return cpu;
227-
}
228222

229-
for_each_cpu(cpu, mask) {
223+
for_each_cpu(cpu, cpu_online_mask) {
230224
/* Skip NUMA nodes, done above. */
231225
if (cpumask_test_cpu(cpu, cpumask_of_node(node)))
232226
continue;

0 commit comments

Comments
 (0)