All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: salil.mehta@opnsrc.net
Cc: qemu-devel@nongnu.org,  qemu-arm@nongnu.org,  mst@redhat.com,
	salil.mehta@huawei.com,  maz@kernel.org,
	 jean-philippe@linaro.org, jonathan.cameron@huawei.com,
	 lpieralisi@kernel.org, peter.maydell@linaro.org,
	 richard.henderson@linaro.org, imammedo@redhat.com,
	 andrew.jones@linux.dev,  david@redhat.com, philmd@linaro.org,
	 eric.auger@redhat.com,  will@kernel.org, ardb@kernel.org,
	 oliver.upton@linux.dev,  pbonzini@redhat.com, gshan@redhat.com,
	 rafael@kernel.org,  borntraeger@linux.ibm.com,
	alex.bennee@linaro.org,  gustavo.romero@linaro.org,
	 npiggin@gmail.com, harshpb@linux.ibm.com,
	 linux@armlinux.org.uk, darren@os.amperecomputing.com,
	 ilkka@os.amperecomputing.com, vishnu@os.amperecomputing.com,
	 gankulkarni@os.amperecomputing.com, karl.heubaum@oracle.com,
	 miguel.luis@oracle.com,  zhukeqian1@huawei.com,
	wangxiongfeng2@huawei.com,  wangyanan55@huawei.com,
	wangzhou1@hisilicon.com,  linuxarm@huawei.com,
	 jiakernel2@gmail.com, maobibo@loongson.cn,
	 lixianglai@loongson.cn,  shahuang@redhat.com,
	zhao1.liu@intel.com
