From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: linux-scsi@vger.kernel.org, virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v17 06/10] blk-mq: prevent offlining hk CPUs with associated online isolated CPUs
Date: Sun, 29 Nov 2026 07:46:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-239399@kernel.org> (raw)
In-Reply-To: <20261129072612.257915-1-atomlin@atomlin.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] blk-mq: missing kexec shutdown exemption in
blk_mq_hctx_can_offline_hk_cpu()
- [Medium] blk-mq: blk_mq_hctx_notify_online() activates hctx without
online hk CPU
--
commit b727ebd4323e3c57fb0bd576c67e6c3d028b7b3e
Author: Daniel Wagner <wagi@kernel.org>
blk-mq: prevent offlining hk CPUs with associated online isolated CPUs
This commit adds blk_mq_hctx_can_offline_hk_cpu() to prevent offlining
the last online housekeeping CPU mapped to an hctx while any isolated CPU
mapped to that hctx remains online.
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index d9ab295be4d92..94a5ef154e5ab 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -3718,6 +3718,76 @@ static bool blk_mq_hctx_has_requests(struct blk_mq_hw_ctx *hctx)
> return data.has_rq;
> }
>
> +/**
> + * blk_mq_hctx_can_offline_hk_cpu - Check if a housekeeping CPU may go offline
> + * @hctx: Hardware queue context being evaluated
> + * @this_cpu: CPU going offline
> + *
> + * Prevent offlining the last online housekeeping CPU mapped to @hctx while
> + * any isolated CPU mapped to @hctx remains online, avoiding stranded I/O
> + * submissions. System suspend and hibernation are exempted via
> + * cpuhp_tasks_frozen.
> + *
> + * Return: true if @this_cpu may go offline, false otherwise.
> + */
> +static bool blk_mq_hctx_can_offline_hk_cpu(struct blk_mq_hw_ctx *hctx,
> + unsigned int this_cpu)
> +{
> + const struct cpumask *hk_mask = housekeeping_cpumask(HK_TYPE_MANAGED_IRQ);
> + int cpu, fallback_isolated_cpu = -1;
> +
> + /*
> + * During system suspend or hibernation, tasks are frozen and all
> + * CPUs are being taken offline. Allow offlining to proceed so
> + * suspend is not aborted.
> + */
> + if (cpuhp_tasks_frozen)
> + return true;
[Severity: High]
Can this trigger BUG_ON(num_online_cpus() > 1) in
smp_shutdown_nonboot_cpus() during a kexec reboot?
During kexec or machine_shutdown(), smp_shutdown_nonboot_cpus() offlines
all non-boot CPUs in ascending order via cpu_down_maps_locked(), which
calls _cpu_down(cpu, 0, CPUHP_OFFLINE) with cpuhp_tasks_frozen == false:
kernel/cpu.c:smp_shutdown_nonboot_cpus() {
...
for_each_online_cpu(cpu) {
if (cpu == primary_cpu)
continue;
error = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
if (error) {
pr_err("Failed to offline CPU%d - error=%d",
cpu, error);
break;
}
}
/*
* Ensure all but the reboot CPU are offline.
*/
BUG_ON(num_online_cpus() > 1);
...
}
If a non-boot housekeeping CPU has a lower CPU ID than an online isolated
CPU mapped to the same hctx, blk_mq_hctx_can_offline_hk_cpu() returns
false, blk_mq_hctx_notify_offline() fails with -EINVAL, and
smp_shutdown_nonboot_cpus() aborts the loop and hits the BUG_ON().
[ ... ]
> @@ -3750,6 +3820,11 @@ static int blk_mq_hctx_notify_offline(unsigned int cpu, struct hlist_node *node)
> struct blk_mq_hw_ctx, cpuhp_online);
> int ret = 0;
>
> + if (housekeeping_enabled(HK_TYPE_MANAGED_IRQ)) {
> + if (!blk_mq_hctx_can_offline_hk_cpu(hctx, cpu))
> + return -EINVAL;
> + }
> +
> if (!hctx->nr_ctx || blk_mq_hctx_has_online_cpu(hctx, cpu))
> return 0;
[Severity: Medium]
Can an hctx still end up active with an online isolated CPU and no online
housekeeping CPU if the isolated CPU is offlined first, the housekeeping
CPU is offlined next, and the isolated CPU is then brought back online?
Once all isolated CPUs mapped to an hctx are offline,
blk_mq_hctx_can_offline_hk_cpu() allows the last housekeeping CPU to go
offline, setting BLK_MQ_S_INACTIVE and shutting down the hctx's managed
IRQ. When an isolated CPU mapped to that hctx is brought back online
before any housekeeping CPU, blk_mq_hctx_notify_online() clears
BLK_MQ_S_INACTIVE without checking whether a housekeeping CPU is online:
block/blk-mq.c:blk_mq_hctx_notify_online() {
...
if (blk_mq_cpu_mapped_to_hctx(cpu, hctx))
clear_bit(BLK_MQ_S_INACTIVE, &hctx->state);
return 0;
}
Because the isolated CPU is excluded from the managed IRQ affinity mask
and hctx->cpumask, the hctx becomes active for I/O from the isolated CPU
with its managed IRQ still shut down and no online housekeeping CPU to
run its block kworkers, causing I/O stalls.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129045436.255364-1-atomlin@atomlin.com?part=6
next prev parent reply other threads:[~2026-11-29 7:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 4:54 [PATCH v17 00/10] blk: honor isolcpus configuration Aaron Tomlin
2026-11-29 4:54 ` [PATCH v17 01/10] scsi: aacraid: use block layer helpers to calculate num of queues Aaron Tomlin
2026-11-29 4:54 ` [PATCH v17 02/10] lib/group_cpus: remove dead !SMP code Aaron Tomlin
2026-11-29 4:54 ` [PATCH v17 03/10] lib/group_cpus: Add group_mask_cpus_evenly() Aaron Tomlin
2026-11-29 7:33 ` sashiko-bot
2026-11-29 4:54 ` [PATCH v17 04/10] sched/isolation: Prevent out-of-bounds read in isolcpus= boot parameter parser Aaron Tomlin
2026-11-29 4:54 ` [PATCH v17 05/10] blk-mq: use hk cpus only when isolcpus=managed_irq is enabled Aaron Tomlin
2026-11-29 7:58 ` sashiko-bot
2026-11-29 7:26 ` [PATCH v17 06/10] blk-mq: prevent offlining hk CPUs with associated online isolated CPUs Aaron Tomlin
2026-11-29 7:46 ` sashiko-bot [this message]
2026-11-29 7:26 ` [PATCH v17 07/10] virtio-fs: honour isolcpus=managed_irq in queue mapping Aaron Tomlin
2026-11-29 7:26 ` [PATCH v17 08/10] genirq/affinity: Restrict managed IRQ affinity to housekeeping CPUs Aaron Tomlin
2026-11-29 7:48 ` sashiko-bot
2026-11-29 7:26 ` [PATCH v17 09/10] docs: update isolcpus=managed_irq documentation Aaron Tomlin
2026-11-29 7:26 ` [PATCH v17 10/10] genirq/affinity: Confine pre and post vectors to housekeeping CPUs Aaron Tomlin
2026-11-29 7:41 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-239399@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atomlin@atomlin.com \
--cc=eperezma@redhat.com \
--cc=linux-scsi@vger.kernel.org \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox