Blow away the panic mutex in favor of using a single atomic_cmpset() on a
panic_cpu shared variable. I used a simple atomic operation here instead of a spin lock as it seemed to be excessive overhead. Also, this can avoid recursive panics if, for example, witness is broken.
This commit is contained in:
parent
3c41f323c9
commit
abd9053ee4
@ -281,14 +281,11 @@ globaldata_find(int cpuid)
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -357,9 +357,6 @@ struct mtx com_mtx;
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
@ -371,7 +368,6 @@ init_locks(void)
|
||||
mtx_init(&mcount_mtx, "mcount", MTX_DEF);
|
||||
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
|
||||
#ifdef USE_COMLOCK
|
||||
mtx_init(&com_mtx, "com", MTX_SPIN);
|
||||
|
@ -357,9 +357,6 @@ struct mtx com_mtx;
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
@ -371,7 +368,6 @@ init_locks(void)
|
||||
mtx_init(&mcount_mtx, "mcount", MTX_DEF);
|
||||
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
|
||||
#ifdef USE_COMLOCK
|
||||
mtx_init(&com_mtx, "com", MTX_SPIN);
|
||||
|
@ -357,9 +357,6 @@ struct mtx com_mtx;
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
@ -371,7 +368,6 @@ init_locks(void)
|
||||
mtx_init(&mcount_mtx, "mcount", MTX_DEF);
|
||||
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
|
||||
#ifdef USE_COMLOCK
|
||||
mtx_init(&com_mtx, "com", MTX_SPIN);
|
||||
|
@ -357,9 +357,6 @@ struct mtx com_mtx;
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
@ -371,7 +368,6 @@ init_locks(void)
|
||||
mtx_init(&mcount_mtx, "mcount", MTX_DEF);
|
||||
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
|
||||
#ifdef USE_COMLOCK
|
||||
mtx_init(&com_mtx, "com", MTX_SPIN);
|
||||
|
@ -357,9 +357,6 @@ struct mtx com_mtx;
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
@ -371,7 +368,6 @@ init_locks(void)
|
||||
mtx_init(&mcount_mtx, "mcount", MTX_DEF);
|
||||
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
|
||||
#ifdef USE_COMLOCK
|
||||
mtx_init(&com_mtx, "com", MTX_SPIN);
|
||||
|
@ -357,9 +357,6 @@ struct mtx com_mtx;
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
@ -371,7 +368,6 @@ init_locks(void)
|
||||
mtx_init(&mcount_mtx, "mcount", MTX_DEF);
|
||||
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
|
||||
#ifdef USE_COMLOCK
|
||||
mtx_init(&com_mtx, "com", MTX_SPIN);
|
||||
|
@ -548,6 +548,10 @@ dumpstatus(vm_offset_t addr, long count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SMP
|
||||
static u_int panic_cpu = NOCPU;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Panic is called on unresolvable fatal errors. It prints "panic: mesg",
|
||||
* and then reboots. If we are called twice, then we avoid trying to sync
|
||||
@ -562,7 +566,11 @@ panic(const char *fmt, ...)
|
||||
|
||||
#ifdef SMP
|
||||
/* Only 1 CPU can panic at a time */
|
||||
mtx_lock(&panic_mtx);
|
||||
if (panic_cpu != PCPU_GET(cpuid) &&
|
||||
atomic_cmpset_int(&panic_cpu, NOCPU, PCPU_GET(cpuid)) == 0) {
|
||||
for (;;)
|
||||
; /* nothing */
|
||||
}
|
||||
#endif
|
||||
|
||||
bootopt = RB_AUTOBOOT | RB_DUMP;
|
||||
|
@ -357,9 +357,6 @@ struct mtx com_mtx;
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
@ -371,7 +368,6 @@ init_locks(void)
|
||||
mtx_init(&mcount_mtx, "mcount", MTX_DEF);
|
||||
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
|
||||
#ifdef USE_COMLOCK
|
||||
mtx_init(&com_mtx, "com", MTX_SPIN);
|
||||
|
@ -232,15 +232,11 @@ globaldata_find(int cpuno)
|
||||
/* lock around the MP rendezvous */
|
||||
static struct mtx smp_rv_mtx;
|
||||
|
||||
/* only 1 CPU can panic at a time :) */
|
||||
struct mtx panic_mtx;
|
||||
|
||||
static void
|
||||
init_locks(void)
|
||||
{
|
||||
|
||||
mtx_init(&smp_rv_mtx, "smp rendezvous", MTX_SPIN);
|
||||
mtx_init(&panic_mtx, "panic", MTX_DEF);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -81,9 +81,6 @@ extern int lbolt; /* once a second sleep address */
|
||||
extern int tickdelta;
|
||||
extern long timedelta;
|
||||
|
||||
/* global data in mp_machdep.c */
|
||||
extern struct mtx panic_mtx;
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user