Skip to content

Commit

Permalink
tracing: Remove show_format and related macros from TRACE_EVENT
Browse files Browse the repository at this point in the history
The previous patches added the use of print_fmt string and changes
the trace_define_field() function to also create the fields and
format output for the event format files.

   text	   data	    bss	    dec	    hex	filename
5857201	1355780	9336808	16549789	 fc879d	vmlinux
5884589	1351684	9337896	16574169	 fce6d9	vmlinux-orig

The above shows the size of the vmlinux after this patch set
compared to the vmlinux-orig which is before the patch set.

This saves us 27k on text, 1k on bss and adds just 4k of data.

The total savings of 24k in size.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
LKML-Reference: <4B273D4D.40604@cn.fujitsu.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Lai Jiangshan authored and Steven Rostedt committed Jan 6, 2010
1 parent 5a65e95 commit 0fa0eda
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 364 deletions.
2 changes: 0 additions & 2 deletions include/linux/ftrace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ struct ftrace_event_call {
int id;
const char *print_fmt;
int (*raw_init)(struct ftrace_event_call *);
int (*show_format)(struct ftrace_event_call *,
struct trace_seq *);
int (*define_fields)(struct ftrace_event_call *);
struct list_head fields;
int filter_active;
Expand Down
2 changes: 0 additions & 2 deletions include/linux/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ struct perf_event_attr;
.system = "syscalls", \
.event = &enter_syscall_print_##sname, \
.raw_init = init_syscall_trace, \
.show_format = syscall_enter_format, \
.define_fields = syscall_enter_define_fields, \
.regfunc = reg_event_syscall_enter, \
.unregfunc = unreg_event_syscall_enter, \
Expand All @@ -166,7 +165,6 @@ struct perf_event_attr;
.system = "syscalls", \
.event = &exit_syscall_print_##sname, \
.raw_init = init_syscall_trace, \
.show_format = syscall_exit_format, \
.define_fields = syscall_exit_define_fields, \
.regfunc = reg_event_syscall_exit, \
.unregfunc = unreg_event_syscall_exit, \
Expand Down
133 changes: 6 additions & 127 deletions include/trace/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,130 +130,6 @@

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/*
* Setup the showing format of trace point.
*
* int
* ftrace_format_##call(struct trace_seq *s)
* {
* struct ftrace_raw_##call field;
* int ret;
*
* ret = trace_seq_printf(s, #type " " #item ";"
* " offset:%u; size:%u;\n",
* offsetof(struct ftrace_raw_##call, item),
* sizeof(field.type));
*
* }
*/

#undef TP_STRUCT__entry
#define TP_STRUCT__entry(args...) args

#undef __field
#define __field(type, item) \
ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
"offset:%u;\tsize:%u;\tsigned:%u;\n", \
(unsigned int)offsetof(typeof(field), item), \
(unsigned int)sizeof(field.item), \
(unsigned int)is_signed_type(type)); \
if (!ret) \
return 0;

#undef __field_ext
#define __field_ext(type, item, filter_type) __field(type, item)

#undef __array
#define __array(type, item, len) \
ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
"offset:%u;\tsize:%u;\tsigned:%u;\n", \
(unsigned int)offsetof(typeof(field), item), \
(unsigned int)sizeof(field.item), \
(unsigned int)is_signed_type(type)); \
if (!ret) \
return 0;

#undef __dynamic_array
#define __dynamic_array(type, item, len) \
ret = trace_seq_printf(s, "\tfield:__data_loc " #type "[] " #item ";\t"\
"offset:%u;\tsize:%u;\tsigned:%u;\n", \
(unsigned int)offsetof(typeof(field), \
__data_loc_##item), \
(unsigned int)sizeof(field.__data_loc_##item), \
(unsigned int)is_signed_type(type)); \
if (!ret) \
return 0;

#undef __string
#define __string(item, src) __dynamic_array(char, item, -1)

#undef __entry
#define __entry REC

#undef __print_symbolic
#undef __get_dynamic_array
#undef __get_str

#undef TP_printk
#define TP_printk(fmt, args...) "\"%s\", %s\n", fmt, __stringify(args)

#undef TP_fast_assign
#define TP_fast_assign(args...) args

#undef TP_perf_assign
#define TP_perf_assign(args...)

#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
static int \
ftrace_format_setup_##call(struct ftrace_event_call *unused, \
struct trace_seq *s) \
{ \
struct ftrace_raw_##call field __attribute__((unused)); \
int ret = 0; \
\
tstruct; \
\
return ret; \
} \
\
static int \
ftrace_format_##call(struct ftrace_event_call *unused, \
struct trace_seq *s) \
{ \
int ret = 0; \
\
ret = ftrace_format_setup_##call(unused, s); \
if (!ret) \
return ret; \
\
ret = trace_seq_printf(s, "\nprint fmt: " print); \
\
return ret; \
}

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args)

