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

sched/topology: Fix sched_numa_find_nth_cpu() in non-NUMA case

When CONFIG_NUMA is enabled, sched_numa_find_nth_cpu() searches for a
CPU in sched_domains_numa_masks. The masks includes only online CPUs,
so effectively offline CPUs are skipped.

When CONFIG_NUMA is disabled, the fallback function should be consistent.

Fixes: cd7f55359c90 ("sched: add sched_numa_find_nth_cpu()")
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>
Link: https://lore.kernel.org/r/20230819141239.287290-5-yury.norov@gmail.com

authored by

Yury Norov and committed by
Ingo Molnar
8ab63d41 617f2c38

+1 -1
+1 -1
include/linux/topology.h
··· 251 251 #else 252 252 static __always_inline int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node) 253 253 { 254 - return cpumask_nth(cpu, cpus); 254 + return cpumask_nth_and(cpu, cpus, cpu_online_mask); 255 255 } 256 256 257 257 static inline const struct cpumask *