aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-03-06 05:40:37 -0500
committerIngo Molnar <mingo@elte.hu>2009-03-06 05:40:37 -0500
commitbc722f508a5bcbb65a7bb0c7ce8e3934f5763a1a (patch)
treed6494e409a671669614e7a08a5328e8def277225
parent16097439703bcd38e9fe5608c12add6dacb825ea (diff)
parent770cb24345c0f6e0d47bd2b94aa6d67bea6f8b54 (diff)
Merge branch 'tip/tracing/ftrace' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/ftrace
-rw-r--r--include/linux/kernel.h29
-rw-r--r--include/linux/ring_buffer.h15
-rw-r--r--kernel/trace/Makefile1
-rw-r--r--kernel/trace/ftrace.c10
-rw-r--r--kernel/trace/ring_buffer.c2
-rw-r--r--kernel/trace/trace.c24
-rw-r--r--kernel/trace/trace_event_types.h165
-rw-r--r--kernel/trace/trace_events.c12
-rw-r--r--kernel/trace/trace_events_stage_2.h53
-rw-r--r--kernel/trace/trace_export.c81
-rw-r--r--kernel/trace/trace_format.h55
-rw-r--r--kernel/trace/trace_sysprof.c2
12 files changed, 357 insertions, 92 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 08bf5da86676..d4614a8a034b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -369,8 +369,35 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
369 369
370/* 370/*
371 * General tracing related utility functions - trace_printk(), 371 * General tracing related utility functions - trace_printk(),
372 * tracing_start()/tracing_stop: 372 * tracing_on/tracing_off and tracing_start()/tracing_stop
373 *
374 * Use tracing_on/tracing_off when you want to quickly turn on or off
375 * tracing. It simply enables or disables the recording of the trace events.
376 * This also corresponds to the user space debugfs/tracing/tracing_on
377 * file, which gives a means for the kernel and userspace to interact.
378 * Place a tracing_off() in the kernel where you want tracing to end.
379 * From user space, examine the trace, and then echo 1 > tracing_on
380 * to continue tracing.
381 *
382 * tracing_stop/tracing_start has slightly more overhead. It is used
383 * by things like suspend to ram where disabling the recording of the
384 * trace is not enough, but tracing must actually stop because things
385 * like calling smp_processor_id() may crash the system.
386 *
387 * Most likely, you want to use tracing_on/tracing_off.
373 */ 388 */
389#ifdef CONFIG_RING_BUFFER
390void tracing_on(void);
391void tracing_off(void);
392/* trace_off_permanent stops recording with no way to bring it back */
393void tracing_off_permanent(void);
394int tracing_is_on(void);
395#else
396static inline void tracing_on(void) { }
397static inline void tracing_off(void) { }
398static inline void tracing_off_permanent(void) { }
399static inline int tracing_is_on(void) { return 0; }
400#endif
374#ifdef CONFIG_TRACING 401#ifdef CONFIG_TRACING
375extern void tracing_start(void); 402extern void tracing_start(void);
376extern void tracing_stop(void); 403extern void tracing_stop(void);
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 79fcbc4b09d6..b1a0068a5557 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -124,21 +124,6 @@ void ring_buffer_normalize_time_stamp(int cpu, u64 *ts);
124size_t ring_buffer_page_len(void *page); 124size_t ring_buffer_page_len(void *page);
125 125
126 126
127/*
128 * The below functions are fine to use outside the tracing facility.
129 */
130#ifdef CONFIG_RING_BUFFER
131void tracing_on(void);
132void tracing_off(void);
133void tracing_off_permanent(void);
134int tracing_is_on(void);
135#else
136static inline void tracing_on(void) { }
137static inline void tracing_off(void) { }
138static inline void tracing_off_permanent(void) { }
139static inline int tracing_is_on(void) { return 0; }
140#endif
141
142void *ring_buffer_alloc_read_page(struct ring_buffer *buffer); 127void *ring_buffer_alloc_read_page(struct ring_buffer *buffer);
143void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data); 128void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data);
144int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page, 129int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page,
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index c931fe0560cb..f44736c7574a 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -41,5 +41,6 @@ obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o
41obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o 41obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
42obj-$(CONFIG_EVENT_TRACER) += trace_events.o 42obj-$(CONFIG_EVENT_TRACER) += trace_events.o
43obj-$(CONFIG_EVENT_TRACER) += events.o 43obj-$(CONFIG_EVENT_TRACER) += events.o
44obj-$(CONFIG_EVENT_TRACER) += trace_export.o
44 45
45libftrace-y := ftrace.o 46libftrace-y := ftrace.o
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 5a3a06b21eee..d7a06a0d9447 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1869,21 +1869,21 @@ ftrace_notrace_release(struct inode *inode, struct file *file)
1869 return ftrace_regex_release(inode, file, 0); 1869 return ftrace_regex_release(inode, file, 0);
1870} 1870}
1871 1871
1872static struct file_operations ftrace_avail_fops = { 1872static const struct file_operations ftrace_avail_fops = {
1873 .open = ftrace_avail_open, 1873 .open = ftrace_avail_open,
1874 .read = seq_read, 1874 .read = seq_read,
1875 .llseek = seq_lseek, 1875 .llseek = seq_lseek,
1876 .release = ftrace_avail_release, 1876 .release = ftrace_avail_release,
1877}; 1877};
1878 1878
1879static struct file_operations ftrace_failures_fops = { 1879static const struct file_operations ftrace_failures_fops = {
1880 .open = ftrace_failures_open, 1880 .open = ftrace_failures_open,
1881 .read = seq_read, 1881 .read = seq_read,
1882 .llseek = seq_lseek, 1882 .llseek = seq_lseek,
1883 .release = ftrace_avail_release, 1883 .release = ftrace_avail_release,
1884}; 1884};
1885 1885
1886static struct file_operations ftrace_filter_fops = { 1886static const struct file_operations ftrace_filter_fops = {
1887 .open = ftrace_filter_open, 1887 .open = ftrace_filter_open,
1888 .read = ftrace_regex_read, 1888 .read = ftrace_regex_read,
1889 .write = ftrace_filter_write, 1889 .write = ftrace_filter_write,
@@ -1891,7 +1891,7 @@ static struct file_operations ftrace_filter_fops = {
1891 .release = ftrace_filter_release, 1891 .release = ftrace_filter_release,
1892}; 1892};
1893 1893
1894static struct file_operations ftrace_notrace_fops = { 1894static const struct file_operations ftrace_notrace_fops = {
1895 .open = ftrace_notrace_open, 1895 .open = ftrace_notrace_open,
1896 .read = ftrace_regex_read, 1896 .read = ftrace_regex_read,
1897 .write = ftrace_notrace_write, 1897 .write = ftrace_notrace_write,
@@ -2423,7 +2423,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
2423 return cnt; 2423 return cnt;
2424} 2424}
2425 2425
2426static struct file_operations ftrace_pid_fops = { 2426static const struct file_operations ftrace_pid_fops = {
2427 .read = ftrace_pid_read, 2427 .read = ftrace_pid_read,
2428 .write = ftrace_pid_write, 2428 .write = ftrace_pid_write,
2429}; 2429};
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index f7473645b9c6..178858492a89 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2606,7 +2606,7 @@ rb_simple_write(struct file *filp, const char __user *ubuf,
2606 return cnt; 2606 return cnt;
2607} 2607}
2608 2608
2609static struct file_operations rb_simple_fops = { 2609static const struct file_operations rb_simple_fops = {
2610 .open = tracing_open_generic, 2610 .open = tracing_open_generic,
2611 .read = rb_simple_read, 2611 .read = rb_simple_read,
2612 .write = rb_simple_write, 2612 .write = rb_simple_write,
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c0e9c1263393..e6144acf2b75 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1882,14 +1882,14 @@ static int show_traces_open(struct inode *inode, struct file *file)
1882 return ret; 1882 return ret;
1883} 1883}
1884 1884
1885static struct file_operations tracing_fops = { 1885static const struct file_operations tracing_fops = {
1886 .open = tracing_open, 1886 .open = tracing_open,
1887 .read = seq_read, 1887 .read = seq_read,
1888 .llseek = seq_lseek, 1888 .llseek = seq_lseek,
1889 .release = tracing_release, 1889 .release = tracing_release,
1890}; 1890};
1891 1891
1892static struct file_operations show_traces_fops = { 1892static const struct file_operations show_traces_fops = {
1893 .open = show_traces_open, 1893 .open = show_traces_open,
1894 .read = seq_read, 1894 .read = seq_read,
1895 .release = seq_release, 1895 .release = seq_release,
@@ -1982,7 +1982,7 @@ err_unlock:
1982 return err; 1982 return err;
1983} 1983}
1984 1984
1985static struct file_operations tracing_cpumask_fops = { 1985static const struct file_operations tracing_cpumask_fops = {
1986 .open = tracing_open_generic, 1986 .open = tracing_open_generic,
1987 .read = tracing_cpumask_read, 1987 .read = tracing_cpumask_read,
1988 .write = tracing_cpumask_write, 1988 .write = tracing_cpumask_write,
@@ -2134,7 +2134,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
2134 return cnt; 2134 return cnt;
2135} 2135}
2136 2136
2137static struct file_operations tracing_iter_fops = { 2137static const struct file_operations tracing_iter_fops = {
2138 .open = tracing_open_generic, 2138 .open = tracing_open_generic,
2139 .read = tracing_trace_options_read, 2139 .read = tracing_trace_options_read,
2140 .write = tracing_trace_options_write, 2140 .write = tracing_trace_options_write,
@@ -2167,7 +2167,7 @@ tracing_readme_read(struct file *filp, char __user *ubuf,
2167 readme_msg, strlen(readme_msg)); 2167 readme_msg, strlen(readme_msg));
2168} 2168}
2169 2169
2170static struct file_operations tracing_readme_fops = { 2170static const struct file_operations tracing_readme_fops = {
2171 .open = tracing_open_generic, 2171 .open = tracing_open_generic,
2172 .read = tracing_readme_read, 2172 .read = tracing_readme_read,
2173}; 2173};
@@ -2927,25 +2927,25 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
2927 return cnt; 2927 return cnt;
2928} 2928}
2929 2929
2930static struct file_operations tracing_max_lat_fops = { 2930static const struct file_operations tracing_max_lat_fops = {
2931 .open = tracing_open_generic, 2931 .open = tracing_open_generic,
2932 .read = tracing_max_lat_read, 2932 .read = tracing_max_lat_read,
2933 .write = tracing_max_lat_write, 2933 .write = tracing_max_lat_write,
2934}; 2934};
2935 2935
2936static struct file_operations tracing_ctrl_fops = { 2936static const struct file_operations tracing_ctrl_fops = {
2937 .open = tracing_open_generic, 2937 .open = tracing_open_generic,
2938 .read = tracing_ctrl_read, 2938 .read = tracing_ctrl_read,
2939 .write = tracing_ctrl_write, 2939 .write = tracing_ctrl_write,
2940}; 2940};
2941 2941
2942static struct file_operations set_tracer_fops = { 2942static const struct file_operations set_tracer_fops = {
2943 .open = tracing_open_generic, 2943 .open = tracing_open_generic,
2944 .read = tracing_set_trace_read, 2944 .read = tracing_set_trace_read,
2945 .write = tracing_set_trace_write, 2945 .write = tracing_set_trace_write,
2946}; 2946};
2947 2947
2948static struct file_operations tracing_pipe_fops = { 2948static const struct file_operations tracing_pipe_fops = {
2949 .open = tracing_open_pipe, 2949 .open = tracing_open_pipe,
2950 .poll = tracing_poll_pipe, 2950 .poll = tracing_poll_pipe,
2951 .read = tracing_read_pipe, 2951 .read = tracing_read_pipe,
@@ -2953,13 +2953,13 @@ static struct file_operations tracing_pipe_fops = {
2953 .release = tracing_release_pipe, 2953 .release = tracing_release_pipe,
2954}; 2954};
2955 2955
2956static struct file_operations tracing_entries_fops = { 2956static const struct file_operations tracing_entries_fops = {
2957 .open = tracing_open_generic, 2957 .open = tracing_open_generic,
2958 .read = tracing_entries_read, 2958 .read = tracing_entries_read,
2959 .write = tracing_entries_write, 2959 .write = tracing_entries_write,
2960}; 2960};
2961 2961
2962static struct file_operations tracing_mark_fops = { 2962static const struct file_operations tracing_mark_fops = {
2963 .open = tracing_open_generic, 2963 .open = tracing_open_generic,
2964 .write = tracing_mark_write, 2964 .write = tracing_mark_write,
2965}; 2965};
@@ -3240,7 +3240,7 @@ tracing_read_dyn_info(struct file *filp, char __user *ubuf,
3240 return r; 3240 return r;
3241} 3241}
3242 3242
3243static struct file_operations tracing_dyn_info_fops = { 3243static const struct file_operations tracing_dyn_info_fops = {
3244 .open = tracing_open_generic, 3244 .open = tracing_open_generic,
3245 .read = tracing_read_dyn_info, 3245 .read = tracing_read_dyn_info,
3246}; 3246};
diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
new file mode 100644
index 000000000000..fb4eba166433
--- /dev/null
+++ b/kernel/trace/trace_event_types.h
@@ -0,0 +1,165 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM ftrace
3
4/*
5 * We cheat and use the proto type field as the ID
6 * and args as the entry type (minus 'struct')
7 */
8TRACE_EVENT_FORMAT(function, TRACE_FN, ftrace_entry, ignore,
9 TRACE_STRUCT(
10 TRACE_FIELD(unsigned long, ip, ip)
11 TRACE_FIELD(unsigned long, parent_ip, parent_ip)
12 ),
13 TPRAWFMT(" %lx <-- %lx")
14);
15
16TRACE_EVENT_FORMAT(funcgraph_entry, TRACE_GRAPH_ENT,
17 ftrace_graph_ent_entry, ignore,
18 TRACE_STRUCT(
19 TRACE_FIELD(unsigned long, graph_ent.func, func)
20 TRACE_FIELD(int, graph_ent.depth, depth)
21 ),
22 TPRAWFMT("--> %lx (%d)")
23);
24
25TRACE_EVENT_FORMAT(funcgraph_exit, TRACE_GRAPH_RET,
26 ftrace_graph_ret_entry, ignore,
27 TRACE_STRUCT(
28 TRACE_FIELD(unsigned long, ret.func, func)
29 TRACE_FIELD(int, ret.depth, depth)
30 ),
31 TPRAWFMT("<-- %lx (%d)")
32);
33
34TRACE_EVENT_FORMAT(wakeup, TRACE_WAKE, ctx_switch_entry, ignore,
35 TRACE_STRUCT(
36 TRACE_FIELD(unsigned int, prev_pid, prev_pid)
37 TRACE_FIELD(unsigned char, prev_prio, prev_prio)
38 TRACE_FIELD(unsigned char, prev_state, prev_state)
39 TRACE_FIELD(unsigned int, next_pid, next_pid)
40 TRACE_FIELD(unsigned char, next_prio, next_prio)
41 TRACE_FIELD(unsigned char, next_state, next_state)
42 TRACE_FIELD(unsigned int, next_cpu, next_cpu)
43 ),
44 TPRAWFMT("%u:%u:%u ==+ %u:%u:%u [%03u]")
45);
46
47TRACE_EVENT_FORMAT(context_switch, TRACE_CTX, ctx_switch_entry, ignore,
48 TRACE_STRUCT(
49 TRACE_FIELD(unsigned int, prev_pid, prev_pid)
50 TRACE_FIELD(unsigned char, prev_prio, prev_prio)
51 TRACE_FIELD(unsigned char, prev_state, prev_state)
52 TRACE_FIELD(unsigned int, next_pid, next_pid)
53 TRACE_FIELD(unsigned char, next_prio, next_prio)
54 TRACE_FIELD(unsigned char, next_state, next_state)
55 TRACE_FIELD(unsigned int, next_cpu, next_cpu)
56 ),
57 TPRAWFMT("%u:%u:%u ==+ %u:%u:%u [%03u]")
58);
59
60TRACE_EVENT_FORMAT(special, TRACE_SPECIAL, special_entry, ignore,
61 TRACE_STRUCT(
62 TRACE_FIELD(unsigned long, arg1, arg1)
63 TRACE_FIELD(unsigned long, arg2, arg2)
64 TRACE_FIELD(unsigned long, arg3, arg3)
65 ),
66 TPRAWFMT("(%08lx) (%08lx) (%08lx)")
67);
68
69/*
70 * Stack-trace entry:
71 */
72
73/* #define FTRACE_STACK_ENTRIES 8 */
74
75TRACE_EVENT_FORMAT(kernel_stack, TRACE_STACK, stack_entry, ignore,
76 TRACE_STRUCT(
77 TRACE_FIELD(unsigned long, caller[0], stack0)
78 TRACE_FIELD(unsigned long, caller[1], stack1)
79 TRACE_FIELD(unsigned long, caller[2], stack2)
80 TRACE_FIELD(unsigned long, caller[3], stack3)
81 TRACE_FIELD(unsigned long, caller[4], stack4)
82 TRACE_FIELD(unsigned long, caller[5], stack5)
83 TRACE_FIELD(unsigned long, caller[6], stack6)
84 TRACE_FIELD(unsigned long, caller[7], stack7)
85 ),
86 TPRAWFMT("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
87 "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n")
88);
89
90TRACE_EVENT_FORMAT(user_stack, TRACE_USER_STACK, userstack_entry, ignore,
91 TRACE_STRUCT(
92 TRACE_FIELD(unsigned long, caller[0], stack0)
93 TRACE_FIELD(unsigned long, caller[1], stack1)
94 TRACE_FIELD(unsigned long, caller[2], stack2)
95 TRACE_FIELD(unsigned long, caller[3], stack3)
96 TRACE_FIELD(unsigned long, caller[4], stack4)
97 TRACE_FIELD(unsigned long, caller[5], stack5)
98 TRACE_FIELD(unsigned long, caller[6], stack6)
99 TRACE_FIELD(unsigned long, caller[7], stack7)
100 ),
101 TPRAWFMT("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
102 "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n")
103);
104
105TRACE_EVENT_FORMAT(print, TRACE_PRINT, print_entry, ignore,
106 TRACE_STRUCT(
107 TRACE_FIELD(unsigned long, ip, ip)
108 TRACE_FIELD(unsigned int, depth, depth)
109 TRACE_FIELD_ZERO_CHAR(buf)
110 ),
111 TPRAWFMT("%08lx (%d) %s")
112);
113
114TRACE_EVENT_FORMAT(branch, TRACE_BRANCH, trace_branch, ignore,
115 TRACE_STRUCT(
116 TRACE_FIELD(unsigned int, line, line)
117 TRACE_FIELD_SPECIAL(char func[TRACE_FUNC_SIZE+1], func, func)
118 TRACE_FIELD_SPECIAL(char file[TRACE_FUNC_SIZE+1], file, file)
119 TRACE_FIELD(char, correct, correct)
120 ),
121 TPRAWFMT("%u:%s:%s (%u)")
122);
123
124TRACE_EVENT_FORMAT(hw_branch, TRACE_HW_BRANCHES, hw_branch_entry, ignore,
125 TRACE_STRUCT(
126 TRACE_FIELD(u64, from, from)
127 TRACE_FIELD(u64, to, to)
128 ),
129 TPRAWFMT("from: %llx to: %llx")
130);
131
132TRACE_EVENT_FORMAT(power, TRACE_POWER, trace_power, ignore,
133 TRACE_STRUCT(
134 TRACE_FIELD(ktime_t, state_data.stamp, stamp)
135 TRACE_FIELD(ktime_t, state_data.end, end)
136 TRACE_FIELD(int, state_data.type, type)
137 TRACE_FIELD(int, state_data.state, state)
138 ),
139 TPRAWFMT("%llx->%llx type:%u state:%u")
140);
141
142TRACE_EVENT_FORMAT(kmem_alloc, TRACE_KMEM_ALLOC, kmemtrace_alloc_entry, ignore,
143 TRACE_STRUCT(
144 TRACE_FIELD(enum kmemtrace_type_id, type_id, type_id)
145 TRACE_FIELD(unsigned long, call_site, call_site)
146 TRACE_FIELD(const void *, ptr, ptr)
147 TRACE_FIELD(size_t, bytes_req, bytes_req)
148 TRACE_FIELD(size_t, bytes_alloc, bytes_alloc)
149 TRACE_FIELD(gfp_t, gfp_flags, gfp_flags)
150 TRACE_FIELD(int, node, node)
151 ),
152 TPRAWFMT("type:%u call_site:%lx ptr:%p req:%lu alloc:%lu"
153 " flags:%x node:%d")
154);
155
156TRACE_EVENT_FORMAT(kmem_free, TRACE_KMEM_FREE, kmemtrace_free_entry, ignore,
157 TRACE_STRUCT(
158 TRACE_FIELD(enum kmemtrace_type_id, type_id, type_id)
159 TRACE_FIELD(unsigned long, call_site, call_site)
160 TRACE_FIELD(const void *, ptr, ptr)
161 ),
162 TPRAWFMT("type:%u call_site:%lx ptr:%p")
163);
164
165#undef TRACE_SYSTEM
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 210e71ff82db..4488d90e75ef 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -656,11 +656,13 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
656 return -1; 656 return -1;
657 } 657 }
658 658
659 entry = debugfs_create_file("enable", 0644, call->dir, call, 659 if (call->regfunc) {
660 &ftrace_enable_fops); 660 entry = debugfs_create_file("enable", 0644, call->dir, call,
661 if (!entry) 661 &ftrace_enable_fops);
662 pr_warning("Could not create debugfs " 662 if (!entry)
663 "'%s/enable' entry\n", call->name); 663 pr_warning("Could not create debugfs "
664 "'%s/enable' entry\n", call->name);
665 }
664 666
665 /* Only let type be writable, if we can change it */ 667 /* Only let type be writable, if we can change it */
666 entry = debugfs_create_file("type", 668 entry = debugfs_create_file("type",
diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
index b1cebba1d9b4..d24a97e74aea 100644
--- a/kernel/trace/trace_events_stage_2.h
+++ b/kernel/trace/trace_events_stage_2.h
@@ -75,56 +75,5 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
75 75
76#include <trace/trace_event_types.h> 76#include <trace/trace_event_types.h>
77 77
78/* 78#include "trace_format.h"
79 * Setup the showing format of trace point.
80 *
81 * int
82 * ftrace_format_##call(struct trace_seq *s)
83 * {
84 * struct ftrace_raw_##call field;
85 * int ret;
86 *
87 * ret = trace_seq_printf(s, #type " " #item ";"
88 * " size:%d; offset:%d;\n",
89 * sizeof(field.type),
90 * offsetof(struct ftrace_raw_##call,
91 * item));
92 *
93 * }
94 */
95
96#undef TRACE_FIELD
97#define TRACE_FIELD(type, item, assign) \
98 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
99 "offset:%lu;\tsize:%lu;\n", \
100 offsetof(typeof(field), item), \
101 sizeof(field.item)); \
102 if (!ret) \
103 return 0;
104
105
106#undef TRACE_FIELD_SPECIAL
107#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
108 ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \
109 "offset:%lu;\tsize:%lu;\n", \
110 offsetof(typeof(field), item), \
111 sizeof(field.item)); \
112 if (!ret) \
113 return 0;
114
115#undef TRACE_EVENT_FORMAT
116#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
117int \
118ftrace_format_##call(struct trace_seq *s) \
119{ \
120 struct ftrace_raw_##call field; \
121 int ret; \
122 \
123 tstruct; \
124 \
125 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
126 \
127 return ret; \
128}
129
130#include <trace/trace_event_types.h> 79#include <trace/trace_event_types.h>
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
new file mode 100644
index 000000000000..0fb7be73e31c
--- /dev/null
+++ b/kernel/trace/trace_export.c
@@ -0,0 +1,81 @@
1/*
2 * trace_export.c - export basic ftrace utilities to user space
3 *
4 * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com>
5 */
6#include <linux/stringify.h>
7#include <linux/kallsyms.h>
8#include <linux/seq_file.h>
9#include <linux/debugfs.h>
10#include <linux/uaccess.h>
11#include <linux/ftrace.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/fs.h>
15
16#include "trace_output.h"
17
18#include "trace_format.h"
19
20#undef TRACE_FIELD_ZERO_CHAR
21#define TRACE_FIELD_ZERO_CHAR(item) \
22 ret = trace_seq_printf(s, "\tfield: char " #item ";\t" \
23 "offset:%lu;\tsize:0;\n", \
24 offsetof(typeof(field), item)); \
25 if (!ret) \
26 return 0;
27
28
29#undef TPRAWFMT
30#define TPRAWFMT(args...) args
31
32#undef TRACE_EVENT_FORMAT
33#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
34static int \
35ftrace_format_##call(struct trace_seq *s) \
36{ \
37 struct args field; \
38 int ret; \
39 \
40 tstruct; \
41 \
42 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
43 \
44 return ret; \
45}
46
47#include "trace_event_types.h"
48
49#undef TRACE_ZERO_CHAR
50#define TRACE_ZERO_CHAR(arg)
51
52#undef TRACE_FIELD
53#define TRACE_FIELD(type, item, assign)\
54 entry->item = assign;
55
56#undef TRACE_FIELD
57#define TRACE_FIELD(type, item, assign)\
58 entry->item = assign;
59
60#undef TPCMD
61#define TPCMD(cmd...) cmd
62
63#undef TRACE_ENTRY
64#define TRACE_ENTRY entry
65
66#undef TRACE_FIELD_SPECIAL
67#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
68 cmd;
69
70#undef TRACE_EVENT_FORMAT
71#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
72 \
73static struct ftrace_event_call __used \
74__attribute__((__aligned__(4))) \
75__attribute__((section("_ftrace_events"))) event_##call = { \
76 .name = #call, \
77 .id = proto, \
78 .system = __stringify(TRACE_SYSTEM), \
79 .show_format = ftrace_format_##call, \
80}
81#include "trace_event_types.h"
diff --git a/kernel/trace/trace_format.h b/kernel/trace/trace_format.h
new file mode 100644
index 000000000000..03f9a4c165ca
--- /dev/null
+++ b/kernel/trace/trace_format.h
@@ -0,0 +1,55 @@
1/*
2 * Setup the showing format of trace point.
3 *
4 * int
5 * ftrace_format_##call(struct trace_seq *s)
6 * {
7 * struct ftrace_raw_##call field;
8 * int ret;
9 *
10 * ret = trace_seq_printf(s, #type " " #item ";"
11 * " size:%d; offset:%d;\n",
12 * sizeof(field.type),
13 * offsetof(struct ftrace_raw_##call,
14 * item));
15 *
16 * }
17 */
18
19#undef TRACE_STRUCT
20#define TRACE_STRUCT(args...) args
21
22#undef TRACE_FIELD
23#define TRACE_FIELD(type, item, assign) \
24 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
25 "offset:%lu;\tsize:%lu;\n", \
26 offsetof(typeof(field), item), \
27 sizeof(field.item)); \
28 if (!ret) \
29 return 0;
30
31
32#undef TRACE_FIELD_SPECIAL
33#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
34 ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \
35 "offset:%lu;\tsize:%lu;\n", \
36 offsetof(typeof(field), item), \
37 sizeof(field.item)); \
38 if (!ret) \
39 return 0;
40
41#undef TRACE_EVENT_FORMAT
42#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
43static int \
44ftrace_format_##call(struct trace_seq *s) \
45{ \
46 struct ftrace_raw_##call field; \
47 int ret; \
48 \
49 tstruct; \
50 \
51 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
52 \
53 return ret; \
54}
55
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c
index c771af4e8f1a..91fd19c2149f 100644
--- a/kernel/trace/trace_sysprof.c
+++ b/kernel/trace/trace_sysprof.c
@@ -314,7 +314,7 @@ sysprof_sample_write(struct file *filp, const char __user *ubuf,
314 return cnt; 314 return cnt;
315} 315}
316 316
317static struct file_operations sysprof_sample_fops = { 317static const struct file_operations sysprof_sample_fops = {
318 .read = sysprof_sample_read, 318 .read = sysprof_sample_read,
319 .write = sysprof_sample_write, 319 .write = sysprof_sample_write,
320}; 320};