Always stop the scheduler when entering kdb

Set curthread->td_stopsched when entering kdb via any vector.
Previously, it was only set when entering via panic, so when
entering kdb another way, mutexes and such were still "live",
and an attempt to lock an already locked mutex would panic.

Reviewed by:	kib, cem
Discussed with:	jhb
Tested by:	pho
MFC after:	2 months
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D17687
This commit is contained in:
Eric van Gyzen 2018-10-30 14:54:15 +00:00
parent 8522d140a5
commit fcbb889fdb

View File

@ -652,9 +652,7 @@ kdb_trap(int type, int code, struct trapframe *tf)
struct kdb_dbbe *be;
register_t intr;
int handled;
#ifdef SMP
int did_stop_cpus;
#endif
be = kdb_dbbe;
if (be == NULL || be->dbbe_trap == NULL)
@ -666,16 +664,17 @@ kdb_trap(int type, int code, struct trapframe *tf)
intr = intr_disable();
#ifdef SMP
if (!SCHEDULER_STOPPED()) {
#ifdef SMP
other_cpus = all_cpus;
CPU_NAND(&other_cpus, &stopped_cpus);
CPU_CLR(PCPU_GET(cpuid), &other_cpus);
stop_cpus_hard(other_cpus);
#endif
curthread->td_stopsched = 1;
did_stop_cpus = 1;
} else
did_stop_cpus = 0;
#endif
kdb_active++;
@ -703,12 +702,13 @@ kdb_trap(int type, int code, struct trapframe *tf)
kdb_active--;
#ifdef SMP
if (did_stop_cpus) {
curthread->td_stopsched = 0;
#ifdef SMP
CPU_AND(&other_cpus, &stopped_cpus);
restart_cpus(other_cpus);
}
#endif
}
intr_restore(intr);