#undef DEFINE_EVENT_PRINT
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
static int \
ftrace_format_##name(struct ftrace_event_call *unused, \
struct trace_seq *s) \
{ \
int ret = 0; \
\
ret = ftrace_format_setup_##template(unused, s); \
if (!ret) \
return ret; \
\
trace_seq_printf(s, "\nprint fmt: " print); \
\
return ret; \
}

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/*
* Stage 3 of the trace events.
*
Expand Down Expand Up @@ -622,7 +498,6 @@ static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
* .raw_init = trace_event_raw_init,
* .regfunc = ftrace_reg_event_<call>,
* .unregfunc = ftrace_unreg_event_<call>,
* .show_format = ftrace_format_<call>,
* }
*
*/
Expand Down Expand Up @@ -657,6 +532,12 @@ static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
#define __assign_str(dst, src) \
strcpy(__get_str(dst), src);

#undef TP_fast_assign
#define TP_fast_assign(args...) args

#undef TP_perf_assign
#define TP_perf_assign(args...)

#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
\
Expand Down Expand Up @@ -750,7 +631,6 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.regfunc = ftrace_raw_reg_event_##call, \
.unregfunc = ftrace_raw_unreg_event_##call, \
.print_fmt = print_fmt_##template, \
.show_format = ftrace_format_##template, \
.define_fields = ftrace_define_fields_##template, \
_TRACE_PROFILE_INIT(call) \
}
Expand All @@ -770,7 +650,6 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.regfunc = ftrace_raw_reg_event_##call, \
.unregfunc = ftrace_raw_unreg_event_##call, \
.print_fmt = print_fmt_##call, \
.show_format = ftrace_format_##call, \
.define_fields = ftrace_define_fields_##template, \
_TRACE_PROFILE_INIT(call) \
}
Expand Down
4 changes: 0 additions & 4 deletions include/trace/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ struct syscall_metadata {
extern unsigned long arch_syscall_addr(int nr);
extern int init_syscall_trace(struct ftrace_event_call *call);

extern int syscall_enter_format(struct ftrace_event_call *call,
struct trace_seq *s);
extern int syscall_exit_format(struct ftrace_event_call *call,
struct trace_seq *s);
extern int syscall_enter_define_fields(struct ftrace_event_call *call);
extern int syscall_exit_define_fields(struct ftrace_event_call *call);
extern int reg_event_syscall_enter(struct ftrace_event_call *call);
Expand Down
12 changes: 0 additions & 12 deletions kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,6 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
return ret;
}

extern char *__bad_type_size(void);

#undef FIELD
#define FIELD(type, name) \
sizeof(type) != sizeof(field.name) ? __bad_type_size() : \
#type, "common_" #name, offsetof(typeof(field), name), \
sizeof(field.name), is_signed_type(type)

static ssize_t
event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
loff_t *ppos)
Expand Down Expand Up @@ -965,10 +957,6 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
filter);
}

/* A trace may not want to export its format */
if (!call->show_format)
return 0;

trace_create_file("format", 0444, call->dir, call,
format);

Expand Down
73 changes: 0 additions & 73 deletions kernel/trace/trace_export.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,78 +62,6 @@ static void __always_unused ____ftrace_check_##name(void) \

#include "trace_entries.h"


#undef __field
#define __field(type, item) \
ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
"offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
offsetof(typeof(field), item), \
sizeof(field.item), is_signed_type(type)); \
if (!ret) \
return 0;

#undef __field_desc
#define __field_desc(type, container, item) \
ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
"offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
offsetof(typeof(field), container.item), \
sizeof(field.container.item), \
is_signed_type(type)); \
if (!ret) \
return 0;

#undef __array
#define __array(type, item, len) \
ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
"offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
offsetof(typeof(field), item), \
sizeof(field.item), is_signed_type(type)); \
if (!ret) \
return 0;

#undef __array_desc
#define __array_desc(type, container, item, len) \
ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
"offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
offsetof(typeof(field), container.item), \
sizeof(field.container.item), \
is_signed_type(type)); \
if (!ret) \
return 0;

#undef __dynamic_array
#define __dynamic_array(type, item) \
ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
"offset:%zu;\tsize:0;\tsigned:%u;\n", \
offsetof(typeof(field), item), \
is_signed_type(type)); \
if (!ret) \
return 0;

#undef F_printk
#define F_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)

#undef __entry
#define __entry REC

#undef FTRACE_ENTRY
#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
static int \
ftrace_format_##name(struct ftrace_event_call *unused, \
struct trace_seq *s) \
{ \
struct struct_name field __attribute__((unused)); \
int ret = 0; \
\
tstruct; \
\
trace_seq_printf(s, "\nprint fmt: " print); \
\
return ret; \
}

#include "trace_entries.h"

#undef __field
#define __field(type, item) \
ret = trace_define_field(event_call, #type, #item, \
Expand Down Expand Up @@ -235,7 +163,6 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.system = __stringify(TRACE_SYSTEM), \
.raw_init = ftrace_raw_init_event, \
.print_fmt = print, \
.show_format = ftrace_format_##call, \
.define_fields = ftrace_define_fields_##call, \
}; \

Expand Down
Loading

0 comments on commit 0fa0eda

Please sign in to comment.