tracing: various updates for tip
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
Lai Jiangshan (1):
tracing/events: add missing type info of dynamic arrays
Li Zefan (2):
tracing/events: record the size of dynamic arrays tracing/filters: improve subsystem filter
Xiao Guangrong (1):
tracing: cleanup for tracing_trace_options_read()
----
include/linux/ftrace_event.h | 4 +- include/trace/ftrace.h | 18 +++-- kernel/trace/trace.c | 6 +- kernel/trace/trace.h | 3 +- kernel/trace/trace_events_filter.c | 130 ++++++++++++++++++++++++------------ 5 files changed, 104 insertions(+), 57 deletions(-)
Steven Rostedt
maintainerPATCH 1/4 tracing/events: add missing type info of dynamic arrays
From: Lai Jiangshan <[email protected]>
The format file doesn't contain enough information for __dynamic_array/__string. The type name is missing.
Before:
# cat format:
name: irq_handler_entry
...
field:__data_loc name; offset:16; size:2;After:
# cat format:
name: irq_handler_entry
...
field:__data_loc char[] name; offset:16; size:2;LKML-Reference: <[email protected]>
--- include/trace/ftrace.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/trace/ftrace.h +2 -2
@@ -120,7 +120,7 @@#undef __dynamic_array#define __dynamic_array (type, item, len) \ - ret = trace_seq_printf(s, "\tfield:__data_loc " #item ";\t" \ + ret = trace_seq_printf(s, "\tfield:__data_loc " #type "[] " #item ";\t"\ "offset:%u;\tsize:%u;\n", \ (unsigned int)offsetof(typeof(field), \ __data_loc_##item), \
@@ -279,7 +279,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \#undef __dynamic_array#define __dynamic_array (type, item, len) \ - ret = trace_define_field(event_call, "__data_loc" "[" #type "]", #item,\ + ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \ offsetof(typeof(field), __data_loc_##item), \ sizeof(field.__data_loc_##item), 0);
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 2/4 tracing/events: record the size of dynamic arrays
In reply to Steven RostedtFrom: Li Zefan <[email protected]>
When a dynamic array is defined, we add __data_loc_foo in trace_entry to record the offset of the array, but the size of the array is not recorded, which causes 2 problems:
- the event filter just compares the first 2 chars of the strings.
- parsers can't parse dynamic arrays.
So we encode the size of each dynamic array in the higher 16 bits of __data_loc_foo, while the offset is in lower 16 bits.
LKML-Reference: <[email protected]>
--- include/trace/ftrace.h | 14 ++++++++------ kernel/trace/trace_events_filter.c | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-)
include/trace/ftrace.h +8 -6
@@ -25,7 +25,7 @@#define __array (type, item, len) type item[len];#undef __dynamic_array -#define __dynamic_array (type, item, len) unsigned short __data_loc_##item; +#define __dynamic_array (type, item, len) u32 __data_loc_##item;#undef __string#define __string (item, src) __dynamic_array(char, item, -1)
@@ -51,13 +51,14 @@* Include the following: * * struct ftrace_data_offsets_<call> { -* int <item1>; -* int <item2>; +* u32 <item1>; +* u32 <item2>; * [...] * }; * -* The __dynamic_array() macro will create each int <item>, this is +* The __dynamic_array() macro will create each u32 <item>, this is * to keep the offset of each array from the beginning of the event. +* The size of an array is also encoded, in the higher 16 bits of <item>. */ #undef __field
@@ -67,7 +68,7 @@#define __array (type, item, len)#undef __dynamic_array -#define __dynamic_array (type, item, len) int item; +#define __dynamic_array (type, item, len) u32 item;#undef __string#define __string (item, src) __dynamic_array(char, item, -1)
@@ -207,7 +208,7 @@ ftrace_format_##call(struct trace_seq *s) \#undef __get_dynamic_array#define __get_dynamic_array (field) \ - ((void *)__entry + __entry->__data_loc_##field) + ((void *)__entry + (__entry->__data_loc_##field & 0xffff))#undef __get_str#define __get_str (field) (char *)__get_dynamic_array(field)
@@ -325,6 +326,7 @@ ftrace_define_fields_##call(void) \#define __dynamic_array (type, item, len) \ __data_offsets->item = __data_size + \ offsetof(typeof(*entry), __data); \ + __data_offsets->item |= (len * sizeof(type)) << 16; \ __data_size += (len) * sizeof(type);#undef __string
kernel/trace/trace_events_filter.c +4 -2
@@ -176,11 +176,13 @@ static int filter_pred_string(struct filter_pred *pred, void *event,static int filter_pred_strloc (struct filter_pred *pred,void *event,int val1,int val2) { -unsigned short str_loc = *(unsigned short *)(event + pred->offset); +u32 str_item = *(u32 *)(event + pred->offset); +int str_loc = str_item &0xffff ; +int str_len = str_item >>16 ;char *addr = (char *)(event + str_loc);int cmp, match; - cmp =strncmp (addr, pred->str_val, pred->str_len); + cmp =strncmp (addr, pred->str_val, str_len); match = (!cmp) ^ pred->not;
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 3/4 tracing: cleanup for tracing_trace_options_read()
In reply to Steven RostedtFrom: Xiao Guangrong <[email protected]>
'\n' is already appended, and what we need is just an extra space for the '\0'.
LKML-Reference: <[email protected]>
--- kernel/trace/trace.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
@@ -2256,8 +2256,8 @@ tracing_trace_options_read(struct file *filp, char __user *ubuf, len +=3 ;/* "no" and newline */ } -/* +2 for \n and \0 */ - buf =kmalloc (len +2 ,GFP_KERNEL ); +/* +1 for \0 */ + buf =kmalloc (len +1 ,GFP_KERNEL );if (!buf) {mutex_unlock (&trace_types_lock);return -ENOMEM ;
@@ -2280,7 +2280,7 @@ tracing_trace_options_read(struct file *filp, char __user *ubuf, }mutex_unlock (&trace_types_lock); -WARN_ON (r >= len +2 ); +WARN_ON (r >= len +1 ); r =simple_read_from_buffer (ubuf, cnt, ppos, buf, r);
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 4/4 tracing/filters: improve subsystem filter
In reply to Steven RostedtFrom: Li Zefan <[email protected]>
Currently a subsystem filter should be applicable to all events under the subsystem, and if it failed, all the event filters will be cleared. Those behaviors make subsys filter much less useful:
# echo 'vec == 1' > irq/softirq_entry/filter # echo 'irq == 5' > irq/filter bash: echo: write error: Invalid argument # cat irq/softirq_entry/filter none
I'd expect it set the filter for irq_handler_entry/exit, and not touch softirq_entry/exit.
The basic idea is, try to see if the filter can be applied to which events, and then just apply to the those events:
# echo 'vec == 1' > softirq_entry/filter # echo 'irq == 5' > filter # cat irq_handler_entry/filter irq == 5 # cat softirq_entry/filter vec == 1
Changelog for v2:
- do some cleanups to address Frederic's comments.
LKML-Reference: <[email protected]>
--- include/linux/ftrace_event.h | 4 +- kernel/trace/trace.h | 3 +- kernel/trace/trace_events_filter.c | 124 ++++++++++++++++++++++++------------ 3 files changed, 87 insertions(+), 44 deletions(-)
include/linux/ftrace_event.h +3 -1
@@ -101,6 +101,8 @@ void trace_current_buffer_discard_commit(struct ring_buffer_event *event);void tracing_record_cmdline (struct task_struct *tsk); +struct event_filter ; +struct ftrace_event_call {struct list_head list;char *name;
@@ -116,7 +118,7 @@ struct ftrace_event_call {int (*define_fields)(void );struct list_head fields;int filter_active; -void *filter; +struct event_filter *filter;void *mod;#ifdef CONFIG_EVENT_PROFILE
kernel/trace/trace.h +2 -1
@@ -750,13 +750,14 @@ struct event_filter {int n_preds;struct filter_pred **preds;char *filter_string; +bool no_reset; };struct event_subsystem {struct list_head list;const char *name;struct dentry *entry; -void *filter; +struct event_filter *filter;int nr_events; };
kernel/trace/trace_events_filter.c +82 -42
236 lines not on this page · raw message
Signature · 3 lines
1.6.3.3 --
Quoted 18 lines · Steven Rostedt
Ingo,
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/coreLai Jiangshan (1):
tracing/events: add missing type info of dynamic arraysLi Zefan (2):
tracing/events: record the size of dynamic arrays tracing/filters: improve subsystem filterXiao Guangrong (1):
tracing: cleanup fortracing_trace_options_read()
Quoted 7 lines
----
include/linux/ftrace_event.h | 4 +- include/trace/ftrace.h | 18 +++-- kernel/trace/trace.c | 6 +- kernel/trace/trace.h | 3 +- kernel/trace/trace_events_filter.c | 130 ++++++++++++++++++++++++------------ 5 files changed, 104 insertions(+), 57 deletions(-)
Pulled, thanks Steve!
Ingo