updates for tip/tracing/ftrace
Steven Rostedt
maintainerIngo,
Please pull the latest tip/tracing/ftrace-1 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/ftrace-1
Steven Rostedt (2):
tracing: increase size of number of possible events
tracing: add size checks for exported ftrace internal structures
----
kernel/trace/trace.h | 5 ++++- kernel/trace/trace_events.c | 5 ++++- kernel/trace/trace_export.c | 4 ++++ kernel/trace/trace_output.c | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-)
Steven Rostedt
maintainerPATCH 1/2 tracing: increase size of number of possible events
From: Steven Rostedt <[email protected]>
With the new event tracing registration, we must increase the number of events that can be registered. Currently the type field is only one byte, which leaves us only 256 possible events.
Since we do not save the CPU number in the tracer anymore (it is determined by the per cpu ring buffer that is used) we have an extra byte to use.
This patch increases the size of type from 1 byte (256 events) to 2 bytes (65,536 events).
It also adds a WARN_ON_ONCE if we exceed that limit.
--- kernel/trace/trace.h | 5 ++++- kernel/trace/trace_events.c | 2 +- kernel/trace/trace_output.c | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-)
kernel/trace/trace.h +4 -1
@@ -48,13 +48,16 @@ enum trace_type {* bash-15816 [01] 235.197585: idle_cpu <- irq_enter */ struct trace_entry { -unsigned char type; +unsigned short type;unsigned char flags;unsigned char preempt_count;int pid;int tgid; }; +#define FTRACE_MAX_EVENT \ + ((1 << (sizeof(((struct trace_entry *)0)->type) * 8)) - 1) +/* * Function trace entry - function address and parent function addres: */
kernel/trace/trace_events.c +1 -1
@@ -357,7 +357,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(unsigned short, type), FIELD(unsigned char, flags), FIELD(unsigned char, preempt_count), FIELD(int, pid),
kernel/trace/trace_output.c +2 -0
@@ -513,6 +513,8 @@ int register_ftrace_event(struct trace_event *event) out:mutex_unlock (&trace_event_mutex); +WARN_ON_ONCE (next_event_type >FTRACE_MAX_EVENT ); +return ret; }
Signature · 3 lines
1.6.2 --
Steven Rostedt
maintainerPATCH 2/2 tracing: add size checks for exported ftrace internal structures
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
The events exported by TRACE_EVENT are automated and are guaranteed to be correct when used.
The internal ftrace sturctures on the other hand are more manually exported. These require the ftrace maintainer to make sure they are up to date.
This patch adds a size check to help flag when a type changes in an internal ftrace data structure, and the update needs to be reflected in the export.
If a export is incorrect, then the only harm is that the user space tools will not know how to correctly read the internal structures of ftrace.
--- kernel/trace/trace_events.c | 3 +++ kernel/trace/trace_export.c | 4 ++++ 2 files changed, 7 insertions(+), 0 deletions(-)
kernel/trace/trace_events.c +3 -0
@@ -341,8 +341,11 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,return cnt; } +extern char *__bad_type_size (void ); +#undef FIELD#define FIELD (type, name) \ + sizeof(type) != sizeof(field.name) ? __bad_type_size() : \ #type, #name, offsetof(typeof(field), name), sizeof(field.name)static int trace_write_header (struct trace_seq *s)
kernel/trace/trace_export.c +4 -0
@@ -19,8 +19,12 @@#undef TRACE_STRUCT #define TRACE_STRUCT(args...) args +extern void __bad_type_size (void ); +#undef TRACE_FIELD#define TRACE_FIELD (type, item, assign) \ + if (sizeof(type) != sizeof(field.item)) \ + __bad_type_size(); \ ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ "offset:%u;\tsize:%u;\n", \ (unsigned int)offsetof(typeof(field), item), \
Signature · 3 lines
1.6.2 --