-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Lai Jiangshan
authored and
Ingo Molnar
committed
Mar 6, 2009
1 parent
546e535
commit 1427cdf
Showing
7 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* trace binary printk | ||
* | ||
* Copyright (C) 2008 Lai Jiangshan <laijs@cn.fujitsu.com> | ||
* | ||
*/ | ||
#include <linux/kernel.h> | ||
#include <linux/ftrace.h> | ||
#include <linux/string.h> | ||
#include <linux/ctype.h> | ||
#include <linux/list.h> | ||
#include <linux/mutex.h> | ||
#include <linux/slab.h> | ||
#include <linux/module.h> | ||
#include <linux/seq_file.h> | ||
#include <linux/fs.h> | ||
#include <linux/marker.h> | ||
#include <linux/uaccess.h> | ||
|
||
#include "trace.h" | ||
|
||
/* binary printk basic */ | ||
static DEFINE_MUTEX(btrace_mutex); | ||
static int btrace_metadata_count; | ||
|
||
static inline void lock_btrace(void) | ||
{ | ||
mutex_lock(&btrace_mutex); | ||
} | ||
|
||
static inline void unlock_btrace(void) | ||
{ | ||
mutex_unlock(&btrace_mutex); | ||
} | ||
|
||
static void get_btrace_metadata(void) | ||
{ | ||
lock_btrace(); | ||
btrace_metadata_count++; | ||
unlock_btrace(); | ||
} | ||
|
||
static void put_btrace_metadata(void) | ||
{ | ||
lock_btrace(); | ||
btrace_metadata_count--; | ||
unlock_btrace(); | ||
} | ||
|
||
/* events tracer */ | ||
int trace_bprintk_enable; | ||
|
||
static void start_bprintk_trace(struct trace_array *tr) | ||
{ | ||
get_btrace_metadata(); | ||
tracing_reset_online_cpus(tr); | ||
trace_bprintk_enable = 1; | ||
} | ||
|
||
static void stop_bprintk_trace(struct trace_array *tr) | ||
{ | ||
trace_bprintk_enable = 0; | ||
tracing_reset_online_cpus(tr); | ||
put_btrace_metadata(); | ||
} | ||
|
||
static int init_bprintk_trace(struct trace_array *tr) | ||
{ | ||
start_bprintk_trace(tr); | ||
return 0; | ||
} | ||
|
||
static struct tracer bprintk_trace __read_mostly = | ||
{ | ||
.name = "events", | ||
.init = init_bprintk_trace, | ||
.reset = stop_bprintk_trace, | ||
.start = start_bprintk_trace, | ||
.stop = stop_bprintk_trace, | ||
}; | ||
|
||
static __init int init_bprintk(void) | ||
{ | ||
return register_tracer(&bprintk_trace); | ||
} | ||
|
||
device_initcall(init_bprintk); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters