From: Jinjie Ruan <ruanjinjie@huawei.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: <tglx@kernel.org>, <peterz@infradead.org>,
<sudeep.holla@kernel.org>, <yangyicong@hisilicon.com>,
<dietmar.eggemann@arm.com>, <Jonathan.Cameron@huawei.com>,
<linux-kernel@vger.kernel.org>, James Morse <james.morse@arm.com>,
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] cpu/hotplug: Fix NULL kobject warning in cpuhp_smt_enable()
Date: Thu, 23 Apr 2026 20:46:29 +0800 [thread overview]
Message-ID: <36b4b9f5-3930-481f-a9c8-039c04c808ab@huawei.com> (raw)
In-Reply-To: <aeOd0Ndec2rQe2J8@arm.com>
On 4/18/2026 11:05 PM, Catalin Marinas wrote:
> On Sat, Apr 18, 2026 at 12:55:22PM +0100, Catalin Marinas wrote:
>> On Fri, Apr 17, 2026 at 03:55:34PM +0800, Jinjie Ruan wrote:
>>> 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.
> [...]
>> Another option would have been to avoid marking such CPUs present but I
>> think this will break other things. Yet another option is to register
>> all CPU devices even if they never come up (like maxcpus greater than
>> actual CPUs).
>
> Something like below, untested (and I don't claim I properly understand
> this code; just lots of tokens used trying to make sense of it ;))
>
> ------------------------8<-------------------------
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index a9d884fd1d00..4c0a5ed906ea 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -448,12 +448,14 @@ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 apci_id,
> return *pcpu;
> }
>
> + set_cpu_present(*pcpu, true);
> return 0;
> }
> EXPORT_SYMBOL(acpi_map_cpu);
>
> int acpi_unmap_cpu(int cpu)
> {
> + set_cpu_present(cpu, false);
This logic, where we set 'present' in acpi_map_cpu() and clear it in
acpi_unmap_cpu(), seems to align with how x86 does it.
acpi_map_cpu()
-> topology_hotplug_apic()
-> topo_set_cpuids()
-> set_cpu_present(cpu, true)
acpi_unmap_cpu()
-> topology_hotunplug_apic(cpu)
-> set_cpu_present(cpu, false)
Should we consider moving the setting/clearing of the 'present' bit into
the generic ACPI code (e.g., within the success path of acpi_map_cpu)?
This would ensure consistency across architectures and prevent new
implementations from missing these critical state updates.
> return 0;
> }
> EXPORT_SYMBOL(acpi_unmap_cpu);
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 1aa324104afb..751a74d997e1 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -510,8 +510,10 @@ int arch_register_cpu(int cpu)
> struct cpu *c = &per_cpu(cpu_devices, cpu);
>
> if (!acpi_disabled && !acpi_handle &&
> - IS_ENABLED(CONFIG_ACPI_HOTPLUG_CPU))
> + IS_ENABLED(CONFIG_ACPI_HOTPLUG_CPU)) {
> + set_cpu_present(cpu, false);
> return -EPROBE_DEFER;
> + }
>
> #ifdef CONFIG_ACPI_HOTPLUG_CPU
> /* For now block anything that looks like physical CPU Hotplug */
>
next prev parent reply other threads:[~2026-04-23 12:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260417075534.3745793-1-ruanjinjie@huawei.com>
2026-04-18 11:55 ` [PATCH] cpu/hotplug: Fix NULL kobject warning in cpuhp_smt_enable() Catalin Marinas
2026-04-18 15:05 ` Catalin Marinas
2026-04-20 1:29 ` Jinjie Ruan
2026-04-23 12:46 ` Jinjie Ruan [this message]
2026-04-23 10:08 ` Thomas Gleixner
2026-04-23 12:32 ` Jinjie Ruan
2026-04-23 20:11 ` Catalin Marinas
2026-04-24 1:56 ` Jinjie Ruan
2026-04-24 12:51 ` Catalin Marinas
2026-04-24 18:27 ` Jonathan Cameron
2026-04-25 2:05 ` Jinjie Ruan
2026-04-24 2:47 ` 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=36b4b9f5-3930-481f-a9c8-039c04c808ab@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=sudeep.holla@kernel.org \
--cc=tglx@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