Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754891AbbGQVH7 (ORCPT ); Fri, 17 Jul 2015 17:07:59 -0400 Received: from smtprelay0142.hostedemail.com ([216.40.44.142]:35439 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754346AbbGQVHm (ORCPT ); Fri, 17 Jul 2015 17:07:42 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::,RULES_HIT:2:41:355:379:541:599:800:960:973:981:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1535:1593:1594:1605:1606:1730:1747:1777:1792:2393:2553:2559:2562:2892:3138:3139:3140:3141:3142:3622:3865:3866:3867:3870:3871:3872:3873:4117:4250:4321:4605:5007:6119:6120:6261:7875:7901:7903:8660:10004:10848:10967:11026:11232:11473:11658:11914:12043:12291:12296:12438:12517:12519:12555:12683:12740:13138:13148:13230:13231:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: show53_25e7b7cd8de20 X-Filterd-Recvd-Size: 6106 Date: Fri, 17 Jul 2015 17:07:39 -0400 From: Steven Rostedt To: Chunyan Zhang Cc: mingo@redhat.com, mathieu.poirier@linaro.org, serge.broslavsky@linaro.org, broonie@kernel.org, alexander.shishkin@linux.intel.com, zhang.lyra@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v3 4/4] trace: Trace log handler for logging into STM blocks Message-ID: <20150717170739.6b8465c2@gandalf.local.home> In-Reply-To: References: X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5122 Lines: 137 On Tue, 7 Jul 2015 18:10:43 +0800 Chunyan Zhang wrote: > 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 > --- > 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); \ This could be moved into trace_event_buffer_commit(). > } > /* > * 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; \ > +} To save a lot of code, as this is duplicated for hundreds of events, you could simply reuse the trace_raw_output_##call(), by passing in a trace_iterator() with just enough to get through it. We can even add a flag to not do the output_prep() work, if need be. -- Steve > + > +#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) \ -- 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/