FreeBSD kernel kern code
kern_ktr.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_ktr.h"
#include "opt_alq.h"
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/alq.h>
#include <sys/cons.h>
#include <sys/cpuset.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/libkern.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/time.h>
#include <machine/cpu.h>
Include dependency graph for kern_ktr.c:

Go to the source code of this file.

Macros

#define KTR_ENTRIES   1024
 
#define KTR_MASK   (0)
 
#define KTR_TIME   get_cyclecount()
 
#define KTR_CPU   PCPU_GET(cpuid)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 FEATURE (ktr,"Kernel support for KTR kernel tracing facility")
 
static SYSCTL_NODE (_debug, OID_AUTO, ktr, CTLFLAG_RD, 0,"KTR options")
 
 TUNABLE_INT ("debug.ktr.mask",&ktr_mask)
 
 SYSCTL_INT (_debug_ktr, OID_AUTO, mask, CTLFLAG_RW,&ktr_mask, 0,"Bitmask of KTR event classes for which logging is enabled")
 
 SYSCTL_INT (_debug_ktr, OID_AUTO, compile, CTLFLAG_RD,&ktr_compile, 0,"Bitmask of KTR event classes compiled into the kernel")
 
 SYSCTL_INT (_debug_ktr, OID_AUTO, entries, CTLFLAG_RD,&ktr_entries, 0,"Number of entries in the KTR buffer")
 
 SYSCTL_INT (_debug_ktr, OID_AUTO, version, CTLFLAG_RD,&ktr_version, 0,"Version of the KTR interface")
 
 TUNABLE_STR ("debug.ktr.cpumask", ktr_cpumask_str, sizeof(ktr_cpumask_str))
 
static void ktr_cpumask_initializer (void *dummy __unused)
 
 SYSINIT (ktr_cpumask_initializer, SI_SUB_TUNABLES, SI_ORDER_ANY, ktr_cpumask_initializer, NULL)
 
static int sysctl_debug_ktr_cpumask (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_debug_ktr, OID_AUTO, cpumask, CTLFLAG_RW|CTLFLAG_MPSAFE|CTLTYPE_STRING, NULL, 0, sysctl_debug_ktr_cpumask,"S","Bitmask of CPUs on which KTR logging is enabled")
 
static int sysctl_debug_ktr_clear (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_debug_ktr, OID_AUTO, clear, CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_debug_ktr_clear,"I","Clear KTR Buffer")
 
void ktr_tracepoint (u_int mask, const char *file, int line, const char *format, u_long arg1, u_long arg2, u_long arg3, u_long arg4, u_long arg5, u_long arg6)
 

Variables

int ktr_mask = KTR_MASK
 
int ktr_compile = KTR_COMPILE
 
int ktr_entries = KTR_ENTRIES
 
int ktr_version = KTR_VERSION
 
cpuset_t ktr_cpumask
 
static char ktr_cpumask_str [CPUSETBUFSIZ]
 
volatile int ktr_idx = 0
 
struct ktr_entry ktr_buf [KTR_ENTRIES]
 

Macro Definition Documentation

#define KTR_CPU   PCPU_GET(cpuid)

Definition at line 75 of file kern_ktr.c.

Referenced by ktr_tracepoint().

#define KTR_ENTRIES   1024

Definition at line 63 of file kern_ktr.c.

Referenced by ktr_tracepoint().

#define KTR_MASK   (0)

Definition at line 67 of file kern_ktr.c.

#define KTR_TIME   get_cyclecount()

Definition at line 71 of file kern_ktr.c.

Referenced by ktr_tracepoint().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
FEATURE ( ktr  ,
"Kernel support for KTR kernel tracing facility  
)
static void ktr_cpumask_initializer ( void *dummy  __unused)
static

Definition at line 104 of file kern_ktr.c.

References cpusetobj_strscan(), ktr_cpumask, and ktr_cpumask_str.

Here is the call graph for this function:

