[RFC PATCH v3 4/4] trace: Trace log handler for logging into STM blocks
From: Chunyan Zhang
Date: Tue Jul 07 2015 - 06:13:12 EST
Add the function 'trace_event_stm_output_##call' for printing events
trace log into STM blocks.
This patch also adds 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@xxxxxxxxxx>
---
include/linux/trace_events.h | 8 ++++++++
include/trace/perf.h | 3 +++
include/trace/trace_events.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 28dcdff..705bd4e 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -418,6 +418,14 @@ enum event_trigger_type {
#ifdef CONFIG_STM_TRACE_EVENT
extern void stm_trace_event_write(const char *buf, unsigned len);
+extern void trace_event_stm_log(struct trace_event_buffer *buffer);
+extern void trace_event_buf_vprintf(struct trace_buffer_stm *tb,
+ const char *fmt, ...) __attribute__ ((weak));
+#else
+static inline void trace_event_stm_log(struct trace_event_buffer *buffer) {}
+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);
diff --git a/include/trace/perf.h b/include/trace/perf.h
index 1b5443c..79906de 100644
--- a/include/trace/perf.h
+++ b/include/trace/perf.h
@@ -175,6 +175,7 @@ trace_event_raw_event_##call(void *__data, proto) \
{ assign; } \
\
trace_event_buffer_commit(&fbuffer); \
+ trace_event_stm_log(&fbuffer); \
}
/*
* The ftrace_test_probe is compiled out, it is only here as a build time check
@@ -234,6 +235,7 @@ static struct trace_event_call __used event_##call = { \
.event.funcs = &trace_event_type_funcs_##template, \
.print_fmt = print_fmt_##template, \
.flags = TRACE_EVENT_FL_TRACEPOINT, \
+ .output_stm = trace_event_stm_output_##template, \
}; \
static struct trace_event_call __used \
__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
@@ -251,6 +253,7 @@ static struct trace_event_call __used event_##call = { \
.event.funcs = &trace_event_type_funcs_##call, \
.print_fmt = print_fmt_##call, \
.flags = TRACE_EVENT_FL_TRACEPOINT, \
+ .output_stm = trace_event_stm_output_##call, \
}; \
static struct trace_event_call __used \
__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 43be3b0..db4d8a7 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -303,6 +303,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 trace_event_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 trace_event_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 \
trace_raw_output_##call(struct trace_iterator *iter, int flags, \
struct trace_event *trace_event) \
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/