From: Bradley Morgan <brads@mainlining.org>
To: longman@redhat.com
Cc: frederic@kernel.org, linux-kernel@vger.kernel.org,
peterz@infradead.org, tglx@kernel.org
Subject: Re: [PATCH] cpu: Fix online housekeeping CPU check in _cpu_down()
Date: Sun, 08 Nov 2026 19:18:37 +0000 [thread overview]
Message-ID: <9B3FDEBA-C79A-4584-9966-641C7300B348@mainlining.org> (raw)
In-Reply-To: <20261108180849.1268263-1-longman@redhat.com>
On 8 November 2026 18:08:49 GMT, Waiman Long <longman@redhat.com> wrote:
>There is currently a check in _cpu_down() to make sure that there is
>at least one online housekeeping (HK) CPU left after the shutdown of
>the given @cpu parameter. However the cpu_online_mask used for the
>check may include the current @cpu to be shut down. So the fact that
>there is at least one online housekeeping CPU at the moment does not
>guarantee that there will be any online housekeeping CPU left for the
>sched domain after the shutdown.
>
>Fix that by making sure that there are at least 2 online housekeeping
>CPUs available if @cpu is currently a housekeeping CPU.
>
>Fixes: de715325cc47 ("cpu: Revert "cpu/hotplug: Prevent self deadlock on CPU hot-unplug"")
>Signed-off-by: Waiman Long <longman@redhat.com>
>---
> kernel/cpu.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
>diff --git a/kernel/cpu.c b/kernel/cpu.c
>index b3c8553d7bd6..ed641ee6b37c 100644
>--- a/kernel/cpu.c
>+++ b/kernel/cpu.c
>@@ -1415,11 +1415,14 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
> cpus_write_lock();
>
> /*
>- * Keep at least one housekeeping cpu onlined to avoid generating
>- * an empty sched_domain span.
>+ * Keep at least one housekeeping cpu online to avoid generating an
>+ * empty sched_domain span. As cpu_online_mask includes the @cpu to be
>+ * shut down, there should be at least 2 online HK CPUs at the moment
>+ * if @cpu is currently a HK CPU.
> */
>- if (cpumask_any_and(cpu_online_mask,
>- housekeeping_cpumask(HK_TYPE_DOMAIN)) >= nr_cpu_ids) {
>+ if (cpumask_test_cpu(cpu, housekeeping_cpumask(HK_TYPE_DOMAIN)) &&
>+ (cpumask_weight_and(cpu_online_mask,
>+ housekeeping_cpumask(HK_TYPE_DOMAIN)) < 2)) {
Well, this patch is good, reasonable enough to me, I may be odd sometimes,
but this patch is sane enough.
Reviewed-by: Bradley Morgan <brads@mainlining.org>
> ret = -EBUSY;
> goto out;
> }
>
--- Thanks!
prev parent reply other threads:[~2026-11-08 19:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 18:08 Waiman Long
2026-11-08 18:19 ` Waiman Long
2026-11-08 19:18 ` Bradley Morgan [this message]
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=9B3FDEBA-C79A-4584-9966-641C7300B348@mainlining.org \
--to=brads@mainlining.org \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
/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
all inboxes | Powered by JetHome®