Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932278AbbFEFiC (ORCPT ); Fri, 5 Jun 2015 01:38:02 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:33357 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbbFEFiA (ORCPT ); Fri, 5 Jun 2015 01:38:00 -0400 MIME-Version: 1.0 Date: Fri, 5 Jun 2015 13:37:59 +0800 Message-ID: Subject: [RFC PATCH 2/3] Trace log handler for logging into STM blocks From: Chunyan Zhang To: Steven Rostedt , mingo@redhat.com Cc: Mathieu Poirier , Kaixu Xia , Serge Broslavsky , Mark Brown , alexander.shishkin@linux.intel.com, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7149 Lines: 142 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 --- include/linux/ftrace_event.h | 15 ++++++++++++++ include/trace/ftrace.h | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) 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); \ } /* * 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/