]> git.karo-electronics.de Git - linux-beck.git/commitdiff
tracing: Add a helper function for event print functions
authorLi Zefan <lizefan@huawei.com>
Thu, 21 Feb 2013 02:32:38 +0000 (10:32 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 15 Mar 2013 04:34:51 +0000 (00:34 -0400)
Move duplicate code in event print functions to a helper function.

This shrinks the size of the kernel by ~13K.

   text    data     bss     dec     hex filename
6596137 1743966 10138672        18478775        119f6b7 vmlinux.o.old
6583002 1743849 10138672        18465523        119c2f3 vmlinux.o.new

Link: http://lkml.kernel.org/r/51258746.2060304@huawei.com
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/ftrace_event.h
include/trace/ftrace.h
kernel/trace/trace_output.c

index fd28c170c597797bcb23e5d8217f78f1e85f809b..4d79d2dc189ce3eef8c674831f802e77be5e1d57 100644 (file)
@@ -38,6 +38,12 @@ const char *ftrace_print_symbols_seq_u64(struct trace_seq *p,
 const char *ftrace_print_hex_seq(struct trace_seq *p,
                                 const unsigned char *buf, int len);
 
+struct trace_iterator;
+struct trace_event;
+
+int ftrace_raw_output_prep(struct trace_iterator *iter,
+                          struct trace_event *event);
+
 /*
  * The trace entry - the most basic unit of tracing. This is what
  * is printed in the end as a single line in the trace output, such as:
@@ -95,8 +101,6 @@ enum trace_iter_flags {
 };
 
 
-struct trace_event;
-
 typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter,
                                      int flags, struct trace_event *event);
 
index e5d140a91fd742f466c792594b03149761de304e..17a77fcac2a2c62eaf87780c5ea35766621ca598 100644 (file)
@@ -227,29 +227,18 @@ static notrace enum print_line_t                                  \
 ftrace_raw_output_##call(struct trace_iterator *iter, int flags,       \
                         struct trace_event *trace_event)               \
 {                                                                      \
-       struct ftrace_event_call *event;                                \
        struct trace_seq *s = &iter->seq;                               \
+       struct trace_seq __maybe_unused *p = &iter->tmp_seq;            \
        struct ftrace_raw_##call *field;                                \
-       struct trace_entry *entry;                                      \
-       struct trace_seq *p = &iter->tmp_seq;                           \
        int ret;                                                        \
                                                                        \
-       event = container_of(trace_event, struct ftrace_event_call,     \
-                            event);                                    \
-                                                                       \
-       entry = iter->ent;                                              \
+       field = (typeof(field))iter->ent;                               \
                                                                        \
-       if (entry->type != event->event.type) {                         \
-               WARN_ON_ONCE(1);                                        \
-               return TRACE_TYPE_UNHANDLED;                            \
-       }                                                               \
-                                                                       \
-       field = (typeof(field))entry;                                   \
-                                                                       \
-       trace_seq_init(p);                                              \
-       ret = trace_seq_printf(s, "%s: ", event->name);                 \
+       ret = ftrace_raw_output_prep(iter, trace_event);                \
        if (ret)                                                        \
-               ret = trace_seq_printf(s, print);                       \
+               return ret;                                             \
+                                                                       \
+       ret = trace_seq_printf(s, print);                               \
        if (!ret)                                                       \
                return TRACE_TYPE_PARTIAL_LINE;                         \
                                                                        \
index 194d79602dc73f1881969a9d27e7e141fb545117..aa92ac322ba2af80f9242ef52af7c1c78c4279a8 100644 (file)
@@ -397,6 +397,32 @@ ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
 }
 EXPORT_SYMBOL(ftrace_print_hex_seq);
 
+int ftrace_raw_output_prep(struct trace_iterator *iter,
+                          struct trace_event *trace_event)
+{
+       struct ftrace_event_call *event;
+       struct trace_seq *s = &iter->seq;
+       struct trace_seq *p = &iter->tmp_seq;
+       struct trace_entry *entry;
+       int ret;
+
+       event = container_of(trace_event, struct ftrace_event_call, event);
+       entry = iter->ent;
+
+       if (entry->type != event->event.type) {
+               WARN_ON_ONCE(1);
+               return TRACE_TYPE_UNHANDLED;
+       }
+
+       trace_seq_init(p);
+       ret = trace_seq_printf(s, "%s: ", event->name);
+       if (!ret)
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       return 0;
+}
+EXPORT_SYMBOL(ftrace_raw_output_prep);
+
 #ifdef CONFIG_KRETPROBES
 static inline const char *kretprobed(const char *name)
 {