@@ -958,11 +958,22 @@ void tick_broadcast(const struct cpumask *mask)
958958}
959959#endif
960960
961+ /*
962+ * The number of CPUs online, not counting this CPU (which may not be
963+ * fully online and so not counted in num_online_cpus()).
964+ */
965+ static inline unsigned int num_other_online_cpus (void )
966+ {
967+ unsigned int this_cpu_online = cpu_online (smp_processor_id ());
968+
969+ return num_online_cpus () - this_cpu_online ;
970+ }
971+
961972void smp_send_stop (void )
962973{
963974 unsigned long timeout ;
964975
965- if (num_online_cpus () > 1 ) {
976+ if (num_other_online_cpus () ) {
966977 cpumask_t mask ;
967978
968979 cpumask_copy (& mask , cpu_online_mask );
@@ -975,10 +986,10 @@ void smp_send_stop(void)
975986
976987 /* Wait up to one second for other CPUs to stop */
977988 timeout = USEC_PER_SEC ;
978- while (num_online_cpus () > 1 && timeout -- )
989+ while (num_other_online_cpus () && timeout -- )
979990 udelay (1 );
980991
981- if (num_online_cpus () > 1 )
992+ if (num_other_online_cpus () )
982993 pr_warn ("SMP: failed to stop secondary CPUs %*pbl\n" ,
983994 cpumask_pr_args (cpu_online_mask ));
984995
@@ -1001,15 +1012,19 @@ void crash_smp_send_stop(void)
10011012
10021013 cpus_stopped = 1 ;
10031014
1004- if (num_online_cpus () == 1 ) {
1015+ /*
1016+ * If this cpu is the only one alive at this point in time, online or
1017+ * not, there are no stop messages to be sent around, so just back out.
1018+ */
1019+ if (num_other_online_cpus () == 0 ) {
10051020 sdei_mask_local_cpu ();
10061021 return ;
10071022 }
10081023
10091024 cpumask_copy (& mask , cpu_online_mask );
10101025 cpumask_clear_cpu (smp_processor_id (), & mask );
10111026
1012- atomic_set (& waiting_for_crash_ipi , num_online_cpus () - 1 );
1027+ atomic_set (& waiting_for_crash_ipi , num_other_online_cpus () );
10131028
10141029 pr_crit ("SMP: stopping secondary CPUs\n" );
10151030 smp_cross_call (& mask , IPI_CPU_CRASH_STOP );
0 commit comments