diff mbox series

blk-mq: set plug->rq_count 0 after sort in blk_mq_flush_plug_list

Message ID 20190406015440.30233-1-shhuiw@foxmail.com (mailing list archive)
State New, archived
Headers show
Series blk-mq: set plug->rq_count 0 after sort in blk_mq_flush_plug_list | expand

Commit Message

Shenghui Wang April 6, 2019, 1:54 a.m. UTC
Set plug->rq_count 0 earlier can skip possible sort.
Move the 0-value set after sort.

Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dongli Zhang April 6, 2019, 11:58 a.m. UTC | #1
On 04/06/2019 09:54 AM, Shenghui Wang wrote:
> Set plug->rq_count 0 earlier can skip possible sort.
> Move the 0-value set after sort.

The same fix already exists at:

https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=for-linus&id=bcc816dfe51ab86ca94663c7b225f2d6eb0fddb9

Dongli Zhang

> 
> Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
> ---
>  block/blk-mq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index f3b0d33bdf88..e5d32f186e81 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1711,10 +1711,10 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
>  	unsigned int depth;
>  
>  	list_splice_init(&plug->mq_list, &list);
> -	plug->rq_count = 0;
>  
>  	if (plug->rq_count > 2 && plug->multiple_queues)
>  		list_sort(NULL, &list, plug_rq_cmp);
> +	plug->rq_count = 0;
>  
>  	this_q = NULL;
>  	this_hctx = NULL;
>
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index f3b0d33bdf88..e5d32f186e81 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1711,10 +1711,10 @@  void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 	unsigned int depth;
 
 	list_splice_init(&plug->mq_list, &list);
-	plug->rq_count = 0;
 
 	if (plug->rq_count > 2 && plug->multiple_queues)
 		list_sort(NULL, &list, plug_rq_cmp);
+	plug->rq_count = 0;
 
 	this_q = NULL;
 	this_hctx = NULL;