]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.44/blk-mq-always-schedule-hctx-next_cpu.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.44 / blk-mq-always-schedule-hctx-next_cpu.patch
CommitLineData
7e0d956d
GKH
1From c02ebfdddbafa9a6a0f52fbd715e6bfa229af9d3 Mon Sep 17 00:00:00 2001
2From: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
3Date: Wed, 28 Sep 2016 00:24:24 -0300
4Subject: blk-mq: Always schedule hctx->next_cpu
5
6From: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
7
8commit c02ebfdddbafa9a6a0f52fbd715e6bfa229af9d3 upstream.
9
10Commit 0e87e58bf60e ("blk-mq: improve warning for running a queue on the
11wrong 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
13last batch execution before round robin, blk_mq_hctx_next_cpu can
14schedule a dead CPU and also update next_cpu to the next alive CPU in
15the mask, which will trigger the WARN_ON despite the previous
16workaround.
17
18The following patch fixes this scenario by always scheduling the value
19in hctx->next_cpu. This changes the moment when we round-robin the CPU
20running the hctx, but it really doesn't matter, since it still executes
21BLK_MQ_CPU_WORK_BATCH times in a row before switching to another CPU.
22
23Fixes: 0e87e58bf60e ("blk-mq: improve warning for running a queue on the wrong CPU")
24Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
25Signed-off-by: Jens Axboe <axboe@fb.com>
26Signed-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;