diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-08-19 03:54:32 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-19 09:02:24 -0400 |
commit | e647d6b314266adb904d4b84973eda0afa856946 (patch) | |
tree | e4f18b57d37a25910b3d19b6c2461f87db0084a3 | |
parent | 14be96c9716cb8c46dca94bd890defd7856e0734 (diff) |
tracing/events: Add trace_define_common_fields()
Extract duplicate code. Also prepare for the later patch.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4A8BAFB8.1010304@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/linux/ftrace_event.h | 8 | ||||
-rw-r--r-- | include/trace/ftrace.h | 8 | ||||
-rw-r--r-- | kernel/trace/trace_events.c | 22 | ||||
-rw-r--r-- | kernel/trace/trace_export.c | 8 |
4 files changed, 29 insertions, 17 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 35b3a4a5ba86..427cbae47f84 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
@@ -142,6 +142,7 @@ extern int filter_current_check_discard(struct ftrace_event_call *call, | |||
142 | 142 | ||
143 | extern int trace_define_field(struct ftrace_event_call *call, char *type, | 143 | extern int trace_define_field(struct ftrace_event_call *call, char *type, |
144 | char *name, int offset, int size, int is_signed); | 144 | char *name, int offset, int size, int is_signed); |
145 | extern int trace_define_common_fields(struct ftrace_event_call *call); | ||
145 | 146 | ||
146 | #define is_signed_type(type) (((type)(-1)) < 0) | 147 | #define is_signed_type(type) (((type)(-1)) < 0) |
147 | 148 | ||
@@ -166,11 +167,4 @@ do { \ | |||
166 | __trace_printk(ip, fmt, ##args); \ | 167 | __trace_printk(ip, fmt, ##args); \ |
167 | } while (0) | 168 | } while (0) |
168 | 169 | ||
169 | #define __common_field(type, item, is_signed) \ | ||
170 | ret = trace_define_field(event_call, #type, "common_" #item, \ | ||
171 | offsetof(typeof(field.ent), item), \ | ||
172 | sizeof(field.ent.item), is_signed); \ | ||
173 | if (ret) \ | ||
174 | return ret; | ||
175 | |||
176 | #endif /* _LINUX_FTRACE_EVENT_H */ | 170 | #endif /* _LINUX_FTRACE_EVENT_H */ |
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 4e81c9b37515..127400255e4c 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -299,11 +299,9 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ | |||
299 | struct ftrace_raw_##call field; \ | 299 | struct ftrace_raw_##call field; \ |
300 | int ret; \ | 300 | int ret; \ |
301 | \ | 301 | \ |
302 | __common_field(int, type, 1); \ | 302 | ret = trace_define_common_fields(event_call); \ |
303 | __common_field(unsigned char, flags, 0); \ | 303 | if (ret) \ |
304 | __common_field(unsigned char, preempt_count, 0); \ | 304 | return ret; \ |
305 | __common_field(int, pid, 1); \ | ||
306 | __common_field(int, tgid, 1); \ | ||
307 | \ | 305 | \ |
308 | tstruct; \ | 306 | tstruct; \ |
309 | \ | 307 | \ |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index af8fb8ebef0b..9c7ecfb3416f 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -62,6 +62,28 @@ err: | |||
62 | } | 62 | } |
63 | EXPORT_SYMBOL_GPL(trace_define_field); | 63 | EXPORT_SYMBOL_GPL(trace_define_field); |
64 | 64 | ||
65 | #define __common_field(type, item) \ | ||
66 | ret = trace_define_field(call, #type, "common_" #item, \ | ||
67 | offsetof(typeof(ent), item), \ | ||
68 | sizeof(ent.item), \ | ||
69 | is_signed_type(type)); \ | ||
70 | if (ret) \ | ||
71 | return ret; | ||
72 | |||
73 | int trace_define_common_fields(struct ftrace_event_call *call) | ||
74 | { | ||
75 | int ret; | ||
76 | struct trace_entry ent; | ||
77 | |||
78 | __common_field(unsigned short, type); | ||
79 | __common_field(unsigned char, flags); | ||
80 | __common_field(unsigned char, preempt_count); | ||
81 | __common_field(int, pid); | ||
82 | __common_field(int, tgid); | ||
83 | |||
84 | return ret; | ||
85 | } | ||
86 | |||
65 | #ifdef CONFIG_MODULES | 87 | #ifdef CONFIG_MODULES |
66 | 88 | ||
67 | static void trace_destroy_fields(struct ftrace_event_call *call) | 89 | static void trace_destroy_fields(struct ftrace_event_call *call) |
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index cf2c752a25bf..70875303ae46 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
@@ -189,11 +189,9 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ | |||
189 | struct args field; \ | 189 | struct args field; \ |
190 | int ret; \ | 190 | int ret; \ |
191 | \ | 191 | \ |
192 | __common_field(unsigned char, type, 0); \ | 192 | ret = trace_define_common_fields(event_call); \ |
193 | __common_field(unsigned char, flags, 0); \ | 193 | if (ret) \ |
194 | __common_field(unsigned char, preempt_count, 0); \ | 194 | return ret; \ |
195 | __common_field(int, pid, 1); \ | ||
196 | __common_field(int, tgid, 1); \ | ||
197 | \ | 195 | \ |
198 | tstruct; \ | 196 | tstruct; \ |
199 | \ | 197 | \ |