blk-mq: initial support for multiple queue maps
authorJens Axboe <axboe@kernel.dk>
Wed, 24 Oct 2018 19:16:11 +0000 (13:16 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 Nov 2018 20:45:00 +0000 (13:45 -0700)
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>
block/blk-mq-cpumap.c
block/blk-mq-pci.c
block/blk-mq-virtio.c
include/linux/blk-mq.h

index 6e6686c559842a979a10c3eadb599cd7d5751f8f..03a53482027150819aaf69769a5c07d0cd5b8a64 100644 (file)
 #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)
@@ -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];
                }
index 40333d60a850d899f06a01943a59371b0c4c50ac..1dce1855398494c445e2c177539820c4ea886a7c 100644 (file)
@@ -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;
index 661fbfef480f0b9361c6bc3426063177dc40c05e..37082716383527adce4b11d174034dbaa4b7a595 100644 (file)
@@ -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;
index 8994c95056a89b29bb13c49d1e18025ef6a2614b..729ce0f00433105426899813ce90e4883270322d 100644 (file)
@@ -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 {