diff options
author | attilio <attilio@FreeBSD.org> | 2013-02-03 20:13:33 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2013-02-03 20:13:33 +0000 |
commit | 0d3b58aee00948d85d75a9d3d222deb454afc98e (patch) | |
tree | 865d112b57519913a8de64b2d9ca8787633c95a2 /sys/kern/kern_ktr.c | |
parent | 561dd1163dbb481d204da7a526739ac6e43d08f2 (diff) | |
parent | 2d2c37fb592dfc24f15e4bf14c2f109b5d4b5a83 (diff) | |
download | FreeBSD-src-0d3b58aee00948d85d75a9d3d222deb454afc98e.zip FreeBSD-src-0d3b58aee00948d85d75a9d3d222deb454afc98e.tar.gz |
MFC
Diffstat (limited to 'sys/kern/kern_ktr.c')
-rw-r--r-- | sys/kern/kern_ktr.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index a83cedf..5b9d7aa 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -66,6 +66,10 @@ __FBSDID("$FreeBSD$"); #include <ddb/db_output.h> #endif +#ifndef KTR_BOOT_ENTRIES +#define KTR_BOOT_ENTRIES 1024 +#endif + #ifndef KTR_ENTRIES #define KTR_ENTRIES 1024 #endif @@ -96,9 +100,9 @@ FEATURE(ktr, "Kernel support for KTR kernel tracing facility"); volatile int ktr_idx = 0; int ktr_mask = KTR_MASK; int ktr_compile = KTR_COMPILE; -int ktr_entries = KTR_ENTRIES; +int ktr_entries = KTR_BOOT_ENTRIES; int ktr_version = KTR_VERSION; -struct ktr_entry ktr_buf_init[KTR_ENTRIES]; +struct ktr_entry ktr_buf_init[KTR_BOOT_ENTRIES]; struct ktr_entry *ktr_buf = ktr_buf_init; cpuset_t ktr_cpumask = CPUSET_T_INITIALIZER(KTR_CPUMASK); static char ktr_cpumask_str[CPUSETBUFSIZ]; @@ -194,6 +198,28 @@ SYSCTL_PROC(_debug_ktr, OID_AUTO, mask, CTLTYPE_UINT|CTLFLAG_RW, 0, 0, sysctl_debug_ktr_mask, "IU", "Bitmask of KTR event classes for which logging is enabled"); +#if KTR_ENTRIES != KTR_BOOT_ENTRIES +/* + * A simplified version of sysctl_debug_ktr_entries. + * No need to care about SMP, scheduling, etc. + */ +static void +ktr_entries_initializer(void *dummy __unused) +{ + int mask; + + /* Temporarily disable ktr in case malloc() is being traced. */ + mask = ktr_mask; + ktr_mask = 0; + ktr_buf = malloc(sizeof(*ktr_buf) * KTR_ENTRIES, M_KTR, + M_WAITOK | M_ZERO); + ktr_entries = KTR_ENTRIES; + ktr_mask = mask; +} +SYSINIT(ktr_entries_initializer, SI_SUB_KMEM, SI_ORDER_ANY, + ktr_entries_initializer, NULL); +#endif + static int sysctl_debug_ktr_entries(SYSCTL_HANDLER_ARGS) { |