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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 24, 2023 at 09:53:49AM -0700, Bart Van Assche wrote:
> 
> 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.

hctx->cpumask is only used for selecting next cpu to schedule run
queue now, so it is fine for hctx->cpumask to be empty.

But the patch has one hole, following the delta fix:


diff --git a/block/blk-mq.c b/block/blk-mq.c
index 0917f8eabab9..1d9a7ded27af 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2159,7 +2159,7 @@ static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx)
 	bool tried = false;
 	int next_cpu = hctx->next_cpu;
 
-	if (hctx->queue->nr_hw_queues == 1)
+	if (hctx->queue->nr_hw_queues == 1 || next_cpu >= nr_cpu_ids)
 		return WORK_CPU_UNBOUND;
 
 	if (--hctx->next_cpu_batch <= 0) {



Thanks,
Ming




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux