From: Juergen Gross Date: Mon, 3 Jun 2019 15:17:51 +0000 (+0200) Subject: remove on-stack cpumask from stop_machine_run() X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~2136 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=07d650f6699f06687732ec35eb539609cd70c7d9;p=xen.git remove on-stack cpumask from stop_machine_run() The "allbutself" cpumask in stop_machine_run() is not needed. Instead of allocating it on the stack it can easily be avoided. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/xen/common/stop_machine.c b/xen/common/stop_machine.c index ce6f5624c4..681b40906d 100644 --- a/xen/common/stop_machine.c +++ b/xen/common/stop_machine.c @@ -69,8 +69,8 @@ static void stopmachine_wait_state(void) int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu) { - cpumask_t allbutself; unsigned int i, nr_cpus; + unsigned int this = smp_processor_id(); int ret; BUG_ON(!local_irq_is_enabled()); @@ -79,9 +79,9 @@ int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu) if ( !get_cpu_maps() ) return -EBUSY; - cpumask_andnot(&allbutself, &cpu_online_map, - cpumask_of(smp_processor_id())); - nr_cpus = cpumask_weight(&allbutself); + nr_cpus = num_online_cpus(); + if ( cpu_online(this) ) + nr_cpus--; /* Must not spin here as the holder will expect us to be descheduled. */ if ( !spin_trylock(&stopmachine_lock) ) @@ -100,8 +100,9 @@ int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu) smp_wmb(); - for_each_cpu ( i, &allbutself ) - tasklet_schedule_on_cpu(&per_cpu(stopmachine_tasklet, i), i); + for_each_online_cpu ( i ) + if ( i != this ) + tasklet_schedule_on_cpu(&per_cpu(stopmachine_tasklet, i), i); stopmachine_set_state(STOPMACHINE_PREPARE); stopmachine_wait_state(); @@ -112,7 +113,7 @@ int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu) spin_debug_disable(); stopmachine_set_state(STOPMACHINE_INVOKE); - if ( (cpu == smp_processor_id()) || (cpu == NR_CPUS) ) + if ( (cpu == this) || (cpu == NR_CPUS) ) { ret = (*fn)(data); if ( ret )