FreeBSD kernel kern code
|
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/boottrace.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/pcpu.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/sbuf.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <machine/stdarg.h>
Go to the source code of this file.
Data Structures | |
struct | bt_event |
struct | bt_table |
Macros | |
#define | dprintf(fmt, ...) |
#define | BT_TABLE_DEFSIZE 3000 |
#define | BT_TABLE_RUNSIZE 2000 |
#define | BT_TABLE_SHTSIZE 1000 |
#define | BT_TABLE_MINSIZE 500 |
#define | BTC_DELTA_PRINT(bte, msecs, delta) |
Functions | |
static | MALLOC_DEFINE (M_BOOTTRACE, "boottrace", "memory for boot tracing") |
TUNABLE_BOOL ("debug.boottrace.dotrace_debugging", &dotrace_debugging) | |
TUNABLE_BOOL ("kern.boottrace.dotrace_kernel", &dotrace_kernel) | |
TUNABLE_BOOL ("kern.boottrace.dotrace_user", &dotrace_user) | |
static int | sysctl_log (SYSCTL_HANDLER_ARGS) |
static int | sysctl_boottrace (SYSCTL_HANDLER_ARGS) |
static int | sysctl_runtrace (SYSCTL_HANDLER_ARGS) |
static int | sysctl_shuttrace (SYSCTL_HANDLER_ARGS) |
static int | sysctl_boottrace_reset (SYSCTL_HANDLER_ARGS) |
SYSCTL_NODE (_kern, OID_AUTO, boottrace, CTLFLAG_RD|CTLFLAG_MPSAFE, 0, "boottrace statistics") | |
SYSCTL_PROC (_kern_boottrace, OID_AUTO, log, CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_SKIP, 0, 0, sysctl_log, "A", "Print a log of the boottrace trace data") | |
SYSCTL_PROC (_kern_boottrace, OID_AUTO, boottrace, CTLTYPE_STRING|CTLFLAG_WR|CTLFLAG_MPSAFE, 0, 0, sysctl_boottrace, "A", "Capture a boot-time trace event") | |
SYSCTL_PROC (_kern_boottrace, OID_AUTO, runtrace, CTLTYPE_STRING|CTLFLAG_WR|CTLFLAG_MPSAFE, 0, 0, sysctl_runtrace, "A", "Capture a run-time trace event") | |
SYSCTL_PROC (_kern_boottrace, OID_AUTO, shuttrace, CTLTYPE_STRING|CTLFLAG_WR|CTLFLAG_MPSAFE, 0, 0, sysctl_shuttrace, "A", "Capture a shutdown-time trace event") | |
SYSCTL_PROC (_kern_boottrace, OID_AUTO, reset, CTLTYPE_INT|CTLFLAG_WR|CTLFLAG_MPSAFE, 0, 0, sysctl_boottrace_reset, "A", "Reset run-time tracing table") | |
SYSCTL_BOOL (_kern_boottrace, OID_AUTO, enabled, CTLFLAG_RDTUN, &boottrace_enabled, 0, "Boot-time and shutdown-time tracing enabled") | |
SYSCTL_BOOL (_kern_boottrace, OID_AUTO, shutdown_trace, CTLFLAG_RWTUN, &shutdown_trace, 0, "Enable kernel shutdown tracing to the console") | |
SYSCTL_INT (_kern_boottrace, OID_AUTO, shutdown_trace_threshold, CTLFLAG_RWTUN, &shutdown_trace_threshold, 0, "Tracing threshold (ms) below which tracing is ignored") | |
static void | boottrace_display (struct sbuf *sbp, struct bt_table *btp, uint64_t dthres) |
void | boottrace_dump_console (void) |
static int | dotrace (struct bt_table *btp, const char *eventname, const char *tdname) |
int | boottrace (const char *tdname, const char *fmt,...) |
static int | runtrace (const char *eventname, const char *tdname) |
static void | boottrace_parse_message (char *message, char **eventname, char **tdname) |
static int | _boottrace_sysctl (struct bt_table *btp, struct sysctl_oid *oidp, struct sysctl_req *req) |
void | boottrace_reset (const char *actor) |
int | boottrace_resize (u_int newsize) |
static void | boottrace_init (void) |
SYSINIT (boottrace, SI_SUB_CPU, SI_ORDER_ANY, boottrace_init, 0) | |
Variables | |
static struct bt_table | bt |
static struct bt_table | rt |
static struct bt_table | st |
static bool | bootdone |
static bool | shutdown |
static bool | dotrace_debugging |
static bool | dotrace_kernel = true |
static bool | dotrace_user = true |
bool __read_mostly | boottrace_enabled = false |
bool | shutdown_trace = false |
static int | shutdown_trace_threshold |
#define BT_TABLE_DEFSIZE 3000 |
Definition at line 50 of file kern_boottrace.c.
#define BT_TABLE_MINSIZE 500 |
Definition at line 53 of file kern_boottrace.c.
#define BT_TABLE_RUNSIZE 2000 |
Definition at line 51 of file kern_boottrace.c.
#define BT_TABLE_SHTSIZE 1000 |
Definition at line 52 of file kern_boottrace.c.
#define BTC_DELTA_PRINT | ( | bte, | |
msecs, | |||
delta | |||
) |
Definition at line 189 of file kern_boottrace.c.
#define dprintf | ( | fmt, | |
... | |||
) |
Definition at line 42 of file kern_boottrace.c.
|
static |
Definition at line 441 of file kern_boottrace.c.
References boottrace_parse_message(), dotrace(), dotrace_user, and sysctl_handle_string().
Referenced by sysctl_boottrace(), sysctl_runtrace(), and sysctl_shuttrace().
int boottrace | ( | const char * | tdname, |
const char * | fmt, | ||
... | |||
) |
Definition at line 383 of file kern_boottrace.c.
References bootdone, bt, dotrace(), dotrace_kernel, rebooting, rt, shutdown, st, and vsnprintf().
|
static |
Definition at line 211 of file kern_boottrace.c.
References BTC_DELTA_PRINT, cputick2usec(), bt_table::curr, maybe_yield(), printf(), sbuf_printf(), bt_table::size, bt_table::table, bt_event::tick, and bt_event::tsc.
Referenced by boottrace_dump_console(), and sysctl_log().
void boottrace_dump_console | ( | void | ) |
Definition at line 298 of file kern_boottrace.c.
References boottrace_display(), boottrace_enabled, bt, rebooting, rt, shutdown, shutdown_trace_threshold, and st.
Referenced by kern_reboot().
|
static |
Definition at line 582 of file kern_boottrace.c.
References boottrace_enabled, bt, BT_TABLE_DEFSIZE, BT_TABLE_MINSIZE, BT_TABLE_RUNSIZE, BT_TABLE_SHTSIZE, bt_event::cpuid, bt_table::curr, malloc(), bt_event::name, rt, bt_table::size, st, bt_table::table, bt_event::tdname, and bt_table::wrap.
|
static |
Definition at line 425 of file kern_boottrace.c.
Referenced by _boottrace_sysctl().
void boottrace_reset | ( | const char * | actor | ) |
Definition at line 539 of file kern_boottrace.c.
References runtrace(), and snprintf().
Referenced by boottrace_resize(), and sysctl_boottrace_reset().
int boottrace_resize | ( | u_int | newsize | ) |
Definition at line 552 of file kern_boottrace.c.
References boottrace_reset(), realloc(), rt, bt_table::size, and bt_table::table.
|
static |
Definition at line 318 of file kern_boottrace.c.
References boottrace_enabled, cpu_ticks, bt_event::cpuid, bt_event::cputime, bt_table::curr, dprintf, bt_table::drops_early, bt_table::drops_full, bt_event::inblock, kern_getrusage(), bt_event::name, bt_event::oublock, bt_event::pid, proc0, bt_table::size, bt_table::table, bt_event::tdname, bt_event::tick, ticks, bt_event::tsc, and bt_table::wrap.
Referenced by _boottrace_sysctl(), boottrace(), and runtrace().
|
static |
|
static |
Definition at line 409 of file kern_boottrace.c.
References bootdone, dotrace(), and rt.
Referenced by boottrace_reset().
SYSCTL_BOOL | ( | _kern_boottrace | , |
OID_AUTO | , | ||
enabled | , | ||
CTLFLAG_RDTUN | , | ||
& | boottrace_enabled, | ||
0 | , | ||
"Boot-time and shutdown-time tracing enabled" | |||
) |
SYSCTL_BOOL | ( | _kern_boottrace | , |
OID_AUTO | , | ||
shutdown_trace | , | ||
CTLFLAG_RWTUN | , | ||
& | shutdown_trace, | ||
0 | , | ||
"Enable kernel shutdown tracing to the console" | |||
) |
|
static |
Definition at line 485 of file kern_boottrace.c.
References _boottrace_sysctl(), bootdone, boottrace_enabled, bt, and rt.
|
static |
Definition at line 569 of file kern_boottrace.c.
References boottrace_enabled, and boottrace_reset().
SYSCTL_INT | ( | _kern_boottrace | , |
OID_AUTO | , | ||
shutdown_trace_threshold | , | ||
CTLFLAG_RWTUN | , | ||
& | shutdown_trace_threshold, | ||
0 | , | ||
"Tracing threshold (ms) below which tracing is ignored" | |||
) |
|
static |
Definition at line 466 of file kern_boottrace.c.
References boottrace_display(), boottrace_enabled, bt, rt, sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_len(), and sbuf_new().
SYSCTL_NODE | ( | _kern | , |
OID_AUTO | , | ||
boottrace | , | ||
CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"boottrace statistics" | |||
) |
SYSCTL_PROC | ( | _kern_boottrace | , |
OID_AUTO | , | ||
boottrace | , | ||
CTLTYPE_STRING|CTLFLAG_WR| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_boottrace | , | ||
"A" | , | ||
"Capture a boot-time trace event" | |||
) |
SYSCTL_PROC | ( | _kern_boottrace | , |
OID_AUTO | , | ||
log | , | ||
CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE| | CTLFLAG_SKIP, | ||
0 | , | ||
0 | , | ||
sysctl_log | , | ||
"A" | , | ||
"Print a log of the boottrace trace data" | |||
) |
SYSCTL_PROC | ( | _kern_boottrace | , |
OID_AUTO | , | ||
reset | , | ||
CTLTYPE_INT|CTLFLAG_WR| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_boottrace_reset | , | ||
"A" | , | ||
"Reset run-time tracing table" | |||
) |
SYSCTL_PROC | ( | _kern_boottrace | , |
OID_AUTO | , | ||
runtrace | , | ||
CTLTYPE_STRING|CTLFLAG_WR| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_runtrace | , | ||
"A" | , | ||
"Capture a run-time trace event" | |||
) |
SYSCTL_PROC | ( | _kern_boottrace | , |
OID_AUTO | , | ||
shuttrace | , | ||
CTLTYPE_STRING|CTLFLAG_WR| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_shuttrace | , | ||
"A" | , | ||
"Capture a shutdown-time trace event" | |||
) |
|
static |
Definition at line 503 of file kern_boottrace.c.
References _boottrace_sysctl(), bootdone, boottrace_enabled, and rt.
|
static |
Definition at line 521 of file kern_boottrace.c.
References _boottrace_sysctl(), boottrace_enabled, shutdown, and st.
SYSINIT | ( | boottrace | , |
SI_SUB_CPU | , | ||
SI_ORDER_ANY | , | ||
boottrace_init | , | ||
0 | |||
) |
TUNABLE_BOOL | ( | "debug.boottrace.dotrace_debugging" | , |
& | dotrace_debugging | ||
) |
TUNABLE_BOOL | ( | "kern.boottrace.dotrace_kernel" | , |
& | dotrace_kernel | ||
) |
TUNABLE_BOOL | ( | "kern.boottrace.dotrace_user" | , |
& | dotrace_user | ||
) |
|
static |
Definition at line 89 of file kern_boottrace.c.
Referenced by boottrace(), runtrace(), sysctl_boottrace(), and sysctl_runtrace().
bool __read_mostly boottrace_enabled = false |
Definition at line 139 of file kern_boottrace.c.
Referenced by boottrace_dump_console(), boottrace_init(), dotrace(), sysctl_boottrace(), sysctl_boottrace_reset(), sysctl_log(), sysctl_runtrace(), and sysctl_shuttrace().
|
static |
Definition at line 80 of file kern_boottrace.c.
Referenced by _bt_fill(), bintime(), bintime_add_tc_delta(), bintime_off(), binuptime(), boottrace(), boottrace_dump_console(), boottrace_init(), bt_alloc(), bt_free(), bt_freetrim(), bt_insbusy(), bt_insfree(), bt_insseg(), bt_insseg_tail(), bt_isfree(), bt_lookupbusy(), bt_rembusy(), bt_remfree(), bt_remseg(), cpu_new_callout(), dtrace_getnanouptime(), filt_timervalidate(), getbintime(), getbinuptime(), getmicrouptime(), getnanouptime(), init_va_filerev(), kqtimer_proc_continue(), lockstat_nsecs(), microtime(), microuptime(), nanotime(), nanouptime(), pps_event(), sysclock_getsnapshot(), sysclock_snap2bintime(), sysctl_boottrace(), sysctl_log(), tc_setclock(), tc_windup(), umtx_abs_timeout_getsbt(), unp_internalize(), uuid_time(), vmem_clip(), vmem_destroy1(), vmem_fit(), vmem_rehash(), vmem_try_release(), vmem_xalloc(), vmem_xalloc_nextfit(), and vmem_xfree().
|
static |
Definition at line 95 of file kern_boottrace.c.
|
static |
Definition at line 99 of file kern_boottrace.c.
Referenced by boottrace().
|
static |
Definition at line 103 of file kern_boottrace.c.
Referenced by _boottrace_sysctl().
|
static |
Definition at line 83 of file kern_boottrace.c.
Referenced by boottrace(), boottrace_dump_console(), boottrace_init(), boottrace_resize(), runtrace(), sysctl_boottrace(), sysctl_log(), and sysctl_runtrace().
|
static |
Definition at line 92 of file kern_boottrace.c.
Referenced by boottrace(), boottrace_dump_console(), and sysctl_shuttrace().
bool shutdown_trace = false |
Definition at line 147 of file kern_boottrace.c.
Referenced by kern_reboot().
|
static |
Definition at line 156 of file kern_boottrace.c.
Referenced by boottrace_dump_console().
|
static |
Definition at line 86 of file kern_boottrace.c.
Referenced by acct_process(), boottrace(), boottrace_dump_console(), boottrace_init(), calcru1(), eventfd_stat(), kdb_backtrace(), kdb_backtrace_thread(), kqueue_stat(), mqf_stat(), stack_create(), stack_destroy(), stack_print(), stack_print_ddb(), stack_print_short(), stack_put(), stack_sbuf_print(), stack_sbuf_print_flags(), stack_zero(), sysctl_kern_callout_stat(), sysctl_shuttrace(), and witness_debugger().