tracing: function graph output for preempt/irqs-off tracers
Subsystems (3)
v6 cover tracing: function graph output for preempt/irqs-off tracers
hi,
updates based on comments by Frederic Weisbecker,
also rebase to latest master.
I'm sending reworked version of the graph output support for preemptirqsoff/preemptoff/irqsoff tracers.
v6:
- using stubs instead of ifdef in trace_irqsoff for graph tracer's calls
v5:
- function graph events are back in game
- changed function graph tracer interface to be able to pass custom tracer flags
- changed calls to trace_function to trace graph records when the display-graph otion is enabled. As function tracer and graph tracer have different spacing during the record output, this way it looks better, and the info stays.
This could be also done via TRACE_PRINT, then it'd be displayed as comment.. I chose the first way, though it could be easily changed.
v4:
- fixed header to display all the info as for
current irqsoff tracer
- fixed reset of the max_tr buffer during the
display-graph switch
v3:
- the function_graph tracer should have the same output as current version even with events enabled, unless I missed something again ;)
- I gave up the idea of function_graph events, since it was unsuitable for outputing other events as comments "/* */"
- I'm not including the raw function_graph for now
attached patches:
- 1/4 adding ftrace events for graph tracer
- 2/4 graph tracer - adding support for passing flags to ouput functions
- 3/4 graph output support for irqsoff tracer
- 4/4 graph output support for preemptirqsoff/preemptoff tracers
plz let me know what you think
wbr,
jirka
---
PATCH v6 1/4 tracing: adding ftrace events for graph tracer
hi,
this patch adds ftrace events for graph tracer, so the graph output could be shared within other tracers.
wbr,
jirka
--- kernel/trace/trace_functions_graph.c | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-)
kernel/trace/trace_functions_graph.c +27 -1
@@ -39,7 +39,7 @@ struct fgraph_data {#define TRACE_GRAPH_PRINT_OVERHEAD 0x4#define TRACE_GRAPH_PRINT_PROC 0x8#define TRACE_GRAPH_PRINT_DURATION 0x10 -#define TRACE_GRAPH_PRINT_ABS_TIME 0X20 +#define TRACE_GRAPH_PRINT_ABS_TIME 0x20static struct tracer_opt trace_opts[] = {/* Display overruns? (for self-debug purpose) */
@@ -1094,6 +1094,12 @@ print_graph_function(struct trace_iterator *iter)return TRACE_TYPE_HANDLED ; } +static enum print_line_t +print_graph_function_event (struct trace_iterator *iter,int flags) +{ +return print_graph_function (iter); +} +static void print_lat_header (struct seq_file *s) {static const char spaces[] =" " /* 16 spaces */
@@ -1197,6 +1203,16 @@ static void graph_trace_close(struct trace_iterator *iter) } } +static struct trace_event graph_trace_entry_event = { + .type =TRACE_GRAPH_ENT , + .trace = print_graph_function_event, +}; + +static struct trace_event graph_trace_ret_event = { + .type =TRACE_GRAPH_RET , + .trace = print_graph_function_event, +}; +static struct tracer graph_trace__read_mostly = { .name ="function_graph" , .open = graph_trace_open,
@@ -1218,6 +1234,16 @@ static __init int init_graph_trace(void) { max_bytes_for_cpu =snprintf (NULL ,0 ,"%d" , nr_cpu_ids -1 ); +if (!register_ftrace_event (&graph_trace_entry_event)) { +pr_warning ("Warning: could not register graph trace events\n" ); +return 1 ; + } + +if (!register_ftrace_event (&graph_trace_ret_event)) { +pr_warning ("Warning: could not register graph trace events\n" ); +return 1 ; + } +return register_tracer (&graph_trace); }
Signature · 1 line
1.6.6.1
[tip:tracing/core] tracing: Add ftrace events for graph tracer
Commit-ID: 9106b69382912ddc403a307b69bf894a6f3004e4 Gitweb: http://git.kernel.org/tip/9106b69382912ddc403a307b69bf894a6f3004e4 Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 2 Apr 2010 19:01:20 +0200 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 26 Apr 2010 16:55:08 -0400
tracing: Add ftrace events for graph tracer
Add ftrace events for graph tracer, so the graph output could be shared with other tracers.
LKML-Reference: <[email protected]>
--- kernel/trace/trace_functions_graph.c | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-)
kernel/trace/trace_functions_graph.c +27 -1
@@ -40,7 +40,7 @@ struct fgraph_data {#define TRACE_GRAPH_PRINT_OVERHEAD 0x4#define TRACE_GRAPH_PRINT_PROC 0x8#define TRACE_GRAPH_PRINT_DURATION 0x10 -#define TRACE_GRAPH_PRINT_ABS_TIME 0X20 +#define TRACE_GRAPH_PRINT_ABS_TIME 0x20static struct tracer_opt trace_opts[] = {/* Display overruns? (for self-debug purpose) */
@@ -1096,6 +1096,12 @@ print_graph_function(struct trace_iterator *iter)return TRACE_TYPE_HANDLED ; } +static enum print_line_t +print_graph_function_event (struct trace_iterator *iter,int flags) +{ +return print_graph_function (iter); +} +static void print_lat_header (struct seq_file *s) {static const char spaces[] =" " /* 16 spaces */
@@ -1199,6 +1205,16 @@ static void graph_trace_close(struct trace_iterator *iter) } } +static struct trace_event graph_trace_entry_event = { + .type =TRACE_GRAPH_ENT , + .trace = print_graph_function_event, +}; + +static struct trace_event graph_trace_ret_event = { + .type =TRACE_GRAPH_RET , + .trace = print_graph_function_event, +}; +static struct tracer graph_trace__read_mostly = { .name ="function_graph" , .open = graph_trace_open,
@@ -1220,6 +1236,16 @@ static __init int init_graph_trace(void) { max_bytes_for_cpu =snprintf (NULL ,0 ,"%d" , nr_cpu_ids -1 ); +if (!register_ftrace_event (&graph_trace_entry_event)) { +pr_warning ("Warning: could not register graph trace events\n" ); +return 1 ; + } + +if (!register_ftrace_event (&graph_trace_ret_event)) { +pr_warning ("Warning: could not register graph trace events\n" ); +return 1 ; + } +return register_tracer (&graph_trace); }
PATCH v6 2/4 tracing: graph tracer - adding support for passing flags to ouput functions
In reply to Jiri Olsahi,
changing function graph tracer's interface functions to be able to use it from another tracer.
The main change is to be able to pass custom tracer flags.
wbr,
jirka
--- kernel/trace/trace.h | 6 +- kernel/trace/trace_functions_graph.c | 123 +++++++++++++++++++--------------- 2 files changed, 73 insertions(+), 56 deletions(-)
kernel/trace/trace.h +4 -2
@@ -487,7 +487,9 @@ extern int trace_clock_id;/* Standard output formatting function used for function return traces */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER -extern enum print_line_t print_graph_function (struct trace_iterator *iter); +extern enum print_line_t +print_graph_function_flags (struct trace_iterator *iter,u32 flags); +extern void print_graph_headers_flags (struct seq_file *s,u32 flags);extern enum print_line_t trace_print_graph_duration (unsigned long long duration,struct trace_seq *s);
@@ -520,7 +522,7 @@ static inline int ftrace_graph_addr(unsigned long addr)#endif /* CONFIG_DYNAMIC_FTRACE */ #else /* CONFIG_FUNCTION_GRAPH_TRACER */ static inline enum print_line_t -print_graph_function (struct trace_iterator *iter) +print_graph_function_flags (struct trace_iterator *iter,u32 flags) {return TRACE_TYPE_UNHANDLED ; }
kernel/trace/trace_functions_graph.c +69 -54
376 lines not on this page · raw message
Signature · 1 line
1.6.6.1
[tip:tracing/core] tracing: Have graph flags passed in to ouput functions
Commit-ID: d7a8d9e907cc294ec7a4a7046d1886375fbcc82e Gitweb: http://git.kernel.org/tip/d7a8d9e907cc294ec7a4a7046d1886375fbcc82e Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 2 Apr 2010 19:01:21 +0200 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 26 Apr 2010 17:30:18 -0400
tracing: Have graph flags passed in to ouput functions
Let the function graph tracer have custom flags passed to its output functions.
LKML-Reference: <[email protected]>
--- kernel/trace/trace.h | 6 +- kernel/trace/trace_functions_graph.c | 123 +++++++++++++++++++--------------- 2 files changed, 73 insertions(+), 56 deletions(-)
kernel/trace/trace.h +4 -2
@@ -491,7 +491,9 @@ extern int trace_clock_id;/* Standard output formatting function used for function return traces */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER -extern enum print_line_t print_graph_function (struct trace_iterator *iter); +extern enum print_line_t +print_graph_function_flags (struct trace_iterator *iter,u32 flags); +extern void print_graph_headers_flags (struct seq_file *s,u32 flags);extern enum print_line_t trace_print_graph_duration (unsigned long long duration,struct trace_seq *s);
@@ -524,7 +526,7 @@ static inline int ftrace_graph_addr(unsigned long addr)#endif /* CONFIG_DYNAMIC_FTRACE */ #else /* CONFIG_FUNCTION_GRAPH_TRACER */ static inline enum print_line_t -print_graph_function (struct trace_iterator *iter) +print_graph_function_flags (struct trace_iterator *iter,u32 flags) {return TRACE_TYPE_UNHANDLED ; }
kernel/trace/trace_functions_graph.c +69 -54
376 lines not on this page · raw message
PATCH v6 3/4 tracing: graph output support for irqsoff tracer
In reply to Jiri Olsahi,
when I was using irqsoff tracer, I thought it could be any use to see the disabled IRQs flow output same way as function graph output.
The graph output is enabled by setting new 'display-graph' trace option of irqsoff tracer.
wbr,
jirka
--- include/linux/ftrace.h | 15 ++- kernel/trace/trace.c | 35 +++-- kernel/trace/trace.h | 21 +++ kernel/trace/trace_functions_graph.c | 15 ++- kernel/trace/trace_irqsoff.c | 259 ++++++++++++++++++++++++++++++++-- 5 files changed, 312 insertions(+), 33 deletions(-)
include/linux/ftrace.h +11 -4
@@ -352,6 +352,10 @@ struct ftrace_graph_ret {int depth; }; +/* Type of the callback handlers for tracing function graph*/ +typedef void (*trace_func_graph_ret_t )(struct ftrace_graph_ret *);/* return */ +typedef int (*trace_func_graph_ent_t )(struct ftrace_graph_ent *);/* entry */ +#ifdef CONFIG_FUNCTION_GRAPH_TRACER /* for init task */
@@ -400,10 +404,6 @@ extern char __irqentry_text_end[];#define FTRACE_RETFUNC_DEPTH 50#define FTRACE_RETSTACK_ALLOC_SIZE 32 -/* Type of the callback handlers for tracing function graph*/ -typedef void (*trace_func_graph_ret_t )(struct ftrace_graph_ret *);/* return */ -typedef int (*trace_func_graph_ent_t )(struct ftrace_graph_ent *);/* entry */ -extern int register_ftrace_graph (trace_func_graph_ret_t retfunc,trace_func_graph_ent_t entryfunc);
@@ -441,6 +441,13 @@ static inline void unpause_graph_tracing(void)static inline void ftrace_graph_init_task (struct task_struct *t) { }static inline void ftrace_graph_exit_task (struct task_struct *t) { } +static inline int register_ftrace_graph (trace_func_graph_ret_t retfunc, +trace_func_graph_ent_t entryfunc) +{ +return -1 ; +} +static inline void unregister_ftrace_graph (void ) { } +static inline int task_curr_ret_stack (struct task_struct *tsk) {return -1 ;
kernel/trace/trace.c +22 -13
@@ -1786,7 +1786,7 @@ static void print_func_help_header(struct seq_file *m) } -static void +void print_trace_header (struct seq_file *m,struct trace_iterator *iter) {unsigned long sym_flags = (trace_flags &TRACE_ITER_SYM_MASK );
@@ -1995,7 +1995,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)return event ? event->binary (iter,0 ) :TRACE_TYPE_HANDLED ; } -static int trace_empty (struct trace_iterator *iter) +int trace_empty (struct trace_iterator *iter) {int cpu;
@@ -2058,6 +2058,23 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)return print_trace_fmt (iter); } +void trace_default_header (struct seq_file *m) +{ +struct trace_iterator *iter = m->private; + +if (iter->iter_flags &TRACE_FILE_LAT_FMT ) { +/* print nothing if the buffers are empty */ +if (trace_empty (iter)) +return ; +print_trace_header (m, iter); +if (!(trace_flags &TRACE_ITER_VERBOSE )) +print_lat_help_header (m); + }else { +if (!(trace_flags &TRACE_ITER_VERBOSE )) +print_func_help_header (m); + } +} +static int s_show (struct seq_file *m,void *v) {struct trace_iterator *iter = v;
@@ -2070,17 +2087,9 @@ static int s_show(struct seq_file *m, void *v) }if (iter->trace && iter->trace->print_header) iter->trace->print_header (m); -else if (iter->iter_flags &TRACE_FILE_LAT_FMT ) { -/* print nothing if the buffers are empty */ -if (trace_empty (iter)) -return 0 ; -print_trace_header (m, iter); -if (!(trace_flags &TRACE_ITER_VERBOSE )) -print_lat_help_header (m); - }else { -if (!(trace_flags &TRACE_ITER_VERBOSE )) -print_func_help_header (m); - } +else +trace_default_header (m); + }else if (iter->leftover) {/* * If we filled the seq_file buffer earlier, we
kernel/trace/trace.h +21 -0
@@ -376,6 +376,9 @@ void trace_function(struct trace_array *tr,unsigned long ip, unsigned long parent_ip, unsigned long flags, int pc); +void trace_default_header (struct seq_file *m); +void print_trace_header (struct seq_file *m,struct trace_iterator *iter); +int trace_empty (struct trace_iterator *iter);void trace_graph_return (struct ftrace_graph_ret *trace);int trace_graph_entry (struct ftrace_graph_ent *trace);
@@ -487,11 +490,29 @@ extern int trace_clock_id;/* Standard output formatting function used for function return traces */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER + +/* Flag options */ +#define TRACE_GRAPH_PRINT_OVERRUN 0x1 +#define TRACE_GRAPH_PRINT_CPU 0x2 +#define TRACE_GRAPH_PRINT_OVERHEAD 0x4 +#define TRACE_GRAPH_PRINT_PROC 0x8 +#define TRACE_GRAPH_PRINT_DURATION 0x10 +#define TRACE_GRAPH_PRINT_ABS_TIME 0x20 +extern enum print_line_t print_graph_function_flags (struct trace_iterator *iter,u32 flags);extern void print_graph_headers_flags (struct seq_file *s,u32 flags);extern enum print_line_t trace_print_graph_duration (unsigned long long duration,struct trace_seq *s); +extern void graph_trace_open (struct trace_iterator *iter); +extern void graph_trace_close (struct trace_iterator *iter); +extern int __trace_graph_entry (struct trace_array *tr, +struct ftrace_graph_ent *trace, +unsigned long flags,int pc); +extern void __trace_graph_return (struct trace_array *tr, +struct ftrace_graph_ret *trace, +unsigned long flags,int pc); +#ifdef CONFIG_DYNAMIC_FTRACE /* TODO: make this variable */
kernel/trace/trace_functions_graph.c +10 -5
@@ -178,7 +178,7 @@ unsigned long ftrace_return_to_handler(unsigned long frame_pointer)return ret; } -static int __trace_graph_entry (struct trace_array *tr, +int __trace_graph_entry (struct trace_array *tr,struct ftrace_graph_ent *trace,unsigned long flags,int pc)
@@ -245,7 +245,7 @@ int trace_graph_thresh_entry(struct ftrace_graph_ent *trace)return trace_graph_entry (trace); } -static void __trace_graph_return (struct trace_array *tr, +void __trace_graph_return (struct trace_array *tr,struct ftrace_graph_ret *trace,unsigned long flags,int pc)
@@ -1091,6 +1091,11 @@ print_graph_function_flags(struct trace_iterator *iter, u32 flags)trace_assign_type (field, entry);return print_graph_return (&field->ret, s, entry, iter, flags); } +case TRACE_STACK : +case TRACE_FN : +/* dont trace stack and functions as comments */ +return TRACE_TYPE_UNHANDLED ; +default :return print_graph_comment (s, entry, iter, flags); }
@@ -1168,12 +1173,12 @@ void print_graph_headers_flags(struct seq_file *s, u32 flags)seq_printf (s," | | | |\n" ); } -static void print_graph_headers (struct seq_file *s) +void print_graph_headers (struct seq_file *s) {print_graph_headers_flags (s, tracer_flags.val); } -static void graph_trace_open (struct trace_iterator *iter) +void graph_trace_open (struct trace_iterator *iter) {/* pid and depth on the last trace processed */ struct fgraph_data *data;
@@ -1208,7 +1213,7 @@ static void graph_trace_open(struct trace_iterator *iter)pr_warning ("function graph tracer: not enough memory\n" ); } -static void graph_trace_close (struct trace_iterator *iter) +void graph_trace_close (struct trace_iterator *iter) {struct fgraph_data *data = iter->private;
kernel/trace/trace_irqsoff.c +248 -11
334 lines not on this page · raw message
Signature · 1 line
1.6.6.1
Re: [PATCHv6 3/4] tracing: graph output support for irqsoff tracer
kernel/trace/trace_irqsoff.c static struct ftrace_ops trace_ops __read_mostly = · line 237
Quoted 11 lines · Jiri Olsa
kernel/trace/trace_irqsoff.c +11
-0+#define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \ + TRACE_GRAPH_PRINT_PROC) + +static enum print_line_t irqsoff_print_line (struct trace_iterator *iter) +{ +u32 flags =GRAPH_TRACER_FLAGS ; + +if (trace_flags &TRACE_ITER_LATENCY_FMT ) + flags |=TRACE_GRAPH_PRINT_DURATION ; +else + flags |=TRACE_GRAPH_PRINT_ABS_TIME ;
Why not having ABS_TIME in any case?
And more important, you probably want to add TRACE_ITER_LATENCY_FMT as well to get the contexts (need-resched, hardirq/softirq, preempt-depth, lock-depth)
Quoted 17 lines
kernel/trace/trace_irqsoff.c +17
-0+/* +* In graph mode call the graph tracer output function, +* otherwise go with the TRACE_FN event handler +*/ +if (is_graph ()) +return print_graph_function_flags (iter, flags); + +return TRACE_TYPE_UNHANDLED ; +} + +static void irqsoff_print_header (struct seq_file *s) +{ +if (is_graph ()) { +struct trace_iterator *iter = s->private; +u32 flags =GRAPH_TRACER_FLAGS ; + +if (trace_flags &TRACE_ITER_LATENCY_FMT ) {
kernel/trace/trace_irqsoff.c static struct ftrace_ops trace_ops __read_mostly = · line 265
Quoted 10 lines
kernel/trace/trace_irqsoff.c +10
-0+/* print nothing if the buffers are empty */ +if (trace_empty (iter)) +return ; + +print_trace_header (s, iter); + flags |=TRACE_GRAPH_PRINT_DURATION ; + }else + flags |=TRACE_GRAPH_PRINT_ABS_TIME ; + +print_graph_headers_flags (s, flags);
Same here.
Other than these few comments, the whole set looks good!
Thanks!
Re: [PATCHv6 3/4] tracing: graph output support for irqsoff tracer
Quoted 17 lines · Frederic Weisbecker
kernel/trace/trace_irqsoff.c static struct ftrace_ops trace_ops __read_mostly = · line 237
Quoted 11 lines · Jiri Olsa
kernel/trace/trace_irqsoff.c +11
-0+#define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \ + TRACE_GRAPH_PRINT_PROC) + +static enum print_line_t irqsoff_print_line (struct trace_iterator *iter) +{ +u32 flags =GRAPH_TRACER_FLAGS ; + +if (trace_flags &TRACE_ITER_LATENCY_FMT ) + flags |=TRACE_GRAPH_PRINT_DURATION ; +else + flags |=TRACE_GRAPH_PRINT_ABS_TIME ;Why not having
ABS_TIMEin any case?
Quoted 3 lines
And more important, you probably want to add
TRACE_ITER_LATENCY_FMTas well to get the contexts (need-resched, hardirq/softirq, preempt-depth, lock-depth)
hi,
latency info
The latency info is governed by global 'trace_flags', the graph tracers follows that as well.
absolute time
The idea was to follow the current irqsoff function trace format. Though it cannot be exatly the same, it can print the same info.
By default I added TRACE_GRAPH_PRINT_CPU and TRACE_GRAPH_PRINT_PROC, since they are always there for current irqsoff trace.
Then the absolute time is printed only in the case when the latency info is switched off.
AFAICS the 'time' field in the output (for latency enabled) actually
represents the duration (computed/printed in trace_print_lat_context function).
Hence I added TRACE_GRAPH_PRINT_DURATION to graph output for the latency case.
So the answer to your question is, the absolute time is not part of the output, since it's not part of the original trace output. My opinion is the absolute time is not be that important for this tracer, the duration is.
latency output OFF:
current tracer:
TASK-PID CPU# TIMESTAMP FUNCTION
graph tracer:
TIME CPU TASK/PID FUNCTION CALLS
latency output ON:
current tracer:
_------=> CPU#
/ _-----=> irqs-off
| / _----=> need-resched || / _---=> hardirq/softirq ||| / _--=> preempt-depth |||| /_--=> lock-depth
|||||/ delay
cmd pid |||||| time | caller
\\ / |||||| \\ | /
graph tracer:
_-----=> irqs-off
/ _----=> need-resched
| / _---=> hardirq/softirq || / _--=> preempt-depth ||| / _-=> lock-depth |||| /
CPU TASK/PID ||||| DURATION FUNCTION CALLS
Also the non-latency case covers the 'verbose' option output.
thanks for your comments,
hopefully I haven't missed anything.. ;)
jirka
Frederic Weisbecker
Acked-byRe: [PATCHv6 3/4] tracing: graph output support for irqsoff tracer
Quoted 22 lines · Jiri Olsa
Quoted 17 lines · Frederic Weisbecker
kernel/trace/trace_irqsoff.c static struct ftrace_ops trace_ops __read_mostly = · line 237
Quoted 11 lines · Jiri Olsa
kernel/trace/trace_irqsoff.c +11
-0+#define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \ + TRACE_GRAPH_PRINT_PROC) + +static enum print_line_t irqsoff_print_line (struct trace_iterator *iter) +{ +u32 flags =GRAPH_TRACER_FLAGS ; + +if (trace_flags &TRACE_ITER_LATENCY_FMT ) + flags |=TRACE_GRAPH_PRINT_DURATION ; +else + flags |=TRACE_GRAPH_PRINT_ABS_TIME ;Why not having
ABS_TIMEin any case?Quoted 3 lines
And more important, you probably want to add
TRACE_ITER_LATENCY_FMTas well to get the contexts (need-resched, hardirq/softirq, preempt-depth, lock-depth)
Quoted 6 lines
hi,
latency info
The latency info is governed by global 'trace_flags', the graph tracers follows that as well.
Doh, right.
Quoted 10 lines
absolute time
The idea was to follow the current irqsoff function trace format. Though it cannot be exatly the same, it can print the same info.By default I added
TRACE_GRAPH_PRINT_CPUandTRACE_GRAPH_PRINT_PROC, since they are always there for current irqsoff trace.Then the absolute time is printed only in the case when the latency info is switched off.
Quoted 8 lines
AFAICS the 'time' field in the output (for latency enabled) actually
represents the duration (computed/printed intrace_print_lat_contextfunction).
Hence I addedTRACE_GRAPH_PRINT_DURATIONto graph output for the latency case.So the answer to your question is, the absolute time is not part of the output, since it's not part of the original trace output. My opinion is the absolute time is not be that important for this tracer, the duration is.
I agree, I've actually made a confusion between both :)
Quoted 42 lines
latency output OFF: current tracer: TASK-PID CPU# TIMESTAMP FUNCTION graph tracer: TIME CPU TASK/PID FUNCTION CALLS latency output ON: current tracer: _------=> CPU# / _-----=> irqs-off | / _----=> need-resched || / _---=> hardirq/softirq ||| / _--=> preempt-depth |||| /_--=> lock-depth |||||/ delay cmd pid |||||| time | caller \\ / |||||| \\ | / graph tracer: _-----=> irqs-off / _----=> need-resched | / _---=> hardirq/softirq || / _--=> preempt-depth ||| / _-=> lock-depth |||| / CPU TASK/PID ||||| DURATION FUNCTION CALLS Also the non-latency case covers the 'verbose' option output.
Quoted 2 lines
thanks for your comments,
hopefully I haven't missed anything.. ;)
And thanks for your work!
For me it's ok.
Steve?
[tip:tracing/core] tracing: Add graph output support for irqsoff tracer
In reply to Jiri OlsaCommit-ID: 62b915f1060996a8e1f69be50e3b8e9e43b710cb Gitweb: http://git.kernel.org/tip/62b915f1060996a8e1f69be50e3b8e9e43b710cb Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 2 Apr 2010 19:01:22 +0200 Committer: Steven Rostedt <[email protected]> CommitDate: Tue, 27 Apr 2010 12:36:53 -0400
tracing: Add graph output support for irqsoff tracer
Add function graph output to irqsoff tracer.
The graph output is enabled by setting new 'display-graph' trace option.
LKML-Reference: <[email protected]>
--- include/linux/ftrace.h | 15 ++- kernel/trace/trace.c | 35 +++-- kernel/trace/trace.h | 21 +++ kernel/trace/trace_functions_graph.c | 15 ++- kernel/trace/trace_irqsoff.c | 271 ++++++++++++++++++++++++++++++++-- 5 files changed, 324 insertions(+), 33 deletions(-)
include/linux/ftrace.h +11 -4
@@ -352,6 +352,10 @@ struct ftrace_graph_ret {int depth; }; +/* Type of the callback handlers for tracing function graph*/ +typedef void (*trace_func_graph_ret_t )(struct ftrace_graph_ret *);/* return */ +typedef int (*trace_func_graph_ent_t )(struct ftrace_graph_ent *);/* entry */ +#ifdef CONFIG_FUNCTION_GRAPH_TRACER /* for init task */
@@ -400,10 +404,6 @@ extern char __irqentry_text_end[];#define FTRACE_RETFUNC_DEPTH 50#define FTRACE_RETSTACK_ALLOC_SIZE 32 -/* Type of the callback handlers for tracing function graph*/ -typedef void (*trace_func_graph_ret_t )(struct ftrace_graph_ret *);/* return */ -typedef int (*trace_func_graph_ent_t )(struct ftrace_graph_ent *);/* entry */ -extern int register_ftrace_graph (trace_func_graph_ret_t retfunc,trace_func_graph_ent_t entryfunc);
@@ -441,6 +441,13 @@ static inline void unpause_graph_tracing(void)static inline void ftrace_graph_init_task (struct task_struct *t) { }static inline void ftrace_graph_exit_task (struct task_struct *t) { } +static inline int register_ftrace_graph (trace_func_graph_ret_t retfunc, +trace_func_graph_ent_t entryfunc) +{ +return -1 ; +} +static inline void unregister_ftrace_graph (void ) { } +static inline int task_curr_ret_stack (struct task_struct *tsk) {return -1 ;
kernel/trace/trace.c +22 -13
@@ -1808,7 +1808,7 @@ static void print_func_help_header(struct seq_file *m) } -static void +void print_trace_header (struct seq_file *m,struct trace_iterator *iter) {unsigned long sym_flags = (trace_flags &TRACE_ITER_SYM_MASK );
@@ -2017,7 +2017,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)return event ? event->binary (iter,0 ) :TRACE_TYPE_HANDLED ; } -static int trace_empty (struct trace_iterator *iter) +int trace_empty (struct trace_iterator *iter) {int cpu;
@@ -2084,6 +2084,23 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)return print_trace_fmt (iter); } +void trace_default_header (struct seq_file *m) +{ +struct trace_iterator *iter = m->private; + +if (iter->iter_flags &TRACE_FILE_LAT_FMT ) { +/* print nothing if the buffers are empty */ +if (trace_empty (iter)) +return ; +print_trace_header (m, iter); +if (!(trace_flags &TRACE_ITER_VERBOSE )) +print_lat_help_header (m); + }else { +if (!(trace_flags &TRACE_ITER_VERBOSE )) +print_func_help_header (m); + } +} +static int s_show (struct seq_file *m,void *v) {struct trace_iterator *iter = v;
@@ -2096,17 +2113,9 @@ static int s_show(struct seq_file *m, void *v) }if (iter->trace && iter->trace->print_header) iter->trace->print_header (m); -else if (iter->iter_flags &TRACE_FILE_LAT_FMT ) { -/* print nothing if the buffers are empty */ -if (trace_empty (iter)) -return 0 ; -print_trace_header (m, iter); -if (!(trace_flags &TRACE_ITER_VERBOSE )) -print_lat_help_header (m); - }else { -if (!(trace_flags &TRACE_ITER_VERBOSE )) -print_func_help_header (m); - } +else +trace_default_header (m); + }else if (iter->leftover) {/* * If we filled the seq_file buffer earlier, we
kernel/trace/trace.h +21 -0
@@ -378,6 +378,9 @@ void trace_function(struct trace_array *tr,unsigned long ip, unsigned long parent_ip, unsigned long flags, int pc); +void trace_default_header (struct seq_file *m); +void print_trace_header (struct seq_file *m,struct trace_iterator *iter); +int trace_empty (struct trace_iterator *iter);void trace_graph_return (struct ftrace_graph_ret *trace);int trace_graph_entry (struct ftrace_graph_ent *trace);
@@ -491,11 +494,29 @@ extern int trace_clock_id;/* Standard output formatting function used for function return traces */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER + +/* Flag options */ +#define TRACE_GRAPH_PRINT_OVERRUN 0x1 +#define TRACE_GRAPH_PRINT_CPU 0x2 +#define TRACE_GRAPH_PRINT_OVERHEAD 0x4 +#define TRACE_GRAPH_PRINT_PROC 0x8 +#define TRACE_GRAPH_PRINT_DURATION 0x10 +#define TRACE_GRAPH_PRINT_ABS_TIME 0x20 +extern enum print_line_t print_graph_function_flags (struct trace_iterator *iter,u32 flags);extern void print_graph_headers_flags (struct seq_file *s,u32 flags);extern enum print_line_t trace_print_graph_duration (unsigned long long duration,struct trace_seq *s); +extern void graph_trace_open (struct trace_iterator *iter); +extern void graph_trace_close (struct trace_iterator *iter); +extern int __trace_graph_entry (struct trace_array *tr, +struct ftrace_graph_ent *trace, +unsigned long flags,int pc); +extern void __trace_graph_return (struct trace_array *tr, +struct ftrace_graph_ret *trace, +unsigned long flags,int pc); +#ifdef CONFIG_DYNAMIC_FTRACE /* TODO: make this variable */
kernel/trace/trace_functions_graph.c +10 -5
@@ -179,7 +179,7 @@ unsigned long ftrace_return_to_handler(unsigned long frame_pointer)return ret; } -static int __trace_graph_entry (struct trace_array *tr, +int __trace_graph_entry (struct trace_array *tr,struct ftrace_graph_ent *trace,unsigned long flags,int pc)
@@ -246,7 +246,7 @@ int trace_graph_thresh_entry(struct ftrace_graph_ent *trace)return trace_graph_entry (trace); } -static void __trace_graph_return (struct trace_array *tr, +void __trace_graph_return (struct trace_array *tr,struct ftrace_graph_ret *trace,unsigned long flags,int pc)
@@ -1093,6 +1093,11 @@ print_graph_function_flags(struct trace_iterator *iter, u32 flags)trace_assign_type (field, entry);return print_graph_return (&field->ret, s, entry, iter, flags); } +case TRACE_STACK : +case TRACE_FN : +/* dont trace stack and functions as comments */ +return TRACE_TYPE_UNHANDLED ; +default :return print_graph_comment (s, entry, iter, flags); }
@@ -1170,12 +1175,12 @@ void print_graph_headers_flags(struct seq_file *s, u32 flags)seq_printf (s," | | | |\n" ); } -static void print_graph_headers (struct seq_file *s) +void print_graph_headers (struct seq_file *s) {print_graph_headers_flags (s, tracer_flags.val); } -static void graph_trace_open (struct trace_iterator *iter) +void graph_trace_open (struct trace_iterator *iter) {/* pid and depth on the last trace processed */ struct fgraph_data *data;
@@ -1210,7 +1215,7 @@ static void graph_trace_open(struct trace_iterator *iter)pr_warning ("function graph tracer: not enough memory\n" ); } -static void graph_trace_close (struct trace_iterator *iter) +void graph_trace_close (struct trace_iterator *iter) {struct fgraph_data *data = iter->private;
kernel/trace/trace_irqsoff.c +260 -11
364 lines not on this page · raw message
PATCH v6 4/4 tracing: graph output support for preemptirqsoff/preemptoff tracers
In reply to Jiri Olsahi,
adding support for graph output for preemptirqsoff/preemptoff tracers.
wbr,
jirka
--- kernel/trace/trace_irqsoff.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
kernel/trace/trace_irqsoff.c +12 -0
@@ -672,9 +672,15 @@ static struct tracer preemptoff_tracer __read_mostly = .start = irqsoff_tracer_start, .stop = irqsoff_tracer_stop, .print_max = 1, + .print_header = irqsoff_print_header, + .print_line = irqsoff_print_line, + .flags = &tracer_flags, + .set_flag = irqsoff_set_flag, #ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_preemptoff, #endif + .open = irqsoff_trace_open, + .close = irqsoff_trace_close, };# define register_preemptoff (trace) register_tracer(&trace)#else
@@ -700,9 +706,15 @@ static struct tracer preemptirqsoff_tracer __read_mostly = .start = irqsoff_tracer_start, .stop = irqsoff_tracer_stop, .print_max = 1, + .print_header = irqsoff_print_header, + .print_line = irqsoff_print_line, + .flags = &tracer_flags, + .set_flag = irqsoff_set_flag, #ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_preemptirqsoff, #endif + .open = irqsoff_trace_open, + .close = irqsoff_trace_close, };# define register_preemptirqsoff (trace) register_tracer(&trace)
Signature · 1 line
1.6.6.1
Steven Rostedt
maintainerRe: [PATCHv6 4/4] tracing: graph output support for preemptirqsoff/preemptoff tracers
Quoted 4 lines · Jiri Olsa
hi,
adding support for graph output for preemptirqsoff/preemptoff tracers.
So far I like the series. But I'm confused why this patch is separate from patch 3. Is there some reason for it?
If not, I'll just merge this into patch 3
-- Steve
Quoted 45 lines
wbr,
jirkaSigned-off-by Jiri Olsa <[email protected]>--- kernel/trace/trace_irqsoff.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)kernel/trace/trace_irqsoff.c +12
-0@@ -672,9 +672,15 @@ static struct tracer preemptoff_tracer __read_mostly = .start = irqsoff_tracer_start, .stop = irqsoff_tracer_stop, .print_max = 1, + .print_header = irqsoff_print_header, + .print_line = irqsoff_print_line, + .flags = &tracer_flags, + .set_flag = irqsoff_set_flag, #ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_preemptoff, #endif + .open = irqsoff_trace_open, + .close = irqsoff_trace_close, };# define register_preemptoff (trace) register_tracer(&trace)#else @@ -700,9 +706,15 @@ static struct tracer preemptirqsoff_tracer __read_mostly = .start = irqsoff_tracer_start, .stop = irqsoff_tracer_stop, .print_max = 1, + .print_header = irqsoff_print_header, + .print_line = irqsoff_print_line, + .flags = &tracer_flags, + .set_flag = irqsoff_set_flag, #ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_preemptirqsoff, #endif + .open = irqsoff_trace_open, + .close = irqsoff_trace_close, };# define register_preemptirqsoff (trace) register_tracer(&trace)
Re: [PATCHv6 4/4] tracing: graph output support for preemptirqsoff/preemptoff tracers
Quoted 10 lines · Steven Rostedt
Quoted 4 lines · Jiri Olsa
hi,
adding support for graph output for preemptirqsoff/preemptoff tracers.
So far I like the series. But I'm confused why this patch is separate from patch 3. Is there some reason for it?
If not, I'll just merge this into patch 3
no particular reason, just wanted to separate the graph support for single tracer... I have no problem with merging those 2
jirka
Quoted 50 lines
-- Steve
Quoted 45 lines
wbr,
jirkaSigned-off-by Jiri Olsa <[email protected]>--- kernel/trace/trace_irqsoff.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)kernel/trace/trace_irqsoff.c +12
-0@@ -672,9 +672,15 @@ static struct tracer preemptoff_tracer __read_mostly = .start = irqsoff_tracer_start, .stop = irqsoff_tracer_stop, .print_max = 1, + .print_header = irqsoff_print_header, + .print_line = irqsoff_print_line, + .flags = &tracer_flags, + .set_flag = irqsoff_set_flag, #ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_preemptoff, #endif + .open = irqsoff_trace_open, + .close = irqsoff_trace_close, };# define register_preemptoff (trace) register_tracer(&trace)#else @@ -700,9 +706,15 @@ static struct tracer preemptirqsoff_tracer __read_mostly = .start = irqsoff_tracer_start, .stop = irqsoff_tracer_stop, .print_max = 1, + .print_header = irqsoff_print_header, + .print_line = irqsoff_print_line, + .flags = &tracer_flags, + .set_flag = irqsoff_set_flag, #ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_preemptirqsoff, #endif + .open = irqsoff_trace_open, + .close = irqsoff_trace_close, };# define register_preemptirqsoff (trace) register_tracer(&trace)
hi,
any feedback?
thanks,
jirka
Quoted 58 lines · Jiri Olsa
hi,
updates based on comments by Frederic Weisbecker,
also rebase to latest master.I'm sending reworked version of the graph output support for preemptirqsoff/preemptoff/irqsoff tracers.
v6:
- using stubs instead of ifdef intrace_irqsofffor graph tracer's callsv5:
- function graph events are back in game
- changed function graph tracer interface to be able to pass custom tracer flags
- changed calls totrace_functionto trace graph records when the display-graph otion is enabled. As function tracer and graph tracer have different spacing during the record output, this way it looks better, and the info stays.This could be also done via
TRACE_PRINT, then it'd be displayed as comment.. I chose the first way, though it could be easily changed.v4:
- fixed header to display all the info as for
current irqsoff tracer
- fixed reset of themax_trbuffer during the
display-graph switchv3:
- thefunction_graphtracer should have the same output as current version even with events enabled, unless I missed something again ;)
- I gave up the idea offunction_graphevents, since it was unsuitable for outputing other events as comments "/* */"
- I'm not including the rawfunction_graphfor nowattached patches:
- 1/4 adding ftrace events for graph tracer
- 2/4 graph tracer - adding support for passing flags to ouput functions
- 3/4 graph output support for irqsoff tracer
- 4/4 graph output support for preemptirqsoff/preemptoff tracersplz let me know what you think
wbr,
jirka
---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Steven Rostedt
maintainerQuoted 8 lines · Jiri Olsa
hi,
updates based on comments by Frederic Weisbecker,
also rebase to latest master.I'm sending reworked version of the graph output support for preemptirqsoff/preemptoff/irqsoff tracers.
Hi Jiri,
I haven't forgotten about you. I came back from the Linux Collaboration Summit with a bunch of TODO's and one of them took me all week. I spent the entire week hacking the ftrace.h file which takes up 100% of my concentration, so I never got to look at your patches.
Your patch set is next on my todo list, so expect feedback from me either later today or tomorrow.
Thanks for you patience,
-- Steve