Skip to content

Commit 1abdfe7

Browse files
Alex BelitsPeter Zijlstra
authored andcommitted
lib: Restrict cpumask_local_spread to houskeeping CPUs
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. Restrict the CPUs that are returned for spreading IRQs only to the available housekeeping CPUs. Signed-off-by: Alex Belits <[email protected]> Signed-off-by: Nitesh Narayan Lal <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 46609ce commit 1abdfe7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/cpumask.c

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

1011
/**
1112
* cpumask_next - get the next cpu in a cpumask
@@ -205,22 +206,27 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask)
205206
*/
206207
unsigned int cpumask_local_spread(unsigned int i, int node)
207208
{
208-
int cpu;
209+
int cpu, hk_flags;
210+
const struct cpumask *mask;
209211

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

213217
if (node == NUMA_NO_NODE) {
214-
for_each_cpu(cpu, cpu_online_mask)
218+
for_each_cpu(cpu, mask) {
215219
if (i-- == 0)
216220
return cpu;
221+
}
217222
} else {
218223
/* NUMA first. */
219-
for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask)
224+
for_each_cpu_and(cpu, cpumask_of_node(node), mask) {
220225
if (i-- == 0)
221226
return cpu;
227+
}
222228

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

0 commit comments

Comments
 (0)