Skip to content

Commit

Permalink
blk-mq: initial support for multiple queue maps
Browse files Browse the repository at this point in the history
Add a queue offset to the tag map. This enables users to map
iteratively, for each queue map type they support.

Bump maximum number of supported maps to 2, we're now fully
able to support more than 1 map.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Nov 7, 2018
1 parent 3110fc7 commit 843477d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions block/blk-mq-cpumap.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
#include "blk.h"
#include "blk-mq.h"

static int cpu_to_queue_index(unsigned int nr_queues, const int cpu)
static int cpu_to_queue_index(struct blk_mq_queue_map *qmap,
unsigned int nr_queues, const int cpu)
{
return cpu % nr_queues;
return qmap->queue_offset + (cpu % nr_queues);
}

static int get_first_sibling(unsigned int cpu)
Expand Down Expand Up @@ -44,11 +45,11 @@ int blk_mq_map_queues(struct blk_mq_queue_map *qmap)
* performace optimizations.
*/
if (cpu < nr_queues) {
map[cpu] = cpu_to_queue_index(nr_queues, cpu);
map[cpu] = cpu_to_queue_index(qmap, nr_queues, cpu);
} else {
first_sibling = get_first_sibling(cpu);
if (first_sibling == cpu)
map[cpu] = cpu_to_queue_index(nr_queues, cpu);
map[cpu] = cpu_to_queue_index(qmap, nr_queues, cpu);
else
map[cpu] = map[first_sibling];
}
Expand Down
2 changes: 1 addition & 1 deletion block/blk-mq-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int blk_mq_pci_map_queues(struct blk_mq_queue_map *qmap, struct pci_dev *pdev,
goto fallback;

for_each_cpu(cpu, mask)
qmap->mq_map[cpu] = queue;
qmap->mq_map[cpu] = qmap->queue_offset + queue;
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion block/blk-mq-virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int blk_mq_virtio_map_queues(struct blk_mq_queue_map *qmap,
goto fallback;

for_each_cpu(cpu, mask)
qmap->mq_map[cpu] = queue;
qmap->mq_map[cpu] = qmap->queue_offset + queue;
}

return 0;
Expand Down
3 changes: 2 additions & 1 deletion include/linux/blk-mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ struct blk_mq_hw_ctx {
struct blk_mq_queue_map {
unsigned int *mq_map;
unsigned int nr_queues;
unsigned int queue_offset;
};

enum {
HCTX_MAX_TYPES = 1,
HCTX_MAX_TYPES = 2,
};

struct blk_mq_tag_set {
Expand Down

0 comments on commit 843477d

Please sign in to comment.