kern_shutdown.c (101153) | kern_shutdown.c (101155) |
---|---|
1/*- 2 * Copyright (c) 1986, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94 | 1/*- 2 * Copyright (c) 1986, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94 |
39 * $FreeBSD: head/sys/kern/kern_shutdown.c 101153 2002-08-01 13:35:38Z jhb $ | 39 * $FreeBSD: head/sys/kern/kern_shutdown.c 101155 2002-08-01 13:39:33Z jhb $ |
40 */ 41 42#include "opt_ddb.h" 43#include "opt_hw_wdog.h" 44#include "opt_panic.h" 45#include "opt_show_busybufs.h" 46 47#include <sys/param.h> --- 367 unchanged lines hidden (view full) --- 415 printf("Rebooting...\n"); 416 DELAY(1000000); /* wait 1 sec for printf's to complete and be read */ 417 /* cpu_boot(howto); */ /* doesn't do anything at the moment */ 418 cpu_reset(); 419 /* NOTREACHED */ /* assuming reset worked */ 420} 421 422#ifdef SMP | 40 */ 41 42#include "opt_ddb.h" 43#include "opt_hw_wdog.h" 44#include "opt_panic.h" 45#include "opt_show_busybufs.h" 46 47#include <sys/param.h> --- 367 unchanged lines hidden (view full) --- 415 printf("Rebooting...\n"); 416 DELAY(1000000); /* wait 1 sec for printf's to complete and be read */ 417 /* cpu_boot(howto); */ /* doesn't do anything at the moment */ 418 cpu_reset(); 419 /* NOTREACHED */ /* assuming reset worked */ 420} 421 422#ifdef SMP |
423static uintptr_t panic_thread = NULL; | 423static u_int panic_cpu = NOCPU; |
424#endif 425 426/* 427 * Panic is called on unresolvable fatal errors. It prints "panic: mesg", 428 * and then reboots. If we are called twice, then we avoid trying to sync 429 * the disks as this often leads to recursive panics. 430 * 431 * MPSAFE --- 4 unchanged lines hidden (view full) --- 436 struct thread *td = curthread; 437 int bootopt; 438 va_list ap; 439 static char buf[256]; 440 441#ifdef SMP 442 /* 443 * We don't want multiple CPU's to panic at the same time, so we | 424#endif 425 426/* 427 * Panic is called on unresolvable fatal errors. It prints "panic: mesg", 428 * and then reboots. If we are called twice, then we avoid trying to sync 429 * the disks as this often leads to recursive panics. 430 * 431 * MPSAFE --- 4 unchanged lines hidden (view full) --- 436 struct thread *td = curthread; 437 int bootopt; 438 va_list ap; 439 static char buf[256]; 440 441#ifdef SMP 442 /* 443 * We don't want multiple CPU's to panic at the same time, so we |
444 * use panic_thread as a simple spinlock. We have to keep checking 445 * panic_thread if we are spinning in case the panic on the first | 444 * use panic_cpu as a simple spinlock. We have to keep checking 445 * panic_cpu if we are spinning in case the panic on the first |
446 * CPU is canceled. 447 */ | 446 * CPU is canceled. 447 */ |
448 if (panic_thread != curthread) 449 while (atomic_cmpset_ptr(&panic_thread, NULL, curthread) == 0) 450 while (panic_thread != NULL) { 451#ifdef __i386__ 452 ia32_pause(); | 448 if (panic_cpu != PCPU_GET(cpuid)) 449 while (atomic_cmpset_int(&panic_cpu, NOCPU, 450 PCPU_GET(cpuid)) == 0) 451 while (panic_cpu != NOCPU) 452 ; /* nothing */ |
453#endif | 453#endif |
454 } 455#endif | |
456 457 bootopt = RB_AUTOBOOT | RB_DUMP; 458 if (panicstr) 459 bootopt |= RB_NOSYNC; 460 else 461 panicstr = fmt; 462 463 va_start(ap, fmt); --- 14 unchanged lines hidden (view full) --- 478 479#if defined(DDB) 480 if (debugger_on_panic) 481 Debugger ("panic"); 482#ifdef RESTARTABLE_PANICS 483 /* See if the user aborted the panic, in which case we continue. */ 484 if (panicstr == NULL) { 485#ifdef SMP | 454 455 bootopt = RB_AUTOBOOT | RB_DUMP; 456 if (panicstr) 457 bootopt |= RB_NOSYNC; 458 else 459 panicstr = fmt; 460 461 va_start(ap, fmt); --- 14 unchanged lines hidden (view full) --- 476 477#if defined(DDB) 478 if (debugger_on_panic) 479 Debugger ("panic"); 480#ifdef RESTARTABLE_PANICS 481 /* See if the user aborted the panic, in which case we continue. */ 482 if (panicstr == NULL) { 483#ifdef SMP |
486 atomic_store_rel_ptr(&panic_thread, NULL); | 484 atomic_store_rel_int(&panic_cpu, NOCPU); |
487#endif 488 return; 489 } 490#endif 491#endif 492 td->td_flags |= TDF_INPANIC; 493 if (!sync_on_panic) 494 bootopt |= RB_NOSYNC; --- 75 unchanged lines hidden --- | 485#endif 486 return; 487 } 488#endif 489#endif 490 td->td_flags |= TDF_INPANIC; 491 if (!sync_on_panic) 492 bootopt |= RB_NOSYNC; --- 75 unchanged lines hidden --- |