tracing/events: make struct trace_entry->type to be int type
PATCH 1/1 tracing/events: make struct trace_entry->type to be int type
struct trace_entry->type is unsigned char, while trace event's id is int type, thus for a event with id >= 256, it's entry->type is cast to (id % 256), and then we can't see the trace output of this event.
# insmod trace-events-sample.ko
# echo foo_bar > /mnt/tracing/set_event
# cat /debug/tracing/events/trace-events-sample/foo_bar/id
256
# cat /mnt/tracing/trace_pipe
<...>-3548 [001] 215.091142: Unknown type 0
<...>-3548 [001] 216.089207: Unknown type 0
<...>-3548 [001] 217.087271: Unknown type 0
<...>-3548 [001] 218.085332: Unknown type 0[ Impact: fix output for trace events with id >= 256 ]
--- include/linux/ftrace_event.h | 4 ++-- include/trace/ftrace.h | 2 +- kernel/trace/trace.c | 4 ++-- kernel/trace/trace.h | 2 +- kernel/trace/trace_events.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
include/linux/ftrace_event.h +2 -2
@@ -16,7 +16,7 @@ struct dentry;* bash-15816 [01] 235.197585: idle_cpu <- irq_enter */ struct trace_entry { -unsigned char type; +int type;unsigned char flags;unsigned char preempt_count;int pid;
@@ -73,7 +73,7 @@ enum print_line_t {struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc);void trace_current_buffer_unlock_commit (struct ring_buffer_event *event,unsigned long flags,int pc);
include/trace/ftrace.h +1 -1
@@ -198,7 +198,7 @@ ftrace_define_fields_##call(void) \ struct ftrace_event_call *event_call = &event_##call; \ int ret; \ \ - __common_field(unsigned char, type); \ + __common_field(int, type); \ __common_field(unsigned char, flags); \ __common_field(unsigned char, preempt_count); \ __common_field(int, pid); \
kernel/trace/trace.c +2 -2
@@ -838,7 +838,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, }struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc) {
@@ -881,7 +881,7 @@ void trace_buffer_unlock_commit(struct trace_array *tr, }struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc) { return trace_buffer_lock_reserve(&global_trace,
kernel/trace/trace.h +1 -1
@@ -422,7 +422,7 @@ void init_tracer_sysprof_debugfs(struct dentry *d_tracer);struct ring_buffer_event ;struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc);
kernel/trace/trace_events.c +1 -1
@@ -398,7 +398,7 @@ static int trace_write_header(struct trace_seq *s)"\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\n" , - FIELD(unsigned char, type), +FIELD (int, type), FIELD(unsigned char, flags), FIELD(unsigned char, preempt_count), FIELD(int, pid),
Signature · 1 line
1.5.4.rc3
Quoted 14 lines · Li Zefan
struct
trace_entry->typeis unsigned char, while trace event's id is int type, thus for a event with id >= 256, it'sentry->typeis cast to (id % 256), and then we can't see the trace output of this event.# insmod trace-events-sample.ko # echo foo_bar > /mnt/tracing/set_event # cat /debug/tracing/events/trace-events-sample/foo_bar/id 256 # cat /mnt/tracing/trace_pipe <...>-3548 [001] 215.091142: Unknown type 0 <...>-3548 [001] 216.089207: Unknown type 0 <...>-3548 [001] 217.087271: Unknown type 0 <...>-3548 [001] 218.085332: Unknown type 0
Quoted 3 lines
[ Impact: fix output for trace events with id >= 256 ]
Signed-off-by Li Zefan <[email protected]>
Indeed, now with the trace_events, we are approaching this possible overflow and the type is indeed an int:
struct trace_event *ftrace_find_event(int type)
Curious: does it only happen with the trace-event-sample? I doubt we already reached this threshold of event number. But anyway, it's a good thing.
Quoted 94 lines
--- include/linux/ftrace_event.h | 4 ++-- include/trace/ftrace.h | 2 +- kernel/trace/trace.c | 4 ++-- kernel/trace/trace.h | 2 +- kernel/trace/trace_events.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)include/linux/ftrace_event.h +2
-2@@ -16,7 +16,7 @@ struct dentry;* bash-15816 [01] 235.197585: idle_cpu <- irq_enter */ struct trace_entry { -unsigned char type; +int type;unsigned char flags;unsigned char preempt_count;int pid;@@ -73,7 +73,7 @@ enum print_line_t {struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc);void trace_current_buffer_unlock_commit (struct ring_buffer_event *event,unsigned long flags,int pc);include/trace/ftrace.h +1
-1@@ -198,7 +198,7 @@ ftrace_define_fields_##call(void) \ struct ftrace_event_call *event_call = &event_##call; \ int ret; \ \ - __common_field(unsigned char, type); \ + __common_field(int, type); \ __common_field(unsigned char, flags); \ __common_field(unsigned char, preempt_count); \ __common_field(int, pid); \kernel/trace/trace.c +2
-2@@ -838,7 +838,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, }struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc) {@@ -881,7 +881,7 @@ void trace_buffer_unlock_commit(struct trace_array *tr, }struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc) { return trace_buffer_lock_reserve(&global_trace,kernel/trace/trace.h +1
-1@@ -422,7 +422,7 @@ void init_tracer_sysprof_debugfs(struct dentry *d_tracer);struct ring_buffer_event ;struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc);kernel/trace/trace_events.c +1
-1@@ -398,7 +398,7 @@ static int trace_write_header(struct trace_seq *s)"\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\n" , - FIELD(unsigned char, type), +FIELD (int, type), FIELD(unsigned char, flags), FIELD(unsigned char, preempt_count), FIELD(int, pid),Signature · 1 line
1.5.4.rc3
Quoted 20 lines · Frederic Weisbecker
Quoted 14 lines · Li Zefan
struct
trace_entry->typeis unsigned char, while trace event's id is int type, thus for a event with id >= 256, it'sentry->typeis cast to (id % 256), and then we can't see the trace output of this event.# insmod trace-events-sample.ko # echo foo_bar > /mnt/tracing/set_event # cat /debug/tracing/events/trace-events-sample/foo_bar/id 256 # cat /mnt/tracing/trace_pipe <...>-3548 [001] 215.091142: Unknown type 0 <...>-3548 [001] 216.089207: Unknown type 0 <...>-3548 [001] 217.087271: Unknown type 0 <...>-3548 [001] 218.085332: Unknown type 0Quoted 3 lines
[ Impact: fix output for trace events with id >= 256 ]
Signed-off-by Li Zefan <[email protected]>
Quoted 9 lines
Indeed, now with the
trace_events, we are approaching this possible overflow and the type is indeed an int:struct
trace_event*ftrace_find_event(int type)Curious: does it only happen with the trace-event-sample? I doubt we already reached this threshold of event number. But anyway, it's a good thing.
I guess we haven't reached this limit, at least for mainline. :)
And the biggest id is 48 in my config.
Quoted 1 line
Quoted 26 lines · Li Zefan
Quoted 25 lines · Frederic Weisbecker
Quoted 14 lines · Li Zefan
struct
trace_entry->typeis unsigned char, while trace event's id is int type, thus for a event with id >= 256, it'sentry->typeis cast to (id % 256), and then we can't see the trace output of this event.# insmod trace-events-sample.ko # echo foo_bar > /mnt/tracing/set_event # cat /debug/tracing/events/trace-events-sample/foo_bar/id 256 # cat /mnt/tracing/trace_pipe <...>-3548 [001] 215.091142: Unknown type 0 <...>-3548 [001] 216.089207: Unknown type 0 <...>-3548 [001] 217.087271: Unknown type 0 <...>-3548 [001] 218.085332: Unknown type 0Quoted 3 lines
[ Impact: fix output for trace events with id >= 256 ]
Signed-off-by Li Zefan <[email protected]>Indeed, now with the
trace_events, we are approaching this possible overflow and the type is indeed an int:struct
trace_event*ftrace_find_event(int type)
Quoted 8 lines
Quoted 4 lines
Curious: does it only happen with the trace-event-sample? I doubt we already reached this threshold of event number. But anyway, it's a good thing.
I guess we haven't reached this limit, at least for mainline. :)
And the biggest id is 48 in my config.
I think we'll hit 256 pretty soon :) Applied, thanks guys!
Btw., has anyone thought about a .config option that turns every dprintk into a tracepoint, enumerated in /debug/tracing/events/ nicely (grouped by subsystems) and toggle-able?
( They cannot have 'format' and 'filter' files [at least yet] - but
integrating them into the existing tracing facilities makes sense nevertheless - they are often used as subsystem tracepoints. Allowing them to be captured via the tracing facilities would make their usage a lot more flexible. )
Ingo
Commit-ID: 7a4f453b6d7379a7c380825949977c5a838aa012 Gitweb: http://git.kernel.org/tip/7a4f453b6d7379a7c380825949977c5a838aa012 Author: Li Zefan <[email protected]> AuthorDate: Wed, 22 Apr 2009 16:53:34 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 22 Apr 2009 11:36:38 +0200
tracing/events: make struct trace_entry->type to be int type
struct trace_entry->type is unsigned char, while trace event's id is int type, thus for a event with id >= 256, it's entry->type is cast to (id % 256), and then we can't see the trace output of this event.
# insmod trace-events-sample.ko
# echo foo_bar > /mnt/tracing/set_event
# cat /debug/tracing/events/trace-events-sample/foo_bar/id
256
# cat /mnt/tracing/trace_pipe
<...>-3548 [001] 215.091142: Unknown type 0
<...>-3548 [001] 216.089207: Unknown type 0
<...>-3548 [001] 217.087271: Unknown type 0
<...>-3548 [001] 218.085332: Unknown type 0[ Impact: fix output for trace events with id >= 256 ]
LKML-Reference: <[email protected]>
--- include/linux/ftrace_event.h | 4 ++-- include/trace/ftrace.h | 2 +- kernel/trace/trace.c | 4 ++-- kernel/trace/trace.h | 2 +- kernel/trace/trace_events.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
include/linux/ftrace_event.h +2 -2
@@ -16,7 +16,7 @@ struct dentry;* bash-15816 [01] 235.197585: idle_cpu <- irq_enter */ struct trace_entry { -unsigned char type; +int type;unsigned char flags;unsigned char preempt_count;int pid;
@@ -73,7 +73,7 @@ enum print_line_t {struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc);void trace_current_buffer_unlock_commit (struct ring_buffer_event *event,unsigned long flags,int pc);
include/trace/ftrace.h +1 -1
@@ -198,7 +198,7 @@ ftrace_define_fields_##call(void) \ struct ftrace_event_call *event_call = &event_##call; \ int ret; \ \ - __common_field(unsigned char, type); \ + __common_field(int, type); \ __common_field(unsigned char, flags); \ __common_field(unsigned char, preempt_count); \ __common_field(int, pid); \
kernel/trace/trace.c +2 -2
@@ -838,7 +838,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, }struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc) {
@@ -881,7 +881,7 @@ void trace_buffer_unlock_commit(struct trace_array *tr, }struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc) { return trace_buffer_lock_reserve(&global_trace,
kernel/trace/trace.h +1 -1
@@ -422,7 +422,7 @@ void init_tracer_sysprof_debugfs(struct dentry *d_tracer);struct ring_buffer_event ;struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc);
kernel/trace/trace_events.c +1 -1
@@ -398,7 +398,7 @@ static int trace_write_header(struct trace_seq *s)"\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\n" , - FIELD(unsigned char, type), +FIELD (int, type), FIELD(unsigned char, flags), FIELD(unsigned char, preempt_count), FIELD(int, pid),
Steven Rostedt
maintainerIngo,
We need to make type 2 bytes not 4.
I sent out a patch to do this change last month
http://patchwork.kernel.org/patch/14573/
-- Steve
Quoted 125 lines · tip-bot for Li Zefan
Commit-ID: 7a4f453b6d7379a7c380825949977c5a838aa012 Gitweb: http://git.kernel.org/tip/7a4f453b6d7379a7c380825949977c5a838aa012 Author: Li Zefan <[email protected]> AuthorDate: Wed, 22 Apr 2009 16:53:34 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 22 Apr 2009 11:36:38 +0200tracing/events: make struct
trace_entry->typeto be int typestruct
trace_entry->typeis unsigned char, while trace event's id is int type, thus for a event with id >= 256, it'sentry->typeis cast to (id % 256), and then we can't see the trace output of this event.# insmod trace-events-sample.ko # echo foo_bar > /mnt/tracing/set_event # cat /debug/tracing/events/trace-events-sample/foo_bar/id 256 # cat /mnt/tracing/trace_pipe <...>-3548 [001] 215.091142: Unknown type 0 <...>-3548 [001] 216.089207: Unknown type 0 <...>-3548 [001] 217.087271: Unknown type 0 <...>-3548 [001] 218.085332: Unknown type 0[ Impact: fix output for trace events with id >= 256 ]
Signed-off-by Li Zefan <[email protected]>Cc Steven Rostedt <[email protected]>Cc Tom Zanussi <[email protected]>LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>--- include/linux/ftrace_event.h | 4 ++-- include/trace/ftrace.h | 2 +- kernel/trace/trace.c | 4 ++-- kernel/trace/trace.h | 2 +- kernel/trace/trace_events.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)include/linux/ftrace_event.h +2
-2@@ -16,7 +16,7 @@ struct dentry;* bash-15816 [01] 235.197585: idle_cpu <- irq_enter */ struct trace_entry { -unsigned char type; +int type;unsigned char flags;unsigned char preempt_count;int pid;@@ -73,7 +73,7 @@ enum print_line_t {struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc);void trace_current_buffer_unlock_commit (struct ring_buffer_event *event,unsigned long flags,int pc);include/trace/ftrace.h +1
-1@@ -198,7 +198,7 @@ ftrace_define_fields_##call(void) \ struct ftrace_event_call *event_call = &event_##call; \ int ret; \ \ - __common_field(unsigned char, type); \ + __common_field(int, type); \ __common_field(unsigned char, flags); \ __common_field(unsigned char, preempt_count); \ __common_field(int, pid); \kernel/trace/trace.c +2
-2@@ -838,7 +838,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, }struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc) {@@ -881,7 +881,7 @@ void trace_buffer_unlock_commit(struct trace_array *tr, }struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc) { return trace_buffer_lock_reserve(&global_trace,kernel/trace/trace.h +1
-1@@ -422,7 +422,7 @@ void init_tracer_sysprof_debugfs(struct dentry *d_tracer);struct ring_buffer_event ;struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc);kernel/trace/trace_events.c +1
-1@@ -398,7 +398,7 @@ static int trace_write_header(struct trace_seq *s)"\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\n" , - FIELD(unsigned char, type), +FIELD (int, type), FIELD(unsigned char, flags), FIELD(unsigned char, preempt_count), FIELD(int, pid),
Quoted 3 lines · Steven Rostedt
Ingo,
We need to make type 2 bytes not 4.
yeah, saw that - it's OK with 2 bytes too.
Quoted 3 lines
I sent out a patch to do this change last month
Mind resending it in your next batch of patches?
Ingo
Steven Rostedt
maintainerQuoted 7 lines · Ingo Molnar
Quoted 3 lines · Steven Rostedt
Ingo,
We need to make type 2 bytes not 4.
Quoted 7 lines
yeah, saw that - it's OK with 2 bytes too.
Quoted 3 lines
I sent out a patch to do this change last month
Mind resending it in your next batch of patches?
OK,
Will do ;-)
-- Steve
Quoted 9 lines · Steven Rostedt
Quoted 7 lines · Ingo Molnar
Quoted 3 lines · Steven Rostedt
Ingo,
We need to make type 2 bytes not 4.
yeah, saw that - it's OK with 2 bytes too.
Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
I sent out a patch to do this change last month
Mind resending it in your next batch of patches?
OK,
Will do ;-)
Ah, I didn't notice that patch, and I thought ushort may be too small for modular TRACE_EVENT.
Steven Rostedt
maintainerQuoted 30 lines · Li Zefan
struct
trace_entry->typeis unsigned char, while trace event's id is int type, thus for a event with id >= 256, it'sentry->typeis cast to (id % 256), and then we can't see the trace output of this event.# insmod trace-events-sample.ko # echo foo_bar > /mnt/tracing/set_event # cat /debug/tracing/events/trace-events-sample/foo_bar/id 256 # cat /mnt/tracing/trace_pipe <...>-3548 [001] 215.091142: Unknown type 0 <...>-3548 [001] 216.089207: Unknown type 0 <...>-3548 [001] 217.087271: Unknown type 0 <...>-3548 [001] 218.085332: Unknown type 0[ Impact: fix output for trace events with id >= 256 ]
Signed-off-by Li Zefan <[email protected]>--- include/linux/ftrace_event.h | 4 ++-- include/trace/ftrace.h | 2 +- kernel/trace/trace.c | 4 ++-- kernel/trace/trace.h | 2 +- kernel/trace/trace_events.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)include/linux/ftrace_event.h +0
-0
include/linux/ftrace_event.h struct dentry; · line 19
Quoted 5 lines
include/linux/ftrace_event.h +1
-1@@ -16,7 +16,7 @@ struct dentry;* bash-15816 [01] 235.197585: idle_cpu <- irq_enter */ struct trace_entry { -unsigned char type; +int type;
I sent out a patch before making this a short. I don't know why it got lost. A short is 65536, which should be more than enough to hold all the necessary events. It also makes the first few items fit nicely into 4 bytes.
I'll go dig that patch out again and resend it.
-- Steve
Quoted 77 lines
include/linux/ftrace_event.h +1
-1unsigned char flags;unsigned char preempt_count;int pid;@@ -73,7 +73,7 @@ enum print_line_t {struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc);void trace_current_buffer_unlock_commit (struct ring_buffer_event *event,unsigned long flags,int pc);include/trace/ftrace.h +1
-1@@ -198,7 +198,7 @@ ftrace_define_fields_##call(void) \ struct ftrace_event_call *event_call = &event_##call; \ int ret; \ \ - __common_field(unsigned char, type); \ + __common_field(int, type); \ __common_field(unsigned char, flags); \ __common_field(unsigned char, preempt_count); \ __common_field(int, pid); \kernel/trace/trace.c +2
-2@@ -838,7 +838,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, }struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc) {@@ -881,7 +881,7 @@ void trace_buffer_unlock_commit(struct trace_array *tr, }struct ring_buffer_event * -trace_current_buffer_lock_reserve (unsigned char type,unsigned long len, +trace_current_buffer_lock_reserve (int type,unsigned long len,unsigned long flags,int pc) { return trace_buffer_lock_reserve(&global_trace,kernel/trace/trace.h +1
-1@@ -422,7 +422,7 @@ void init_tracer_sysprof_debugfs(struct dentry *d_tracer);struct ring_buffer_event ;struct ring_buffer_event *trace_buffer_lock_reserve (struct trace_array *tr, -unsigned char type, +int type,unsigned long len,unsigned long flags,int pc);kernel/trace/trace_events.c +1
-1@@ -398,7 +398,7 @@ static int trace_write_header(struct trace_seq *s)"\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" "\n" , - FIELD(unsigned char, type), +FIELD (int, type), FIELD(unsigned char, flags), FIELD(unsigned char, preempt_count), FIELD(int, pid),Signature · 1 line
1.5.4.rc3