]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tracing/events: Add trace_define_common_fields()
authorLi Zefan <lizf@cn.fujitsu.com>
Wed, 19 Aug 2009 07:54:32 +0000 (15:54 +0800)
committerIngo Molnar <mingo@elte.hu>
Wed, 19 Aug 2009 13:02:24 +0000 (15:02 +0200)
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>
include/linux/ftrace_event.h
include/trace/ftrace.h
kernel/trace/trace_events.c
kernel/trace/trace_export.c

index 35b3a4a5ba861e5e7710d2015619aaa39cbfe217..427cbae47f8483c755a2cd0b661aac3bca71f44c 100644 (file)
@@ -142,6 +142,7 @@ extern int filter_current_check_discard(struct ftrace_event_call *call,
 
 extern int trace_define_field(struct ftrace_event_call *call, char *type,
                              char *name, int offset, int size, int is_signed);
+extern int trace_define_common_fields(struct ftrace_event_call *call);
 
 #define is_signed_type(type)   (((type)(-1)) < 0)
 
@@ -166,11 +167,4 @@ do {                                                                       \
                __trace_printk(ip, fmt, ##args);                        \
 } while (0)
 
-#define __common_field(type, item, is_signed)                          \
-       ret = trace_define_field(event_call, #type, "common_" #item,    \
-                                offsetof(typeof(field.ent), item),     \
-                                sizeof(field.ent.item), is_signed);    \
-       if (ret)                                                        \
-               return ret;
-
 #endif /* _LINUX_FTRACE_EVENT_H */
index 4e81c9b37515a225b978f5c811ec19c0dd9ad50d..127400255e4c3400ef95245f09e9848c640505e0 100644 (file)
@@ -299,11 +299,9 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call)  \
        struct ftrace_raw_##call field;                                 \
        int ret;                                                        \
                                                                        \
-       __common_field(int, type, 1);                                   \
-       __common_field(unsigned char, flags, 0);                        \
-       __common_field(unsigned char, preempt_count, 0);                \
-       __common_field(int, pid, 1);                                    \
-       __common_field(int, tgid, 1);                                   \
+       ret = trace_define_common_fields(event_call);                   \
+       if (ret)                                                        \
+               return ret;                                             \
                                                                        \
        tstruct;                                                        \
                                                                        \
index af8fb8ebef0bdfb4fe066122b794894d9cd6352b..9c7ecfb3416f4d7ad503a89bf41395696824a997 100644 (file)
@@ -62,6 +62,28 @@ err:
 }
 EXPORT_SYMBOL_GPL(trace_define_field);
 
+#define __common_field(type, item)                                     \
+       ret = trace_define_field(call, #type, "common_" #item,          \
+                                offsetof(typeof(ent), item),           \
+                                sizeof(ent.item),                      \
+                                is_signed_type(type));                 \
+       if (ret)                                                        \
+               return ret;
+
+int trace_define_common_fields(struct ftrace_event_call *call)
+{
+       int ret;
+       struct trace_entry ent;
+
+       __common_field(unsigned short, type);
+       __common_field(unsigned char, flags);
+       __common_field(unsigned char, preempt_count);
+       __common_field(int, pid);
+       __common_field(int, tgid);
+
+       return ret;
+}
+
 #ifdef CONFIG_MODULES
 
 static void trace_destroy_fields(struct ftrace_event_call *call)
index cf2c752a25bf0d5216704d59e04cbfd80fb8423c..70875303ae463301e57ee12029f73d1ae7c4a1d8 100644 (file)
@@ -189,11 +189,9 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call)  \
        struct args field;                                              \
        int ret;                                                        \
                                                                        \
-       __common_field(unsigned char, type, 0);                         \
-       __common_field(unsigned char, flags, 0);                        \
-       __common_field(unsigned char, preempt_count, 0);                \
-       __common_field(int, pid, 1);                                    \
-       __common_field(int, tgid, 1);                                   \
+       ret = trace_define_common_fields(event_call);                   \
+       if (ret)                                                        \
+               return ret;                                             \
                                                                        \
        tstruct;                                                        \
                                                                        \