tracing: various fixes
Steven Rostedt
maintainerIngo,
Please pull the latest tip/tracing/core tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/core
Li Zefan (3):
tracing: fix F_printk() typos
ftrace: add compile-time check on F_printk()
tracing: remove some unused macros
Steven Rostedt (3):
tracing: add static to generated TRACE_EVENT functions
tracing: have TRACE_EVENT macro use __flags to not shadow parameter
tracing: make testing syscall events a separate configuration
----
include/trace/ftrace.h | 8 ++-- kernel/trace/Kconfig | 12 +++++++ kernel/trace/trace_entries.h | 27 +++++---------- kernel/trace/trace_events.c | 14 ++++++++- kernel/trace/trace_export.c | 71 ++++++++++++++++++++++++----------------- 5 files changed, 79 insertions(+), 53 deletions(-)
Steven Rostedt
maintainerPATCH 1/6 tracing: add static to generated TRACE_EVENT functions
From: Steven Rostedt <[email protected]>
Some of the generated functions used in the TRACE_EVENT macros are not declared static, but they are not global.
Discovered by sparse.
--- include/trace/ftrace.h | 4 ++-- kernel/trace/trace_events.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/trace/ftrace.h +2 -2
@@ -254,7 +254,7 @@ ftrace_format_##call(struct ftrace_event_call *unused, \#undef TRACE_EVENT#define TRACE_EVENT (call, proto, args, tstruct, assign, print) \ -enum print_line_t \ +static enum print_line_t \ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \ { \ struct trace_seq *s = &iter->seq; \
@@ -317,7 +317,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \#undef TRACE_EVENT#define TRACE_EVENT (call, proto, args, tstruct, func, print) \ -int \ +static int \ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ { \ struct ftrace_raw_##call field; \
kernel/trace/trace_events.c +1 -1
@@ -1154,7 +1154,7 @@ static int trace_module_notify(struct notifier_block *self, }#endif /* CONFIG_MODULES */ -struct notifier_block trace_module_nb = { +static struct notifier_block trace_module_nb = { .notifier_call = trace_module_notify, .priority =0 , };
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 2/6 tracing: have TRACE_EVENT macro use __flags to not shadow parameter
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
The generated functions of TRACE_EVENT uses "flags" in one of the sub macros which shadows a parameter in the outside macro.
Simple fix is to make the submacro use __flags instead.
Discovered by sparse.
--- include/trace/ftrace.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/trace/ftrace.h +2 -2
@@ -239,9 +239,9 @@ ftrace_format_##call(struct ftrace_event_call *unused, \#undef __print_flags #define __print_flags(flag, delim, flag_array...) \ ({ \ - static const struct trace_print_flags flags[] = \ + static const struct trace_print_flags __flags[] = \ { flag_array, { -1, NULL }}; \ - ftrace_print_flags_seq(p, delim, flag, flags); \ + ftrace_print_flags_seq(p, delim, flag, __flags); \ })#undef __print_symbolic
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 3/6 tracing: fix F_printk() typos
In reply to Steven RostedtFrom: Li Zefan <[email protected]>
I found some typos in F_printk(), so I wrote compile-time check for it, and triggered some compile errors and warnings.
I've fixed them on x86_32, but I have no x86_64 in my hand, so there may still be some compile warnings on 64bits.
LKML-Reference: <[email protected]>
[ tested on x86_64, and works fine ]
--- kernel/trace/trace_entries.h | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
kernel/trace/trace_entries.h +9 -9
@@ -78,7 +78,7 @@ FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,__field_desc ( int, graph_ent, depth ) ), -F_printk ("--> %lx (%d)" , __entry->graph_ent.func, __entry->depth) +F_printk ("--> %lx (%d)" , __entry->func, __entry->depth) );/* Function return entry */
@@ -97,8 +97,8 @@ FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry,F_printk ("<-- %lx (%d) (start: %llx end: %llx) over: %d" , __entry->func, __entry->depth, - __entry->calltime, __entry->rettim, - __entrty->depth) + __entry->calltime, __entry->rettime, + __entry->depth) );/*
@@ -133,7 +133,7 @@ FTRACE_ENTRY(context_switch, ctx_switch_entry,FTRACE_CTX_FIELDS ), -F_printk (b"%u:%u:%u ==> %u:%u:%u [%03u]" , +F_printk ("%u:%u:%u ==> %u:%u:%u [%03u]" , __entry->prev_pid, __entry->prev_prio, __entry->prev_state, __entry->next_pid, __entry->next_prio, __entry->next_state, __entry->next_cpu
@@ -257,8 +257,8 @@ FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw, __field_desc( unsigned char, rw, width ) ), -F_printk ("%lx %lx %lx %d %lx %lx" , - __entry->phs, __entry->value, __entry->pc, +F_printk ("%lx %lx %lx %d %x %x" , + (unsigned long )__entry->phys, __entry->value, __entry->pc, __entry->map_id, __entry->opcode, __entry->width) );
@@ -275,8 +275,8 @@ FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map, __field_desc( unsigned char, map, opcode ) ), -F_printk ("%lx %lx %lx %d %lx" , - __entry->phs, __entry->virt, __entry->len, +F_printk ("%lx %lx %lx %d %x" , + (unsigned long )__entry->phys, __entry->virt, __entry->len, __entry->map_id, __entry->opcode) );
@@ -370,7 +370,7 @@ FTRACE_ENTRY(kmem_alloc, kmemtrace_alloc_entry,__field ( int, node ) ), - F_printk("type:%u call_site:%lx ptr:%p req:%lu alloc:%lu" + F_printk("type:%u call_site:%lx ptr:%p req:%zi alloc:%zi" " flags:%x node:%d", __entry->type_id, __entry->call_site, __entry->ptr, __entry->bytes_req, __entry->bytes_alloc,
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 5/6 tracing: remove some unused macros
In reply to Steven RostedtFrom: Li Zefan <[email protected]>
- remove FTRACE_ENTRY_STRUCT_ONLY()
- remove TRACE_XXX() macros
LKML-Reference: <[email protected]>
--- kernel/trace/trace_entries.h | 9 --------- kernel/trace/trace_export.c | 26 -------------------------- 2 files changed, 0 insertions(+), 35 deletions(-)
kernel/trace/trace_entries.h +0 -9
@@ -116,15 +116,6 @@ FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry, __field( unsigned char, next_state ) \ __field( unsigned int, next_cpu ) -#if 0 -FTRACE_ENTRY_STRUCT_ONLY (ctx_switch_entry, - -F_STRUCT ( -FTRACE_CTX_FIELDS - ) -); -#endif - FTRACE_ENTRY(context_switch, ctx_switch_entry, TRACE_CTX,
kernel/trace/trace_export.c +0 -26
@@ -209,32 +209,6 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#undef __dynamic_array#define __dynamic_array (type, item) - -#undef TRACE_ZERO_CHAR -#define TRACE_ZERO_CHAR (arg) - -#undef TRACE_FIELD -#define TRACE_FIELD (type, item, assign)\ - entry->item = assign; - -#undef TRACE_FIELD -#define TRACE_FIELD (type, item, assign)\ - entry->item = assign; - -#undef TRACE_FIELD_SIGN -#define TRACE_FIELD_SIGN (type, item, assign, is_signed) \ - TRACE_FIELD(type, item, assign) - -#undef TP_CMD -#define TP_CMD(cmd...) cmd - -#undef TRACE_ENTRY -#define TRACE_ENTRY entry - -#undef TRACE_FIELD_SPECIAL -#define TRACE_FIELD_SPECIAL (type_item, item, len, cmd) \ - cmd; -#undef FTRACE_ENTRY#define FTRACE_ENTRY (call, struct_name, type, tstruct, print) \ static int ftrace_raw_init_event_##call(void); \
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 6/6 tracing: make testing syscall events a separate configuration
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Parag noticed that the number of event tests has increased tremendously:
grep "Testing event" dmesg.31rc9 |wc -l
100
grep "Testing event" dmesg.31git |wc -l
1172
This is due to the testing of every syscall event when ftrace self test is enabled. This adds a bit more time to kernel boot up and can affect development by slowing down the time it takes between reboots.
This option makes the testing of the syscall events into a separate config, to still be able to test most of ftrace internals at boot up but not have to wait for all the syscall events to be tested.
The syscall event testing only tests the enabling and disabling of the trace point, since the syscalls are not executed. What really needs to be done is to somehow have a userspace tool test the syscall tracepoints as well.
LKML-Reference: <[email protected]>
--- kernel/trace/Kconfig | 12 ++++++++++++ kernel/trace/trace_events.c | 12 ++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-)
kernel/trace/Kconfig +12 -0
@@ -469,6 +469,18 @@ config FTRACE_STARTUP_TEST functioning properly. It will do tests on all the configured tracers of ftrace. +config EVENT_TRACE_TEST_SYSCALLS + bool "Run selftest on syscall events" + depends on FTRACE_STARTUP_TEST + help + This option will also enable testing every syscall event. + It only enables the event and disables it and runs various loads + with the event enabled. This adds a bit more time for kernel boot + up since it runs this on every system call defined. + + TBD - enable a way to actually call the syscalls as we test their + events + config MMIOTRACE bool "Memory mapped IO tracing" depends on HAVE_MMIOTRACE_SUPPORT && PCI
kernel/trace/trace_events.c +12 -0
@@ -1326,6 +1326,18 @@ static __init void event_trace_self_tests(void)if (!call->regfunc)continue ; +/* +* Testing syscall events here is pretty useless, but +* we still do it if configured. But this is time consuming. +* What we really need is a user thread to perform the +* syscalls as we test. +*/ +#ifndef CONFIG_EVENT_TRACE_TEST_SYSCALLS +if (call->system && +strcmp (call->system,"syscalls" ) ==0 ) +continue ; +#endif +pr_info ("Testing event %s: " , call->name);/*
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 4/6 ftrace: add compile-time check on F_printk()
In reply to Steven RostedtFrom: Li Zefan <[email protected]>
Make sure F_printk() has corrent format and args, and make sure changes in F_STRUCT() won't break F_printk().
LKML-Reference: <[email protected]>
--- kernel/trace/trace_export.c | 45 +++++++++++++++++++++++++++++++++++++++--- 1 files changed, 41 insertions(+), 4 deletions(-)
kernel/trace/trace_export.c +41 -4
@@ -23,6 +23,47 @@#define __field_struct (type, item)#undef __field +#define __field (type, item) type item; + +#undef __field_desc +#define __field_desc (type, container, item) type item; + +#undef __array +#define __array (type, item, size) type item[size]; + +#undef __array_desc +#define __array_desc (type, container, item, size) type item[size]; + +#undef __dynamic_array +#define __dynamic_array (type, item) type item[]; + +#undef F_STRUCT +#define F_STRUCT(args...) args + +#undef F_printk +#define F_printk(fmt, args...) fmt, args + +#undef FTRACE_ENTRY +#define FTRACE_ENTRY (name, struct_name, id, tstruct, print) \ +struct ____ftrace_##name { \ + tstruct \ +}; \ +static void __used ____ftrace_check_##name(void) \ +{ \ + struct ____ftrace_##name *__entry = NULL; \ + \ +/* force cmpile-time check on F_printk() */ \ +printk (print); \ +} + +#undef FTRACE_ENTRY_DUP +#define FTRACE_ENTRY_DUP (name, struct_name, id, tstruct, print) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) + +#include "trace_entries.h" + + +#undef __field#define __field (type, item) \ ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ "offset:%zu;\tsize:%zu;\n", \
@@ -88,10 +129,6 @@ ftrace_format_##name(struct ftrace_event_call *unused, \return ret; \ } -#undef FTRACE_ENTRY_DUP -#define FTRACE_ENTRY_DUP (name, struct_name, id, tstruct, print) \ - FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) -#include "trace_entries.h"
Signature · 3 lines
1.6.3.3 --