From: Jinjie Ruan <ruanjinjie@huawei.com>
To: Will Deacon <will@kernel.org>
Cc: <catalin.marinas@arm.com>, <corbet@lwn.net>,
<skhan@linuxfoundation.org>, <punit.agrawal@oss.qualcomm.com>,
<jic23@kernel.org>, <osama.abdelkader@gmail.com>,
<chenl311@chinatelecom.cn>, <fengchengwen@huawei.com>,
<suzuki.poulose@arm.com>, <maz@kernel.org>,
<lpieralisi@kernel.org>, <timothy.hayes@arm.com>,
<sascha.bischoff@arm.com>, <arnd@arndb.de>,
<mrigendra.chaubey@gmail.com>, <pierre.gondois@arm.com>,
<dietmar.eggemann@arm.com>, <yangyicong@hisilicon.com>,
<sudeep.holla@kernel.org>, <linux-arm-kernel@lists.infradead.org>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] cpu/hotplug: Fix NULL kobject warning in cpuhp_smt_enable()
Date: Tue, 2 Jun 2026 20:14:26 +0800 [thread overview]
Message-ID: <37bc3f0c-adeb-41b8-9b26-fabe43f47e6a@huawei.com> (raw)
In-Reply-To: <ah65zXlOH6a9geD9@willie-the-truck>
On 6/2/2026 7:09 PM, Will Deacon wrote:
> On Wed, May 20, 2026 at 10:20:23AM +0800, Jinjie Ruan wrote:
>> On arm64, when booting with `maxcpus` greater than the number of present
>> CPUs (e.g., QEMU -smp cpus=4,maxcpus=8), some CPUs are marked as 'present'
>> but have not yet been registered via register_cpu(). Consequently,
>> the per-cpu device objects for these CPUs are not yet initialized.
>>
>> In cpuhp_smt_enable(), the code iterates over all present CPUs. Calling
>> _cpu_up() for these unregistered CPUs eventually leads to
>> sysfs_create_group() being called with a NULL kobject (or a kobject
>> without a directory), triggering the following warning in
>> fs/sysfs/group.c:
>>
>> if (WARN_ON(!kobj || (!update && !kobj->sd)))
>> return -EINVAL;
>>
>> When booting with ACPI, arm64 smp_prepare_cpus() currently sets all
>> enumerated CPUs as "present" regardless of their status in the MADT. This
>> causes issues with SMT hotplug control. For instance, with QEMU's
>> "-smp 4,maxcpus=8" configuration, the MADT GICC entries are populated as
>> follows: the first four CPUs are marked Enabled while the remaining four
>> are marked Online Capable to support potential hot-plugging.
>>
>> Fix this by:
>>
>> 1. When booting with ACPI, checking the ACPI_MADT_ENABLED flag in the GICC
>> entry before calling set_cpu_present() during SMP initialization.
>>
>> 2. Properly managing the present mask in acpi_map_cpu() and
>> acpi_unmap_cpu() to support actual CPU hotplug events, This aligns with
>> other architectures like x86 and LoongArch.
>>
>> 3. Update the arm64 CPU hotplug documentation to no longer state that all
>> online-capable vCPUs are marked as present by the kernel at boot time.
>>
>> This ensures that only physically available or explicitly enabled CPUs
>> are in the present mask, keeping the SMT control logic consistent with
>> the actual hardware state.
>
> Please can you check the Sashiko review comment?
>
> https://sashiko.dev/#/patchset/20260520022023.126670-1-ruanjinjie@huawei.com
On arm64, arch_unregister_cpu() enforces a safety block against physical
CPU hot-removal by aborting early if cpu_present() is true but the
device is no longer physically present, thereby skipping
unregister_cpu() and leaking the sysfs device node.
If acpi_unmap_cpu() blindly clears the present bit while the sysfs
device remains registered, a subsequent hot-add attempt will see the
valid leaked device pointer, skip acpi_processor_hotadd_init() (and thus
skip acpi_map_cpu()), leaving the hot-added CPU permanently absent and
deadlocked.
Hi, Will,
what do you think about fix it like this?
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -455,7 +455,6 @@ EXPORT_SYMBOL(acpi_map_cpu);
int acpi_unmap_cpu(int cpu)
{
- set_cpu_present(cpu, false);
return 0;
}
EXPORT_SYMBOL(acpi_unmap_cpu);
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 5932e5b30b71..507c6d761434 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -554,6 +554,7 @@ void arch_unregister_cpu(int cpu)
}
unregister_cpu(c);
+ set_cpu_present(cpu, false);
}
#endif /* CONFIG_ACPI_HOTPLUG_CPU */
>
> Cheers,
>
> Will
>
next prev parent reply other threads:[~2026-06-02 12:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 2:20 Jinjie Ruan
2026-06-02 11:09 ` Will Deacon
2026-06-02 12:14 ` Jinjie Ruan [this message]
2026-06-02 12:47 ` Will Deacon
2026-06-03 6:38 ` Jinjie Ruan
2026-06-09 17:58 ` Catalin Marinas
2026-06-10 2:44 ` Jinjie Ruan
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=37bc3f0c-adeb-41b8-9b26-fabe43f47e6a@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=chenl311@chinatelecom.cn \
--cc=corbet@lwn.net \
--cc=dietmar.eggemann@arm.com \
--cc=fengchengwen@huawei.com \
--cc=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=maz@kernel.org \
--cc=mrigendra.chaubey@gmail.com \
--cc=osama.abdelkader@gmail.com \
--cc=pierre.gondois@arm.com \
--cc=punit.agrawal@oss.qualcomm.com \
--cc=sascha.bischoff@arm.com \
--cc=skhan@linuxfoundation.org \
--cc=sudeep.holla@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=timothy.hayes@arm.com \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.com \
/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®