]>
Commit | Line | Data |
---|---|---|
7e0d956d GKH |
1 | From c02ebfdddbafa9a6a0f52fbd715e6bfa229af9d3 Mon Sep 17 00:00:00 2001 |
2 | From: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com> | |
3 | Date: Wed, 28 Sep 2016 00:24:24 -0300 | |
4 | Subject: blk-mq: Always schedule hctx->next_cpu | |
5 | ||
6 | From: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com> | |
7 | ||
8 | commit c02ebfdddbafa9a6a0f52fbd715e6bfa229af9d3 upstream. | |
9 | ||
10 | Commit 0e87e58bf60e ("blk-mq: improve warning for running a queue on the | |
11 | wrong CPU") attempts to avoid triggering the WARN_ON in | |
12 | __blk_mq_run_hw_queue when the expected CPU is dead. Problem is, in the | |
13 | last batch execution before round robin, blk_mq_hctx_next_cpu can | |
14 | schedule a dead CPU and also update next_cpu to the next alive CPU in | |
15 | the mask, which will trigger the WARN_ON despite the previous | |
16 | workaround. | |
17 | ||
18 | The following patch fixes this scenario by always scheduling the value | |
19 | in hctx->next_cpu. This changes the moment when we round-robin the CPU | |
20 | running the hctx, but it really doesn't matter, since it still executes | |
21 | BLK_MQ_CPU_WORK_BATCH times in a row before switching to another CPU. | |
22 | ||
23 | Fixes: 0e87e58bf60e ("blk-mq: improve warning for running a queue on the wrong CPU") | |
24 | Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com> | |
25 | Signed-off-by: Jens Axboe <axboe@fb.com> | |
26 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
27 | ||
28 | --- | |
29 | block/blk-mq.c | 4 +--- | |
30 | 1 file changed, 1 insertion(+), 3 deletions(-) | |
31 | ||
32 | --- a/block/blk-mq.c | |
33 | +++ b/block/blk-mq.c | |
34 | @@ -842,7 +842,7 @@ static int blk_mq_hctx_next_cpu(struct b | |
35 | return WORK_CPU_UNBOUND; | |
36 | ||
37 | if (--hctx->next_cpu_batch <= 0) { | |
38 | - int cpu = hctx->next_cpu, next_cpu; | |
39 | + int next_cpu; | |
40 | ||
41 | next_cpu = cpumask_next(hctx->next_cpu, hctx->cpumask); | |
42 | if (next_cpu >= nr_cpu_ids) | |
43 | @@ -850,8 +850,6 @@ static int blk_mq_hctx_next_cpu(struct b | |
44 | ||
45 | hctx->next_cpu = next_cpu; | |
46 | hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH; | |
47 | - | |
48 | - return cpu; | |
49 | } | |
50 | ||
51 | return hctx->next_cpu; |