Skip to contentSkip to conversation

blk-mq: only dispatch to non-defauly queue maps if they have queues

PATCH Applied Christoph Hellwig 3 participants 6 messages Dec 17, 2018

Subsystems (2)
lore
Share & tools
lore

Christoph Hellwig

author maintainer
#0 lore raw

PATCH 1/2 blk-mq: only dispatch to non-defauly queue maps if they have queues

We should check if a given queue map actually has queues enabled before dispatching to it. This allows drivers to not initialize optional but not used map types, which subsequently will allow fixing problems with queue map rebuilds for that case.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 block/blk-mq.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
block/blk-mq.h +8 -5
index b63a0de8a07a..d1ed096723fb 100644
@@ -105,14 +105,17 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
 {
 	enum hctx_type type = HCTX_TYPE_DEFAULT;
 
-	if (q->tag_set->nr_maps > HCTX_TYPE_POLL &&
-	    ((flags & REQ_HIPRI) && test_bit(QUEUE_FLAG_POLL, &q->queue_flags)))
+	if ((flags & REQ_HIPRI) &&
+	    q->tag_set->nr_maps > HCTX_TYPE_POLL && 
+	    q->tag_set->map[HCTX_TYPE_POLL].nr_queues &&
+	    test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
 		type = HCTX_TYPE_POLL;
 
-	else if (q->tag_set->nr_maps > HCTX_TYPE_READ &&
-		 ((flags & REQ_OP_MASK) == REQ_OP_READ))
+	else if (((flags & REQ_OP_MASK) == REQ_OP_READ) &&
+	         q->tag_set->nr_maps > HCTX_TYPE_READ &&
+		 q->tag_set->map[HCTX_TYPE_READ].nr_queues)
 		type = HCTX_TYPE_READ;
-
+	
 	return blk_mq_map_queue_type(q, type, cpu);
 }
 
Signature · 1 line
2.19.2
author maintainer
#1 lore raw

PATCH 2/2 nvme-pci: don't share queue maps

Now that the block layer checks if a queue map has any queues inside it there is no more reason to duplicate the maps for the non-default types.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/pci.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/nvme/host/pci.c +1 -5
index fb9d8270f32c..698b350b38cf 100644
@@ -496,11 +496,7 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)
 		map->nr_queues = dev->io_queues[i];
 		if (!map->nr_queues) {
 			BUG_ON(i == HCTX_TYPE_DEFAULT);
-
-			/* shared set, resuse read set parameters */
-			map->nr_queues = dev->io_queues[HCTX_TYPE_DEFAULT];
-			qoff = 0;
-			offset = queue_irq_offset(dev);
+			continue;
 		}
 
 		/*
Signature · 1 line
2.19.2
Reviewed-by on v1 1/2
#4 lore raw
In reply to Christoph Hellwig
Quoted 26 lines · Christoph Hellwig

We should check if a given queue map actually has queues enabled before dispatching to it. This allows drivers to not initialize optional but not used map types, which subsequently will allow fixing problems with queue map rebuilds for that case.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 block/blk-mq.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
block/blk-mq.h +4 -2
index b63a0de8a07a..d1ed096723fb 100644
@@ -105,14 +105,17 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
 {
 	enum hctx_type type = HCTX_TYPE_DEFAULT;
 
-	if (q->tag_set->nr_maps > HCTX_TYPE_POLL &&
-	    ((flags & REQ_HIPRI) && test_bit(QUEUE_FLAG_POLL, &q->queue_flags)))
+	if ((flags & REQ_HIPRI) &&
+	    q->tag_set->nr_maps > HCTX_TYPE_POLL && 
+	    q->tag_set->map[HCTX_TYPE_POLL].nr_queues &&
+	    test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
 		type = HCTX_TYPE_POLL;
 

block/blk-mq.h static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q, · line 120

Quoted 10 lines
block/blk-mq.h +4 -3
-	else if (q->tag_set->nr_maps > HCTX_TYPE_READ &&
-		 ((flags & REQ_OP_MASK) == REQ_OP_READ))
+	else if (((flags & REQ_OP_MASK) == REQ_OP_READ) &&
+	         q->tag_set->nr_maps > HCTX_TYPE_READ &&
+		 q->tag_set->map[HCTX_TYPE_READ].nr_queues)
 		type = HCTX_TYPE_READ;
-
+	
 	return blk_mq_map_queue_type(q, type, cpu);
 }
Reviewed-by Ming Lei <ming.lei at redhat.com>

Thanks,
Ming

Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] nvme-pci: don't share queue maps

In reply to Christoph Hellwig
Quoted 29 lines · Christoph Hellwig

Now that the block layer checks if a queue map has any queues inside it there is no more reason to duplicate the maps for the non-default types.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/pci.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/nvme/host/pci.c +1 -5
index fb9d8270f32c..698b350b38cf 100644
@@ -496,11 +496,7 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)
 		map->nr_queues = dev->io_queues[i];
 		if (!map->nr_queues) {
 			BUG_ON(i == HCTX_TYPE_DEFAULT);
-
-			/* shared set, resuse read set parameters */
-			map->nr_queues = dev->io_queues[HCTX_TYPE_DEFAULT];
-			qoff = 0;
-			offset = queue_irq_offset(dev);
+			continue;
 		}
 
 		/*
Signature · 1 line
2.19.2
Reviewed-by Ming Lei <ming.lei at redhat.com>

Thanks,
Ming

maintainer Applied
#5 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

We should check if a given queue map actually has queues enabled before dispatching to it. This allows drivers to not initialize optional but not used map types, which subsequently will allow fixing problems with queue map rebuilds for that case.

Applied, thanks.

Signature · 1 line
Jens Axboe
maintainer Applied
#3 lore raw

Re: [PATCH 2/2] nvme-pci: don't share queue maps

In reply to Christoph Hellwig
Quoted 3 lines · Christoph Hellwig

Now that the block layer checks if a queue map has any queues inside it there is no more reason to duplicate the maps for the non-default types.

Applied, thanks.

Signature · 1 line
Jens Axboe