Skip to content

Commit 6e8210a

Browse files
Gabriel Krisman Bertazigregkh
authored andcommitted
blk-mq: Always schedule hctx->next_cpu
commit c02ebfdddbafa9a6a0f52fbd715e6bfa229af9d3 upstream. Commit 0e87e58bf60e ("blk-mq: improve warning for running a queue on the wrong CPU") attempts to avoid triggering the WARN_ON in __blk_mq_run_hw_queue when the expected CPU is dead. Problem is, in the last batch execution before round robin, blk_mq_hctx_next_cpu can schedule a dead CPU and also update next_cpu to the next alive CPU in the mask, which will trigger the WARN_ON despite the previous workaround. The following patch fixes this scenario by always scheduling the value in hctx->next_cpu. This changes the moment when we round-robin the CPU running the hctx, but it really doesn't matter, since it still executes BLK_MQ_CPU_WORK_BATCH times in a row before switching to another CPU. Fixes: 0e87e58bf60e ("blk-mq: improve warning for running a queue on the wrong CPU") Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com> Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ddf0c37 commit 6e8210a

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

block/blk-mq.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -842,16 +842,14 @@ static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx)
842842
return WORK_CPU_UNBOUND;
843843

844844
if (--hctx->next_cpu_batch <= 0) {
845-
int cpu = hctx->next_cpu, next_cpu;
845+
int next_cpu;
846846

847847
next_cpu = cpumask_next(hctx->next_cpu, hctx->cpumask);
848848
if (next_cpu >= nr_cpu_ids)
849849
next_cpu = cpumask_first(hctx->cpumask);
850850

851851
hctx->next_cpu = next_cpu;
852852
hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH;
853-
854-
return cpu;
855853
}
856854

857855
return hctx->next_cpu;

0 commit comments

Comments
 (0)