diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2009-03-06 11:21:47 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-06 11:59:11 -0500 |
commit | 1427cdf0592368bdec57276edaf714040ee8744f (patch) | |
tree | 4b214ee49643db383328cf53a31959eb0627a167 /kernel/trace/trace_bprintk.c | |
parent | 546e5354a6e4ec760ac03ef1148e9a4762abb5f5 (diff) |
tracing: infrastructure for supporting binary record
Impact: save on memory for tracing
Current tracers are typically using a struct(like struct ftrace_entry,
struct ctx_switch_entry, struct special_entr etc...)to record a binary
event. These structs can only record a their own kind of events.
A new kind of tracer need a new struct and a lot of code too handle it.
So we need a generic binary record for events. This infrastructure
is for this purpose.
[fweisbec@gmail.com: rebase against latest -tip, make it safe while sched
tracing as reported by Steven Rostedt]
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1236356510-8381-3-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_bprintk.c')
-rw-r--r-- | kernel/trace/trace_bprintk.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/kernel/trace/trace_bprintk.c b/kernel/trace/trace_bprintk.c new file mode 100644 index 000000000000..1f8e532c3fb9 --- /dev/null +++ b/kernel/trace/trace_bprintk.c | |||
@@ -0,0 +1,87 @@ | |||
1 | /* | ||
2 | * trace binary printk | ||
3 | * | ||
4 | * Copyright (C) 2008 Lai Jiangshan <laijs@cn.fujitsu.com> | ||
5 | * | ||
6 | */ | ||
7 | #include <linux/kernel.h> | ||
8 | #include <linux/ftrace.h> | ||
9 | #include <linux/string.h> | ||
10 | #include <linux/ctype.h> | ||
11 | #include <linux/list.h> | ||
12 | #include <linux/mutex.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/seq_file.h> | ||
16 | #include <linux/fs.h> | ||
17 | #include <linux/marker.h> | ||
18 | #include <linux/uaccess.h> | ||
19 | |||
20 | #include "trace.h" | ||
21 | |||
22 | /* binary printk basic */ | ||
23 | static DEFINE_MUTEX(btrace_mutex); | ||
24 | static int btrace_metadata_count; | ||
25 | |||
26 | static inline void lock_btrace(void) | ||
27 | { | ||
28 | mutex_lock(&btrace_mutex); | ||
29 | } | ||
30 | |||
31 | static inline void unlock_btrace(void) | ||
32 | { | ||
33 | mutex_unlock(&btrace_mutex); | ||
34 | } | ||
35 | |||
36 | static void get_btrace_metadata(void) | ||
37 | { | ||
38 | lock_btrace(); | ||
39 | btrace_metadata_count++; | ||
40 | unlock_btrace(); | ||
41 | } | ||
42 | |||
43 | static void put_btrace_metadata(void) | ||
44 | { | ||
45 | lock_btrace(); | ||
46 | btrace_metadata_count--; | ||
47 | unlock_btrace(); | ||
48 | } | ||
49 | |||
50 | /* events tracer */ | ||
51 | int trace_bprintk_enable; | ||
52 | |||
53 | static void start_bprintk_trace(struct trace_array *tr) | ||
54 | { | ||
55 | get_btrace_metadata(); | ||
56 | tracing_reset_online_cpus(tr); | ||
57 | trace_bprintk_enable = 1; | ||
58 | } | ||
59 | |||
60 | static void stop_bprintk_trace(struct trace_array *tr) | ||
61 | { | ||
62 | trace_bprintk_enable = 0; | ||
63 | tracing_reset_online_cpus(tr); | ||
64 | put_btrace_metadata(); | ||
65 | } | ||
66 | |||
67 | static int init_bprintk_trace(struct trace_array *tr) | ||
68 | { | ||
69 | start_bprintk_trace(tr); | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | static struct tracer bprintk_trace __read_mostly = | ||
74 | { | ||
75 | .name = "events", | ||
76 | .init = init_bprintk_trace, | ||
77 | .reset = stop_bprintk_trace, | ||
78 | .start = start_bprintk_trace, | ||
79 | .stop = stop_bprintk_trace, | ||
80 | }; | ||
81 | |||
82 | static __init int init_bprintk(void) | ||
83 | { | ||
84 | return register_tracer(&bprintk_trace); | ||
85 | } | ||
86 | |||
87 | device_initcall(init_bprintk); | ||