tracing: updates
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 (1):
ftrace: Allow to remove a single function from function graph filter
Steven Rostedt (2):
tracing: Add correct/incorrect to sort keys for branch annotation output
tracing: Add notrace to TRACE_EVENT implementation functions
----
include/trace/ftrace.h | 31 +++++++++++++++----------- kernel/trace/ftrace.c | 51 ++++++++++++++++++++++++++---------------- kernel/trace/trace.h | 3 +- kernel/trace/trace_branch.c | 19 ++++++++++++++- 4 files changed, 68 insertions(+), 36 deletions(-)
Steven Rostedt
maintainerPATCH 1/3 tracing: Add correct/incorrect to sort keys for branch annotation output
From: Steven Rostedt <[email protected]>
The branch annotation is a bit difficult to see the worst offenders because it only sorts by percentage:
correct incorrect % Function File Line
------- --------- - -------- ---- ----
0 163 100 qdisc_restart sch_generic.c 179
0 163 100 pfifo_fast_dequeue sch_generic.c 447
0 4 100 pskb_trim_rcsum skbuff.h 1689
0 4 100 llc_rcv llc_input.c 170
0 18 100 psmouse_interrupt psmouse-base.c 304
0 3 100 atkbd_interrupt atkbd.c 389
0 5 100 usb_alloc_dev usb.c 437
0 11 100 vsscanf vsprintf.c 1897
0 2 100 IS_ERR err.h 34
0 23 100 __rmqueue_fallback page_alloc.c 865
0 4 100 probe_wakeup_sched_switch trace_sched_wakeup.c 142
0 3 100 move_masked_irq migration.c 11Adding the incorrect and correct values as sort keys makes this file a bit more informative:
correct incorrect % Function File Line
------- --------- - -------- ---- ----
0 366541 100 audit_syscall_entry auditsc.c 1637
0 366538 100 audit_syscall_exit auditsc.c 1685
0 115839 100 sched_info_switch sched_stats.h 269
0 74567 100 sched_info_queued sched_stats.h 222
0 66578 100 sched_info_dequeued sched_stats.h 177
0 15113 100 trace_workqueue_insertion workqueue.h 38
0 15107 100 trace_workqueue_execution workqueue.h 45
0 3622 100 syscall_trace_leave ptrace.c 1772
0 2750 100 sched_move_task sched.c 10100
0 2750 100 sched_move_task sched.c 10110
0 1815 100 pre_schedule_rt sched_rt.c 1462
0 837 100 audit_alloc auditsc.c 879
0 814 100 tcp_mss_split_point tcp_output.c 1302--- kernel/trace/trace_branch.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-)
kernel/trace/trace_branch.c +17 -2
@@ -307,8 +307,23 @@ static int annotated_branch_stat_cmp(void *p1, void *p2)return -1 ;if (percent_a > percent_b)return 1 ; -else -return 0 ; + +if (a->incorrect < b->incorrect) +return -1 ; +if (a->incorrect > b->incorrect) +return 1 ; + +/* +* Since the above shows worse (incorrect) cases +* first, we continue that by showing best (correct) +* cases last. +*/ +if (a->correct > b->correct) +return -1 ; +if (a->correct < b->correct) +return 1 ; + +return 0 ; }static struct tracer_stat annotated_branch_stats = {
Signature · 1 line
1.6.5
Steven Rostedt
maintainerPATCH 2/3 ftrace: Allow to remove a single function from function graph filter
In reply to Steven RostedtFrom: Li Zefan <[email protected]>
I don't see why we can only clear all functions from the filter.
After patching:
# echo sys_open > set_graph_function # echo sys_close >> set_graph_function # cat set_graph_function sys_open sys_close # echo '!sys_close' >> set_graph_function # cat set_graph_function sys_open
LKML-Reference: <[email protected]>
--- kernel/trace/ftrace.c | 51 +++++++++++++++++++++++++++++------------------- kernel/trace/trace.h | 3 +- 2 files changed, 33 insertions(+), 21 deletions(-)
kernel/trace/ftrace.c +31 -20
@@ -2426,6 +2426,7 @@ static const struct file_operations ftrace_notrace_fops = {static DEFINE_MUTEX (graph_lock);int ftrace_graph_count; +int ftrace_graph_filter_enabled;unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS ]__read_mostly ; static void *
@@ -2448,7 +2449,7 @@ static void *g_start(struct seq_file *m, loff_t *pos)mutex_lock (&graph_lock);/* Nothing, tell g_show to print all functions are enabled */ -if (!ftrace_graph_count && !*pos) +if (!ftrace_graph_filter_enabled && !*pos)return (void *)1 ;return __g_next (m, pos);
@@ -2494,6 +2495,7 @@ ftrace_graph_open(struct inode *inode, struct file *file)mutex_lock (&graph_lock);if ((file->f_mode &FMODE_WRITE ) && (file->f_flags &O_TRUNC )) { + ftrace_graph_filter_enabled =0 ; ftrace_graph_count =0 ;memset (ftrace_graph_funcs,0 ,sizeof (ftrace_graph_funcs)); }
@@ -2519,7 +2521,7 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)struct dyn_ftrace *rec;struct ftrace_page *pg;int search_len; -int found =0 ; +int fail =1 ;int type, not;char *search;bool exists;
@@ -2530,37 +2532,51 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)/* decode regex */ type =filter_parse_regex (buffer,strlen (buffer), &search, ¬); -if (not) -return -EINVAL ; +if (!not && *idx >=FTRACE_GRAPH_MAX_FUNCS ) +return -EBUSY ; search_len =strlen (search);mutex_lock (&ftrace_lock);do_for_each_ftrace_rec (pg, rec) { -if (*idx >=FTRACE_GRAPH_MAX_FUNCS ) -break ; -if (rec->flags & (FTRACE_FL_FAILED |FTRACE_FL_FREE ))continue ;if (ftrace_match_record (rec, search, search_len, type)) { -/* ensure it is not already in the array */ +/* if it is in the array */ exists = false; -for (i =0 ; i < *idx; i++) +for (i =0 ; i < *idx; i++) {if (array[i] == rec->ip) { exists = true;break ; } -if (!exists) - array[(*idx)++] = rec->ip; - found =1 ; + } + +if (!not) { + fail =0 ; +if (!exists) { + array[(*idx)++] = rec->ip; +if (*idx >=FTRACE_GRAPH_MAX_FUNCS ) + goto out; + } + }else { +if (exists) { + array[i] = array[--(*idx)]; + array[*idx] =0 ; + fail =0 ; + } + } } }while_for_each_ftrace_rec (); - +out:mutex_unlock (&ftrace_lock); -return found ?0 : -EINVAL ; +if (fail) +return -EINVAL ; + + ftrace_graph_filter_enabled =1 ; +return 0 ; } static ssize_t
@@ -2570,16 +2586,11 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,struct trace_parser parser;ssize_t read, ret; -if (!cnt || cnt <0 ) +if (!cnt)return 0 ;mutex_lock (&graph_lock); -if (ftrace_graph_count >=FTRACE_GRAPH_MAX_FUNCS ) { - ret = -EBUSY ; - goto out_unlock; - } -if (trace_parser_get_init (&parser,FTRACE_BUFF_MAX )) { ret = -ENOMEM ; goto out_unlock;
kernel/trace/trace.h +2 -1
@@ -497,6 +497,7 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);#ifdef CONFIG_DYNAMIC_FTRACE /* TODO: make this variable */ #define FTRACE_GRAPH_MAX_FUNCS 32 +extern int ftrace_graph_filter_enabled;extern int ftrace_graph_count;extern unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS ];
@@ -504,7 +505,7 @@ static inline int ftrace_graph_addr(unsigned long addr) {int i; -if (!ftrace_graph_count) +if (!ftrace_graph_filter_enabled)return 1 ;for (i =0 ; i < ftrace_graph_count; i++) {
Signature · 1 line
1.6.5
Steven Rostedt
maintainerPATCH 3/3 tracing: Add notrace to TRACE_EVENT implementation functions
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
The functions used to implement the TRACE_EVENT macro show up in function tracing. This is considered a distraction, and these should not be displayed. For example:
<idle>-0 [000] 57.202149: task_of <-update_stats_wait_end
<idle>-0 [000] 57.202149: ftrace_raw_event_sched_stat_wait <-update_stats_wait_end
<idle>-0 [000] 57.202150: ftrace_raw_event_id_sched_stat_template <-ftrace_raw_event_sched_stat_wait
<idle>-0 [000] 57.202150: sched_stat_wait: comm=sshd pid=2735 delay=19207 [ns]The "ftrace_raw_event_*" traces are just the utility functions used by TRACE_EVENT tracepoints.
--- include/trace/ftrace.h | 31 ++++++++++++++++++------------- 1 files changed, 18 insertions(+), 13 deletions(-)
include/trace/ftrace.h +18 -13
@@ -199,7 +199,7 @@#undef DECLARE_EVENT_CLASS#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ -static enum print_line_t \ +static notrace enum print_line_t \ ftrace_raw_output_id_##call(int event_id, const char *name, \ struct trace_iterator *iter, int flags) \ { \
@@ -232,7 +232,7 @@ ftrace_raw_output_id_##call(int event_id, const char *name, \#undef DEFINE_EVENT#define DEFINE_EVENT (template, name, proto, args) \ -static enum print_line_t \ +static notrace enum print_line_t \ ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \ { \ return ftrace_raw_output_id_##template(event_##name.id, \
@@ -241,7 +241,7 @@ ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \#undef DEFINE_EVENT_PRINT#define DEFINE_EVENT_PRINT (template, call, proto, args, print) \ -static enum print_line_t \ +static notrace enum print_line_t \ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \ { \ struct trace_seq *s = &iter->seq; \
@@ -307,7 +307,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \#undef DECLARE_EVENT_CLASS#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, func, print) \ -static int \ +static int notrace \ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ { \ struct ftrace_raw_##call field; \
@@ -355,7 +355,7 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \#undef DECLARE_EVENT_CLASS#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ -static inline int ftrace_get_offsets_##call( \ +static inline notrace int ftrace_get_offsets_##call( \ struct ftrace_data_offsets_##call *__data_offsets, proto) \ { \ int __data_size = 0; \
@@ -402,12 +402,14 @@ static inline int ftrace_get_offsets_##call( \ \ static void ftrace_profile_##name(proto); \ \ -static int ftrace_profile_enable_##name(struct ftrace_event_call *unused)\ +static notrace int \ +ftrace_profile_enable_##name(struct ftrace_event_call *unused) \ { \ return register_trace_##name(ftrace_profile_##name); \ } \ \ -static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\ +static notrace void \ +ftrace_profile_disable_##name(struct ftrace_event_call *unused) \ { \ unregister_trace_##name(ftrace_profile_##name); \ }
@@ -541,7 +543,8 @@ static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\#undef DECLARE_EVENT_CLASS#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ \ -static void ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \ +static notrace void \ +ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \ proto) \ { \ struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
@@ -578,17 +581,19 @@ static void ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \#undef DEFINE_EVENT#define DEFINE_EVENT (template, call, proto, args) \ \ -static void ftrace_raw_event_##call(proto) \ +static notrace void ftrace_raw_event_##call(proto) \ { \ ftrace_raw_event_id_##template(&event_##call, args); \ } \ \ -static int ftrace_raw_reg_event_##call(struct ftrace_event_call *unused)\ +static notrace int \ +ftrace_raw_reg_event_##call(struct ftrace_event_call *unused) \ { \ return register_trace_##call(ftrace_raw_event_##call); \ } \ \ -static void ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused)\ +static notrace void \ +ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused) \ { \ unregister_trace_##call(ftrace_raw_event_##call); \ } \
@@ -750,7 +755,7 @@ __attribute__((section("_ftrace_events"))) event_##call = { \#undef DECLARE_EVENT_CLASS#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ -static void \ +static notrace void \ ftrace_profile_templ_##call(struct ftrace_event_call *event_call, \ proto) \ { \
@@ -820,7 +825,7 @@ end_recursion: \#undef DEFINE_EVENT#define DEFINE_EVENT (template, call, proto, args) \ -static void ftrace_profile_##call(proto) \ +static notrace void ftrace_profile_##call(proto) \ { \ struct ftrace_event_call *event_call = &event_##call; \ \
Signature · 1 line
1.6.5
Quoted 16 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/coreLi Zefan (1):
ftrace: Allow to remove a single function from function graph filterSteven Rostedt (2):
tracing: Add correct/incorrect to sort keys for branch annotation output
tracing: Add notrace toTRACE_EVENTimplementation functions
Quoted 6 lines
----
include/trace/ftrace.h | 31 +++++++++++++++----------- kernel/trace/ftrace.c | 51 ++++++++++++++++++++++++++---------------- kernel/trace/trace.h | 3 +- kernel/trace/trace_branch.c | 19 ++++++++++++++- 4 files changed, 68 insertions(+), 36 deletions(-)
Pulled, thanks a lot Steve!
Ingo