From 64dd590ece7b4aaa41990dca511f91e50f22ba0d Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Sat, 9 Oct 2010 08:07:49 +0000 Subject: [PATCH] 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 --- sys/kern/kern_shutdown.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 018bd8eecfd..0f1462380b5 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -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;