[Bionic][PATCH v2 11/21] blk-mq: make sure that correct hctx->next_cpu is set

Jose Ricardo Ziviani joserz at linux.vnet.ibm.com
Thu May 10 16:23:24 UTC 2018


From: Ming Lei <ming.lei at redhat.com>

>From commit 20e4d81393196 (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 at linux.vnet.ibm.com>
Tested-by: Christian Borntraeger <borntraeger at de.ibm.com>
Reviewed-by: Christoph Hellwig <hch at lst.de>
Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
Fixes: 20e4d81393196 ("blk-mq: simplify queue mapping & schedule with each possisble CPU")
Cc: stable at vger.kernel.org
Signed-off-by: Ming Lei <ming.lei at redhat.com>
Signed-off-by: Jens Axboe <axboe at kernel.dk>
(cherry picked from commit a1c735fb790745f94a359df45c11df4a69760389)
Signed-off-by: Jose Ricardo Ziviani <joserz at linux.ibm.com>
---
 block/blk-mq.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index f5e7624d6fe1..ce5a08e3c0f3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2280,6 +2280,8 @@ static void blk_mq_map_swqueue(struct request_queue *q)
 		 */
 		hctx->next_cpu = cpumask_first_and(hctx->cpumask,
 				cpu_online_mask);
+		if (hctx->next_cpu >= nr_cpu_ids)
+			hctx->next_cpu = cpumask_first(hctx->cpumask);
 		hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH;
 	}
 }
-- 
2.17.0





More information about the kernel-team mailing list