blk-mq: two improvemens on slow MQ devices
cover blk-mq: two improvemens on slow MQ devices
Hi,
The 1st patch always applies io scheduler path if 'none' isn't used, so that sequential IO performance can be improved on slow MQ device. Also write order for zone device can be maintained becasue zone device requires mq-dealine to do that.
The 2nd patch applies normal plugging for MQ HDD.
Ming Lei (2):
blk-mq: respect io scheduler
blk-mq: apply normal plugging for HDD
block/blk-mq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 blk-mq: respect io scheduler
Now in case of real MQ, io scheduler may be bypassed, and not only this way may hurt performance for some slow MQ device, but also break zoned device which depends on mq-deadline for respecting the write order in one zone.
So don't bypass io scheduler if we have one setup.
This patch can double sequential write performance basically on MQ scsi_debug when mq-deadline is applied.
--- block/blk-mq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
block/blk-mq.c +4 -2
@@ -2003,6 +2003,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) }blk_add_rq_to_plug (plug, rq); + }else if (q->elevator) { +blk_mq_sched_insert_request (rq, false, true, true); }else if (plug && !blk_queue_nomerges (q)) {/* * We do limited plugging. If the bio can be merged, do that.
@@ -2026,8 +2028,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)blk_mq_try_issue_directly (data.hctx, same_queue_rq, &cookie); } - }else if ((q->nr_hw_queues >1 && is_sync) || (!q->elevator && - !data.hctx->dispatch_busy)) { + }else if ((q->nr_hw_queues >1 && is_sync) || + !data.hctx->dispatch_busy) {blk_mq_try_issue_directly (data.hctx, rq, &cookie); }else {blk_mq_sched_insert_request (rq, false, true, true);
Signature · 1 line
2.20.1
Re: [PATCH 1/2] blk-mq: respect io scheduler
Quoted 46 lines · Ming Lei
Now in case of real MQ, io scheduler may be bypassed, and not only this way may hurt performance for some slow MQ device, but also break zoned device which depends on mq-deadline for respecting the write order in one zone.
So don't bypass io scheduler if we have one setup.
This patch can double sequential write performance basically on MQ
scsi_debugwhen mq-deadline is applied.Cc Bart Van Assche <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Damien Le Moal <[email protected]>Cc Dave Chinner <[email protected]>Signed-off-by Ming Lei <[email protected]>---
block/blk-mq.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)block/blk-mq.c +4
-3@@ -2003,6 +2003,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) }blk_add_rq_to_plug (plug, rq); + }else if (q->elevator) { +blk_mq_sched_insert_request (rq, false, true, true); }else if (plug && !blk_queue_nomerges (q)) {/* * We do limited plugging. If the bio can be merged, do that. @@ -2026,8 +2028,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)blk_mq_try_issue_directly (data.hctx, same_queue_rq, &cookie); } - }else if ((q->nr_hw_queues >1 && is_sync) || (!q->elevator && - !data.hctx->dispatch_busy)) { + }else if ((q->nr_hw_queues >1 && is_sync) || + !data.hctx->dispatch_busy) {blk_mq_try_issue_directly (data.hctx, rq, &cookie); }else {blk_mq_sched_insert_request (rq, false, true, true); --
Quoted 1 line
2.20.1
Looks good to me. Fixes a couple issues we have seen with zoned devices too.
Re: [PATCH 1/2] blk-mq: respect io scheduler
In reply to Ming LeiQuoted 45 lines · Ming Lei
Now in case of real MQ, io scheduler may be bypassed, and not only this way may hurt performance for some slow MQ device, but also break zoned device which depends on mq-deadline for respecting the write order in one zone.
So don't bypass io scheduler if we have one setup.
This patch can double sequential write performance basically on MQ
scsi_debugwhen mq-deadline is applied.Cc Bart Van Assche <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Damien Le Moal <[email protected]>Cc Dave Chinner <[email protected]>Signed-off-by Ming Lei <[email protected]>--- block/blk-mq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)block/blk-mq.c +4
-3@@ -2003,6 +2003,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) }blk_add_rq_to_plug (plug, rq); + }else if (q->elevator) { +blk_mq_sched_insert_request (rq, false, true, true); }else if (plug && !blk_queue_nomerges (q)) {/* * We do limited plugging. If the bio can be merged, do that. @@ -2026,8 +2028,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)blk_mq_try_issue_directly (data.hctx, same_queue_rq, &cookie); } - }else if ((q->nr_hw_queues >1 && is_sync) || (!q->elevator && - !data.hctx->dispatch_busy)) { + }else if ((q->nr_hw_queues >1 && is_sync) || + !data.hctx->dispatch_busy) {blk_mq_try_issue_directly (data.hctx, rq, &cookie); }else {blk_mq_sched_insert_request (rq, false, true, true); --
Quoted 2 lines
2.20.1
I've verified that the issue I saw with zone locking being skipped due to scheduler bypass is resolved with this patch.
Thanks,
Hans
Re: [PATCH 1/2] blk-mq: respect io scheduler
In reply to Ming LeiQuoted 33 lines · Ming Lei
Now in case of real MQ, io scheduler may be bypassed, and not only this way may hurt performance for some slow MQ device, but also break zoned device which depends on mq-deadline for respecting the write order in one zone.
So don't bypass io scheduler if we have one setup.
This patch can double sequential write performance basically on MQ
scsi_debugwhen mq-deadline is applied.Cc Bart Van Assche <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Damien Le Moal <[email protected]>Cc Dave Chinner <[email protected]>Signed-off-by Ming Lei <[email protected]>--- block/blk-mq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)block/blk-mq.c +2
-0@@ -2003,6 +2003,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) }blk_add_rq_to_plug (plug, rq); + }else if (q->elevator) { + blk_mq_sched_insert_request(rq, false, true, true);> } else if (plug && !blk_queue_nomerges(q)) {/* * We do limited plugging. If the bio can be merged, do that.
block/blk-mq.c static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) · line 2035
Quoted 10 lines
block/blk-mq.c +2
-2@@ -2026,8 +2028,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)blk_mq_try_issue_directly (data.hctx, same_queue_rq, &cookie); } - }else if ((q->nr_hw_queues >1 && is_sync) || (!q->elevator && - !data.hctx->dispatch_busy)) { + }else if ((q->nr_hw_queues >1 && is_sync) || + !data.hctx->dispatch_busy) {blk_mq_try_issue_directly (data.hctx, rq, &cookie); }else {blk_mq_sched_insert_request (rq, false, true, true);
I think this patch should have a Cc: [email protected]
This fixes a problem existing since we added deadline zone write-locking with commit 5700f69178e9 ("mq-deadline: Introduce zone locking support").
Otherwise:
Signature · 2 lines
Damien Le Moal Western Digital Research
Jens Axboe
maintainerRe: [PATCH 1/2] blk-mq: respect io scheduler
Quoted 40 lines · Damien Le Moal
Quoted 39 lines · Ming Lei
Now in case of real MQ, io scheduler may be bypassed, and not only this way may hurt performance for some slow MQ device, but also break zoned device which depends on mq-deadline for respecting the write order in one zone.
So don't bypass io scheduler if we have one setup.
This patch can double sequential write performance basically on MQ
scsi_debugwhen mq-deadline is applied.Cc Bart Van Assche <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Damien Le Moal <[email protected]>Cc Dave Chinner <[email protected]>Signed-off-by Ming Lei <[email protected]>--- block/blk-mq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)block/blk-mq.c +4
-2@@ -2003,6 +2003,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) }blk_add_rq_to_plug (plug, rq); + }else if (q->elevator) { + blk_mq_sched_insert_request(rq, false, true, true);> } else if (plug && !blk_queue_nomerges(q)) {/* * We do limited plugging. If the bio can be merged, do that. @@ -2026,8 +2028,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)blk_mq_try_issue_directly (data.hctx, same_queue_rq, &cookie); } - }else if ((q->nr_hw_queues >1 && is_sync) || (!q->elevator && - !data.hctx->dispatch_busy)) { + }else if ((q->nr_hw_queues >1 && is_sync) || + !data.hctx->dispatch_busy) {
Quoted 8 lines
block/blk-mq.c static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) · line 2035
Quoted 4 lines
block/blk-mq.c +0
-0blk_mq_try_issue_directly (data.hctx, rq, &cookie); }else {blk_mq_sched_insert_request (rq, false, true, true);I think this patch should have a Cc: [email protected]
This fixes a problem existing since we added deadline zone write-locking with commit5700f69178e9("mq-deadline: Introduce zone locking support").
I'd rather not mark it for stable until it's been in the kernel for some weeks at least, since we are potentially dealing with behavioral change for everyone. We've been burnt by stuff like this in the past.
That said, this patch could be a candidate. Let's revisit in a few weeks.
Signature · 1 line
Jens Axboe
Re: [PATCH 1/2] blk-mq: respect io scheduler
Quoted 50 lines · Jens Axboe
Quoted 40 lines · Damien Le Moal
Quoted 39 lines · Ming Lei
Now in case of real MQ, io scheduler may be bypassed, and not only this way may hurt performance for some slow MQ device, but also break zoned device which depends on mq-deadline for respecting the write order in one zone.
So don't bypass io scheduler if we have one setup.
This patch can double sequential write performance basically on MQ
scsi_debugwhen mq-deadline is applied.Cc Bart Van Assche <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Damien Le Moal <[email protected]>Cc Dave Chinner <[email protected]>Signed-off-by Ming Lei <[email protected]>--- block/blk-mq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)block/blk-mq.c +4
-2@@ -2003,6 +2003,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) }blk_add_rq_to_plug (plug, rq); + }else if (q->elevator) { + blk_mq_sched_insert_request(rq, false, true, true);> } else if (plug && !blk_queue_nomerges(q)) {/* * We do limited plugging. If the bio can be merged, do that. @@ -2026,8 +2028,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)blk_mq_try_issue_directly (data.hctx, same_queue_rq, &cookie); } - }else if ((q->nr_hw_queues >1 && is_sync) || (!q->elevator && - !data.hctx->dispatch_busy)) { + }else if ((q->nr_hw_queues >1 && is_sync) || + !data.hctx->dispatch_busy) {Quoted 8 lines
block/blk-mq.c static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) · line 2035
Quoted 4 lines
block/blk-mq.c +0
-0blk_mq_try_issue_directly (data.hctx, rq, &cookie); }else {blk_mq_sched_insert_request (rq, false, true, true);I think this patch should have a Cc: [email protected]
This fixes a problem existing since we added deadline zone write-locking with commit5700f69178e9("mq-deadline: Introduce zone locking support").
Quoted 6 lines
I'd rather not mark it for stable until it's been in the kernel for some weeks at least, since we are potentially dealing with behavioral change for everyone. We've been burnt by stuff like this in the past.
That said, this patch could be a candidate. Let's revisit in a few weeks.
OK. Thanks !
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 1/2] blk-mq: respect io scheduler
In reply to Ming LeiHello Ming Lei,
Quoted 34 lines · Ming Lei
Now in case of real MQ, io scheduler may be bypassed, and not only this way may hurt performance for some slow MQ device, but also break zoned device which depends on mq-deadline for respecting the write order in one zone.
So don't bypass io scheduler if we have one setup.
This patch can double sequential write performance basically on MQ
scsi_debugwhen mq-deadline is applied.Cc Bart Van Assche <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Damien Le Moal <[email protected]>Cc Dave Chinner <[email protected]>Signed-off-by Ming Lei <[email protected]>--- block/blk-mq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)block/blk-mq.c +2
-0@@ -2003,6 +2003,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) }blk_add_rq_to_plug (plug, rq); + }else if (q->elevator) { +blk_mq_sched_insert_request (rq, false, true, true); }else if (plug && !blk_queue_nomerges (q)) {/* * We do limited plugging. If the bio can be merged, do that.
block/blk-mq.c static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) · line 2035
Quoted 10 lines
block/blk-mq.c +2
-2@@ -2026,8 +2028,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)blk_mq_try_issue_directly (data.hctx, same_queue_rq, &cookie); } - }else if ((q->nr_hw_queues >1 && is_sync) || (!q->elevator && - !data.hctx->dispatch_busy)) { + }else if ((q->nr_hw_queues >1 && is_sync) || + !data.hctx->dispatch_busy) {blk_mq_try_issue_directly (data.hctx, rq, &cookie); }else {blk_mq_sched_insert_request (rq, false, true, true);
This patch introduces identical branches, both "else if (q->elevator)" and "else" do the same thing. Wouldn't be enough to just remove the condition "!q->elevator" without adding a new if?
Thanks,
André
PATCH 2/2 blk-mq: apply normal plugging for HDD
In reply to Ming LeiSome HDD drive may expose multiple hw queue, such as MegraRaid, so still apply the normal plugging for such devices because sequential IO may benefit a lot from plug merging.
--- block/blk-mq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
block/blk-mq.c +5 -1
@@ -1983,10 +1983,14 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)/* bypass scheduler for flush rq */ blk_insert_flush (rq);blk_mq_run_hw_queue (data.hctx, true); - }else if (plug && (q->nr_hw_queues ==1 || q->mq_ops->commit_rqs)) { + }else if (plug && (q->nr_hw_queues ==1 || q->mq_ops->commit_rqs || + !blk_queue_nonrot (q))) {/* * Use plugging if we have a ->commit_rqs() hook as well, as * we know the driver uses bd->last in a smart fashion. +* +* Use normal plugging if this disk is slow HDD, as sequential +* IO may benefit a lot from plug merging. */ unsigned int request_count = plug->rq_count;struct request *last =NULL ;
Signature · 1 line
2.20.1
Re: [PATCH 2/2] blk-mq: apply normal plugging for HDD
Quoted 24 lines · Ming Lei
Some HDD drive may expose multiple hw queue, such as MegraRaid, so still apply the normal plugging for such devices because sequential IO may benefit a lot from plug merging.
Cc Bart Van Assche <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Damien Le Moal <[email protected]>Cc Dave Chinner <[email protected]>Signed-off-by Ming Lei <[email protected]>--- block/blk-mq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)block/blk-mq.c +1
-1@@ -1983,10 +1983,14 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)/* bypass scheduler for flush rq */ blk_insert_flush (rq);blk_mq_run_hw_queue (data.hctx, true); - }else if (plug && (q->nr_hw_queues ==1 || q->mq_ops->commit_rqs)) { + } else if (plug && (q->nr_hw_queues == 1 || q->mq_ops->commit_rqs ||
block/blk-mq.c static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) · line 1996
Quoted 10 lines
block/blk-mq.c +4
-0+ !blk_queue_nonrot(q))) {/* * Use plugging if we have a ->commit_rqs() hook as well, as * we know the driver uses bd->last in a smart fashion. +* +* Use normal plugging if this disk is slow HDD, as sequential +* IO may benefit a lot from plug merging. */ unsigned int request_count = plug->rq_count;struct request *last =NULL ;
Cc stable needed ?
Signature · 2 lines
Damien Le Moal Western Digital Research
Jens Axboe
maintainerQuoted 8 lines · Ming Lei
Hi,
The 1st patch always applies io scheduler path if 'none' isn't used, so that sequential IO performance can be improved on slow MQ device. Also write order for zone device can be maintained becasue zone device requires mq-dealine to do that.
The 2nd patch applies normal plugging for MQ HDD.
Both look clean and fine to me. I will wait with queueing them up until I've done some testing.
Signature · 1 line
Jens Axboe