Skip to content

Commit

Permalink
tracing: Give system name a pointer
Browse files Browse the repository at this point in the history
Normally the compiler will use the same pointer for a string throughout
the file. But there's no guarantee of that happening. Later changes will
require that all events have the same pointer to the system string.

Name the system string and have all events point to it.

Testing this, it did not increases the size of the text, except for the
notes section, which should not harm the real size any.

Link: http://lkml.kernel.org/r/20150403013802.220157513@goodmis.org

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (Red Hat) committed Apr 8, 2015
1 parent 6e9dd8d commit acd388f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/linux/ftrace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ enum trace_reg {
struct ftrace_event_call;

struct ftrace_event_class {
char *system;
const char *system;
void *probe;
#ifdef CONFIG_PERF_EVENTS
void *perf_probe;
Expand Down
19 changes: 17 additions & 2 deletions include/trace/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@

#include <linux/ftrace_event.h>

#ifndef TRACE_SYSTEM_VAR
#define TRACE_SYSTEM_VAR TRACE_SYSTEM
#endif

#define __app__(x, y) str__##x##y
#define __app(x, y) __app__(x, y)

#define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name)

#define TRACE_MAKE_SYSTEM_STR() \
static const char TRACE_SYSTEM_STRING[] = \
__stringify(TRACE_SYSTEM)

TRACE_MAKE_SYSTEM_STR();

/*
* DECLARE_EVENT_CLASS can be used to add a generic function
* handlers for events. That is, if all events have the same
Expand Down Expand Up @@ -105,7 +120,6 @@

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)


/*
* Stage 2 of the trace events.
*
Expand Down Expand Up @@ -692,7 +706,7 @@ static inline void ftrace_test_probe_##call(void) \
_TRACE_PERF_PROTO(call, PARAMS(proto)); \
static const char print_fmt_##call[] = print; \
static struct ftrace_event_class __used __refdata event_class_##call = { \
.system = __stringify(TRACE_SYSTEM), \
.system = TRACE_SYSTEM_STRING, \
.define_fields = ftrace_define_fields_##call, \
.fields = LIST_HEAD_INIT(event_class_##call.fields),\
.raw_init = trace_event_raw_init, \
Expand Down Expand Up @@ -735,6 +749,7 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

#undef TRACE_SYSTEM_VAR

#ifdef CONFIG_PERF_EVENTS

Expand Down

0 comments on commit acd388f

Please sign in to comment.