2 #include <linux/interrupt.h>
3 #include <linux/kernel.h>
4 #include <linux/slab.h>
7 static int get_first_sibling(unsigned int cpu
)
11 ret
= cpumask_first(topology_sibling_cpumask(cpu
));
18 * Take a map of online CPUs and the number of available interrupt vectors
19 * and generate an output cpumask suitable for spreading MSI/MSI-X vectors
20 * so that they are distributed as good as possible around the CPUs. If
21 * more vectors than CPUs are available we'll map one to each CPU,
22 * otherwise we map one to the first sibling of each socket.
24 * If there are more vectors than CPUs we will still only have one bit
25 * set per CPU, but interrupt code will keep on assigning the vectors from
26 * the start of the bitmap until we run out of vectors.
28 struct cpumask
*irq_create_affinity_mask(unsigned int *nr_vecs
)
30 struct cpumask
*affinity_mask
;
31 unsigned int max_vecs
= *nr_vecs
;
36 affinity_mask
= kzalloc(cpumask_size(), GFP_KERNEL
);
42 if (max_vecs
>= num_online_cpus()) {
43 cpumask_copy(affinity_mask
, cpu_online_mask
);
44 *nr_vecs
= num_online_cpus();
46 unsigned int vecs
= 0, cpu
;
48 for_each_online_cpu(cpu
) {
49 if (cpu
== get_first_sibling(cpu
)) {
50 cpumask_set_cpu(cpu
, affinity_mask
);
This page took 0.03937 seconds and 5 git commands to generate.