Skip to contentSkip to conversation

blk-mq-sched: don't run the queue async from blk_mq_try_issue_directly()

PATCH In review Jens Axboe 3 participants 5 messages Mar 14, 2017 Block layer

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 blk-mq-sched: don't run the queue async from blk_mq_try_issue_directly()

If we have scheduling enabled, we jump directly to insert-and-run. That's fine, but we run the queue async and we don't pass in information on whether we can block from this context or not. Fixup both these cases.

block/blk-mq.c +5 -4
index 159187a28d66..4196d6bee92d 100644
@@ -1434,7 +1434,8 @@ static blk_qc_t request_to_qc_t(struct blk_mq_hw_ctx *hctx, struct request *rq)
 	return blk_tag_to_qc_t(rq->internal_tag, hctx->queue_num, true);
 }
 
-static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie)
+static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie,
+				      bool can_block)
 {
 	struct request_queue *q = rq->q;
 	struct blk_mq_queue_data bd = {
@@ -1475,7 +1476,7 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie)
 	}
 
 insert:
-	blk_mq_sched_insert_request(rq, false, true, true, false);
+	blk_mq_sched_insert_request(rq, false, true, false, can_block);
 }
 
 /*
@@ -1569,11 +1570,11 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
 
 		if (!(data.hctx->flags & BLK_MQ_F_BLOCKING)) {
 			rcu_read_lock();
-			blk_mq_try_issue_directly(old_rq, &cookie);
+			blk_mq_try_issue_directly(old_rq, &cookie, false);
 			rcu_read_unlock();
 		} else {
 			srcu_idx = srcu_read_lock(&data.hctx->queue_rq_srcu);
-			blk_mq_try_issue_directly(old_rq, &cookie);
+			blk_mq_try_issue_directly(old_rq, &cookie, true);
 			srcu_read_unlock(&data.hctx->queue_rq_srcu, srcu_idx);
 		}
 		goto done;
Signature · 1 line
Jens Axboe
#1 lore raw

On 03/14/2017 07:57 AM, Jens Axboe wrote:=0A=

Quoted 2 lines

If we have scheduling enabled, we jump directly to insert-and-run.=0A= That's fine, but we run the queue async and we don't pass in information=

=0A=

Quoted 2 lines

on whether we can block from this context or not. Fixup both these=0A= cases.=0A=

=0A=
How about renaming "can_block" into "may_sleep"? Otherwise this patch=0A= looks fine to me.=0A=
=0A=
Bart.=0A=

author maintainer
#2 lore raw
Quoted 8 lines · Bart Van Assche
Quoted 4 lines · Jens Axboe

If we have scheduling enabled, we jump directly to insert-and-run. That's fine, but we run the queue async and we don't pass in information on whether we can block from this context or not. Fixup both these cases.

How about renaming "can_block" into "may_sleep"? Otherwise this patch looks fine to me.

Sure, either one is fine with me, at least to me they convey the same information.

Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#3 lore raw
In reply to Jens Axboe
Quoted 4 lines · Jens Axboe

If we have scheduling enabled, we jump directly to insert-and-run. That's fine, but we run the queue async and we don't pass in information on whether we can block from this context or not. Fixup both these cases.

Just one question: we call blk_mq_get_driver_tag() with wait=false in blk_mq_try_issue_directly(). Should we change that to wait=can_block? Maybe it's pointless to try a direct issue if we'd have to wait for a tag anyways, though.

Quoted 43 lines
block/blk-mq.c +5 -4
index 159187a28d66..4196d6bee92d 100644
@@ -1434,7 +1434,8 @@ static blk_qc_t request_to_qc_t(struct blk_mq_hw_ctx *hctx, struct request *rq)
 	return blk_tag_to_qc_t(rq->internal_tag, hctx->queue_num, true);
 }
 
-static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie)
+static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie,
+				      bool can_block)
 {
 	struct request_queue *q = rq->q;
 	struct blk_mq_queue_data bd = {
@@ -1475,7 +1476,7 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie)
 	}
 
 insert:
-	blk_mq_sched_insert_request(rq, false, true, true, false);
+	blk_mq_sched_insert_request(rq, false, true, false, can_block);
 }
 
 /*
@@ -1569,11 +1570,11 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
 
 		if (!(data.hctx->flags & BLK_MQ_F_BLOCKING)) {
 			rcu_read_lock();
-			blk_mq_try_issue_directly(old_rq, &cookie);
+			blk_mq_try_issue_directly(old_rq, &cookie, false);
 			rcu_read_unlock();
 		} else {
 			srcu_idx = srcu_read_lock(&data.hctx->queue_rq_srcu);
-			blk_mq_try_issue_directly(old_rq, &cookie);
+			blk_mq_try_issue_directly(old_rq, &cookie, true);
 			srcu_read_unlock(&data.hctx->queue_rq_srcu, srcu_idx);
 		}
 		goto done;
Signature · 2 lines
-- 
Jens Axboe
author maintainer
#4 lore raw
Quoted 6 lines · Omar Sandoval
Quoted 4 lines · Jens Axboe

If we have scheduling enabled, we jump directly to insert-and-run. That's fine, but we run the queue async and we don't pass in information on whether we can block from this context or not. Fixup both these cases.

Quoted 6 lines

Just one question: we call blk_mq_get_driver_tag() with wait=false in blk_mq_try_issue_directly(). Should we change that to wait=can_block? Maybe it's pointless to try a direct issue if we'd have to wait for a tag anyways, though.

Exactly, don't want to wait for a tag, at that point we are just pointlessly stalling an app that could perhaps be submitting more IO. So I don't think we should factor that in here, better to let the blocking vs non-blocking drivers behave the same in that regard.

Signature · 1 line
Jens Axboe