Skip to contentSkip to conversation

block: don't call blk_mq_quiesce_queue() during switching mq sched

PATCH In review Ming Lei 3 participants 6 messages Apr 28, 2017 – May 2, 2017 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block: don't call blk_mq_quiesce_queue() during switching mq sched

We have freezed queue already, not necessary to call blk_mq_quiesce_queue() any more, so remove it.

Cc Bart Van Assche <[email protected]>
---
 block/elevator.c | 3 ---
 1 file changed, 3 deletions(-)
block/elevator.c +0 -3
index bf11e70f008b..c7a4ee682033 100644
@@ -950,7 +950,6 @@ static int elevator_switch_mq(struct request_queue *q,
 	int ret;
 
 	blk_mq_freeze_queue(q);
-	blk_mq_quiesce_queue(q);
 
 	if (q->elevator) {
 		if (q->elevator->registered)
@@ -978,9 +977,7 @@ static int elevator_switch_mq(struct request_queue *q,
 
 out:
 	blk_mq_unfreeze_queue(q);
-	blk_mq_start_stopped_hw_queues(q, true);
 	return ret;
-
 }
 
 /*
Signature · 1 line
2.9.3
#1 lore raw
Quoted 2 lines · Ming Lei

We have freezed queue already, not necessary to call blk_mq_quiesce_queue() any more, so remove it.

Are you sure? It ensures that we also aren't in the middle of blk_mq_make_request(), we need a stable view of the sched status throughout that.

Similarly with updating the request maps.

Signature · 1 line
Jens Axboe
author
#2 lore raw

Hi Jens,

Quoted 7 lines · Jens Axboe
Quoted 2 lines · Ming Lei

We have freezed queue already, not necessary to call blk_mq_quiesce_queue() any more, so remove it.

Are you sure? It ensures that we also aren't in the middle of blk_mq_make_request(), we need a stable view of the sched status throughout that.

After blk_mq_freeze_queue() returned, no requests belonging to this queue can be in use, so there shouldn't be any .queue_rq() running for this queue.

Or you mean any .queue_rq()(even not belongs to this queue) can't be running during mq scheduler switch? If yes, per-hctx srcu can't guarantee that too for BLOCKING case.

Thanks,
Ming

#3 lore raw
In reply to Jens Axboe
Quoted 7 lines · Jens Axboe
Quoted 2 lines · Ming Lei

We have freezed queue already, not necessary to call blk_mq_quiesce_queue() any more, so remove it.

=20
Are you sure? It ensures that we also aren't in the middle of blk_mq_make_request(), we need a stable view of the sched status throughout that.

Hello Jens,

My understanding is that blk_mq_freeze_queue() provides stronger guarantees than=A0blk_mq_quiesce_queue(). The former waits until all pending requests = have
finished while the latter only waits until pending .queue_rq() calls have finished. blk_mq_freeze_queue() also causes new blk_get_request() calls to wait until blk_mq_unfreeze_queue() is called while=A0blk_get_request() can still succeed after blk_mq_quiesce_queue() returned and before blk_mq_start_stopped_hw_queues() is called.

Regarding blk_mq_make_request(): I think that the blk_queue_enter() call in generic_make_request() prevents that blk_mq_make_request() gets called afte= r
a queue has been frozen.

Bart.=

author
#4 lore raw
Quoted 19 lines · Bart Van Assche
Quoted 7 lines · Jens Axboe
Quoted 2 lines · Ming Lei

We have freezed queue already, not necessary to call blk_mq_quiesce_queue() any more, so remove it.

Are you sure? It ensures that we also aren't in the middle of blk_mq_make_request(), we need a stable view of the sched status throughout that.

Hello Jens,

My understanding is that blk_mq_freeze_queue() provides stronger guarantees than�blk_mq_quiesce_queue(). The former waits until all pending requests have finished while the latter only waits until pending .queue_rq() calls have finished. blk_mq_freeze_queue() also causes new blk_get_request() calls to wait until blk_mq_unfreeze_queue() is called while�blk_get_request() can still succeed after blk_mq_quiesce_queue() returned and before blk_mq_start_stopped_hw_queues() is called.

Quoted 3 lines

Regarding blk_mq_make_request(): I think that the blk_queue_enter() call in generic_make_request() prevents that blk_mq_make_request() gets called after a queue has been frozen.

Jens & Bart, so I understand you don't object to this patch any more, then I will post a v1 for covering blk_mq_update_nr_requests().

Thanks,
Ming

#5 lore raw
In reply to Bart Van Assche
Quoted 20 lines · Bart Van Assche
Quoted 7 lines · Jens Axboe
Quoted 2 lines · Ming Lei

We have freezed queue already, not necessary to call blk_mq_quiesce_queue() any more, so remove it.

Are you sure? It ensures that we also aren't in the middle of blk_mq_make_request(), we need a stable view of the sched status throughout that.

Hello Jens,

My understanding is that blk_mq_freeze_queue() provides stronger guarantees than blk_mq_quiesce_queue(). The former waits until all pending requests have finished while the latter only waits until pending .queue_rq() calls have finished. blk_mq_freeze_queue() also causes new blk_get_request() calls to wait until blk_mq_unfreeze_queue() is called while blk_get_request() can still succeed after blk_mq_quiesce_queue() returned and before blk_mq_start_stopped_hw_queues() is called.

Quoted 3 lines

Regarding blk_mq_make_request(): I think that the blk_queue_enter() call in generic_make_request() prevents that blk_mq_make_request() gets called after a queue has been frozen.

Bart, you are right, I'm fine with the patch.

Signature · 1 line
Jens Axboe