[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xen/arm: Allow setting the number of CPUs to activate at runtime
commit 7ac12e3634cc3ed9234de03e48149e7f5fbf73c3 Author: Michal Orzel <michal.orzel@xxxxxxx> AuthorDate: Mon May 23 11:13:24 2022 +0200 Commit: Julien Grall <jgrall@xxxxxxxxxx> CommitDate: Wed Jun 8 11:16:38 2022 +0100 xen/arm: Allow setting the number of CPUs to activate at runtime Introduce a command line parameter "maxcpus" on Arm to allow adjusting the number of CPUs to activate. Currently the limit is defined by the config option CONFIG_NR_CPUS. Such parameter already exists on x86. Define a parameter "maxcpus" and a corresponding static variable max_cpus in Arm smpboot.c. Modify function smp_get_max_cpus to take max_cpus as a limit and to return proper unsigned int instead of int. Take the opportunity to remove redundant variable cpus from start_xen function and to directly assign the return value from smp_get_max_cpus to nr_cpu_ids (global variable in Xen used to store the number of CPUs actually activated). Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx> Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx> --- docs/misc/xen-command-line.pandoc | 5 ++++- xen/arch/arm/include/asm/smp.h | 2 +- xen/arch/arm/setup.c | 10 ++++------ xen/arch/arm/smpboot.c | 18 ++++++++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 881fe409ac..0d1d98d715 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1652,13 +1652,16 @@ with **crashinfo_maxaddr**. Specify the threshold below which Xen will inform dom0 that the quantity of free memory is getting low. Specifying `0` will disable this notification. -### maxcpus (x86) +### maxcpus > `= <integer>` Specify the maximum number of CPUs that should be brought up. This option is ignored in **pv-shim** mode. +**WARNING: On Arm big.LITTLE systems, when `hmp-unsafe` option is enabled, this command line +option does not guarantee on which CPU types will be used.** + ### max_cstate (x86) > `= <integer>[,<integer>]` diff --git a/xen/arch/arm/include/asm/smp.h b/xen/arch/arm/include/asm/smp.h index 83c0cd6976..8133d5c295 100644 --- a/xen/arch/arm/include/asm/smp.h +++ b/xen/arch/arm/include/asm/smp.h @@ -33,7 +33,7 @@ extern void init_secondary(void); extern void smp_init_cpus(void); extern void smp_clear_cpu_maps (void); -extern int smp_get_max_cpus (void); +extern unsigned int smp_get_max_cpus(void); #define cpu_physical_id(cpu) cpu_logical_map(cpu) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ea1f5ee3d3..65fdaa0900 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -871,11 +871,10 @@ void __init start_xen(unsigned long boot_phys_offset, unsigned long fdt_paddr) { size_t fdt_size; - int cpus, i; const char *cmdline; struct bootmodule *xen_bootmodule; struct domain *d; - int rc; + int rc, i; dcache_line_bytes = read_dcache_line_bytes(); @@ -951,9 +950,8 @@ void __init start_xen(unsigned long boot_phys_offset, processor_id(); smp_init_cpus(); - cpus = smp_get_max_cpus(); - printk(XENLOG_INFO "SMP: Allowing %u CPUs\n", cpus); - nr_cpu_ids = cpus; + nr_cpu_ids = smp_get_max_cpus(); + printk(XENLOG_INFO "SMP: Allowing %u CPUs\n", nr_cpu_ids); /* * Some errata relies on SMCCC version which is detected by psci_init() @@ -997,7 +995,7 @@ void __init start_xen(unsigned long boot_phys_offset, for_each_present_cpu ( i ) { - if ( (num_online_cpus() < cpus) && !cpu_online(i) ) + if ( (num_online_cpus() < nr_cpu_ids) && !cpu_online(i) ) { int ret = cpu_up(i); if ( ret != 0 ) diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 9bb32a301a..22fede6600 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -43,6 +43,10 @@ cpumask_t cpu_possible_map; struct cpuinfo_arm cpu_data[NR_CPUS]; +/* maxcpus: maximum number of CPUs to activate. */ +static unsigned int __initdata max_cpus; +integer_param("maxcpus", max_cpus); + /* CPU logical map: map xen cpuid to an MPIDR */ register_t __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID }; @@ -277,16 +281,18 @@ void __init smp_init_cpus(void) "unless the cpu affinity of all domains is specified.\n"); } -int __init -smp_get_max_cpus (void) +unsigned int __init smp_get_max_cpus(void) { - int i, max_cpus = 0; + unsigned int i, cpus = 0; + + if ( ( !max_cpus ) || ( max_cpus > nr_cpu_ids ) ) + max_cpus = nr_cpu_ids; - for ( i = 0; i < nr_cpu_ids; i++ ) + for ( i = 0; i < max_cpus; i++ ) if ( cpu_possible(i) ) - max_cpus++; + cpus++; - return max_cpus; + return cpus; } void __init -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |