Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795938377; b=GcwyhauoEcQCCq3lluv+rmqJ869NDcJQGYlsHN6CNdocGv7EycyTSQguk71jQd2MG0MR 05dFBW4PYjLCRWocS9igJ8/QGeqzbZxE0A6eQ7npxZ2e2BzMr3ol9VLA/TAL47CVVNPB7 Eb3MLjl12CBQyZr1vIGejRvZwCxsjsPCgpBiIDImIFk870rotgw4dKkhdJqRV622L+udG ku5kDOdK/BFFI/be2TnYOU3olFrBF+ZwdOoutnkLtv4mzH1kOv2VB+EDtvXOWN9KkmAp8 RmmWfmlC4cleRxn9JnUs1JRguZJurq5z3oW3h13R+rn/VhhKUvP1bNRHDmeiGuAapyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795938377; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=NatqwhmmlyunW2SdaqyV2EYVnS4D8Eepz+dTK/IVBTw=; b=kRITQfWW7WuvXfNoeId2P5we9JgZwmfrdelz1/IHNKkOS7NIumSTNTxBrBCg0mHoKXR1 BASButUznoRIK69zO0XtqvUKftKod5w1Jewbw+KR+7lIW2m5/TXYkI9qqx/Ak/ZeiP6fX A//a5Msx1ILwN/OOdzXdkMIfF8AjEDBEtIO920ZzHtt04L1gA/kSXR/xrCW8CIy+SVONi 6oSm238dfBQwrAfHJJoWl/ljz7nRfALwJz3x09jicGxRx19RK+DFUE2S71dr4upQ/+oYI tJpjGiy0eao/4epLuKMfFBZZzJSnJhHsIArBOJZLp1EQAGeIkr3ERO60kHQMibG6KPg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KHJQB+ux; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA7CD606A327; Sun, 29 Nov 2026 07:46:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KHJQB+ux Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46D931F00896; Sun, 29 Nov 2026 07:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795938377; bh=NatqwhmmlyunW2SdaqyV2EYVnS4D8Eepz+dTK/IVBTw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=KHJQB+uxr87QtsKMXj6wmz529/q0V29OcvZV62FToQaUxV5xHJ6gSTP3hM+lpT559 UA6FHJ3TFMlpnxzVmjAlGd3KoOMvW6AfBuigpNf4hn1UHtxLTb4mZ68FCU0U90Rypc aNaN2njbQJxnsrFvXoSUR1vw33r+Ajg6vD/TRZhqfdKegt9IDDUbCQ/InizuzxUfmG RHMF0yrDepD63Lx6uPcyAPGu8nBqgeI5tyLjNHVVtjFb0uaZmwIozJ4tkq9Rcl6RHt UceHDL2KphjqAVegAXUfI55j/J6lcSUEhALicLVKK26q/0lZRUwAIKoMGsXLIUdI34 xiMTYu8YuFEFg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v17 06/10] blk-mq: prevent offlining hk CPUs with associated online isolated CPUs Reply-To: sashiko-reviews@lists.linux.dev To: "Aaron Tomlin" Cc: linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261129072612.257915-1-atomlin@atomlin.com> References: <20261129045436.255364-1-atomlin@atomlin.com> <20261129072612.257915-1-atomlin@atomlin.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 07:46:16 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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; > } > =20 > +/** > + * blk_mq_hctx_can_offline_hk_cpu - Check if a housekeeping CPU may go o= ffline > + * @hctx: Hardware queue context being evaluated > + * @this_cpu: CPU going offline > + * > + * Prevent offlining the last online housekeeping CPU mapped to @hctx wh= ile > + * 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 =3D housekeeping_cpumask(HK_TYPE_MANAGED_= IRQ); > + int cpu, fallback_isolated_cpu =3D -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 =3D=3D false: kernel/cpu.c:smp_shutdown_nonboot_cpus() { ... for_each_online_cpu(cpu) { if (cpu =3D=3D primary_cpu) continue; error =3D cpu_down_maps_locked(cpu, CPUHP_OFFLINE); if (error) { pr_err("Failed to offline CPU%d - error=3D%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 =3D 0; > =20 > + 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129045436.2553= 64-1-atomlin@atomlin.com?part=3D6