[PATCH] blk-mq: remove wrong 'unlikely' checks

2018-05-22 Thread huhai
When dispatch_rq_from_ctx is called, in the vast majority of cases
the ctx->rq_list is not empty

Fixes: b347689ffbca ("blk-mq-sched: improve dispatching from sw queue")
Signed-off-by: huhai <hu...@kylinos.cn>
---
 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 4cbfd784e837..df928200b17e 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1036,7 +1036,7 @@ static bool dispatch_rq_from_ctx(struct sbitmap *sb, 
unsigned int bitnr,
struct blk_mq_ctx *ctx = hctx->ctxs[bitnr];
 
spin_lock(>lock);
-   if (unlikely(!list_empty(>rq_list))) {
+   if (!list_empty(>rq_list)) {
dispatch_data->rq = list_entry_rq(ctx->rq_list.next);
list_del_init(_data->rq->queuelist);
if (list_empty(>rq_list))
-- 
2.17.0





Re: blk-mq: make sure that correct hctx->dispatch_from is set

2018-05-18 Thread huhai
Yes, it is more readable

Finally, thank you for reminding me. Next time I'll change gmail to submit 
patch.

 
 
 
-- Original --
From:  "Jens Axboe"<ax...@kernel.dk>;
Date:  Fri, May 18, 2018 10:31 PM
To:  "胡海"<hu...@kylinos.cn>;
Cc:  "ming.lei"<ming@redhat.com>; 
"linux-block"<linux-block@vger.kernel.org>;
Subject:  Re: blk-mq: make sure that correct hctx->dispatch_from is set
 
On 5/18/18 8:27 AM, Jens Axboe wrote:
> On 5/18/18 7:42 AM, 胡海 wrote:
>> Author: huhai <hu...@kylinos.cn>
>> Date:   Fri May 18 17:09:56 2018 +0800
>>
>> blk-mq: make sure that correct hctx->dispatch_from is set
>> 
>> When the number of hardware queues is changed, the drivers will call
>> blk_mq_update_nr_hw_queues() to remap hardware queues, and then
>> the ctx mapped on hctx will also change, but the current code forgets to
>> make sure that correct hctx->dispatch_from is set, and 
>> hctx->dispatch_from
>> may point to a ctx that does not belong to the current hctx.
> 
> Looks good, thanks. One minor note for future patches - for cases like this,
> when the patch fixes an issue with a specific commit, add a fixes line.
> For this one, it would be:
> 
> Fixes: b347689ffbca ("blk-mq-sched: improve dispatching from sw queue")

Two more notes... Your patches are still coming through as base64 encoded,
they should just be plain text.

Finally, I think the below is much clearer, since that's the loop where
we clear any existing hctx context.


diff --git a/block/blk-mq.c b/block/blk-mq.c
index 6c6aef44badd..4cbfd784e837 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2358,6 +2358,7 @@ static void blk_mq_map_swqueue(struct request_queue *q)
queue_for_each_hw_ctx(q, hctx, i) {
cpumask_clear(hctx->cpumask);
hctx->nr_ctx = 0;
+   hctx->dispatch_from = NULL;
}
 
/*

-- 
Jens Axboe