blob: 1f8e532c3fb971d5c13da9473735009bf32ff344 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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);
|