]>
git.ipfire.org Git - thirdparty/linux.git/blob - block/blk-mq-cpumap.c
1 // SPDX-License-Identifier: GPL-2.0
3 * CPU <-> hardware queue mapping helpers
5 * Copyright (C) 2013-2014 Jens Axboe
7 #include <linux/kernel.h>
8 #include <linux/threads.h>
9 #include <linux/module.h>
11 #include <linux/smp.h>
12 #include <linux/cpu.h>
13 #include <linux/group_cpus.h>
15 #include <linux/blk-mq.h>
19 void blk_mq_map_queues(struct blk_mq_queue_map
*qmap
)
21 const struct cpumask
*masks
;
22 unsigned int queue
, cpu
;
24 masks
= group_cpus_evenly(qmap
->nr_queues
);
26 for_each_possible_cpu(cpu
)
27 qmap
->mq_map
[cpu
] = qmap
->queue_offset
;
31 for (queue
= 0; queue
< qmap
->nr_queues
; queue
++) {
32 for_each_cpu(cpu
, &masks
[queue
])
33 qmap
->mq_map
[cpu
] = qmap
->queue_offset
+ queue
;
37 EXPORT_SYMBOL_GPL(blk_mq_map_queues
);
40 * blk_mq_hw_queue_to_node - Look up the memory node for a hardware queue index
41 * @qmap: CPU to hardware queue map.
42 * @index: hardware queue index.
44 * We have no quick way of doing reverse lookups. This is only used at
45 * queue init time, so runtime isn't important.
47 int blk_mq_hw_queue_to_node(struct blk_mq_queue_map
*qmap
, unsigned int index
)
51 for_each_possible_cpu(i
) {
52 if (index
== qmap
->mq_map
[i
])
53 return cpu_to_node(i
);