Index: sys/kern/init_main.c =================================================================== --- sys/kern/init_main.c +++ sys/kern/init_main.c @@ -53,6 +53,7 @@ #include #include +#include #include #include #include @@ -234,8 +235,8 @@ struct sysinit **xipp; /* interior loop of sort*/ struct sysinit *save; /* bubble*/ -#if defined(VERBOSE_SYSINIT) int last; +#if defined(VERBOSE_SYSINIT) int verbose; #endif @@ -266,8 +267,8 @@ } } -#if defined(VERBOSE_SYSINIT) last = SI_SUB_COPYRIGHT; +#if defined(VERBOSE_SYSINIT) verbose = 0; #if !defined(DDB) printf("VERBOSE_SYSINIT: DDB not enabled, symbol lookups disabled.\n"); @@ -285,10 +286,12 @@ if ((*sipp)->subsystem == SI_SUB_DONE) continue; + if ((*sipp)->subsystem > last) + BOOTTRACE_INIT("sysinit 0x%7x", (*sipp)->subsystem); + #if defined(VERBOSE_SYSINIT) if ((*sipp)->subsystem > last && verbose_sysinit != 0) { verbose = 1; - last = (*sipp)->subsystem; printf("subsystem %x\n", last); } if (verbose) { @@ -319,6 +322,7 @@ #endif /* Check off the one we're just done */ + last = (*sipp)->subsystem; (*sipp)->subsystem = SI_SUB_DONE; /* Check if we've installed more sysinit items via KLD */ @@ -334,6 +338,7 @@ } TSEXIT(); /* Here so we don't overlap with start_init. */ + BOOTTRACE_KERN("mi_startup done"); mtx_assert(&Giant, MA_OWNED | MA_NOTRECURSED); mtx_unlock(&Giant); Index: sys/kern/kern_linker.c =================================================================== --- sys/kern/kern_linker.c +++ sys/kern/kern_linker.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -194,6 +195,7 @@ linker_file_sysinit(linker_file_t lf) { struct sysinit **start, **stop, **sipp, **xipp, *save; + int subsystem; KLD_DPF(FILE, ("linker_file_sysinit: calling SYSINITs for %s\n", lf->filename)); @@ -225,14 +227,20 @@ * Traverse the (now) ordered list of system initialization tasks. * Perform each task, and continue on to the next task. */ + subsystem = SI_SUB_DUMMY; sx_xunlock(&kld_sx); mtx_lock(&Giant); for (sipp = start; sipp < stop; sipp++) { if ((*sipp)->subsystem == SI_SUB_DUMMY) continue; /* skip dummy task(s) */ + if ((*sipp)->subsystem > subsystem) + BOOTTRACE_KERN("%s: sysinit 0x%7x", lf->filename, + (*sipp)->subsystem); + /* Call function */ (*((*sipp)->func)) ((*sipp)->udata); + subsystem = (*sipp)->subsystem; } mtx_unlock(&Giant); sx_xlock(&kld_sx); @@ -242,6 +250,7 @@ linker_file_sysuninit(linker_file_t lf) { struct sysinit **start, **stop, **sipp, **xipp, *save; + int subsystem; KLD_DPF(FILE, ("linker_file_sysuninit: calling SYSUNINITs for %s\n", lf->filename)); @@ -277,12 +286,18 @@ */ sx_xunlock(&kld_sx); mtx_lock(&Giant); + subsystem = SI_SUB_DUMMY; for (sipp = start; sipp < stop; sipp++) { if ((*sipp)->subsystem == SI_SUB_DUMMY) continue; /* skip dummy task(s) */ + if ((*sipp)->subsystem > subsystem) + BOOTTRACE_KERN("%s: sysuninit 0x%7x", lf->filename, + (*sipp)->subsystem); + /* Call function */ (*((*sipp)->func)) ((*sipp)->udata); + subsystem = (*sipp)->subsystem; } mtx_unlock(&Giant); sx_xlock(&kld_sx); Index: sys/kern/kern_shutdown.c =================================================================== --- sys/kern/kern_shutdown.c +++ sys/kern/kern_shutdown.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -323,14 +324,19 @@ howto = (uintptr_t)arg; /* Send a signal to init(8) and have it shutdown the world. */ PROC_LOCK(initproc); - if (howto & RB_POWEROFF) + if (howto & RB_POWEROFF) { + BOOTTRACE_KERN("SIGUSR2 to init(8)"); kern_psignal(initproc, SIGUSR2); - else if (howto & RB_POWERCYCLE) + } else if (howto & RB_POWERCYCLE) { + BOOTTRACE_KERN("SIGWINCH to init(8)"); kern_psignal(initproc, SIGWINCH); - else if (howto & RB_HALT) + } else if (howto & RB_HALT) { + BOOTTRACE_KERN("SIGUSR1 to init(8)"); kern_psignal(initproc, SIGUSR1); - else + } else { + BOOTTRACE_KERN("SIGINT to init(8)"); kern_psignal(initproc, SIGINT); + } PROC_UNLOCK(initproc); } @@ -345,6 +351,7 @@ { if (initproc != NULL && !SCHEDULER_STOPPED()) { + BOOTTRACE_KERN("shutdown initiated", NULL); shutdown_nice_task.ta_context = (void *)(uintptr_t)howto; taskqueue_enqueue(taskqueue_fast, &shutdown_nice_task); } else { @@ -420,6 +427,29 @@ return (error); } +/* + * Trace the shutdown reason. + */ +static void +reboottrace(int howto) +{ + if (howto & RB_DUMP) { + if (howto & RB_HALT) + BOOTTRACE_KERN("system panic: halting..."); + if (howto & RB_POWEROFF) + BOOTTRACE_KERN("system panic: powering off..."); + if (!(howto & (RB_HALT|RB_POWEROFF))) + BOOTTRACE_KERN("system panic: rebooting..."); + } else { + if (howto & RB_HALT) + BOOTTRACE_KERN("system halting..."); + if (howto & RB_POWEROFF) + BOOTTRACE_KERN("system powering off..."); + if (!(howto & (RB_HALT|RB_POWEROFF))) + BOOTTRACE_KERN("system rebooting..."); + } +} + /* * Shutdown the system cleanly to prepare for reboot, halt, or power off. */ @@ -428,6 +458,11 @@ { static int once = 0; + if (initproc != NULL && curproc != initproc) + BOOTTRACE_KERN("kernel shutdown (dirty) started"); + else + BOOTTRACE_KERN("kernel shutdown (clean) started"); + /* * Normal paths here don't hold Giant, but we can wind up here * unexpectedly with it held. Drop it now so we don't have to @@ -455,6 +490,7 @@ #endif /* We're in the process of rebooting. */ rebooting = 1; + reboottrace(howto); /* We are out of the debugger now. */ kdb_active = 0; @@ -463,13 +499,16 @@ * Do any callouts that should be done BEFORE syncing the filesystems. */ EVENTHANDLER_INVOKE(shutdown_pre_sync, howto); + BOOTTRACE_KERN("shutdown pre sync complete"); /* * Now sync filesystems */ if (!cold && (howto & RB_NOSYNC) == 0 && once == 0) { once = 1; + BOOTTRACE_KERN("bufshutdown begin"); bufshutdown(show_busybufs); + BOOTTRACE_KERN("bufshutdown end"); } print_uptime(); @@ -481,11 +520,17 @@ * been completed. */ EVENTHANDLER_INVOKE(shutdown_post_sync, howto); + BOOTTRACE_KERN("shutdown post sync complete"); if ((howto & (RB_HALT|RB_DUMP)) == RB_DUMP && !cold && !dumping) doadump(TRUE); /* Now that we're going to really halt the system... */ + BOOTTRACE_KERN("shutdown final begin"); + + if (shutdown_trace) + boottrace_dump_console(); + EVENTHANDLER_INVOKE(shutdown_final, howto); for(;;) ; /* safety against shutdown_reset not working */ Index: sys/kern/vfs_bio.c =================================================================== --- sys/kern/vfs_bio.c +++ sys/kern/vfs_bio.c @@ -52,9 +52,10 @@ #include #include #include +#include +#include #include #include -#include #include #include #include @@ -1441,9 +1442,11 @@ * Failed to sync all blocks. Indicate this and don't * unmount filesystems (thus forcing an fsck on reboot). */ + BOOTTRACE_KERN("shutdown failed to sync buffers"); printf("Giving up on %d buffers\n", nbusy); DELAY(5000000); /* 5 seconds */ } else { + BOOTTRACE_KERN("shutdown sync complete"); if (!first_buf_printf) printf("Final sync complete\n"); /* @@ -1451,6 +1454,7 @@ */ if (!KERNEL_PANICKED()) vfs_unmountall(); + BOOTTRACE_KERN("shutdown unmounted all filesystems"); } swapoff_all(); DELAY(100000); /* wait for console output to finish */