Index: sys/amd64/amd64/vm_machdep.c =================================================================== --- sys/amd64/amd64/vm_machdep.c (revision 206480) +++ sys/amd64/amd64/vm_machdep.c (working copy) @@ -67,6 +67,10 @@ #include #include +#if defined(DIAGNOSTIC) && defined(KDB) +#include +#endif + #include #include #include @@ -520,13 +524,31 @@ cpu_reset() { #ifdef SMP - u_int cnt, map; + u_int cnt, map, sb; if (smp_active) { map = PCPU_GET(other_cpus) & ~stopped_cpus; if (map != 0) { printf("cpu_reset: Stopping other CPUs\n"); stop_cpus(map); + sb = 0; +#ifdef DIAGNOSTIC + while ((stopped_cpus & map) != map) { + if (sb++ < 100000) + cpu_spinwait(); + if (sb == 3000000) { + printf("cpu_reset: Deadlock while stopping other CPUs (0x%x)\n", + map - (map & stopped_cpus)); + printf("cpu_reset: Retry with an hard stop\n"); + stop_cpus_hard(map - + (map & stopped_cpus)); +#ifdef KDB + kdb_enter(KDB_WHY_UNSET, + "deadlock on cpu_reset"); +#endif + } + } +#endif } if (PCPU_GET(cpuid) != 0) {