Skip to content

Commit a1c735f

Browse files
Ming Leiaxboe
authored andcommitted
blk-mq: make sure that correct hctx->next_cpu is set
From commit 20e4d81 (blk-mq: simplify queue mapping & schedule with each possisble CPU), one hctx can be mapped from all offline CPUs, then hctx->next_cpu can be set as wrong. This patch fixes this issue by making hctx->next_cpu pointing to the first CPU in hctx->cpumask if all CPUs in hctx->cpumask are offline. Cc: Stefan Haberland <sth@linux.vnet.ibm.com> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Fixes: 20e4d81 ("blk-mq: simplify queue mapping & schedule with each possisble CPU") Cc: stable@vger.kernel.org Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent bdac616 commit a1c735f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

block/blk-mq.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,8 @@ static void blk_mq_map_swqueue(struct request_queue *q)
24312431
*/
24322432
hctx->next_cpu = cpumask_first_and(hctx->cpumask,
24332433
cpu_online_mask);
2434+
if (hctx->next_cpu >= nr_cpu_ids)
2435+
hctx->next_cpu = cpumask_first(hctx->cpumask);
24342436
hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH;
24352437
}
24362438
}

0 commit comments

Comments
 (0)