aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/trace/define_trace.h4
-rw-r--r--include/trace/ftrace.h (renamed from kernel/trace/trace_events_stage_3.h)215
-rw-r--r--include/trace/trace_events.h7
-rw-r--r--kernel/trace/Makefile1
-rw-r--r--kernel/trace/events.c15
-rw-r--r--kernel/trace/trace_events_stage_1.h39
-rw-r--r--kernel/trace/trace_events_stage_2.h170
7 files changed, 218 insertions, 233 deletions
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index de9dc7d8508b..980eb66a6e38 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -56,6 +56,10 @@
56 56
57#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 57#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
58 58
59#ifdef CONFIG_EVENT_TRACER
60#include <trace/ftrace.h>
61#endif
62
59#undef TRACE_HEADER_MULTI_READ 63#undef TRACE_HEADER_MULTI_READ
60 64
61/* Only undef what we defined in this file */ 65/* Only undef what we defined in this file */
diff --git a/kernel/trace/trace_events_stage_3.h b/include/trace/ftrace.h
index 45c04e1f38db..955b967acd74 100644
--- a/kernel/trace/trace_events_stage_3.h
+++ b/include/trace/ftrace.h
@@ -1,4 +1,217 @@
1/* 1/*
2 * Stage 1 of the trace events.
3 *
4 * Override the macros in <trace/trace_events.h> to include the following:
5 *
6 * struct ftrace_raw_<call> {
7 * struct trace_entry ent;
8 * <type> <item>;
9 * <type2> <item2>[<len>];
10 * [...]
11 * };
12 *
13 * The <type> <item> is created by the __field(type, item) macro or
14 * the __array(type2, item2, len) macro.
15 * We simply do "type item;", and that will create the fields
16 * in the structure.
17 */
18
19#include <linux/ftrace_event.h>
20
21#undef TRACE_FORMAT
22#define TRACE_FORMAT(call, proto, args, fmt)
23
24#undef __array
25#define __array(type, item, len) type item[len];
26
27#undef __field
28#define __field(type, item) type item;
29
30#undef TP_STRUCT__entry
31#define TP_STRUCT__entry(args...) args
32
33#undef TRACE_EVENT
34#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
35 struct ftrace_raw_##name { \
36 struct trace_entry ent; \
37 tstruct \
38 }; \
39 static struct ftrace_event_call event_##name
40
41#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
42
43/*
44 * Stage 2 of the trace events.
45 *
46 * Override the macros in <trace/trace_events.h> to include the following:
47 *
48 * enum print_line_t
49 * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags)
50 * {
51 * struct trace_seq *s = &iter->seq;
52 * struct ftrace_raw_<call> *field; <-- defined in stage 1
53 * struct trace_entry *entry;
54 * int ret;
55 *
56 * entry = iter->ent;
57 *
58 * if (entry->type != event_<call>.id) {
59 * WARN_ON_ONCE(1);
60 * return TRACE_TYPE_UNHANDLED;
61 * }
62 *
63 * field = (typeof(field))entry;
64 *
65 * ret = trace_seq_printf(s, <TP_printk> "\n");
66 * if (!ret)
67 * return TRACE_TYPE_PARTIAL_LINE;
68 *
69 * return TRACE_TYPE_HANDLED;
70 * }
71 *
72 * This is the method used to print the raw event to the trace
73 * output format. Note, this is not needed if the data is read
74 * in binary.
75 */
76
77#undef __entry
78#define __entry field
79
80#undef TP_printk
81#define TP_printk(fmt, args...) fmt "\n", args
82
83#undef TRACE_EVENT
84#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
85enum print_line_t \
86ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
87{ \
88 struct trace_seq *s = &iter->seq; \
89 struct ftrace_raw_##call *field; \
90 struct trace_entry *entry; \
91 int ret; \
92 \
93 entry = iter->ent; \
94 \
95 if (entry->type != event_##call.id) { \
96 WARN_ON_ONCE(1); \
97 return TRACE_TYPE_UNHANDLED; \
98 } \
99 \
100 field = (typeof(field))entry; \
101 \
102 ret = trace_seq_printf(s, #call ": " print); \
103 if (!ret) \
104 return TRACE_TYPE_PARTIAL_LINE; \
105 \
106 return TRACE_TYPE_HANDLED; \
107}
108
109#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
110
111/*
112 * Setup the showing format of trace point.
113 *
114 * int
115 * ftrace_format_##call(struct trace_seq *s)
116 * {
117 * struct ftrace_raw_##call field;
118 * int ret;
119 *
120 * ret = trace_seq_printf(s, #type " " #item ";"
121 * " offset:%u; size:%u;\n",
122 * offsetof(struct ftrace_raw_##call, item),
123 * sizeof(field.type));
124 *
125 * }
126 */
127
128#undef TP_STRUCT__entry
129#define TP_STRUCT__entry(args...) args
130
131#undef __field
132#define __field(type, item) \
133 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
134 "offset:%u;\tsize:%u;\n", \
135 (unsigned int)offsetof(typeof(field), item), \
136 (unsigned int)sizeof(field.item)); \
137 if (!ret) \
138 return 0;
139
140#undef __array
141#define __array(type, item, len) \
142 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
143 "offset:%u;\tsize:%u;\n", \
144 (unsigned int)offsetof(typeof(field), item), \
145 (unsigned int)sizeof(field.item)); \
146 if (!ret) \
147 return 0;
148
149#undef __entry
150#define __entry REC
151
152#undef TP_printk
153#define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
154
155#undef TP_fast_assign
156#define TP_fast_assign(args...) args
157
158#undef TRACE_EVENT
159#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
160static int \
161ftrace_format_##call(struct trace_seq *s) \
162{ \
163 struct ftrace_raw_##call field; \
164 int ret; \
165 \
166 tstruct; \
167 \
168 trace_seq_printf(s, "\nprint fmt: " print); \
169 \
170 return ret; \
171}
172
173#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
174
175#undef __field
176#define __field(type, item) \
177 ret = trace_define_field(event_call, #type, #item, \
178 offsetof(typeof(field), item), \
179 sizeof(field.item)); \
180 if (ret) \
181 return ret;
182
183#undef __array
184#define __array(type, item, len) \
185 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
186 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
187 offsetof(typeof(field), item), \
188 sizeof(field.item)); \
189 if (ret) \
190 return ret;
191
192#undef TRACE_EVENT
193#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
194int \
195ftrace_define_fields_##call(void) \
196{ \
197 struct ftrace_raw_##call field; \
198 struct ftrace_event_call *event_call = &event_##call; \
199 int ret; \
200 \
201 __common_field(unsigned char, type); \
202 __common_field(unsigned char, flags); \
203 __common_field(unsigned char, preempt_count); \
204 __common_field(int, pid); \
205 __common_field(int, tgid); \
206 \
207 tstruct; \
208 \
209 return ret; \
210}
211
212#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
213
214/*
2 * Stage 3 of the trace events. 215 * Stage 3 of the trace events.
3 * 216 *
4 * Override the macros in <trace/trace_events.h> to include the following: 217 * Override the macros in <trace/trace_events.h> to include the following:
@@ -272,7 +485,7 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
272 _TRACE_PROFILE_INIT(call) \ 485 _TRACE_PROFILE_INIT(call) \
273} 486}
274 487
275#include <trace/trace_events.h> 488#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
276 489
277#undef _TRACE_PROFILE 490#undef _TRACE_PROFILE
278#undef _TRACE_PROFILE_INIT 491#undef _TRACE_PROFILE_INIT
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
deleted file mode 100644
index 13d6b85668cf..000000000000
--- a/include/trace/trace_events.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/* trace/<type>.h here */
2
3#include <trace/sched.h>
4#include <trace/irq.h>
5#include <trace/lockdep.h>
6#include <trace/skb.h>
7#include <trace/kmem.h>
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index 3ad367e7c97f..fb9d7f964898 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -41,7 +41,6 @@ obj-$(CONFIG_KMEMTRACE) += kmemtrace.o
41obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o 41obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o
42obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o 42obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
43obj-$(CONFIG_EVENT_TRACING) += trace_events.o 43obj-$(CONFIG_EVENT_TRACING) += trace_events.o
44obj-$(CONFIG_EVENT_TRACER) += events.o
45obj-$(CONFIG_EVENT_TRACING) += trace_export.o 44obj-$(CONFIG_EVENT_TRACING) += trace_export.o
46obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o 45obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
47obj-$(CONFIG_EVENT_PROFILE) += trace_event_profile.o 46obj-$(CONFIG_EVENT_PROFILE) += trace_event_profile.o
diff --git a/kernel/trace/events.c b/kernel/trace/events.c
deleted file mode 100644
index 5a35a914f0e2..000000000000
--- a/kernel/trace/events.c
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * This is the place to register all trace points as events.
3 */
4
5#include <linux/stringify.h>
6
7#include <trace/trace_events.h>
8
9#include "trace_output.h"
10
11#define TRACE_HEADER_MULTI_READ
12#include "trace_events_stage_1.h"
13#include "trace_events_stage_2.h"
14#include "trace_events_stage_3.h"
15
diff --git a/kernel/trace/trace_events_stage_1.h b/kernel/trace/trace_events_stage_1.h
deleted file mode 100644
index 475f46a047ae..000000000000
--- a/kernel/trace/trace_events_stage_1.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Stage 1 of the trace events.
3 *
4 * Override the macros in <trace/trace_events.h> to include the following:
5 *
6 * struct ftrace_raw_<call> {
7 * struct trace_entry ent;
8 * <type> <item>;
9 * <type2> <item2>[<len>];
10 * [...]
11 * };
12 *
13 * The <type> <item> is created by the __field(type, item) macro or
14 * the __array(type2, item2, len) macro.
15 * We simply do "type item;", and that will create the fields
16 * in the structure.
17 */
18
19#undef TRACE_FORMAT
20#define TRACE_FORMAT(call, proto, args, fmt)
21
22#undef __array
23#define __array(type, item, len) type item[len];
24
25#undef __field
26#define __field(type, item) type item;
27
28#undef TP_STRUCT__entry
29#define TP_STRUCT__entry(args...) args
30
31#undef TRACE_EVENT
32#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
33 struct ftrace_raw_##name { \
34 struct trace_entry ent; \
35 tstruct \
36 }; \
37 static struct ftrace_event_call event_##name
38
39#include <trace/trace_events.h>
diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
deleted file mode 100644
index aa4a67a0656f..000000000000
--- a/kernel/trace/trace_events_stage_2.h
+++ /dev/null
@@ -1,170 +0,0 @@
1/*
2 * Stage 2 of the trace events.
3 *
4 * Override the macros in <trace/trace_events.h> to include the following:
5 *
6 * enum print_line_t
7 * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags)
8 * {
9 * struct trace_seq *s = &iter->seq;
10 * struct ftrace_raw_<call> *field; <-- defined in stage 1
11 * struct trace_entry *entry;
12 * int ret;
13 *
14 * entry = iter->ent;
15 *
16 * if (entry->type != event_<call>.id) {
17 * WARN_ON_ONCE(1);
18 * return TRACE_TYPE_UNHANDLED;
19 * }
20 *
21 * field = (typeof(field))entry;
22 *
23 * ret = trace_seq_printf(s, <TP_printk> "\n");
24 * if (!ret)
25 * return TRACE_TYPE_PARTIAL_LINE;
26 *
27 * return TRACE_TYPE_HANDLED;
28 * }
29 *
30 * This is the method used to print the raw event to the trace
31 * output format. Note, this is not needed if the data is read
32 * in binary.
33 */
34
35#undef __entry
36#define __entry field
37
38#undef TP_printk
39#define TP_printk(fmt, args...) fmt "\n", args
40
41#undef TRACE_EVENT
42#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
43enum print_line_t \
44ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
45{ \
46 struct trace_seq *s = &iter->seq; \
47 struct ftrace_raw_##call *field; \
48 struct trace_entry *entry; \
49 int ret; \
50 \
51 entry = iter->ent; \
52 \
53 if (entry->type != event_##call.id) { \
54 WARN_ON_ONCE(1); \
55 return TRACE_TYPE_UNHANDLED; \
56 } \
57 \
58 field = (typeof(field))entry; \
59 \
60 ret = trace_seq_printf(s, #call ": " print); \
61 if (!ret) \
62 return TRACE_TYPE_PARTIAL_LINE; \
63 \
64 return TRACE_TYPE_HANDLED; \
65}
66
67#include <trace/trace_events.h>
68
69/*
70 * Setup the showing format of trace point.
71 *
72 * int
73 * ftrace_format_##call(struct trace_seq *s)
74 * {
75 * struct ftrace_raw_##call field;
76 * int ret;
77 *
78 * ret = trace_seq_printf(s, #type " " #item ";"
79 * " offset:%u; size:%u;\n",
80 * offsetof(struct ftrace_raw_##call, item),
81 * sizeof(field.type));
82 *
83 * }
84 */
85
86#undef TP_STRUCT__entry
87#define TP_STRUCT__entry(args...) args
88
89#undef __field
90#define __field(type, item) \
91 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
92 "offset:%u;\tsize:%u;\n", \
93 (unsigned int)offsetof(typeof(field), item), \
94 (unsigned int)sizeof(field.item)); \
95 if (!ret) \
96 return 0;
97
98#undef __array
99#define __array(type, item, len) \
100 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
101 "offset:%u;\tsize:%u;\n", \
102 (unsigned int)offsetof(typeof(field), item), \
103 (unsigned int)sizeof(field.item)); \
104 if (!ret) \
105 return 0;
106
107#undef __entry
108#define __entry REC
109
110#undef TP_printk
111#define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
112
113#undef TP_fast_assign
114#define TP_fast_assign(args...) args
115
116#undef TRACE_EVENT
117#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
118static int \
119ftrace_format_##call(struct trace_seq *s) \
120{ \
121 struct ftrace_raw_##call field; \
122 int ret; \
123 \
124 tstruct; \
125 \
126 trace_seq_printf(s, "\nprint fmt: " print); \
127 \
128 return ret; \
129}
130
131#include <trace/trace_events.h>
132
133#undef __field
134#define __field(type, item) \
135 ret = trace_define_field(event_call, #type, #item, \
136 offsetof(typeof(field), item), \
137 sizeof(field.item)); \
138 if (ret) \
139 return ret;
140
141#undef __array
142#define __array(type, item, len) \
143 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
144 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
145 offsetof(typeof(field), item), \
146 sizeof(field.item)); \
147 if (ret) \
148 return ret;
149
150#undef TRACE_EVENT
151#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
152int \
153ftrace_define_fields_##call(void) \
154{ \
155 struct ftrace_raw_##call field; \
156 struct ftrace_event_call *event_call = &event_##call; \
157 int ret; \
158 \
159 __common_field(unsigned char, type); \
160 __common_field(unsigned char, flags); \
161 __common_field(unsigned char, preempt_count); \
162 __common_field(int, pid); \
163 __common_field(int, tgid); \
164 \
165 tstruct; \
166 \
167 return ret; \
168}
169
170#include <trace/trace_events.h>