Implement CPU hotplug on Arm
cover Implement CPU hotplug on Arm
This series implements support for CPU hotplug/unplug on Arm. To achieve this, several things need to be done:
1. XEN_SYSCTL_CPU_HOTPLUG_* calls implemented.
2. timer and GIC maintenance interrupts switched to static irqactions to remove the need for freeing them during release_irq.
3. Enabled the build of xen-hptool on Arm.
Tested on QEMU.
Mykyta Poturai (4):
arm/time: Use static irqaction
arm/gic: Use static irqaction
arm/sysctl: Implement cpu hotplug ops
tools: Allow building xen-hptool without CONFIG_MIGRATE
config/arm64.mk | 1 + config/x86_32.mk | 1 + config/x86_64.mk | 1 + tools/libs/guest/Makefile.common | 4 +- tools/misc/Makefile | 2 +- xen/arch/arm/gic.c | 10 ++++- xen/arch/arm/sysctl.c | 67 ++++++++++++++++++++++++++++++++ xen/arch/arm/time.c | 20 ++++++++-- 8 files changed, 98 insertions(+), 8 deletions(-)
Signature · 1 line
2.34.1
PATCH 4/4 tools: Allow building xen-hptool without CONFIG_MIGRATE
With CPU hotplug sysctls implemented on Arm it becomes useful to have a tool for calling them. Introduce new CONFIG_HOTPLUG to allow building hptool separately from other migration tools and enable it for Arm.
--- config/arm64.mk | 1 + config/x86_32.mk | 1 + config/x86_64.mk | 1 + tools/libs/guest/Makefile.common | 4 +++- tools/misc/Makefile | 2 +- 5 files changed, 7 insertions(+), 2 deletions(-)
config/arm64.mk +1 -0
@@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_64 := y +CONFIG_HOTPLUG := y CONFIG_XEN_INSTALL_SUFFIX :=
config/x86_32.mk +1 -0
@@ -3,6 +3,7 @@ CONFIG_X86_32 := y CONFIG_MIGRATE := y CONFIG_XCUTILS := y +CONFIG_HOTPLUG := y CFLAGS += -m32 -march=i686
config/x86_64.mk +1 -0
@@ -3,6 +3,7 @@ CONFIG_X86_64 := y CONFIG_MIGRATE := y CONFIG_XCUTILS := y +CONFIG_HOTPLUG := y CONFIG_XEN_INSTALL_SUFFIX := .gz
tools/libs/guest/Makefile.common +3 -1
@@ -7,6 +7,9 @@ OBJS-y += xg_private.o OBJS-y += xg_domain.o OBJS-y += xg_suspend.o OBJS-y += xg_resume.o + +OBJS-$(CONFIG_HOTPLUG) += xg_offline_page.o + ifeq ($(CONFIG_MIGRATE),y) OBJS-y += xg_sr_common.o OBJS-$(CONFIG_X86) += xg_sr_common_x86.o
@@ -17,7 +20,6 @@ OBJS-$(CONFIG_X86) += xg_sr_save_x86_pv.o OBJS-$(CONFIG_X86) += xg_sr_save_x86_hvm.o OBJS-y += xg_sr_restore.o OBJS-y += xg_sr_save.o -OBJS-y += xg_offline_page.o else OBJS-y += xg_nomigrate.o endif
tools/misc/Makefile +1 -1
@@ -16,7 +16,7 @@ INSTALL_BIN += xencov_split INSTALL_BIN += $(INSTALL_BIN-y) # Everything to be installed in regular sbin/ -INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool +INSTALL_SBIN-$(CONFIG_HOTPLUG) += xen-hptool INSTALL_SBIN-$(CONFIG_X86) += xen-hvmcrash INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx INSTALL_SBIN-$(CONFIG_X86) += xen-lowmemd
Signature · 1 line
2.34.1
PATCH 1/4 arm/time: Use static irqaction
In reply to Mykyta PoturaiWhen stopping a core deinit_timer_interrupt is called in non-alloc context, which causes xfree in release_irq to fail an assert.
To fix this, switch to a statically allocated irqaction that does not need to be freed in release_irq.
--- xen/arch/arm/time.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
xen/arch/arm/time.c +16 -4
@@ -303,6 +303,20 @@ static void check_timer_irq_cfg(unsigned int irq, const char *which) "WARNING: %s-timer IRQ%u is not level triggered.\n", which, irq); } +static struct irqaction __read_mostly irq_hyp = { + .name ="hyptimer" , + .handler = htimer_interrupt, + .dev_id =NULL , + .free_on_release =0 , +}; + +static struct irqaction __read_mostly irq_virt = { + .name ="virtimer" , + .handler = vtimer_interrupt, + .dev_id =NULL , + .free_on_release =0 , +}; +/* Set up the timer interrupt on this CPU */ void init_timer_interrupt (void ) {
@@ -314,10 +328,8 @@ void init_timer_interrupt(void)WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Hypervisor's timer disabled */ isb (); -request_irq (timer_irq[TIMER_HYP_PPI ],0 , htimer_interrupt, -"hyptimer" ,NULL ); -request_irq (timer_irq[TIMER_VIRT_PPI ],0 , vtimer_interrupt, -"virtimer" ,NULL ); +setup_irq (timer_irq[TIMER_HYP_PPI ],0 , &irq_hyp); +setup_irq (timer_irq[TIMER_VIRT_PPI ],0 , &irq_virt);check_timer_irq_cfg (timer_irq[TIMER_HYP_PPI ],"hypervisor" );check_timer_irq_cfg (timer_irq[TIMER_VIRT_PPI ],"virtual" );
Signature · 1 line
2.34.1
PATCH 3/4 arm/sysctl: Implement cpu hotplug ops
In reply to Mykyta PoturaiImplement XEN_SYSCTL_CPU_HOTPLUG_* calls to allow for enabling/disabling CPU cores in runtime.
--- xen/arch/arm/sysctl.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
xen/arch/arm/sysctl.c +67 -0
@@ -12,6 +12,7 @@#include <xen/dt-overlay.h> #include <xen/errno.h> #include <xen/hypercall.h> +#include <xen/cpu.h> #include <asm/arm64/sve.h> #include <public/sysctl.h>
@@ -23,6 +24,68 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK); } +static long cpu_up_helper (void *data) +{ +unsigned long cpu = (unsigned long ) data; +return cpu_up (cpu); +} + +static long cpu_down_helper (void *data) +{ +unsigned long cpu = (unsigned long ) data; +return cpu_down (cpu); +} + +static long smt_up_down_helper (void *data) +{ +bool up = (bool ) data; +unsigned int cpu; +int ret; + +for_each_present_cpu ( cpu ) + { +if ( cpu ==0 ) +continue ; + +if ( up ) + ret =cpu_up (cpu); +else + ret =cpu_down (cpu); + +if ( ret ) +return ret; + } + +return 0 ; +} + +static long cpu_hotplug_sysctl (struct xen_sysctl_cpu_hotplug *hotplug) +{ +bool up; + +switch (hotplug->op) { +case XEN_SYSCTL_CPU_HOTPLUG_ONLINE : +if ( hotplug->cpu ==0 ) +return -EINVAL ; +return continue_hypercall_on_cpu (0 , cpu_up_helper,_p (hotplug->cpu)); + +case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE : +if ( hotplug->cpu ==0 ) +return -EINVAL ; +return continue_hypercall_on_cpu (0 , cpu_down_helper,_p (hotplug->cpu)); + +case XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE : +case XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE : +if (CONFIG_NR_CPUS <=1 ) +return 0 ; + up = hotplug->op ==XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE ; +return continue_hypercall_on_cpu (0 , smt_up_down_helper,_p (up)); + +default : +return -EINVAL ; + } +} +long arch_do_sysctl (struct xen_sysctl *sysctl,XEN_GUEST_HANDLE_PARAM (xen_sysctl_t) u_sysctl) {
@@ -34,6 +97,10 @@ long arch_do_sysctl(struct xen_sysctl *sysctl, ret =dt_overlay_sysctl (&sysctl->u.dt_overlay);break ; +case XEN_SYSCTL_cpu_hotplug: + ret =cpu_hotplug_sysctl (&sysctl->u.cpu_hotplug); +break ; +default : ret = -ENOSYS ;break ;
Signature · 1 line
2.34.1
PATCH 2/4 arm/gic: Use static irqaction
In reply to Mykyta PoturaiWhen stopping a core cpu_gic_callback is called in non-alloc context, which causes xfree in release_irq to fail an assert.
To fix this, switch to a statically allocated irqaction that does not need to be freed in release_irq.
--- xen/arch/arm/gic.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
xen/arch/arm/gic.c +8 -2
@@ -386,10 +386,16 @@ void gic_dump_info(struct vcpu *v) gic_hw_ops->dump_state (v); } +static struct irqaction __read_mostly irq_maintenance = { + .name ="irq-maintenance" , + .handler = maintenance_interrupt, + .dev_id =NULL , + .free_on_release =0 , +}; +void init_maintenance_interrupt (void ) { -request_irq (gic_hw_ops->info->maintenance_irq,0 , maintenance_interrupt, -"irq-maintenance" ,NULL ); +setup_irq (gic_hw_ops->info->maintenance_irq,0 , &irq_maintenance); } int gic_make_hwdom_dt_node(const struct domain *d,
Signature · 1 line
2.34.1
Re: [PATCH v1 1/4] arm/time: Use static irqaction
In reply to Mykyta PoturaiHi Mykyta,
Quoted 21 lines · Mykyta Poturai
When stopping a core
deinit_timer_interruptis called in non-alloc context, which causes xfree inrelease_irqto fail an assert.To fix this, switch to a statically allocated irqaction that does not need to be freed in
release_irq.Quoted 1 line
Signed-off-by Mykyta Poturai <[email protected]>--- xen/arch/arm/time.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)xen/arch/arm/time.c +3
-0@@ -303,6 +303,20 @@ static void check_timer_irq_cfg(unsigned int irq, const char *which) "WARNING: %s-timer IRQ%u is not level triggered.\n", which, irq); } +static struct irqaction __read_mostly irq_hyp = { + .name ="hyptimer" , + .handler = htimer_interrupt,
xen/arch/arm/time.c static void check_timer_irq_cfg(unsigned int irq, const char *which) · line 318
Quoted 10 lines
xen/arch/arm/time.c +10
-0+ .dev_id = NULL, + .free_on_release = 0, +}; + +static struct irqaction __read_mostly irq_virt = { + .name ="virtimer" , + .handler = vtimer_interrupt, + .dev_id =NULL , + .free_on_release =0 , +};
setup_irq() will update the field "next" in irqaction. So we need one instance per call. Effectively, this means one per CPU. Therefore, we want to use DEFINE_PER_CPU. This applies to the rest of the series.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/4] arm/sysctl: Implement cpu hotplug ops
In reply to Mykyta PoturaiHi Mykyta,
Quoted 27 lines · Mykyta Poturai
Implement XEN_SYSCTL_CPU_HOTPLUG_* calls to allow for enabling/disabling CPU cores in runtime.
Signed-off-by Mykyta Poturai <[email protected]>--- xen/arch/arm/sysctl.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)xen/arch/arm/sysctl.c +4
-0@@ -12,6 +12,7 @@#include <xen/dt-overlay.h> #include <xen/errno.h> #include <xen/hypercall.h> +#include <xen/cpu.h> #include <asm/arm64/sve.h> #include <public/sysctl.h> @@ -23,6 +24,68 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK); } +static long cpu_up_helper (void *data) +{ +unsigned long cpu = (unsigned long ) data;
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 39
Quoted 10 lines
xen/arch/arm/sysctl.c +10
-0+return cpu_up (cpu); +} + +static long cpu_down_helper (void *data) +{ +unsigned long cpu = (unsigned long ) data; +return cpu_down (cpu); +} + +static long smt_up_down_helper (void *data)
Looking at the code, you will effectively disable all the CPUs but CPU0. But I don't understand why. From the name is goal seems to be disable SMT threading.
Quoted 5 lines
xen/arch/arm/sysctl.c +5
-0+{ +bool up = (bool ) data; +unsigned int cpu; +int ret; +
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 54
Quoted 10 lines
xen/arch/arm/sysctl.c +10
-0+for_each_present_cpu ( cpu ) + { +if ( cpu ==0 ) +continue ; + +if ( up ) + ret =cpu_up (cpu); +else + ret =cpu_down (cpu); +
Regardless what I wrote above, you likely want to handle preemption.
Quoted 4 lines
xen/arch/arm/sysctl.c +4
-0+if ( ret ) +return ret; + } +
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 68
Quoted 10 lines
xen/arch/arm/sysctl.c +10
-0+return 0 ; +} + +static long cpu_hotplug_sysctl (struct xen_sysctl_cpu_hotplug *hotplug) +{ +bool up; + +switch (hotplug->op) { +case XEN_SYSCTL_CPU_HOTPLUG_ONLINE : +if ( hotplug->cpu ==0 )
I can't find a similar check on x86. Do you have any pointer?
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 69
Quoted 1 line
xen/arch/arm/sysctl.c +1
-0+return -EINVAL ;
On x86, they seem to check for XSM permission before continuing. Can you explain why this is not necessary? Same questions applies below.
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 78
Quoted 9 lines
xen/arch/arm/sysctl.c +9
-0+return continue_hypercall_on_cpu (0 , cpu_up_helper,_p (hotplug->cpu)); + +case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE : +if ( hotplug->cpu ==0 ) +return -EINVAL ; +return continue_hypercall_on_cpu (0 , cpu_down_helper,_p (hotplug->cpu)); + +case XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE : +case XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE :
Why are we implementing those helpers on Arm?
Quoted 14 lines
xen/arch/arm/sysctl.c +10
-0+if (CONFIG_NR_CPUS <=1 ) +return 0 ; + up = hotplug->op ==XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE ; +return continue_hypercall_on_cpu (0 , smt_up_down_helper,_p (up)); + +default : +return -EINVAL ; + } +} +long arch_do_sysctl (struct xen_sysctl *sysctl,XEN_GUEST_HANDLE_PARAM (xen_sysctl_t) u_sysctl) {
xen/arch/arm/sysctl.c long arch_do_sysctl(struct xen_sysctl *sysctl, · line 100
Quoted 4 lines
xen/arch/arm/sysctl.c +1
-0@@ -34,6 +97,10 @@ long arch_do_sysctl(struct xen_sysctl *sysctl, ret =dt_overlay_sysctl (&sysctl->u.dt_overlay);break ; +case XEN_SYSCTL_cpu_hotplug:
This will also enable CPU hotplug on 32-bit Arm. Is this what you intended? (I see patch #4 only mention 64-bit Arm).
xen/arch/arm/sysctl.c long arch_do_sysctl(struct xen_sysctl *sysctl, · line 106
Quoted 6 lines
xen/arch/arm/sysctl.c +3
-0+ ret =cpu_hotplug_sysctl (&sysctl->u.cpu_hotplug); +break ; +default : ret = -ENOSYS ;break ;
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/4] arm/sysctl: Implement cpu hotplug ops
Quoted 10 lines · Julien Grall
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 68
Quoted 7 lines · Mykyta Poturai
xen/arch/arm/sysctl.c +7
-0+static long cpu_hotplug_sysctl (struct xen_sysctl_cpu_hotplug *hotplug) +{ +bool up; + +switch (hotplug->op) { +case XEN_SYSCTL_CPU_HOTPLUG_ONLINE : +if ( hotplug->cpu ==0 )I can't find a similar check on x86. Do you have any pointer?
When CPU 0 cannot be brought down (see cpu_down()), tryin to bring it up is kind of pointless, and hence can perhaps be short circuited like this?
Jan
Re: [PATCH v1 4/4] tools: Allow building xen-hptool without CONFIG_MIGRATE
In reply to Mykyta PoturaiQuoted 22 lines · Mykyta Poturai
config/arm64.mk +1
-0@@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_64 := y +CONFIG_HOTPLUG := y CONFIG_XEN_INSTALL_SUFFIX :=config/x86_32.mk +1
-0@@ -3,6 +3,7 @@ CONFIG_X86_32 := y CONFIG_MIGRATE := y CONFIG_XCUTILS := y +CONFIG_HOTPLUG := y CFLAGS += -m32 -march=i686
config/x86_64.mk CONFIG_X86_64 := y · line 8
Quoted 6 lines
config/x86_64.mk +1
-0@@ -3,6 +3,7 @@ CONFIG_X86_64 := y CONFIG_MIGRATE := y CONFIG_XCUTILS := y +CONFIG_HOTPLUG := y CONFIG_XEN_INSTALL_SUFFIX := .gz
I realize you only do what is already being done, but I question this way of doing things when the scope is tools-only. Any CONFIG_* put here cannot have an identically named, but potentially set differently Kconfig setting in xen/: Any use of such in a Makefile could end up being wrong, and would pretty surely end up being confusing.
Jan
Re: [PATCH v1 4/4] tools: Allow building xen-hptool without CONFIG_MIGRATE
Quoted 36 lines · Jan Beulich
Quoted 22 lines · Mykyta Poturai
config/arm64.mk +1
-0@@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_64 := y +CONFIG_HOTPLUG := y CONFIG_XEN_INSTALL_SUFFIX :=config/x86_32.mk +1
-0@@ -3,6 +3,7 @@ CONFIG_X86_32 := y CONFIG_MIGRATE := y CONFIG_XCUTILS := y +CONFIG_HOTPLUG := y CFLAGS += -m32 -march=i686config/x86_64.mk CONFIG_X86_64 := y · line 8
Quoted 6 lines
config/x86_64.mk +1
-0@@ -3,6 +3,7 @@ CONFIG_X86_64 := y CONFIG_MIGRATE := y CONFIG_XCUTILS := y +CONFIG_HOTPLUG := y CONFIG_XEN_INSTALL_SUFFIX := .gzI realize you only do what is already being done, but I question this way of doing things when the scope is tools-only. Any CONFIG_* put here cannot have an identically named, but potentially set differently
Kconfigsetting in xen/: Any use of such in aMakefilecould end up being wrong, and would pretty surely end up being confusing.
Quoted 1 line
Jan
I have checked the whole codebase and didn't find any other CONFIG_HOTPLUG, the only similar thing is CONFIG_HOTPLUG_CPU. Anyway, I can change it to something more specific like CONFIG_HPTOOL for example.
Signature · 1 line
Mykyta
Re: [PATCH v1 3/4] arm/sysctl: Implement cpu hotplug ops
In reply to Julien GrallQuoted 35 lines · Julien Grall
Hi Mykyta,
Quoted 32 lines · Mykyta Poturai
Implement XEN_SYSCTL_CPU_HOTPLUG_* calls to allow for enabling/disabling CPU cores in runtime.
Signed-off-by Mykyta Poturai <[email protected]>--- xen/arch/arm/sysctl.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)xen/arch/arm/sysctl.c +10
-0@@ -12,6 +12,7 @@#include <xen/dt-overlay.h> #include <xen/errno.h> #include <xen/hypercall.h> +#include <xen/cpu.h> #include <asm/arm64/sve.h> #include <public/sysctl.h> @@ -23,6 +24,68 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK); } +static long cpu_up_helper (void *data) +{ +unsigned long cpu = (unsigned long ) data; +return cpu_up (cpu); +} + +static long cpu_down_helper (void *data) +{ +unsigned long cpu = (unsigned long ) data;
Quoted 9 lines
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 39
Quoted 4 lines
xen/arch/arm/sysctl.c +4
-0+return cpu_down (cpu); +} + +static long smt_up_down_helper (void *data)Looking at the code, you will effectively disable all the CPUs but CPU0. But I don't understand why. From the name is goal seems to be disable SMT threading.
Sorry I have slightly misunderstood the x86 implementation/reasoning of this ops. I will drop them in V2.
Quoted 18 lines
Quoted 5 lines
xen/arch/arm/sysctl.c +5
-0+{ +bool up = (bool ) data; +unsigned int cpu; +int ret; +xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 54
Quoted 10 lines
xen/arch/arm/sysctl.c +10
-0+for_each_present_cpu ( cpu ) + { +if ( cpu ==0 ) +continue ; + +if ( up ) + ret =cpu_up (cpu); +else + ret =cpu_down (cpu); +Regardless what I wrote above, you likely want to handle preemption.
Quoted 16 lines
Quoted 4 lines
xen/arch/arm/sysctl.c +4
-0+if ( ret ) +return ret; + } +xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 68
Quoted 10 lines
xen/arch/arm/sysctl.c +10
-0+return 0 ; +} + +static long cpu_hotplug_sysctl (struct xen_sysctl_cpu_hotplug *hotplug) +{ +bool up; + +switch (hotplug->op) { +case XEN_SYSCTL_CPU_HOTPLUG_ONLINE : +if ( hotplug->cpu ==0 )I can't find a similar check on x86. Do you have any pointer?
Jan correctly mentioned that CPU0 can't be disabled so this is a short circuit for clarity.
Quoted 5 lines
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 69
Quoted 2 lines
xen/arch/arm/sysctl.c +1
-0+return -EINVAL ;On x86, they seem to check for XSM permission before continuing. Can you explain why this is not necessary? Same questions applies below.
I will add XSM checks thanks for pointing this out.
Quoted 28 lines
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 78
Quoted 12 lines
xen/arch/arm/sysctl.c +9
-0+return continue_hypercall_on_cpu (0 , cpu_up_helper,_p (hotplug->cpu)); + +case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE : +if ( hotplug->cpu ==0 ) +return -EINVAL ; +return continue_hypercall_on_cpu (0 , cpu_down_helper,_p (hotplug->cpu)); + +case XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE : +case XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE :Why are we implementing those helpers on Arm?
Quoted 13 lines
xen/arch/arm/sysctl.c +10
-0+if (CONFIG_NR_CPUS <=1 ) +return 0 ; + up = hotplug->op ==XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE ; +return continue_hypercall_on_cpu (0 , smt_up_down_helper,_p (up)); + +default : +return -EINVAL ; + } +} +long arch_do_sysctl(struct
xen_sysctl*sysctl,
XEN_GUEST_HANDLE_PARAM(xen_sysctl_t)u_sysctl)
Quoted 8 lines
xen/arch/arm/sysctl.c long arch_do_sysctl(struct xen_sysctl *sysctl, · line 99
Quoted 5 lines
{xen/arch/arm/sysctl.c +1
-0@@ -34,6 +97,10 @@ long arch_do_sysctl(struct xen_sysctl *sysctl, ret =dt_overlay_sysctl (&sysctl->u.dt_overlay);break ; +case XEN_SYSCTL_cpu_hotplug:This will also enable CPU hotplug on 32-bit Arm. Is this what you intended? (I see patch #4 only mention 64-bit Arm).
It wasn't intended. I will additionally check if it works on arm32 end explicitly specify it.
Quoted 10 lines
xen/arch/arm/sysctl.c long arch_do_sysctl(struct xen_sysctl *sysctl, · line 106
Quoted 7 lines
xen/arch/arm/sysctl.c +3
-0+ ret =cpu_hotplug_sysctl (&sysctl->u.cpu_hotplug); +break ; +default : ret = -ENOSYS ;break ;Cheers,
Signature · 1 line
Mykyta
Re: [PATCH v1 4/4] tools: Allow building xen-hptool without CONFIG_MIGRATE
In reply to Mykyta PoturaiQuoted 37 lines · Mykyta Poturai
Quoted 28 lines · Jan Beulich
Quoted 27 lines · Mykyta Poturai
config/arm64.mk +1
-0@@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_64 := y +CONFIG_HOTPLUG := y CONFIG_XEN_INSTALL_SUFFIX :=config/x86_32.mk +1
-0@@ -3,6 +3,7 @@ CONFIG_X86_32 := y CONFIG_MIGRATE := y CONFIG_XCUTILS := y +CONFIG_HOTPLUG := y CFLAGS += -m32 -march=i686config/x86_64.mk +1
-0@@ -3,6 +3,7 @@ CONFIG_X86_64 := y CONFIG_MIGRATE := y CONFIG_XCUTILS := y +CONFIG_HOTPLUG := yQuoted 7 lines
config/x86_64.mk CONFIG_X86_64 := y · line 8
Quoted 1 line
config/x86_64.mk +0
-0CONFIG_XEN_INSTALL_SUFFIX := .gzI realize you only do what is already being done, but I question this way of doing things when the scope is tools-only. Any CONFIG_* put here cannot have an identically named, but potentially set differently
Kconfigsetting in xen/: Any use of such in aMakefilecould end up being wrong, and would pretty surely end up being confusing.
Quoted 3 lines
I have checked the whole codebase and didn't find any other
CONFIG_HOTPLUG, the only similar thing isCONFIG_HOTPLUG_CPU. Anyway, I can change it to something more specific likeCONFIG_HPTOOLfor example.
Iff no other way (configure?) can be found, then yes, please use this more specific name. But not extending this legacy way of "configuring" things would be much preferred.
Jan
Hi Mykyta,
Thank a lot for your patches.
Quoted 16 lines · Mykyta Poturai
This series implements support for CPU hotplug/unplug on Arm. To achieve this, several things need to be done:
1. XEN_SYSCTL_CPU_HOTPLUG_* calls implemented.
2. timer and GIC maintenance interrupts switched to static irqactions to remove the need for freeing them duringrelease_irq.
3. Enabled the build of xen-hptool on Arm.Tested on QEMU.
Mykyta Poturai (4):
arm/time: Use static irqaction
arm/gic: Use static irqaction
arm/sysctl: Implement cpu hotplug ops
tools: Allow building xen-hptool withoutCONFIG_MIGRATE
Quoted 10 lines
config/arm64.mk | 1 + config/x86_32.mk | 1 + config/x86_64.mk | 1 + tools/libs/guest/Makefile.common | 4 +- tools/misc/Makefile | 2 +- xen/arch/arm/gic.c | 10 ++++- xen/arch/arm/sysctl.c | 67 ++++++++++++++++++++++++++++++++ xen/arch/arm/time.c | 20 ++++++++-- 8 files changed, 98 insertions(+), 8 deletions(-)
Hence you introducing new feature for ARM I'd very much appreciated if you add corresponding documentation under docs/hypervisor-guide/arm/.
Signature · 2 lines
Best regards, -grygorii
Hi Grygorii,
Quoted 28 lines · Grygorii Strashko
Quoted 24 lines · Mykyta Poturai
This series implements support for CPU hotplug/unplug on Arm. To achieve this, several things need to be done:
1. XEN_SYSCTL_CPU_HOTPLUG_* calls implemented.
2. timer and GIC maintenance interrupts switched to static irqactions to remove the need for freeing them duringrelease_irq.
3. Enabled the build of xen-hptool on Arm.Tested on QEMU.
Mykyta Poturai (4):
arm/time: Use static irqaction
arm/gic: Use static irqaction
arm/sysctl: Implement cpu hotplug ops
tools: Allow building xen-hptool withoutCONFIG_MIGRATEconfig/arm64.mk | 1 +
config/x86_32.mk | 1 +
config/x86_64.mk | 1 +tools/libs/guest/Makefile.common| 4 +- tools/misc/Makefile | 2 +- xen/arch/arm/gic.c | 10 ++++- xen/arch/arm/sysctl.c | 67 ++++++++++++++++++++++++++++++++ xen/arch/arm/time.c | 20 ++++++++--Quoted 2 lines
8 files changed, 98 insertions(+), 8 deletions(-)
Quoted 2 lines
Hence you introducing new feature for ARM I'd very much appreciated if you add corresponding documentation under docs/hypervisor-guide/arm/.
I think some documentation is good. But why does this need to be Arm specific?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/4] arm/sysctl: Implement cpu hotplug ops
In reply to Jan BeulichHi Jan,
Quoted 12 lines · Jan Beulich
Quoted 10 lines · Julien Grall
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 68
Quoted 7 lines · Mykyta Poturai
xen/arch/arm/sysctl.c +7
-0+static long cpu_hotplug_sysctl (struct xen_sysctl_cpu_hotplug *hotplug) +{ +bool up; + +switch (hotplug->op) { +case XEN_SYSCTL_CPU_HOTPLUG_ONLINE : +if ( hotplug->cpu ==0 )I can't find a similar check on x86. Do you have any pointer?
Quoted 2 lines
When CPU 0 cannot be brought down (see
cpu_down()), tryin to bring it up is kind of pointless, and hence can perhaps be short circuited like this?
Thanks for the clarification, I missed the check in cpu_down(). That said, I don't see any value to short circuit it. In fact, I see this as more a risk because if we ever decide to allow CPU 0 to be offlined, then it would be more difficult to find places where we short circuit it.
So I would rather prefer if we remove the checks.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/4] arm/sysctl: Implement cpu hotplug ops
In reply to Mykyta PoturaiHi Mykyta,
Quoted 84 lines · Mykyta Poturai
Quoted 35 lines · Julien Grall
Hi Mykyta,
Quoted 32 lines · Mykyta Poturai
Implement XEN_SYSCTL_CPU_HOTPLUG_* calls to allow for enabling/disabling CPU cores in runtime.
Signed-off-by Mykyta Poturai <[email protected]>--- xen/arch/arm/sysctl.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)xen/arch/arm/sysctl.c +10
-0@@ -12,6 +12,7 @@#include <xen/dt-overlay.h> #include <xen/errno.h> #include <xen/hypercall.h> +#include <xen/cpu.h> #include <asm/arm64/sve.h> #include <public/sysctl.h> @@ -23,6 +24,68 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK); } +static long cpu_up_helper (void *data) +{ +unsigned long cpu = (unsigned long ) data; +return cpu_up (cpu); +} + +static long cpu_down_helper (void *data) +{ +unsigned long cpu = (unsigned long ) data;Quoted 9 lines
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 39
Quoted 4 lines
xen/arch/arm/sysctl.c +4
-0+return cpu_down (cpu); +} + +static long smt_up_down_helper (void *data)Looking at the code, you will effectively disable all the CPUs but CPU0. But I don't understand why. From the name is goal seems to be disable SMT threading.
Sorry I have slightly misunderstood the x86 implementation/reasoning of this ops. I will drop them in V2.
Quoted 18 lines
Quoted 5 lines
xen/arch/arm/sysctl.c +5
-0+{ +bool up = (bool ) data; +unsigned int cpu; +int ret; +xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 54
Quoted 10 lines
xen/arch/arm/sysctl.c +10
-0+for_each_present_cpu ( cpu ) + { +if ( cpu ==0 ) +continue ; + +if ( up ) + ret =cpu_up (cpu); +else + ret =cpu_down (cpu); +Regardless what I wrote above, you likely want to handle preemption.
Quoted 16 lines
Quoted 4 lines
xen/arch/arm/sysctl.c +4
-0+if ( ret ) +return ret; + } +xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 68
Quoted 10 lines
xen/arch/arm/sysctl.c +10
-0+return 0 ; +} + +static long cpu_hotplug_sysctl (struct xen_sysctl_cpu_hotplug *hotplug) +{ +bool up; + +switch (hotplug->op) { +case XEN_SYSCTL_CPU_HOTPLUG_ONLINE : +if ( hotplug->cpu ==0 )I can't find a similar check on x86. Do you have any pointer?
Quoted 2 lines
Jan correctly mentioned that CPU0 can't be disabled so this is a short circuit for clarity.
I have replied to Jan. In short, the clarify you are referring is what would make more difficult to support offlining CPU0. So I would rather prefer if they are not present.
Quoted 37 lines
Quoted 28 lines
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 78
Quoted 12 lines
xen/arch/arm/sysctl.c +9
-0+return continue_hypercall_on_cpu (0 , cpu_up_helper,_p (hotplug->cpu)); + +case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE : +if ( hotplug->cpu ==0 ) +return -EINVAL ; +return continue_hypercall_on_cpu (0 , cpu_down_helper,_p (hotplug->cpu)); + +case XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE : +case XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE :Why are we implementing those helpers on Arm?
Quoted 13 lines
xen/arch/arm/sysctl.c +10
-0+if (CONFIG_NR_CPUS <=1 ) +return 0 ; + up = hotplug->op ==XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE ; +return continue_hypercall_on_cpu (0 , smt_up_down_helper,_p (up)); + +default : +return -EINVAL ; + } +} +long arch_do_sysctl (struct xen_sysctl *sysctl,XEN_GUEST_HANDLE_PARAM (xen_sysctl_t) u_sysctl)Quoted 8 lines
xen/arch/arm/sysctl.c long arch_do_sysctl(struct xen_sysctl *sysctl, · line 99
Quoted 5 lines
{xen/arch/arm/sysctl.c +1
-0@@ -34,6 +97,10 @@ long arch_do_sysctl(struct xen_sysctl *sysctl, ret =dt_overlay_sysctl (&sysctl->u.dt_overlay);break ; +case XEN_SYSCTL_cpu_hotplug:This will also enable CPU hotplug on 32-bit Arm. Is this what you intended? (I see patch #4 only mention 64-bit Arm).
Quoted 2 lines
It wasn't intended. I will additionally check if it works on arm32 end explicitly specify it.
It will not work properly on arm32 because of the page table code. We have per-CPU pagetables (see init_domheap_mappings()) and they will need to be freed.
Note this is not a request to add support for arm32 CPU offlining.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/4] arm/sysctl: Implement cpu hotplug ops
In reply to Julien GrallQuoted 16 lines · Julien Grall
Quoted 12 lines · Jan Beulich
Quoted 10 lines · Julien Grall
xen/arch/arm/sysctl.c void arch_do_physinfo(struct xen_sysctl_physinfo *pi) · line 68
Quoted 7 lines · Mykyta Poturai
xen/arch/arm/sysctl.c +7
-0+static long cpu_hotplug_sysctl (struct xen_sysctl_cpu_hotplug *hotplug) +{ +bool up; + +switch (hotplug->op) { +case XEN_SYSCTL_CPU_HOTPLUG_ONLINE : +if ( hotplug->cpu ==0 )I can't find a similar check on x86. Do you have any pointer?
Quoted 2 lines
When CPU 0 cannot be brought down (see
cpu_down()), tryin to bring it up is kind of pointless, and hence can perhaps be short circuited like this?
Quoted 6 lines
Thanks for the clarification, I missed the check in
cpu_down(). That said, I don't see any value to short circuit it. In fact, I see this as more a risk because if we ever decide to allow CPU 0 to be offlined, then it would be more difficult to find places where we short circuit it.So I would rather prefer if we remove the checks.
In fact I agree (and I merely wanted to point out the present situation):
CPU0 not (normally) being possible to be brought down is, I think, pretty much an x86 thing. I.e. I think the check would want to go away from common code.
Jan
Quoted 31 lines · Julien Grall
Hi Grygorii,
Quoted 28 lines · Grygorii Strashko
Quoted 26 lines · Mykyta Poturai
This series implements support for CPU hotplug/unplug on Arm. To achieve this, several things need to be done:
1. XEN_SYSCTL_CPU_HOTPLUG_* calls implemented.
2. timer and GIC maintenance interrupts switched to static irqactions to remove the need for freeing them duringrelease_irq.
3. Enabled the build of xen-hptool on Arm.Tested on QEMU.
Mykyta Poturai (4):
arm/time: Use static irqaction
arm/gic: Use static irqaction
arm/sysctl: Implement cpu hotplug ops
tools: Allow building xen-hptool withoutCONFIG_MIGRATEconfig/arm64.mk | 1 +
config/x86_32.mk | 1 +
config/x86_64.mk | 1 +tools/libs/guest/Makefile.common| 4 +- tools/misc/Makefile | 2 +- xen/arch/arm/gic.c | 10 ++++- xen/arch/arm/sysctl.c | 67 ++++++++++++++++++++++++++++++++ xen/arch/arm/time.c | 20 ++++++++--8 files changed, 98 insertions(+), 8 deletions(-)
Quoted 4 lines
Quoted 2 lines
Hence you introducing new feature for ARM I'd very much appreciated if you add corresponding documentation under docs/hypervisor-guide/arm/.
I think some documentation is good. But why does this need to be Arm specific?
Only because this series is for ARM, if it could be generic (at least partially) - even better.
Signature · 2 lines
Best regards, -grygorii