FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_kdb.h"
#include "opt_panic.h"
#include "opt_sched.h"
#include "opt_watchdog.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/conf.h>
#include <sys/cons.h>
#include <sys/eventhandler.h>
#include <sys/jail.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/kerneldump.h>
#include <sys/kthread.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <sys/sysproto.h>
#include <sys/vnode.h>
#include <sys/watchdog.h>
#include <ddb/ddb.h>
#include <machine/cpu.h>
#include <machine/pcb.h>
#include <machine/smp.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_pager.h>
#include <vm/swap_pager.h>
#include <sys/signalvar.h>
#include <machine/stdarg.h>
Go to the source code of this file.
Macros | |
#define | PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ |
#define | POWEROFF_DELAY 5000 |
Functions | |
__FBSDID ("$BSDSUniX$") | |
SYSCTL_INT (_kern, OID_AUTO, panic_reboot_wait_time, CTLFLAG_RW|CTLFLAG_TUN,&panic_reboot_wait_time, 0,"Seconds to wait before rebooting after a panic") | |
TUNABLE_INT ("kern.panic_reboot_wait_time",&panic_reboot_wait_time) | |
SYSCTL_INT (_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW|CTLFLAG_TUN,&sync_on_panic, 0,"Do a sync before rebooting from a panic") | |
TUNABLE_INT ("kern.sync_on_panic",&sync_on_panic) | |
SYSCTL_INT (_kern, OID_AUTO, stop_scheduler_on_panic, CTLFLAG_RW|CTLFLAG_TUN,&stop_scheduler_on_panic, 0,"stop scheduler upon entering panic") | |
TUNABLE_INT ("kern.stop_scheduler_on_panic",&stop_scheduler_on_panic) | |
static | SYSCTL_NODE (_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0,"Shutdown environment") |
SYSCTL_INT (_kern_shutdown, OID_AUTO, show_busybufs, CTLFLAG_RW,&show_busybufs, 0,"") | |
static void | poweroff_wait (void *, int) |
static void | shutdown_halt (void *junk, int howto) |
static void | shutdown_panic (void *junk, int howto) |
static void | shutdown_reset (void *junk, int howto) |
static void | shutdown_conf (void *unused) |
SYSINIT (shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL) | |
int | sys_reboot (struct thread *td, struct reboot_args *uap) |
void | shutdown_nice (int howto) |
static void | print_uptime (void) |
int | doadump (boolean_t textdump) |
static int | isbufbusy (struct buf *bp) |
void | kern_reboot (int howto) |
void | panic (const char *fmt,...) |
SYSCTL_INT (_kern_shutdown, OID_AUTO, poweroff_delay, CTLFLAG_RW,&poweroff_delay, 0,"") | |
SYSCTL_INT (_kern_shutdown, OID_AUTO, kproc_shutdown_wait, CTLFLAG_RW,&kproc_shutdown_wait, 0,"") | |
void | kproc_shutdown (void *arg, int howto) |
void | kthread_shutdown (void *arg, int howto) |
int | set_dumper (struct dumperinfo *di) |
int | dump_write (struct dumperinfo *di, void *virtual, vm_offset_t physical, off_t offset, size_t length) |
void | mkdumpheader (struct kerneldumpheader *kdh, char *magic, uint32_t archver, uint64_t dumplen, uint32_t blksz) |
Variables | |
static int | panic_reboot_wait_time = PANIC_REBOOT_WAIT_TIME |
static int | sync_on_panic = 0 |
static int | stop_scheduler_on_panic = 1 |
static int | show_busybufs |
const char * | panicstr |
int | dumping |
int | rebooting |
static struct dumperinfo | dumper |
static struct pcb | dumppcb |
lwpid_t | dumptid |
static int | shutdown_howto = 0 |
static int | waittime = -1 |
static int | poweroff_delay = POWEROFF_DELAY |
static int | kproc_shutdown_wait = 60 |
#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ |
Definition at line 88 of file kern_shutdown.c.
#define POWEROFF_DELAY 5000 |
Definition at line 653 of file kern_shutdown.c.
__FBSDID | ( | "$BSDSUniX$" | ) |
int doadump | ( | boolean_t | textdump | ) |
Definition at line 256 of file kern_shutdown.c.
References coredump(), dumper, dumping, dumppcb, and dumptid.
Referenced by kern_reboot().
int dump_write | ( | struct dumperinfo * | di, |
void * | virtual, | ||
vm_offset_t | physical, | ||
off_t | offset, | ||
size_t | length | ||
) |
Definition at line 737 of file kern_shutdown.c.
References printf().
|
static |
Definition at line 284 of file kern_shutdown.c.
Referenced by kern_reboot().
void kern_reboot | ( | int | howto | ) |
Definition at line 297 of file kern_shutdown.c.
References buf, cngrab(), doadump(), dumping, isbufbusy(), kdb_active, mi_switch(), mountlist, nbuf, panicstr, print_uptime(), printf(), rebooting, sched_bind(), show_busybufs, shutdown_howto, sys_sync(), vfs_unmountall(), vn_printf(), and waittime.
Referenced by panic(), shutdown_nice(), sys_reboot(), and vfs_mountroot_parse().
void kproc_shutdown | ( | void * | arg, |
int | howto | ||
) |
Definition at line 681 of file kern_shutdown.c.
References hz, kproc_shutdown_wait, kproc_suspend(), panicstr, and printf().
Referenced by buf_daemon(), syncer_shutdown(), and vnlru_proc().
void kthread_shutdown | ( | void * | arg, |
int | howto | ||
) |
Definition at line 701 of file kern_shutdown.c.
References hz, kproc_shutdown_wait, kthread_suspend(), panicstr, and printf().
void mkdumpheader | ( | struct kerneldumpheader * | kdh, |
char * | magic, | ||
uint32_t | archver, | ||
uint64_t | dumplen, | ||
uint32_t | blksz | ||
) |
Definition at line 753 of file kern_shutdown.c.
References panicstr, prison0, and time_second.
void panic | ( | const char * | fmt, |
... | |||
) |
Definition at line 557 of file kern_shutdown.c.
References all_cpus, buf, cngrab(), critical_enter(), critical_exit(), kdb_active, kdb_backtrace(), kdb_enter(), kern_reboot(), panicstr, printf(), stop_scheduler_on_panic, sync_on_panic, vprintf(), and vsnprintf().
Referenced by __lockmgr_args(), __stack_chk_fail(), _bus_dmamap_load_ccb(), _callout_stop_safe(), _fdrop(), _mtx_lock_spin_failed(), _rw_downgrade(), _sx_downgrade(), acl_posix1e_acl_to_mode(), aio_daemon(), aio_proc_rundown(), aio_swake_cb(), allocbuf(), assert_lockmgr(), blst_leaf_free(), blst_meta_alloc(), blst_meta_fill(), blst_meta_free(), bp_unmapped_get_kva(), bqrelse(), brelse(), brelvp(), bufbdflush(), bufdone_finish(), bufobj_invalbuf(), bus_set_pass(), busdma_bufalloc_alloc_uncacheable(), busdma_bufalloc_findzone(), calc_remaining(), clone_create(), cluster_rbuild(), cluster_wbuild_gb(), config_intrhook_disestablish(), copyinfrom(), copyinstrfrom(), core_output(), cpu_initclocks_bsp(), cpuset_init(), create_init(), devclass_delete_device(), device_busy(), device_probe_child(), device_unbusy(), domain_init(), enroll(), exec_unregister(), exit1(), fail_point_eval_nontrivial(), filt_mqdetach(), filt_usertouch(), free(), getblk(), getnewbuf_reuse_bp(), idle_setup(), intr_event_describe_handler(), intr_event_remove_handler(), ithread_create(), itimers_event_hook_exit(), itismychild(), kdb_panic(), kdb_switch(), kdb_sysctl_panic(), kern_getsockopt(), kern_mknodat(), kern_msgctl(), kern_msgrcv(), kern_msgsnd(), kern_posix_fallocate(), kern_setsockopt(), kobj_class_compile(), kproc_create(), kproc_start(), kthread_add(), kthread_start(), kthread_suspend_check(), lf_clearlock(), lf_findoverlap(), link_elf_init(), link_elf_link_preload(), link_elf_load_file(), link_elf_reloc_local(), linker_preload(), lock_lockmgr(), lock_rm(), lock_spin(), lookup(), m_pulldown(), make_dev_alias_v(), make_dev_credv(), malloc_init(), mb_ctor_clust(), mb_reserve(), modlist_newmodule(), module_register_init(), module_release(), mqfs_allocv(), mqfs_create(), mqfs_readdir(), msg_freehdr(), msginit(), null_fetch_syscall_args(), null_set_syscall_retval(), proc_fini(), propagate_priority(), reassignbuf(), relocate_file(), relookup(), resource_list_add(), resource_list_delete(), resource_list_free(), resource_list_release(), resource_list_reserve(), resource_list_unreserve(), rman_adjust_resource(), rman_init(), root_setup_intr(), sbappendaddr_locked(), sbappendcontrol_locked(), sbdrop_internal(), sbflush_internal(), sbsndptr(), selrecord(), semexit_myhook(), set_rootvnode(), setrunnable(), sleepq_catch_signals(), sleepq_switch(), softclock_call_cc(), soopt_mcopyin(), soupcall_clear(), soupcall_set(), start_init(), start_softclock(), start_softintr(), sys_semop(), sysctl_ctx_free(), sysctl_register_oid(), sysinit_add(), tdsendsignal(), thread_dtor(), thread_exit(), timeout(), ttydevsw_deffree(), ttydevsw_defoutwakeup(), uipc_attach(), uipc_rcvd(), uipc_send(), umtx_pi_setowner(), unlock_lockmgr(), unlock_spin(), unp_connect2(), unp_init(), unp_pcblist(), ureadc(), vdropl(), vfs_allocate_syncvnode(), vfs_domount_first(), vfs_mount_destroy(), vfs_mountroot_parse(), vfs_unbusy_pages(), vget(), vgonel(), vn_finished_secondary_write(), vn_finished_write(), vop_panic(), vop_stdfsync(), vputx(), witness_assert(), witness_checkorder(), witness_destroy(), witness_downgrade(), witness_init(), witness_restore(), witness_save(), witness_setflag(), witness_thread_exit(), witness_unlock(), witness_upgrade(), and witness_warn().
|
static |
Definition at line 661 of file kern_shutdown.c.
References poweroff_delay.
Referenced by shutdown_conf().
|
static |
Definition at line 229 of file kern_shutdown.c.
References getnanouptime(), and printf().
Referenced by kern_reboot().
int set_dumper | ( | struct dumperinfo * | di | ) |
Definition at line 722 of file kern_shutdown.c.
References dumper.
|
static |
Definition at line 166 of file kern_shutdown.c.
References poweroff_wait(), shutdown_halt(), shutdown_panic(), and shutdown_reset().
|
static |
Definition at line 467 of file kern_shutdown.c.
References cngetc(), and printf().
Referenced by shutdown_conf().
void shutdown_nice | ( | int | howto | ) |
Definition at line 210 of file kern_shutdown.c.
References initproc, kern_psignal(), kern_reboot(), and shutdown_howto.
Referenced by kdb_reboot().
|
static |
Definition at line 490 of file kern_shutdown.c.
References cncheckc(), cngetc(), panic_reboot_wait_time, and printf().
Referenced by shutdown_conf().
|
static |
Definition at line 523 of file kern_shutdown.c.
References printf().
Referenced by shutdown_conf().
int sys_reboot | ( | struct thread * | td, |
struct reboot_args * | uap | ||
) |
Definition at line 186 of file kern_shutdown.c.
References Giant, kern_reboot(), and priv_check().
SYSCTL_INT | ( | _kern | , |
OID_AUTO | , | ||
panic_reboot_wait_time | , | ||
CTLFLAG_RW| | CTLFLAG_TUN, | ||
& | panic_reboot_wait_time, | ||
0 | , | ||
"Seconds to wait before rebooting after a panic" | |||
) |
SYSCTL_INT | ( | _kern | , |
OID_AUTO | , | ||
sync_on_panic | , | ||
CTLFLAG_RW| | CTLFLAG_TUN, | ||
& | sync_on_panic, | ||
0 | , | ||
"Do a sync before rebooting from a panic" | |||
) |
SYSCTL_INT | ( | _kern | , |
OID_AUTO | , | ||
stop_scheduler_on_panic | , | ||
CTLFLAG_RW| | CTLFLAG_TUN, | ||
& | stop_scheduler_on_panic, | ||
0 | , | ||
"stop scheduler upon entering panic" | |||
) |
SYSCTL_INT | ( | _kern_shutdown | , |
OID_AUTO | , | ||
show_busybufs | , | ||
CTLFLAG_RW | , | ||
& | show_busybufs, | ||
0 | , | ||
"" | |||
) |
SYSCTL_INT | ( | _kern_shutdown | , |
OID_AUTO | , | ||
poweroff_delay | , | ||
CTLFLAG_RW | , | ||
& | poweroff_delay, | ||
0 | , | ||
"" | |||
) |
SYSCTL_INT | ( | _kern_shutdown | , |
OID_AUTO | , | ||
kproc_shutdown_wait | , | ||
CTLFLAG_RW | , | ||
& | kproc_shutdown_wait, | ||
0 | , | ||
"" | |||
) |
|
static |
SYSINIT | ( | shutdown_conf | , |
SI_SUB_INTRINSIC | , | ||
SI_ORDER_ANY | , | ||
shutdown_conf | , | ||
NULL | |||
) |
TUNABLE_INT | ( | "kern.panic_reboot_wait_time" | , |
& | panic_reboot_wait_time | ||
) |
TUNABLE_INT | ( | "kern.sync_on_panic" | , |
& | sync_on_panic | ||
) |
TUNABLE_INT | ( | "kern.stop_scheduler_on_panic" | , |
& | stop_scheduler_on_panic | ||
) |
|
static |
Definition at line 153 of file kern_shutdown.c.
Referenced by doadump(), and set_dumper().
int dumping |
Definition at line 151 of file kern_shutdown.c.
Referenced by doadump(), and kern_reboot().
|
static |
Definition at line 156 of file kern_shutdown.c.
Referenced by doadump().
lwpid_t dumptid |
Definition at line 157 of file kern_shutdown.c.
Referenced by doadump().
|
static |
Definition at line 676 of file kern_shutdown.c.
Referenced by kproc_shutdown(), and kthread_shutdown().
|
static |
Definition at line 90 of file kern_shutdown.c.
Referenced by shutdown_panic().
const char* panicstr |
Definition at line 149 of file kern_shutdown.c.
Referenced by __lockmgr_args(), _cv_timedwait(), _cv_timedwait_sig(), _cv_wait(), _cv_wait_sig(), _cv_wait_unlock(), _thread_lock_flags(), choosethread(), enroll(), kern_reboot(), kproc_shutdown(), kthread_shutdown(), ktr_tracepoint(), maybe_preempt(), mi_switch(), mkdumpheader(), panic(), putbuf(), putchar(), sched_setpreempt(), vop_strategy_pre(), vprintf(), witness_assert(), witness_checkorder(), witness_defineorder(), witness_downgrade(), witness_init(), witness_lock(), witness_restore(), witness_save(), witness_setflag(), witness_thread_exit(), witness_unlock(), witness_upgrade(), and witness_warn().
|
static |
Definition at line 655 of file kern_shutdown.c.
Referenced by poweroff_wait().
int rebooting |
Definition at line 152 of file kern_shutdown.c.
Referenced by exit1(), and kern_reboot().
|
static |
Definition at line 138 of file kern_shutdown.c.
Referenced by kern_reboot().
|
static |
Definition at line 207 of file kern_shutdown.c.
Referenced by kern_reboot(), and shutdown_nice().
|
static |
Definition at line 129 of file kern_shutdown.c.
Referenced by panic().
|
static |
Definition at line 124 of file kern_shutdown.c.
Referenced by panic().
|
static |
Definition at line 226 of file kern_shutdown.c.
Referenced by __lockmgr_args(), _mtx_lock_sleep(), _mtx_trylock(), _rw_rlock(), _rw_wlock_hard(), _sx_slock_hard(), _sx_xlock_hard(), and kern_reboot().