void ktr_tracepoint ( u_int  mask,
const char *  file,
int  line,
const char *  format,
u_long  arg1,
u_long  arg2,
u_long  arg3,
u_long  arg4,
u_long  arg5,
u_long  arg6 
)

Definition at line 235 of file kern_ktr.c.

References alq_get(), ktr_buf, KTR_CPU, ktr_cpumask, KTR_ENTRIES, ktr_idx, ktr_mask, KTR_TIME, panicstr, and printf().

Here is the call graph for this function:

static int sysctl_debug_ktr_clear ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 151 of file kern_ktr.c.

References ktr_buf, and sysctl_handle_int().

Here is the call graph for this function:

static int sysctl_debug_ktr_cpumask ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 125 of file kern_ktr.c.

References cpusetobj_strprint(), cpusetobj_strscan(), ktr_cpumask, and sysctl_handle_string().

Here is the call graph for this function:

SYSCTL_INT ( _debug_ktr  ,
OID_AUTO  ,
mask  ,
CTLFLAG_RW  ,
ktr_mask,
,
"Bitmask of KTR event classes for which logging is enabled"   
)
SYSCTL_INT ( _debug_ktr  ,
OID_AUTO  ,
compile  ,
CTLFLAG_RD  ,
ktr_compile,
,
"Bitmask of KTR event classes compiled into the kernel"   
)
SYSCTL_INT ( _debug_ktr  ,
OID_AUTO  ,
entries  ,
CTLFLAG_RD  ,
ktr_entries,
,
"Number of entries in the KTR buffer"   
)
SYSCTL_INT ( _debug_ktr  ,
OID_AUTO  ,
version  ,
CTLFLAG_RD  ,
ktr_version,
,
"Version of the KTR interface"   
)
static SYSCTL_NODE ( _debug  ,
OID_AUTO  ,
ktr  ,
CTLFLAG_RD  ,
,
"KTR options"   
)
static
SYSCTL_PROC ( _debug_ktr  ,
OID_AUTO  ,
cpumask  ,
CTLFLAG_RW|CTLFLAG_MPSAFE|  CTLTYPE_STRING,
NULL  ,
,
sysctl_debug_ktr_cpumask  ,
"S"  ,
"Bitmask of CPUs on which KTR logging is enabled"   
)
SYSCTL_PROC ( _debug_ktr  ,
OID_AUTO  ,
clear  ,
CTLTYPE_INT|  CTLFLAG_RW,
,
,
sysctl_debug_ktr_clear  ,
"I"  ,
"Clear KTR Buffer"   
)
SYSINIT ( ktr_cpumask_initializer  ,
SI_SUB_TUNABLES  ,
SI_ORDER_ANY  ,
ktr_cpumask_initializer  ,
NULL   
)
TUNABLE_INT ( "debug.ktr.mask"  ,
ktr_mask 
)
TUNABLE_STR ( "debug.ktr.cpumask"  ,
ktr_cpumask_str  ,
sizeof(ktr_cpumask_str  
)

Variable Documentation

struct ktr_entry ktr_buf[KTR_ENTRIES]

Definition at line 148 of file kern_ktr.c.

Referenced by ktr_tracepoint(), and sysctl_debug_ktr_clear().

int ktr_compile = KTR_COMPILE

Definition at line 87 of file kern_ktr.c.

cpuset_t ktr_cpumask

Definition at line 99 of file kern_ktr.c.

Referenced by ktr_cpumask_initializer(), ktr_tracepoint(), and sysctl_debug_ktr_cpumask().

char ktr_cpumask_str[CPUSETBUFSIZ]
static

Definition at line 100 of file kern_ktr.c.

Referenced by ktr_cpumask_initializer().

int ktr_entries = KTR_ENTRIES

Definition at line 91 of file kern_ktr.c.

volatile int ktr_idx = 0

Definition at line 147 of file kern_ktr.c.

Referenced by ktr_tracepoint().

int ktr_mask = KTR_MASK

Definition at line 82 of file kern_ktr.c.

Referenced by ktr_tracepoint().

int ktr_version = KTR_VERSION

Definition at line 95 of file kern_ktr.c.