diff mbox series

[7/7] blk-mq: use plug for devices that implement ->commits_rqs()

Message ID 20181128133538.20329-8-axboe@kernel.dk (mailing list archive)
State New, archived
Headers show
Series block plugging improvements | expand

Commit Message

Jens Axboe Nov. 28, 2018, 1:35 p.m. UTC
If we have that hook, we know the driver handles bd->last == true in
a smart fashion. If it does, even for multiple hardware queues, it's
a good idea to flush batches of requests to the device, if we have
batches of requests from the submitter.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Ming Lei Nov. 29, 2018, 7:13 a.m. UTC | #1
On Wed, Nov 28, 2018 at 06:35:38AM -0700, Jens Axboe wrote:
> If we have that hook, we know the driver handles bd->last == true in
> a smart fashion. If it does, even for multiple hardware queues, it's
> a good idea to flush batches of requests to the device, if we have
> batches of requests from the submitter.
> 
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
>  block/blk-mq.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 9e1045152e45..091557a43d53 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1945,7 +1945,12 @@ 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) {
> +	} else if (plug && (q->nr_hw_queues == 1 || q->mq_ops->commit_rqs)) {
> +		/*
> +		 * Use plugging if we have a ->commit_rqs() hook as well,
> +		 * as we know the driver uses bd->last in a smart
> +		 * fashion.
> +		 */
>  		unsigned int request_count = plug->rq_count;
>  		struct request *last = NULL;
>  
> -- 
> 2.17.1
> 

Reviewed-by: Ming Lei <ming.lei@redhat.com>

thanks,
Ming
Christoph Hellwig Nov. 29, 2018, 3:49 p.m. UTC | #2
> +		/*
> +		 * Use plugging if we have a ->commit_rqs() hook as well,
> +		 * as we know the driver uses bd->last in a smart
> +		 * fashion.
> +		 */

Nipick: this could flow on just two lines:

		/*
		 * Use plugging if we have a ->commit_rqs() hook as well, as we
		 * know the driver uses bd->last in a smart fashion.
		 */
Christoph Hellwig Nov. 29, 2018, 3:50 p.m. UTC | #3
On Thu, Nov 29, 2018 at 07:49:59AM -0800, Christoph Hellwig wrote:
> > +		/*
> > +		 * Use plugging if we have a ->commit_rqs() hook as well,
> > +		 * as we know the driver uses bd->last in a smart
> > +		 * fashion.
> > +		 */
> 
> Nipick: this could flow on just two lines:
> 
> 		/*
> 		 * Use plugging if we have a ->commit_rqs() hook as well, as we
> 		 * know the driver uses bd->last in a smart fashion.
> 		 */

But of course otherwise this looks fine:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Jens Axboe Nov. 29, 2018, 5:05 p.m. UTC | #4
On 11/29/18 8:49 AM, Christoph Hellwig wrote:
>> +		/*
>> +		 * Use plugging if we have a ->commit_rqs() hook as well,
>> +		 * as we know the driver uses bd->last in a smart
>> +		 * fashion.
>> +		 */
> 
> Nipick: this could flow on just two lines:
> 
> 		/*
> 		 * Use plugging if we have a ->commit_rqs() hook as well, as we
> 		 * know the driver uses bd->last in a smart fashion.
> 		 */

Fixed up.
Sagi Grimberg Dec. 4, 2018, 1:39 a.m. UTC | #5
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 9e1045152e45..091557a43d53 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1945,7 +1945,12 @@  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) {
+	} else if (plug && (q->nr_hw_queues == 1 || q->mq_ops->commit_rqs)) {
+		/*
+		 * Use plugging if we have a ->commit_rqs() hook as well,
+		 * as we know the driver uses bd->last in a smart
+		 * fashion.
+		 */
 		unsigned int request_count = plug->rq_count;
 		struct request *last = NULL;