Re: [PATCH V2] blk-mq: don't schedule block kworker on isolated CPUs

From: Bart Van Assche
Date: Tue Oct 24 2023 - 12:53:57 EST



On 10/13/23 05:47, Ming Lei wrote:
@@ -3926,6 +3941,15 @@ static void blk_mq_map_swqueue(struct request_queue *q)
*/
sbitmap_resize(&hctx->ctx_map, hctx->nr_ctx);
+ /*
+ * rule out isolated CPUs from hctx->cpumask for avoiding to
+ * run wq worker on isolated CPU
+ */
+ for_each_cpu(cpu, hctx->cpumask) {
+ if (cpu_is_isolated(cpu))
+ cpumask_clear_cpu(cpu, hctx->cpumask);
+ }

What will happen if this code makes hctx->cpumask empty? Code like
blk_mq_first_mapped_cpu() and blk_mq_hctx_next_cpu() assumes that
hctx->cpumask is not empty. There may be other code that assumes that
hctx->cpumask is not empty.

Thanks,

Bart.