panic_cpu variable should be volatile

This is to prevent caching of its value in a register when it is checked
and modified by multiple CPUs in parallel.
Also, move the variable  into the scope of the only function that uses it.

Reviewed by:	jhb
Hint from:	mdf
MFC after:	1 week
This commit is contained in:
Andriy Gapon 2010-10-09 08:07:49 +00:00
parent 6f0ebf473d
commit 64dd590ece

View file

@ -513,10 +513,6 @@ shutdown_reset(void *junk, int howto)
/* NOTREACHED */ /* assuming reset worked */
}
#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
@ -525,6 +521,9 @@ static u_int panic_cpu = NOCPU;
void
panic(const char *fmt, ...)
{
#ifdef SMP
static volatile u_int panic_cpu = NOCPU;
#endif
struct thread *td = curthread;
int bootopt, newpanic;
va_list ap;