lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20150717170739.6b8465c2@gandalf.local.home>
Date:	Fri, 17 Jul 2015 17:07:39 -0400
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Chunyan Zhang <zhang.chunyan@...aro.org>
Cc:	mingo@...hat.com, mathieu.poirier@...aro.org,
	serge.broslavsky@...aro.org, broonie@...nel.org,
	alexander.shishkin@...ux.intel.com, zhang.lyra@...il.com,
	linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v3 4/4] trace: Trace log handler for logging into
 STM blocks

On Tue,  7 Jul 2015 18:10:43 +0800
Chunyan Zhang <zhang.chunyan@...aro.org> 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 <zhang.chunyan@...aro.org>
> ---
>  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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