Subject: Re: [PATCH RFC V6 02/24] hw/core, qemu-options.hx: Introduce 'disabledcpus' SMP parameter
Date: Thu, 09 Oct 2025 13:51:57 +0200	[thread overview]
Message-ID: <87ikgoqoma.fsf@pond.sub.org> (raw)
In-Reply-To: <20251001010127.3092631-3-salil.mehta@opnsrc.net> (salil mehta's message of "Wed, 1 Oct 2025 01:01:05 +0000")

salil.mehta@opnsrc.net writes:

> From: Salil Mehta <salil.mehta@huawei.com>
>
> Add support for a new SMP configuration parameter, 'disabledcpus', which
> specifies the number of additional CPUs that are present in the virtual
> machine but administratively disabled at boot. These CPUs are visible in
> firmware (e.g. ACPI tables) yet unavailable to the guest until explicitly
> enabled via QMP/HMP, or via the 'device_set' API (introduced in later
> patches).
>
> This feature is intended for architectures that lack native CPU hotplug
> support but can change the administrative power state of present CPUs.
> It allows simulating CPU hot-add–like scenarios while all CPUs remain
> physically present in the topology at boot time.
>
> Note: ARM is the first architecture to support this concept.
>
> Changes include:
>  - Extend CpuTopology with a 'disabledcpus' field.
>  - Update machine_parse_smp_config() to account for disabled CPUs when
>    computing 'cpus' and 'maxcpus'.
>  - Update SMPConfiguration in QAPI to accept 'disabledcpus'.
>  - Extend -smp option documentation to describe 'disabledcpus' usage and
>    behavior.
>
> Signed-off-by: Salil Mehta <salil.mehta@huawei.com>

[...]

> diff --git a/qapi/machine.json b/qapi/machine.json
> index 038eab281c..e45740da33 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -1634,6 +1634,8 @@
>  #
>  # @cpus: number of virtual CPUs in the virtual machine
>  #
> +# @disabledcpus: number of additional present but disabled(or offline) CPUs
> +#
>  # @maxcpus: maximum number of hotpluggable virtual CPUs in the virtual
>  #     machine
>  #
> @@ -1657,6 +1659,7 @@
>  ##
>  { 'struct': 'SMPConfiguration', 'data': {
>       '*cpus': 'int',
> +     '*disabledcpus': 'int',
>       '*drawers': 'int',
>       '*books': 'int',
>       '*sockets': 'int',

We prefer words-with-dashes to wordsruntogether in QAPI/QMP, for
readability: disabled-cpus.

Missing here even before the patch: how these values are related.  That
information appears to be buried in machine_parse_smp_config(), which is
160 lines long and with too many conditionals for me to make sense of
now.

> diff --git a/qemu-options.hx b/qemu-options.hx
> index ab23f14d21..83ccde341b 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -326,12 +326,15 @@ SRST
>  ERST
>  
>  DEF("smp", HAS_ARG, QEMU_OPTION_smp,
> -    "-smp [[cpus=]n][,maxcpus=maxcpus][,drawers=drawers][,books=books][,sockets=sockets]\n"
> -    "               [,dies=dies][,clusters=clusters][,modules=modules][,cores=cores]\n"
> -    "               [,threads=threads]\n"
> -    "                set the number of initial CPUs to 'n' [default=1]\n"
> -    "                maxcpus= maximum number of total CPUs, including\n"
> -    "                offline CPUs for hotplug, etc\n"
> +    "-smp [[cpus=]n][,disabledcpus=disabledcpus][,maxcpus=maxcpus][,drawers=drawers][,books=books]\n"
> +    "               [,sockets=sockets][,dies=dies][,clusters=clusters][,modules=modules]\n"
> +    "               [,cores=cores][,threads=threads]\n"
> +    "                set the initial number of CPUs present and\n"
> +    "                  administratively enabled at boot time to 'n' [default=1]\n"
> +    "                disabledcpus= number of present but administratively\n"
> +    "                  disabled CPUs (unavailable to the guest at boot)\n"
> +    "                maxcpus= maximum total CPUs (present + hotpluggable)\n"
> +    "                  on machines without CPU hotplug, defaults to n + disabledcpus\n"
>      "                drawers= number of drawers on the machine board\n"
>      "                books= number of books in one drawer\n"
>      "                sockets= number of sockets in one book\n"
> @@ -351,22 +354,49 @@ DEF("smp", HAS_ARG, QEMU_OPTION_smp,
>      "      For a particular machine type board, an expected CPU topology hierarchy\n"
>      "      can be defined through the supported sub-option. Unsupported parameters\n"
>      "      can also be provided in addition to the sub-option, but their values\n"
> -    "      must be set as 1 in the purpose of correct parsing.\n",
> +    "      must be set as 1 in the purpose of correct parsing.\n"
> +    "                                                          \n"
> +    "      Administratively disabled CPUs: Some machine types do not support vCPU\n"
> +    "      hotplug but their CPUs can be marked disabled (powered off) and kept\n"
> +    "      unavailable to the guest. Later, such CPUs can be enabled via QMP/HMP\n"
> +    "      (e.g., 'device_set ... admin-state=enable'). This is similar to hotplug,\n"
> +    "      except all disabled CPUs are already present at boot. Useful on\n"
> +    "      architectures that lack architectural CPU hotplug.\n",
>      QEMU_ARCH_ALL)
>  SRST
> -``-smp [[cpus=]n][,maxcpus=maxcpus][,drawers=drawers][,books=books][,sockets=sockets][,dies=dies][,clusters=clusters][,modules=modules][,cores=cores][,threads=threads]``
> -    Simulate a SMP system with '\ ``n``\ ' CPUs initially present on
> -    the machine type board. On boards supporting CPU hotplug, the optional
> -    '\ ``maxcpus``\ ' parameter can be set to enable further CPUs to be
> -    added at runtime. When both parameters are omitted, the maximum number
> +``-smp [[cpus=]n][,disabledcpus=disabledcpus][,maxcpus=maxcpus][,drawers=drawers][,books=books][,sockets=sockets][,dies=dies][,clusters=clusters][,modules=modules][,cores=cores][,threads=threads]``
> +    Simulate a SMP system with '\ ``n``\ ' CPUs initially present & enabled on
> +    the machine type board. Furthermore, on architectures that support changing
> +    the administrative power state of CPUs, optional '\ ``disabledcpus``\ '
> +    parameter specifies *additional* CPUs that are present in firmware (e.g.,
> +    ACPI) but are administratively disabled (i.e., not usable by the guest at
> +    boot time).
> +
> +    This is different from CPU hotplug where additional CPUs are not even
> +    present in the system description. Administratively disabled CPUs appear in
> +    ACPI tables i.e. are provisioned, but cannot be used until explicitly
> +    enabled via QMP/HMP or the deviceset API.
> +
> +    On boards supporting CPU hotplug, the optional '\ ``maxcpus``\ ' parameter
> +    can be set to enable further CPUs to be added at runtime. When both
> +    '\ ``n``\ ' & '\ ``maxcpus``\ ' parameters are omitted, the maximum number
>      of CPUs will be calculated from the provided topology members and the
> -    initial CPU count will match the maximum number. When only one of them
> -    is given then the omitted one will be set to its counterpart's value.
> -    Both parameters may be specified, but the maximum number of CPUs must
> -    be equal to or greater than the initial CPU count. Product of the
> -    CPU topology hierarchy must be equal to the maximum number of CPUs.
> -    Both parameters are subject to an upper limit that is determined by
> -    the specific machine type chosen.
> +    initial CPU count will match the maximum number. When only one of them is
> +    given then the omitted one will be set to its counterpart's value. Both
> +    parameters may be specified, but the maximum number of CPUs must be equal
> +    to or greater than the initial CPU count. Product of the CPU topology
> +    hierarchy must be equal to the maximum number of CPUs. Both parameters are
> +    subject to an upper limit that is determined by the specific machine type
> +    chosen. Boards that support administratively disabled CPUs but do *not*
> +    support CPU hotplug derive the maximum number of CPUs implicitly:
> +    '\ ``maxcpus``\ ' is treated as '\ ``n + disabledcpus``\ ' (the total CPUs
> +    present in firmware). If '\ ``maxcpus``\ ' is provided, it must equal
> +    '\ ``n + disabledcpus``\ '. The topology product must equal this derived
> +    maximum as well.
> +
> +    Note: Administratively disabled CPUs will appear to the guest as
> +    unavailable, and any attempt to bring them online must go through QMP/HMP
> +    commands like 'device_set'.
>  
>      To control reporting of CPU topology information, values of the topology
>      parameters can be specified. Machines may only support a subset of the
> @@ -425,6 +455,24 @@ SRST
>  
>          -smp 2
>  
> +    Examples using 'disabledcpus':
> +
> +    For a board without CPU hotplug, enable 4 CPUs at boot and provision
> +    2 additional administratively disabled CPUs (maximum is derived
> +    implicitly as 6 = 4 + 2):
> +
> +    ::
> +
> +        -smp cpus=4,disabledcpus=2
> +
> +    For a board that supports CPU hotplug and 'disabledcpus', enable 4 CPUs
> +    at boot, provision 2 administratively disabled CPUs, and allow hotplug of
> +    2 more CPUs (for a maximum of 8):
> +
> +    ::
> +
> +        -smp cpus=4,disabledcpus=2,maxcpus=8
> +

So, maxcpus = cpus + disabledcpus?

Is drawers * books * sockets * dies * clusters * modules * cores *
threads equal or greater than maxcpus?

>      Note: The cluster topology will only be generated in ACPI and exposed
>      to guest if it's explicitly specified in -smp.
>  ERST
> diff --git a/system/vl.c b/system/vl.c
> index 3b7057e6c6..2f0fd21a1f 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -736,6 +736,9 @@ static QemuOptsList qemu_smp_opts = {
>          {
>              .name = "cpus",
>              .type = QEMU_OPT_NUMBER,
> +        }, {
> +            .name = "disabledcpus",
> +            .type = QEMU_OPT_NUMBER,
>          }, {
>              .name = "drawers",
>              .type = QEMU_OPT_NUMBER,



  parent reply	other threads:[~2025-10-09 11:53 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01  1:01 [PATCH RFC V6 00/24] Support of Virtual CPU Hotplug-like Feature for ARMv8+ Arch salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 01/24] hw/core: Introduce administrative power-state property and its accessors salil.mehta
2025-10-09 10:48   ` Miguel Luis
2025-10-01  1:01 ` [PATCH RFC V6 02/24] hw/core, qemu-options.hx: Introduce 'disabledcpus' SMP parameter salil.mehta
2025-10-09 11:28   ` Miguel Luis
2025-10-09 13:17     ` Igor Mammedov
2025-10-09 11:51   ` Markus Armbruster [this message]
2025-10-28  5:48   ` Gavin Shan
2025-10-01  1:01 ` [PATCH RFC V6 03/24] hw/arm/virt: Clamp 'maxcpus' as-per machine's vCPU deferred online-capability salil.mehta
2025-10-09 12:32   ` Miguel Luis
2025-10-09 13:11     ` Igor Mammedov
2025-10-01  1:01 ` [PATCH RFC V6 04/24] arm/virt, target/arm: Add new ARMCPU {socket, cluster, core, thread}-id property salil.mehta
2025-10-28  6:24   ` [PATCH RFC V6 04/24] arm/virt,target/arm: Add new ARMCPU {socket,cluster,core,thread}-id property Gavin Shan
2025-10-01  1:01 ` [PATCH RFC V6 05/24] arm/virt, kvm: Pre-create KVM vCPUs for 'disabled' QOM vCPUs at machine init salil.mehta
2025-10-22 10:36   ` [PATCH RFC V6 05/24] arm/virt,kvm: " Gavin Shan
2025-10-22 18:18     ` Salil Mehta
2025-10-22 18:50       ` Salil Mehta
2025-10-23  0:14         ` Gavin Shan
2025-10-23  0:35           ` Salil Mehta
2025-10-23  1:29             ` Salil Mehta
2025-10-23  4:14               ` Gavin Shan
2025-10-23 11:27                 ` Salil Mehta
2025-10-23  1:58             ` Gavin Shan
2025-10-23 11:17               ` Salil Mehta
2025-10-01  1:01 ` [PATCH RFC V6 06/24] arm/virt, gicv3: Pre-size GIC with possible " salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 07/24] arm/gicv3: Refactor CPU interface init for shared TCG/KVM use salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 08/24] arm/virt, gicv3: Guard CPU interface access for admin disabled vCPUs salil.mehta
2025-10-24  4:07   ` Gavin Shan
2025-10-28 11:59   ` Gavin Shan
2025-10-01  1:01 ` [PATCH RFC V6 09/24] hw/intc/arm_gicv3_common: Migrate & check 'GICv3CPUState' accessibility mismatch salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 10/24] arm/virt: Init PMU at host for all present vCPUs salil.mehta
2025-10-03 15:02   ` Igor Mammedov
2025-10-01  1:01 ` [PATCH RFC V6 11/24] hw/arm/acpi: MADT change to size the guest with possible vCPUs salil.mehta
2025-10-03 15:09   ` Igor Mammedov
     [not found]     ` <0175e40f70424dd9a29389b8a4f16c42@huawei.com>
2025-10-07 12:20       ` Igor Mammedov
2025-10-10  3:15         ` Salil Mehta
2025-10-01  1:01 ` [PATCH RFC V6 12/24] hw/core: Introduce generic device power-state handler interface salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 13/24] qdev: make admin power state changes trigger platform transitions via ACPI salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 14/24] arm/acpi: Introduce dedicated CPU OSPM interface for ARM-like platforms salil.mehta
2025-10-03 14:58   ` Igor Mammedov
     [not found]     ` <7da6a9c470684754810414f0abd23a62@huawei.com>
2025-10-07 12:06       ` Igor Mammedov
2025-10-10  3:00         ` Salil Mehta
2025-11-12 16:55           ` Igor Mammedov
2025-10-24  4:47   ` Gavin Shan
2025-10-01  1:01 ` [PATCH RFC V6 15/24] acpi/ged: Notify OSPM of CPU administrative state changes via GED salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 16/24] arm/virt/acpi: Update ACPI DSDT Tbl to include 'Online-Capable' CPUs AML salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 17/24] hw/arm/virt, acpi/ged: Add PowerStateHandler hooks for runtime CPU state changes salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 18/24] target/arm/kvm, tcg: Handle SMCCC hypercall exits in VMM during PSCI_CPU_{ON, OFF} salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 19/24] target/arm/cpu: Add the Accessor hook to fetch ARM CPU arch-id salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 20/24] target/arm/kvm: Write vCPU's state back to KVM on cold-reset salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 21/24] hw/intc/arm-gicv3-kvm: Pause all vCPUs & cache ICC_CTLR_EL1 for userspace PSCI CPU_ON salil.mehta
2025-10-01  1:01 ` [PATCH RFC V6 22/24] monitor, qdev: Introduce 'device_set' to change admin state of existing devices salil.mehta
2025-10-09  8:55   ` [PATCH RFC V6 22/24] monitor,qdev: " Markus Armbruster
2025-10-09 12:51     ` Igor Mammedov
2025-10-09 14:03       ` Daniel P. Berrangé
2025-10-09 14:55       ` Markus Armbruster
2025-10-09 15:19         ` Peter Maydell
2025-10-10  4:59           ` Markus Armbruster
2025-10-17 14:50         ` Igor Mammedov
2025-10-20 11:22           ` Markus Armbruster
2025-10-29 10:08             ` Igor Mammedov
2025-10-29 11:38               ` Markus Armbruster
2025-11-03  8:27                 ` Igor Mammedov
2025-11-07 13:10                   ` Markus Armbruster
2025-10-01  1:01 ` [PATCH RFC V6 23/24] monitor, qapi: add 'info cpus-powerstate' and QMP query (Admin + Oper states) salil.mehta
2025-10-09 11:53   ` [PATCH RFC V6 23/24] monitor,qapi: " Markus Armbruster
2025-10-01  1:01 ` [PATCH RFC V6 24/24] tcg: Defer TB flush for 'lazy realized' vCPUs on first region alloc salil.mehta
2025-10-01 21:34   ` Richard Henderson
2025-10-02 12:27     ` Salil Mehta via
2025-10-02 12:27       ` Salil Mehta via
2025-10-02 15:41       ` Richard Henderson
2025-10-07 10:14         ` Salil Mehta via
2025-10-07 10:14           ` Salil Mehta via
2025-10-06 14:00 ` [PATCH RFC V6 00/24] Support of Virtual CPU Hotplug-like Feature for ARMv8+ Arch Igor Mammedov
2025-10-13  0:34 ` Gavin Shan
2025-10-22 10:07 ` Gavin Shan
2025-10-24  6:55   ` Gavin Shan

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=87ikgoqoma.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=andrew.jones@linux.dev \
    --cc=ardb@kernel.org \
    --cc=borntraeger@linux.ibm.com \
    --cc=darren@os.amperecomputing.com \
    --cc=david@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=gankulkarni@os.amperecomputing.com \
    --cc=gshan@redhat.com \
    --cc=gustavo.romero@linaro.org \
    --cc=harshpb@linux.ibm.com \
    --cc=ilkka@os.amperecomputing.com \
    --cc=imammedo@redhat.com \
    --cc=jean-philippe@linaro.org \
    --cc=jiakernel2@gmail.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=karl.heubaum@oracle.com \
    --cc=linux@armlinux.org.uk \
    --cc=linuxarm@huawei.com \
    --cc=lixianglai@loongson.cn \
    --cc=lpieralisi@kernel.org \
    --cc=maobibo@loongson.cn \
    --cc=maz@kernel.org \
    --cc=miguel.luis@oracle.com \
    --cc=mst@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rafael@kernel.org \
    --cc=richard.henderson@linaro.org \
    --cc=salil.mehta@huawei.com \
    --cc=salil.mehta@opnsrc.net \
    --cc=shahuang@redhat.com \
    --cc=vishnu@os.amperecomputing.com \
    --cc=wangxiongfeng2@huawei.com \
    --cc=wangyanan55@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=will@kernel.org \
    --cc=zhao1.liu@intel.com \
    --cc=zhukeqian1@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.