public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: Thomas Gleixner <tglx@kernel.org>,
	peterz@infradead.org, sudeep.holla@kernel.org,
	yangyicong@hisilicon.com, dietmar.eggemann@arm.com,
	Jonathan Cameron <jic23@kernel.org>,
	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: Fri, 24 Apr 2026 13:51:25 +0100	[thread overview]
Message-ID: <aetnTT51ucm2azGG@arm.com> (raw)
In-Reply-To: <c6fe5e31-c397-4cf1-a422-f8d1a28fe20b@huawei.com>

(updating Jonathan's email address to match MAINTAINERS)

On Fri, Apr 24, 2026 at 09:56:24AM +0800, Jinjie Ruan wrote:
> On 4/24/2026 4:11 AM, Catalin Marinas wrote:
> > On Thu, Apr 23, 2026 at 08:32:34PM +0800, Jinjie Ruan wrote:
> >> On 4/23/2026 6:08 PM, Thomas Gleixner wrote:
> >>> On Sat, Apr 18 2026 at 12:55, Catalin Marinas wrote:
> >>>> 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).
> >>>>
> >>>> Opinions? It might be an arm64+ACPI-only thing.
> >>>
> >>> I think so. The proper thing to do is to apply sane limits:
> >>>
> >>>  1) The possible CPUs enumerated by firmware N_POSSIBLE_FW
> >>>
> >>>  2) The maxcpus limit on the command line N_MAXCPUS_CL
> >>>
> >>> So the actual possible CPUs evaluates to:
> >>>
> >>>    num_possible = min(N_POSSIBLE_FW, N_MAXCPUS_CL, CONFIG_NR_CPUS);
> >>>
> >>> The evaluation of the firmware should not mark CPUs present which are
> >>> actually not. ACPI gives you that information. See:
> >>>
> >>>          5.2.12.14 GIC CPU Interface (GICC) Structure
> >>>
> >>> in the ACPI spec. That has two related bits:
> >>>
> >>> Enabled:
> >>>
> >>>    If this bit is set, the processor is ready for use. If this bit is
> >>>    clear and the Online Capable bit is set, the system supports enabling
> >>>    this processor during OS runtime. If this bit is clear and the Online
> >>>    Capable bit is also clear, this processor is un- usable, and the
> >>>    operating system support will not attempt to use it.
> >>>
> >>> Online Capable:
> >>>
> >>>    The information conveyed by this bit depends on the value of the
> >>>    Enabled bit. If the Enabled bit is set, this bit is reserved and must
> >>>    be zero. Otherwise, if this bit is set, the system supports enabling
> >>>    this processor later during OS runtime
> >>>
> >>> So the combination of those gives you the right answer:
> >>>
> >>>    Enabled	Online
> >>>    	        Capable
> >>>    0            0        Not present, not possible
> >>>    0            1        Not present, but possible to "hotplug" layter
> >>>    1            0        Present
> >>>    1            1        Invalid
> >>
> >> On x86, it seems that all CPUs with the ACPI_MADT_ENABLED bit set will
> >> be marked as present.
> >>
> >> acpi_parse_x2apic()
> >>   -> enabled = processor->lapic_flags & ACPI_MADT_ENABLED
> >>   -> topology_register_apic(enabled)
> >>      -> topo_register_apic(enabled)
> >>         -> set_cpu_present(cpu, true)
> > 
> > Yes but arm64 marks all CPUs present even if !ACPI_MADT_ENABLED as we
> > don't have the notion of hardware CPU hotplug.
> > 
> > I need to dig some more into the original vCPU hotplug support and why
> > we ended up with all CPUs marked as present even if not calling
> > register_cpu():
> > 
> > https://lore.kernel.org/linux-arm-kernel/20240529133446.28446-1-Jonathan.Cameron@huawei.com/
> > 
> > What's the MADT GICC provided by qemu with "-smp cpus=4,maxcpus=8"? If
> > it says Enabled for the first 4 and Online Capable for the rest, maybe
> > we can try something like below:
> 
> Yes, you are absolutely right,Enabled for the first 4(with GIC Flags:
> 0x1, bit0 set) and Online Capable for the rest(with GIC Flags: 0x8, bit3
> set). The ACPI MADT disassembly result is as follows:

That's great, thanks for checking.

I'd like to get some feedback from Jonathan and James as they
contributed the vCPU hotplug support. The reason was for kubernetes to
add vCPUs to an existing VM. Hopefully no-one relied on
/sys/devices/system/cpu/present to report 0-7 in the above
configuration.

Have you tried the vCPU hotplug with this patch (the original use-case)?

Anyway, feel free to post a v2 with the above proposal, cc Jonathan (on
kernel.org) and James Morse and we'll take it from there. You can add a
suggested-by me.

Thanks.

-- 
Catalin


  reply	other threads:[~2026-04-24 12:51 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
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 [this message]
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=aetnTT51ucm2azGG@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=james.morse@arm.com \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=ruanjinjie@huawei.com \
    --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