diff mbox

[RFC,2/3] Trace log handler for logging into STM blocks

Message ID CAG2=9p_Y2fD6Y=vVKNirK=ei6MNxWHtmVf9Sbf+T9Gu=f0Y42g@mail.gmail.com
State New
Headers show

Commit Message

Chunyan Zhang June 5, 2015, 5:37 a.m. UTC
Adding the function 'trace_event_stm_output_##call' for printing events
trace log into STM blocks.

This patch also added a function call at where the events have been
committed to ring buffer to export the trace event information to
STM blocks.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
---
 include/linux/ftrace_event.h | 15 ++++++++++++++
 include/trace/ftrace.h       | 47 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)

  * The ftrace_test_probe is compiled out, it is only here as a build time check
@@ -742,6 +787,7 @@ static struct ftrace_event_call __used
event_##call = {                     \
        .event.funcs            = &ftrace_event_type_funcs_##template,  \
        .print_fmt              = print_fmt_##template,                 \
        .flags                  = TRACE_EVENT_FL_TRACEPOINT,            \
+       .output_stm             = trace_event_stm_output_##template,    \
 };                                                                     \
 static struct ftrace_event_call __used                                 \
 __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
@@ -759,6 +805,7 @@ static struct ftrace_event_call __used
event_##call = {                     \
        .event.funcs            = &ftrace_event_type_funcs_##call,      \
        .print_fmt              = print_fmt_##call,                     \
        .flags                  = TRACE_EVENT_FL_TRACEPOINT,            \
+       .output_stm             = trace_event_stm_output_##call,        \
 };                                                                     \
 static struct ftrace_event_call __used                                 \
 __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 46e83c2..f0c7426 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -14,6 +14,7 @@  struct trace_buffer;
 struct tracer;
 struct dentry;
 struct bpf_prog;
+struct trace_buffer_stm;

 struct trace_print_flags {
        unsigned long           mask;
@@ -304,6 +305,9 @@  struct ftrace_event_call {
         */
        int                     flags; /* static flags of different events */

+       void (*output_stm)(struct trace_seq *tmp_seq, void *entry,
+                          struct trace_buffer_stm *tb);
+
 #ifdef CONFIG_PERF_EVENTS
        int                             perf_refcount;
        struct hlist_head __percpu      *perf_events;
@@ -423,6 +427,17 @@  enum event_trigger_type {
        ETT_EVENT_ENABLE        = (1 << 3),
 };

+#ifdef CONFIG_STM_TRACE_EVENT
+extern void trace_event_stm_log(struct ftrace_event_buffer *fbuffer);
+extern void trace_event_buf_vprintf(struct trace_buffer_stm *tb,
+                           const char *fmt, ...) __attribute__ ((weak));
+extern void stm_trace_event_write(const char *buf, unsigned len);
+#else
+static inline void trace_event_stm_log(struct ftrace_event_buffer *fbuffer) {}
+static inline void trace_event_buf_vprintf(struct trace_buffer_stm *tb,
+                           const char *fmt, ...) {}
+#endif
+
 extern int filter_match_preds(struct event_filter *filter, void *rec);

 extern int filter_check_discard(struct ftrace_event_file *file, void *rec,
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 37d4b10..cc1b426 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -302,6 +302,50 @@  TRACE_MAKE_SYSTEM_STR();
        })

 #undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)  \
+static notrace void                                     \
+trace_event_stm_output_##call(struct trace_seq *tmp_seq,               \
+                        void *entry,                   \
+                        struct trace_buffer_stm *trace_buf)            \
+{                                                                      \
+       struct ftrace_raw_##call *field = entry;                        \
+       struct trace_seq *p = tmp_seq;                                  \
+                                                                       \
+       trace_seq_init(p);                                              \
+                                                                       \
+       trace_event_buf_vprintf(trace_buf, print);                      \
+                                                                       \
+       return;                                                         \
+}
+
+#undef DEFINE_EVENT_PRINT
+#define DEFINE_EVENT_PRINT(template, call, proto, args, print)         \
+static notrace void                                                    \
+trace_event_stm_output_##call(struct trace_seq *tmp_seq,               \
+                        void *entry,                                   \
+                        struct trace_buffer_stm *trace_buf)            \
+{                                                                      \
+       struct trace_seq *p = tmp_seq;                                  \
+       struct trace_entry *ent = entry;                                \
+       struct ftrace_raw_##template *field;                            \
+                                                                       \
+       if (ent->type != event_##call.event.type) {                     \
+               WARN_ON_ONCE(1);                                        \
+               return;                                                 \
+       }                                                               \
+                                                                       \
+       field = (typeof(field))entry;                                   \
+                                                                       \
+       trace_seq_init(p);                                              \
+                                                                       \
+       trace_event_buf_vprintf(trace_buf, print);                      \
+                                                                       \
+       return;                                                         \
+}
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+#undef DECLARE_EVENT_CLASS
 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
 static notrace enum print_line_t                                       \
 ftrace_raw_output_##call(struct trace_iterator *iter, int flags,       \
@@ -683,6 +727,7 @@  ftrace_raw_event_##call(void *__data, proto)
                         \
        { assign; }                                                     \
                                                                        \
        ftrace_event_buffer_commit(&fbuffer);                           \
+       trace_event_stm_log(&fbuffer);          \
 }
 /*