]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - kernel/irq/affinity.c
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
);
43 if (max_vecs
>= num_online_cpus()) {
44 cpumask_copy(affinity_mask
, cpu_online_mask
);
45 *nr_vecs
= num_online_cpus();
47 unsigned int vecs
= 0, cpu
;
49 for_each_online_cpu(cpu
) {
50 if (cpu
== get_first_sibling(cpu
)) {
51 cpumask_set_cpu(cpu
, affinity_mask
);