tracing: Fix F_printk()
PATCH 1/3 tracing: Fix F_printk()
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.
--- 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 · 1 line
1.6.3
PATCH 2/3 ftrace: Add compile-time check on F_printk()
Make sure F_printk() has corrent format and args, and make sure changes in F_STRUCT() won't break F_printk().
--- 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 · 1 line
1.6.3
Re: [PATCH 2/3] ftrace: Add compile-time check on F_printk()
Quoted 1 line
+static void
__used____ftrace_check_##name(void) \
oops, I should use "__maybe_unused"..
Quoted 6 lines
kernel/trace/trace_export.c +6
-0+{ \ + struct ____ftrace_##name *__entry = NULL; \ + \ +/* force cmpile-time check on F_printk() */ \ +printk (print); \ +}
[tip:tracing/core] ftrace: add compile-time check on F_printk()
In reply to Li ZefanCommit-ID: 05ffa2d02066c2cb169c02d5417308ee8ecab638 Gitweb: http://git.kernel.org/tip/05ffa2d02066c2cb169c02d5417308ee8ecab638 Author: Li Zefan <[email protected]> AuthorDate: Mon, 14 Sep 2009 15:54:52 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 14 Sep 2009 11:42:10 -0400
ftrace: add compile-time check on F_printk()
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"
PATCH 3/3 tracing: Remove some unused macros
In reply to Li Zefan- remove FTRACE_ENTRY_STRUCT_ONLY()
- remove TRACE_XXX() macros
--- 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 · 1 line
1.6.3
Steven Rostedt
maintainerRe: [PATCH 3/3] tracing: Remove some unused macros
Quoted 15 lines · Li Zefan
- remove
FTRACE_ENTRY_STRUCT_ONLY()
- removeTRACE_XXX()macrosSigned-off-by Li Zefan <[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
-0@@ -116,15 +116,6 @@ FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry, __field( unsigned char, next_state ) \
kernel/trace/trace_entries.h FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry, · line 126
Quoted 10 lines
kernel/trace/trace_entries.h +0
-8__field( unsigned int, next_cpu ) -#if 0 -FTRACE_ENTRY_STRUCT_ONLY (ctx_switch_entry, - -F_STRUCT ( -FTRACE_CTX_FIELDS - ) -); -#endif
Ug! Where's my paper bag.
Thanks Li! I'll pull them in later today.
-- Steve
Quoted 41 lines
kernel/trace/trace_entries.h +0
-1- 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); \
[tip:tracing/core] tracing: remove some unused macros
In reply to Li ZefanCommit-ID: 20a58a77231c5f5f61470932503b889303e8d4f3 Gitweb: http://git.kernel.org/tip/20a58a77231c5f5f61470932503b889303e8d4f3 Author: Li Zefan <[email protected]> AuthorDate: Mon, 14 Sep 2009 15:55:18 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 14 Sep 2009 11:43:24 -0400
tracing: remove some unused macros
- 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); \
[tip:tracing/core] tracing: fix F_printk() typos
In reply to Li ZefanCommit-ID: c16de8fd7a608aba8708dd056cf6e4d9462e800a Gitweb: http://git.kernel.org/tip/c16de8fd7a608aba8708dd056cf6e4d9462e800a Author: Li Zefan <[email protected]> AuthorDate: Mon, 14 Sep 2009 15:51:39 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 14 Sep 2009 11:40:59 -0400
tracing: fix F_printk() typos
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,