Skip to contentSkip to conversation

blk-mq: run hw queue asynchronously in blk_mq_start_hw_queues

PATCH In review Ming Lei 2 participants 4 messages Jun 24, 2014 – Jun 25, 2014 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 blk-mq: run hw queue asynchronously in blk_mq_start_hw_queues

Quoted 1 line

From API view, it isn't good to run all hw queues synchronously

in one context, since it isn't correct for multi hw queue case.

So this patch adds 'async' parameter to blk_mq_start_hw_queue(), and make blk_mq_start_hw_queues() to run hw queues asynchronously at default.

---
 block/blk-mq.c         |    6 +++---
 include/linux/blk-mq.h |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
block/blk-mq.c +3 -3
index 0ef2dc7..f83eacd 100644
@@ -873,12 +873,12 @@ void blk_mq_stop_hw_queues(struct request_queue *q)
 }
 EXPORT_SYMBOL(blk_mq_stop_hw_queues);
 
-void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx)
+void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
 {
 	clear_bit(BLK_MQ_S_STOPPED, &hctx->state);
 
 	preempt_disable();
-	__blk_mq_run_hw_queue(hctx);
+	blk_mq_run_hw_queue(hctx, async);
 	preempt_enable();
 }
 EXPORT_SYMBOL(blk_mq_start_hw_queue);
@@ -889,7 +889,7 @@ void blk_mq_start_hw_queues(struct request_queue *q)
 	int i;
 
 	queue_for_each_hw_ctx(q, hctx, i)
-		blk_mq_start_hw_queue(hctx);
+		blk_mq_start_hw_queue(hctx, true);
 }
 EXPORT_SYMBOL(blk_mq_start_hw_queues);
 
include/linux/blk-mq.h +1 -1
index eb726b9..49e84b5 100644
@@ -169,7 +169,7 @@ void blk_mq_kick_requeue_list(struct request_queue *q);
 void blk_mq_complete_request(struct request *rq);
 
 void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx);
-void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx);
+void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
 void blk_mq_stop_hw_queues(struct request_queue *q);
 void blk_mq_start_hw_queues(struct request_queue *q);
 void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async);
Signature · 1 line
1.7.9.5
author
#1 lore raw
Quoted 6 lines · Ming Lei

From API view, it isn't good to run all hw queues synchronously in one context, since it isn't correct for multi hw queue case.

So this patch adds 'async' parameter to blk_mq_start_hw_queue(), and make blk_mq_start_hw_queues() to run hw queues asynchronously at default.

BTW, without the change, it is easy to trigger the WARN_ON() in __blk_mq_run_hw_queue().

Thanks,

Signature · 1 line
Ming Lei
maintainer
#2 lore raw
Quoted 10 lines · Ming Lei
Quoted 6 lines · Ming Lei

From API view, it isn't good to run all hw queues synchronously
in one context, since it isn't correct for multi hw queue case.

So this patch adds 'async' parameter to blk_mq_start_hw_queue(), and make blk_mq_start_hw_queues() to run hw queues asynchronously at default.

BTW, without the change, it is easy to trigger the WARN_ON() in __blk_mq_run_hw_queue().

Why not just have it call blk_mq_run_hw_queue()? Pass in async == false, but let the cpumask logic sort out if we need to force an async run.

Signature · 1 line
Jens Axboe
block/blk-mq.c +1 -1
index 0ef2dc7f01bf..ad69ef657e85 100644
@@ -878,7 +878,7 @@ void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx)
 	clear_bit(BLK_MQ_S_STOPPED, &hctx->state);
 
 	preempt_disable();
-	__blk_mq_run_hw_queue(hctx);
+	blk_mq_run_hw_queue(hctx, false);
 	preempt_enable();
 }
 EXPORT_SYMBOL(blk_mq_start_hw_queue);
author
#3 lore raw
Quoted 12 lines · Jens Axboe
Quoted 11 lines · Ming Lei
Quoted 7 lines · Ming Lei

From API view, it isn't good to run all hw queues synchronously
in one context, since it isn't correct for multi hw queue case.

So this patch adds 'async' parameter to blk_mq_start_hw_queue(), and make blk_mq_start_hw_queues() to run hw queues asynchronously at default.

Quoted 6 lines
Quoted 2 lines

BTW, without the change, it is easy to trigger the WARN_ON() in __blk_mq_run_hw_queue().

Why not just have it call blk_mq_run_hw_queue()? Pass in async == false, but let the cpumask logic sort out if we need to force an async run.

That looks better, thanks.

Thanks,

Signature · 1 line
Ming Lei