From: Jan Beulich <jbeulich@suse.com>
To: Mykyta Poturai <Mykyta_Poturai@epam.com>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>,
"Bertrand Marquis" <bertrand.marquis@arm.com>,
"Michal Orzel" <michal.orzel@amd.com>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Timothy Pearson" <tpearson@raptorengineering.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Connor Davis" <connojdavis@gmail.com>,
"Oleksii Kurochko" <oleksii.kurochko@gmail.com>,
"Daniel P. Smith" <dpsmith@apertussolutions.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v5 3/5] arm/sysctl: Implement cpu hotplug ops
Date: Wed, 14 Jan 2026 10:49:47 +0100 [thread overview]
Message-ID: <00e17b41-f31e-4121-80c8-d4ea2bb02f34@suse.com> (raw)
In-Reply-To: <54a015e0e47ea311471bad7f13fbf21e14389ef3.1768293759.git.mykyta_poturai@epam.com>
On 13.01.2026 09:45, Mykyta Poturai wrote:
> Move XEN_SYSCTL_CPU_HOTPLUG_{ONLINE,OFFLINE} handlers to common code to
> allow for enabling/disabling CPU cores in runtime on Arm64.
>
> SMT-disable enforcement check is moved into a separate
> architecture-specific function.
>
> For now this operations only support Arm64. For proper Arm32 support,
> there needs to be a mechanism to free per-cpu page tables, allocated in
> init_domheap_mappings. Also, hotplug is not supported if ITS, FFA, or
> TEE is enabled, as they use non-static IRQ actions.
For all of these "not supported" cases, what if a user nevertheless tries?
Wouldn't the request better be outright denied, rather leaving the system in
a questionable state? Hmm, I see you ...
> --- a/xen/arch/arm/Kconfig
> +++ b/xen/arch/arm/Kconfig
> @@ -7,6 +7,7 @@ config ARM_64
> def_bool y
> depends on !ARM_32
> select 64BIT
> + select CPU_HOTPLUG if !TEE && !FFA && !HAS_ITS
... make the select conditional. But do TEE, FFA, and HAS_ITS each mean the
feature is actually in use when the hypervisor runs?
> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -176,6 +176,9 @@ config LIBFDT
> config MEM_ACCESS_ALWAYS_ON
> bool
>
> +config CPU_HOTPLUG
> + bool
Nit: Indentation by a single tab please. See adjacent entries.
> @@ -104,6 +105,39 @@ void smp_call_function_interrupt(void)
> irq_exit();
> }
>
> +#ifdef CONFIG_CPU_HOTPLUG
> +long cf_check cpu_up_helper(void *data)
> +{
> + unsigned int cpu = (unsigned long)data;
Note this for the first comment below on cpu_down_helper().
> + int ret = cpu_up(cpu);
> +
> + /* Have one more go on EBUSY. */
> + if ( ret == -EBUSY )
> + ret = cpu_up(cpu);
> +
> + if ( !ret && arch_smt_cpu_disable(cpu) )
As you validly note in a comment in do_sysctl(), SMT is an arch-specific concept
and perhaps even an arch-specific term. Hence using it in the name of an arch
hook feels inappropriate. Plus - the hook could be used for other purposes. What
the arch needs to indicate is whether the CPU that was brought up may actually
stay online. That more generic purpose is what imo the name wants to cover.
> + {
> + ret = cpu_down_helper(data);
> + if ( ret )
> + printk("Could not re-offline CPU%u (%d)\n", cpu, ret);
> + else
> + ret = -EPERM;
> + }
> +
> + return ret;
> +}
> +
> +long cf_check cpu_down_helper(void *data)
> +{
> + int cpu = (unsigned long)data;
Why is this left as plain int? Yes, it was like this in the original code,
but wrongly so.
> + int ret = cpu_down(cpu);
> + /* Have one more go on EBUSY. */
Also please add the missing blank line after the declarations.
> --- a/xen/common/sysctl.c
> +++ b/xen/common/sysctl.c
> @@ -483,6 +483,51 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
> copyback = 1;
> break;
>
> +#ifdef CONFIG_CPU_HOTPLUG
> + case XEN_SYSCTL_cpu_hotplug:
Please see the pretty recent
https://lists.xen.org/archives/html/xen-devel/2026-01/msg00329.html
(scroll down to the xen/arch/x86/platform_hypercall.c change).
> + {
> + unsigned int cpu = op->u.cpu_hotplug.cpu;
> + unsigned int hp_op = op->u.cpu_hotplug.op;
> + bool plug;
> + long (*fn)(void *data);
> + void *hcpu;
> +
> + switch ( hp_op )
> + {
> + case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
> + plug = true;
> + fn = cpu_up_helper;
> + hcpu = _p(cpu);
> + break;
> +
> + case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
> + plug = false;
> + fn = cpu_down_helper;
> + hcpu = _p(cpu);
> + break;
> +
> + case XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE:
> + case XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE:
> + /* Use arch specific handlers as SMT is very arch-dependent */
> + ret = arch_do_sysctl(op, u_sysctl);
> + copyback = 0;
> + goto out;
I wonder if it wouldn't be neater for this and actually also ...
> + default:
> + ret = -EOPNOTSUPP;
> + break;
... this to fall through to ...
> + }
> +
> + if ( !ret )
> + ret = plug ? xsm_resource_plug_core(XSM_HOOK)
> + : xsm_resource_unplug_core(XSM_HOOK);
> +
> + if ( !ret )
> + ret = continue_hypercall_on_cpu(0, fn, hcpu);
> + break;
> + }
> +#endif
> +
> default:
> ret = arch_do_sysctl(op, u_sysctl);
... here. (Minimally the earlier default case wants uniformly forwarding to
the arch handler, or else arch-specific additions would always require
adjustment here.)
Jan
next prev parent reply other threads:[~2026-01-14 9:50 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 8:45 [PATCH v5 0/5] Implement CPU hotplug on Arm Mykyta Poturai
2026-01-13 8:45 ` [PATCH v5 2/5] arm/irq: Migrate IRQs during CPU up/down operations Mykyta Poturai
2026-02-04 14:20 ` Bertrand Marquis
2026-02-05 13:23 ` Mykyta Poturai
2026-02-05 14:07 ` Bertrand Marquis
2026-03-03 23:55 ` Stefano Stabellini
2026-01-13 8:45 ` [PATCH v5 1/5] arm/irq: Keep track of irq affinities Mykyta Poturai
2026-02-03 16:51 ` Bertrand Marquis
2026-01-13 8:45 ` [PATCH v5 4/5] tools: Allow building xen-hptool without CONFIG_MIGRATE Mykyta Poturai
2026-01-13 9:32 ` Jan Beulich
2026-01-13 8:45 ` [PATCH v5 3/5] arm/sysctl: Implement cpu hotplug ops Mykyta Poturai
2026-01-14 9:49 ` Jan Beulich [this message]
2026-02-03 10:30 ` Mykyta Poturai
2026-02-03 11:20 ` Jan Beulich
2026-01-13 8:45 ` [PATCH v5 5/5] docs: Document CPU hotplug Mykyta Poturai
2026-02-03 16:35 ` [PATCH v5 0/5] Implement CPU hotplug on Arm Bertrand Marquis
2026-02-04 12:58 ` Mykyta Poturai
2026-02-04 13:02 ` Bertrand Marquis
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=00e17b41-f31e-4121-80c8-d4ea2bb02f34@suse.com \
--to=jbeulich@suse.com \
--cc=Mykyta_Poturai@epam.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=alistair.francis@wdc.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=bertrand.marquis@arm.com \
--cc=connojdavis@gmail.com \
--cc=dpsmith@apertussolutions.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=oleksii.kurochko@gmail.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tpearson@raptorengineering.com \
--cc=xen-devel@lists.xenproject.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 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.