Re: [PATCH v3] blk-mq: dispatch kworker to housekeeping CPU when hctx cpumask is empty

From: Jens Axboe

Date: Tue Oct 20 2026 - 11:28:55 EST


On 10/15/26 11:22 PM, Aaron Tomlin wrote:
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 025a799f35b9..1a113679f15b 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2241,6 +2241,21 @@ static bool blk_mq_hctx_empty_cpumask(struct blk_mq_hw_ctx *hctx)
> return hctx->next_cpu >= nr_cpu_ids;
> }
>
> +static inline int blk_mq_hctx_unbound_cpu(void)
> +{
> + if (cpu_is_isolated(raw_smp_processor_id())) {
> + int cpu;
> +
> + guard(rcu)();
> +
> + cpu = cpumask_any_and_distribute(housekeeping_cpumask(HK_TYPE_DOMAIN),
> + cpu_online_mask);
> + if (cpu < nr_cpu_ids)
> + return cpu;
> + }
> + return WORK_CPU_UNBOUND;
> +}

Not opposed to this, but let's please think about making the
common case the fast path. CPU isolation is not the common
path. That might mean annotating the hctx itself.

--
Jens Axboe