All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-mq: issue directly if hw queue isn't busy in case of 'none'
@ 2018-07-10  1:03 Ming Lei
  2018-07-17 15:41 ` Kashyap Desai
  2018-07-17 22:04 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2018-07-10  1:03 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Ming Lei, Kashyap Desai, Laurence Oberman,
	Omar Sandoval, Christoph Hellwig, Bart Van Assche,
	Hannes Reinecke

In case of 'none' io scheduler, when hw queue isn't busy, it isn't
necessary to enqueue request to sw queue and dequeue it from
sw queue because request may be submitted to hw queue asap without
extra cost, meantime there shouldn't be much request in sw queue,
and we don't need to worry about effect on IO merge.

There are still some single hw queue SCSI HBAs(HPSA, megaraid_sas, ...)
which may connect high performance devices, so 'none' is often required
for obtaining good performance.

This patch improves IOPS and decreases CPU unilization on megaraid_sas,
per Kashyap's test.

Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Laurence Oberman <loberman@redhat.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Hannes Reinecke <hare@suse.de>
Reported-by: Kashyap Desai <kashyap.desai@broadcom.com>
Tested-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-mq-sched.c | 13 ++++++++++++-
 block/blk-mq.c       | 23 ++++++++++++++++++++++-
 block/blk-mq.h       |  2 ++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index fdc129e64cc4..cf9c66c6d35a 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -405,8 +405,19 @@ void blk_mq_sched_insert_requests(struct request_queue *q,
 
 	if (e && e->type->ops.mq.insert_requests)
 		e->type->ops.mq.insert_requests(hctx, list, false);
-	else
+	else {
+		/*
+		 * try to issue requests directly if the hw queue isn't
+		 * busy in case of 'none' scheduler, and this way may save
+		 * us one extra enqueue & dequeue to sw queue.
+		 */
+		if (!hctx->dispatch_busy && !e && !run_queue_async) {
+			blk_mq_try_issue_list_directly(hctx, list);
+			if (list_empty(list))
+				return;
+		}
 		blk_mq_insert_requests(hctx, ctx, list);
+	}
 
 	blk_mq_run_hw_queue(hctx, run_queue_async);
 }
diff --git a/block/blk-mq.c b/block/blk-mq.c
index d7e09d35d1fb..86c1a90319ae 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1691,13 +1691,16 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx,
 	ret = q->mq_ops->queue_rq(hctx, &bd);
 	switch (ret) {
 	case BLK_STS_OK:
+		blk_mq_update_dispatch_busy(hctx, false);
 		*cookie = new_cookie;
 		break;
 	case BLK_STS_RESOURCE:
 	case BLK_STS_DEV_RESOURCE:
+		blk_mq_update_dispatch_busy(hctx, true);
 		__blk_mq_requeue_request(rq);
 		break;
 	default:
+		blk_mq_update_dispatch_busy(hctx, false);
 		*cookie = BLK_QC_T_NONE;
 		break;
 	}
@@ -1780,6 +1783,23 @@ blk_status_t blk_mq_request_issue_directly(struct request *rq)
 	return ret;
 }
 
+void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
+		struct list_head *list)
+{
+	while (!list_empty(list)) {
+		blk_status_t ret;
+		struct request *rq = list_first_entry(list, struct request,
+				queuelist);
+
+		list_del_init(&rq->queuelist);
+		ret = blk_mq_request_issue_directly(rq);
+		if (ret != BLK_STS_OK) {
+			list_add(&rq->queuelist, list);
+			break;
+		}
+	}
+}
+
 static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
 {
 	const int is_sync = op_is_sync(bio->bi_opf);
@@ -1881,7 +1901,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) {
+	} else if ((q->nr_hw_queues > 1 && is_sync) || (!q->elevator &&
+			!data.hctx->dispatch_busy)) {
 		blk_mq_put_ctx(data.ctx);
 		blk_mq_bio_to_request(rq, bio);
 		blk_mq_try_issue_directly(data.hctx, rq, &cookie);
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 23659f41bf2c..114fa28da44c 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -64,6 +64,8 @@ void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx,
 
 /* Used by blk_insert_cloned_request() to issue request directly */
 blk_status_t blk_mq_request_issue_directly(struct request *rq);
+void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
+				    struct list_head *list);
 
 /*
  * CPU -> queue mappings
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] blk-mq: issue directly if hw queue isn't busy in case of 'none'
  2018-07-10  1:03 [PATCH] blk-mq: issue directly if hw queue isn't busy in case of 'none' Ming Lei
@ 2018-07-17 15:41 ` Kashyap Desai
  2018-07-17 22:04 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Kashyap Desai @ 2018-07-17 15:41 UTC (permalink / raw)
  To: Ming Lei, Jens Axboe
  Cc: linux-block, Laurence Oberman, Omar Sandoval, Christoph Hellwig,
	Bart Van Assche, Hannes Reinecke

> -----Original Message-----
> From: Ming Lei [mailto:ming.lei@redhat.com]
> Sent: Tuesday, July 10, 2018 6:34 AM
> To: Jens Axboe
> Cc: linux-block@vger.kernel.org; Ming Lei; Kashyap Desai; Laurence
Oberman;
> Omar Sandoval; Christoph Hellwig; Bart Van Assche; Hannes Reinecke
> Subject: [PATCH] blk-mq: issue directly if hw queue isn't busy in case
of 'none'
>
> In case of 'none' io scheduler, when hw queue isn't busy, it isn't
> necessary to enqueue request to sw queue and dequeue it from
> sw queue because request may be submitted to hw queue asap without
> extra cost, meantime there shouldn't be much request in sw queue,
> and we don't need to worry about effect on IO merge.
>
> There are still some single hw queue SCSI HBAs(HPSA, megaraid_sas, ...)
> which may connect high performance devices, so 'none' is often required
> for obtaining good performance.

This Patch is tested on my setup and seeing very good performance
improvement.  Just use one R0 VD from configuration -

Without upstream fix and RHEL7.5 kernel -
IOPS goes 840K and CPU utilization goes upto 11%.

After applying another block layer fix -
IOPS goes 1066K and CPU utilization goes up to 6%.

Overall performance improvement is 30% performance and 80% less cpu
utilization.

Any review comments ?

Kashyap

>
> This patch improves IOPS and decreases CPU unilization on megaraid_sas,
> per Kashyap's test.
>
> Cc: Kashyap Desai <kashyap.desai@broadcom.com>
> Cc: Laurence Oberman <loberman@redhat.com>
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Reported-by: Kashyap Desai <kashyap.desai@broadcom.com>
> Tested-by: Kashyap Desai <kashyap.desai@broadcom.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-mq: issue directly if hw queue isn't busy in case of 'none'
  2018-07-10  1:03 [PATCH] blk-mq: issue directly if hw queue isn't busy in case of 'none' Ming Lei
  2018-07-17 15:41 ` Kashyap Desai
@ 2018-07-17 22:04 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2018-07-17 22:04 UTC (permalink / raw)
  To: Ming Lei
  Cc: linux-block, Kashyap Desai, Laurence Oberman, Omar Sandoval,
	Christoph Hellwig, Bart Van Assche, Hannes Reinecke

On 7/9/18 7:03 PM, Ming Lei wrote:
> In case of 'none' io scheduler, when hw queue isn't busy, it isn't
> necessary to enqueue request to sw queue and dequeue it from
> sw queue because request may be submitted to hw queue asap without
> extra cost, meantime there shouldn't be much request in sw queue,
> and we don't need to worry about effect on IO merge.
> 
> There are still some single hw queue SCSI HBAs(HPSA, megaraid_sas, ...)
> which may connect high performance devices, so 'none' is often required
> for obtaining good performance.
> 
> This patch improves IOPS and decreases CPU unilization on megaraid_sas,
> per Kashyap's test.

Looks reasonable to me, applied for 4.19.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-17 22:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-10  1:03 [PATCH] blk-mq: issue directly if hw queue isn't busy in case of 'none' Ming Lei
2018-07-17 15:41 ` Kashyap Desai
2018-07-17 22:04 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.