* [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers
@ 2010-02-22 12:56 Jiri Olsa
2010-02-22 12:56 ` [PATCH 1/4] tracing: adding ftrace events for graph tracer Jiri Olsa
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Jiri Olsa @ 2010-02-22 12:56 UTC (permalink / raw)
To: mingo, rostedt, fweisbec; +Cc: linux-kernel
hi,
I'm sending reworked version of the graph output support for
preemptirqsoff/preemptoff/irqsoff tracers.
I made the graph output as an output event, so it could be shared
within tracers - patch 1/4.
I also added raw trace output for graph tracer. I have this one around
for long time and it was quite handy for investigating graph tracer issues.
(patch 4/4)
attached patches:
- 1/4 adding ftrace events for graph tracer
- 2/4 graph output support for irqsoff tracer
- 3/4 graph output support for preemptirqsoff/preemptoff tracers
- 4/4 raw output for graph tracer
wbr,
jirka
---
kernel/trace/trace.c | 2 +-
kernel/trace/trace.h | 11 ++-
kernel/trace/trace_functions_graph.c | 117 +++++++++++++++++++----
kernel/trace/trace_irqsoff.c | 174 ++++++++++++++++++++++++++++++++--
4 files changed, 277 insertions(+), 27 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/4] tracing: adding ftrace events for graph tracer
2010-02-22 12:56 [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
@ 2010-02-22 12:56 ` Jiri Olsa
2010-03-08 19:29 ` Steven Rostedt
2010-02-22 12:57 ` [PATCH 2/4] tracing: graph output support for irqsoff tracer Jiri Olsa
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2010-02-22 12:56 UTC (permalink / raw)
To: mingo, rostedt, fweisbec; +Cc: linux-kernel, Jiri Olsa
hi,
this patch adds ftrace events for graph tracer, so the graph output
could be shared within other tracers.
wbr,
jirka
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
kernel/trace/trace.h | 3 ++-
kernel/trace/trace_functions_graph.c | 25 ++++++++++++++++++++++---
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index b477fce..1feda87 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -490,7 +490,8 @@ 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(struct trace_iterator *iter,
+ int flags);
extern enum print_line_t
trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 616b135..41cec17 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -38,7 +38,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 0x20
static struct tracer_opt trace_opts[] = {
/* Display overruns? (for self-debug purpose) */
@@ -985,7 +985,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
enum print_line_t
-print_graph_function(struct trace_iterator *iter)
+print_graph_function(struct trace_iterator *iter, int flags)
{
struct ftrace_graph_ent_entry *field;
struct fgraph_data *data = iter->private;
@@ -1143,6 +1143,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,
+};
+
+static struct trace_event graph_trace_ret_event = {
+ .type = TRACE_GRAPH_RET,
+ .trace = print_graph_function,
+};
+
static struct tracer graph_trace __read_mostly = {
.name = "function_graph",
.open = graph_trace_open,
@@ -1152,7 +1162,6 @@ static struct tracer graph_trace __read_mostly = {
.wait_pipe = poll_wait_pipe,
.init = graph_trace_init,
.reset = graph_trace_reset,
- .print_line = print_graph_function,
.print_header = print_graph_headers,
.flags = &tracer_flags,
#ifdef CONFIG_FTRACE_SELFTEST
@@ -1164,6 +1173,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);
}
--
1.6.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] tracing: graph output support for irqsoff tracer
2010-02-22 12:56 [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
2010-02-22 12:56 ` [PATCH 1/4] tracing: adding ftrace events for graph tracer Jiri Olsa
@ 2010-02-22 12:57 ` Jiri Olsa
2010-02-22 12:57 ` [PATCH 3/4] tracing: graph output support for preemptirqsoff/preemptoff tracers Jiri Olsa
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2010-02-22 12:57 UTC (permalink / raw)
To: mingo, rostedt, fweisbec; +Cc: linux-kernel, Jiri Olsa
hi,
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.
It looks like this:
[root@dell-pe1950-05 tracing]# echo irqsoff-graph > ./trace_options
[root@dell-pe1950-05 tracing]# cat ./trace
# tracer: irqsoff
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / _-=> lock-depth
# |||| /
# CPU||||| DURATION FUNCTION CALLS
# | ||||| | | | | | |
hald-add-1048 3d...0 0us : _raw_spin_lock_irqsave <-scsi_dispatch_cmd
3) d...0 | ata_scsi_queuecmd() {
3) d...0 0.318 us | _raw_spin_lock();
3) d...0 | ata_scsi_find_dev() {
3) d...0 | __ata_scsi_find_dev() {
3) d...0 0.273 us | ata_find_dev();
3) d...0 0.798 us | }
3) d...0 1.419 us | }
3) d...0 | __ata_scsi_queuecmd() {
3) d...0 | ata_qc_new_init() {
3) d...0 | ata_qc_reinit() {
3) d...0 0.258 us | ata_tf_init();
3) d...0 0.784 us | }
3) d...0 1.441 us | }
3) d...0 0.348 us | atapi_xlat();
3) d...0 | ata_qc_issue() {
...
SNIP
...
3) d...0+ 31.244 us | }
3) d...0+ 32.393 us | }
3) d...0+ 99.146 us | }
3) d...0! 100.455 us | }
3) d...0! 103.669 us | }
3) d...0 0.267 us | _raw_spin_lock();
3) d...0! 107.264 us | }
3) d...0 | spin_unlock_irqrestore() {
3) d...0 | _raw_spin_unlock_irqrestore() {
hald-add-1048 3d...0 109us : _raw_spin_unlock_irqrestore <-return_to_handler
hald-add-1048 3d...0 109us : trace_hardirqs_on <-return_to_handler
hald-add-1048 3d...0 109us : <stack trace>
=> trace_hardirqs_on
=> _raw_spin_unlock_irqrestore
=> return_to_handler
=> scsi_dispatch_cmd
=> return_to_handler
=> __generic_unplug_device
=> scsi_request_fn
=> return_to_handler
[root@dell-pe1950-05 tracing]#
wbr,
jirka
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
kernel/trace/trace.h | 8 ++
kernel/trace/trace_functions_graph.c | 25 ++----
kernel/trace/trace_irqsoff.c | 162 ++++++++++++++++++++++++++++++++--
3 files changed, 172 insertions(+), 23 deletions(-)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 1feda87..d2a42c9 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -494,6 +494,14 @@ extern enum print_line_t print_graph_function(struct trace_iterator *iter,
int flags);
extern enum print_line_t
trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
+void graph_trace_open(struct trace_iterator *iter);
+void graph_trace_close(struct trace_iterator *iter);
+int __trace_graph_entry(struct trace_array *tr, struct ftrace_graph_ent *trace,
+ unsigned long flags, int pc);
+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 */
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 41cec17..eca09b3 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -177,7 +177,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)
@@ -236,7 +236,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
return ret;
}
-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)
@@ -911,9 +911,7 @@ static enum print_line_t
print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
struct trace_iterator *iter)
{
- unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
struct fgraph_data *data = iter->private;
- struct trace_event *event;
int depth = 0;
int ret;
int i;
@@ -960,14 +958,6 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
if (ret != TRACE_TYPE_HANDLED)
return ret;
break;
- default:
- event = ftrace_find_event(ent->type);
- if (!event)
- return TRACE_TYPE_UNHANDLED;
-
- ret = event->trace(iter, sym_flags);
- if (ret != TRACE_TYPE_HANDLED)
- return ret;
}
/* Strip ending newline */
@@ -1033,8 +1023,11 @@ print_graph_function(struct trace_iterator *iter, int flags)
trace_assign_type(field, entry);
return print_graph_return(&field->ret, s, entry, iter);
}
- default:
+ case TRACE_BPRINT:
+ case TRACE_PRINT:
return print_graph_comment(s, entry, iter);
+ default:
+ return TRACE_TYPE_UNHANDLED;
}
return TRACE_TYPE_HANDLED;
@@ -1062,7 +1055,7 @@ static void print_lat_header(struct seq_file *s)
seq_printf(s, "#%.*s|||| / \n", size, spaces);
}
-static void print_graph_headers(struct seq_file *s)
+void print_graph_headers(struct seq_file *s)
{
int lat = trace_flags & TRACE_ITER_LATENCY_FMT;
@@ -1098,7 +1091,7 @@ static void print_graph_headers(struct seq_file *s)
seq_printf(s, " | | | |\n");
}
-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;
@@ -1133,7 +1126,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;
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 2974bc7..f3f43fc 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -34,6 +34,9 @@ static int trace_type __read_mostly;
static int save_lat_flag;
+static void stop_irqsoff_tracer(struct trace_array *tr, int graph);
+static int start_irqsoff_tracer(struct trace_array *tr, int graph);
+
#ifdef CONFIG_PREEMPT_TRACER
static inline int
preempt_trace(void)
@@ -55,6 +58,23 @@ irq_trace(void)
# define irq_trace() (0)
#endif
+#define TRACE_IRQSOFF_GRAPH 1
+
+static struct tracer_opt trace_opts[] = {
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ /* display latency trace as call graph */
+ { TRACER_OPT(irqsoff-graph, TRACE_IRQSOFF_GRAPH) },
+#endif
+ { } /* Empty entry */
+};
+
+static struct tracer_flags tracer_flags = {
+ .val = 0,
+ .opts = trace_opts,
+};
+
+#define is_graph() (tracer_flags.val & TRACE_IRQSOFF_GRAPH)
+
/*
* Sequence count - we record it when starting a measurement and
* skip the latency if the sequence has changed - some other section
@@ -108,6 +128,109 @@ static struct ftrace_ops trace_ops __read_mostly =
};
#endif /* CONFIG_FUNCTION_TRACER */
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+static int irqsoff_set_flag(u32 old_flags, u32 bit, int set)
+{
+ int cpu;
+
+ if (!(bit & TRACE_IRQSOFF_GRAPH))
+ return -EINVAL;
+
+ if (!(is_graph() ^ set))
+ return 0;
+
+ stop_irqsoff_tracer(irqsoff_trace, !set);
+
+ for_each_possible_cpu(cpu)
+ per_cpu(tracing_cpu, cpu) = 0;
+
+ tracing_max_latency = 0;
+ tracing_reset_online_cpus(irqsoff_trace);
+
+ return start_irqsoff_tracer(irqsoff_trace, set);
+}
+
+static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
+{
+ struct trace_array *tr = irqsoff_trace;
+ struct trace_array_cpu *data;
+ unsigned long flags;
+ long disabled;
+ int ret;
+ int cpu;
+ int pc;
+
+ cpu = raw_smp_processor_id();
+ if (likely(!per_cpu(tracing_cpu, cpu)))
+ return 0;
+
+ local_save_flags(flags);
+ /* slight chance to get a false positive on tracing_cpu */
+ if (!irqs_disabled_flags(flags))
+ return 0;
+
+ data = tr->data[cpu];
+ disabled = atomic_inc_return(&data->disabled);
+
+ if (likely(disabled == 1)) {
+ pc = preempt_count();
+ ret = __trace_graph_entry(tr, trace, flags, pc);
+ } else
+ ret = 0;
+
+ atomic_dec(&data->disabled);
+ return ret;
+}
+
+static void irqsoff_graph_return(struct ftrace_graph_ret *trace)
+{
+ struct trace_array *tr = irqsoff_trace;
+ struct trace_array_cpu *data;
+ unsigned long flags;
+ long disabled;
+ int cpu;
+ int pc;
+
+ cpu = raw_smp_processor_id();
+ if (likely(!per_cpu(tracing_cpu, cpu)))
+ return;
+
+ local_save_flags(flags);
+ /* slight chance to get a false positive on tracing_cpu */
+ if (!irqs_disabled_flags(flags))
+ return;
+
+ data = tr->data[cpu];
+ disabled = atomic_inc_return(&data->disabled);
+
+ if (likely(disabled == 1)) {
+ pc = preempt_count();
+ __trace_graph_return(tr, trace, flags, pc);
+ }
+
+ atomic_dec(&data->disabled);
+}
+
+static void irqsoff_trace_open(struct trace_iterator *iter)
+{
+ if (is_graph())
+ graph_trace_open(iter);
+
+}
+
+static void irqsoff_trace_close(struct trace_iterator *iter)
+{
+ if (iter->private)
+ graph_trace_close(iter);
+}
+
+#else
+static int irqsoff_set_flag(u32 old_flags, u32 bit, int set)
+{
+ return -EINVAL;
+}
+#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
/*
* Should this new latency be reported/recorded?
*/
@@ -347,19 +470,36 @@ void trace_preempt_off(unsigned long a0, unsigned long a1)
}
#endif /* CONFIG_PREEMPT_TRACER */
-static void start_irqsoff_tracer(struct trace_array *tr)
+static int start_irqsoff_tracer(struct trace_array *tr, int graph)
{
- register_ftrace_function(&trace_ops);
- if (tracing_is_enabled())
+ int ret = 0;
+
+ if (!graph)
+ ret = register_ftrace_function(&trace_ops);
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ else
+ ret = register_ftrace_graph(&irqsoff_graph_return,
+ &irqsoff_graph_entry);
+#endif
+
+ if (!ret && tracing_is_enabled())
tracer_enabled = 1;
else
tracer_enabled = 0;
+
+ return ret;
}
-static void stop_irqsoff_tracer(struct trace_array *tr)
+static void stop_irqsoff_tracer(struct trace_array *tr, int graph)
{
tracer_enabled = 0;
- unregister_ftrace_function(&trace_ops);
+
+ if (!graph)
+ unregister_ftrace_function(&trace_ops);
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ else
+ unregister_ftrace_graph();
+#endif
}
static void __irqsoff_tracer_init(struct trace_array *tr)
@@ -372,12 +512,14 @@ static void __irqsoff_tracer_init(struct trace_array *tr)
/* make sure that the tracer is visible */
smp_wmb();
tracing_reset_online_cpus(tr);
- start_irqsoff_tracer(tr);
+
+ if (start_irqsoff_tracer(tr, is_graph()))
+ printk(KERN_ERR "failed to start irqsoff tracer\n");
}
static void irqsoff_tracer_reset(struct trace_array *tr)
{
- stop_irqsoff_tracer(tr);
+ stop_irqsoff_tracer(tr, is_graph());
if (!save_lat_flag)
trace_flags &= ~TRACE_ITER_LATENCY_FMT;
@@ -408,10 +550,16 @@ static struct tracer irqsoff_tracer __read_mostly =
.reset = irqsoff_tracer_reset,
.start = irqsoff_tracer_start,
.stop = irqsoff_tracer_stop,
+ .flags = &tracer_flags,
.print_max = 1,
+ .set_flag = irqsoff_set_flag,
#ifdef CONFIG_FTRACE_SELFTEST
.selftest = trace_selftest_startup_irqsoff,
#endif
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ .open = irqsoff_trace_open,
+ .close = irqsoff_trace_close,
+#endif
};
# define register_irqsoff(trace) register_tracer(&trace)
#else
--
1.6.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] tracing: graph output support for preemptirqsoff/preemptoff tracers
2010-02-22 12:56 [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
2010-02-22 12:56 ` [PATCH 1/4] tracing: adding ftrace events for graph tracer Jiri Olsa
2010-02-22 12:57 ` [PATCH 2/4] tracing: graph output support for irqsoff tracer Jiri Olsa
@ 2010-02-22 12:57 ` Jiri Olsa
2010-02-22 12:57 ` [PATCH 4/4] tracing: raw output for graph tracer Jiri Olsa
2010-03-08 7:07 ` [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
4 siblings, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2010-02-22 12:57 UTC (permalink / raw)
To: mingo, rostedt, fweisbec; +Cc: linux-kernel, Jiri Olsa
hi,
adding support for graph output for preemptirqsoff/preemptoff tracers.
wbr,
jirka
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
kernel/trace/trace_irqsoff.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index f3f43fc..15e05c9 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -58,12 +58,12 @@ irq_trace(void)
# define irq_trace() (0)
#endif
-#define TRACE_IRQSOFF_GRAPH 1
+#define TRACE_DISPLAY_GRAPH 1
static struct tracer_opt trace_opts[] = {
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
/* display latency trace as call graph */
- { TRACER_OPT(irqsoff-graph, TRACE_IRQSOFF_GRAPH) },
+ { TRACER_OPT(display-graph, TRACE_DISPLAY_GRAPH) },
#endif
{ } /* Empty entry */
};
@@ -73,7 +73,7 @@ static struct tracer_flags tracer_flags = {
.opts = trace_opts,
};
-#define is_graph() (tracer_flags.val & TRACE_IRQSOFF_GRAPH)
+#define is_graph() (tracer_flags.val & TRACE_DISPLAY_GRAPH)
/*
* Sequence count - we record it when starting a measurement and
@@ -133,7 +133,7 @@ static int irqsoff_set_flag(u32 old_flags, u32 bit, int set)
{
int cpu;
- if (!(bit & TRACE_IRQSOFF_GRAPH))
+ if (!(bit & TRACE_DISPLAY_GRAPH))
return -EINVAL;
if (!(is_graph() ^ set))
@@ -550,8 +550,8 @@ static struct tracer irqsoff_tracer __read_mostly =
.reset = irqsoff_tracer_reset,
.start = irqsoff_tracer_start,
.stop = irqsoff_tracer_stop,
- .flags = &tracer_flags,
.print_max = 1,
+ .flags = &tracer_flags,
.set_flag = irqsoff_set_flag,
#ifdef CONFIG_FTRACE_SELFTEST
.selftest = trace_selftest_startup_irqsoff,
@@ -583,9 +583,15 @@ static struct tracer preemptoff_tracer __read_mostly =
.start = irqsoff_tracer_start,
.stop = irqsoff_tracer_stop,
.print_max = 1,
+ .flags = &tracer_flags,
+ .set_flag = irqsoff_set_flag,
#ifdef CONFIG_FTRACE_SELFTEST
.selftest = trace_selftest_startup_preemptoff,
#endif
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ .open = irqsoff_trace_open,
+ .close = irqsoff_trace_close,
+#endif
};
# define register_preemptoff(trace) register_tracer(&trace)
#else
@@ -611,9 +617,15 @@ static struct tracer preemptirqsoff_tracer __read_mostly =
.start = irqsoff_tracer_start,
.stop = irqsoff_tracer_stop,
.print_max = 1,
+ .flags = &tracer_flags,
+ .set_flag = irqsoff_set_flag,
#ifdef CONFIG_FTRACE_SELFTEST
.selftest = trace_selftest_startup_preemptirqsoff,
#endif
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ .open = irqsoff_trace_open,
+ .close = irqsoff_trace_close,
+#endif
};
# define register_preemptirqsoff(trace) register_tracer(&trace)
--
1.6.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] tracing: raw output for graph tracer
2010-02-22 12:56 [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
` (2 preceding siblings ...)
2010-02-22 12:57 ` [PATCH 3/4] tracing: graph output support for preemptirqsoff/preemptoff tracers Jiri Olsa
@ 2010-02-22 12:57 ` Jiri Olsa
2010-03-08 7:07 ` [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
4 siblings, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2010-02-22 12:57 UTC (permalink / raw)
To: mingo, rostedt, fweisbec; +Cc: linux-kernel, Jiri Olsa
hi,
this patch adds raw trace output for graph tracer.
I have this one around for long time and it was quite handy
for investigating graph tracer issues.
wbr,
jirka
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
kernel/trace/trace.c | 2 +-
kernel/trace/trace_functions_graph.c | 69 ++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 032c57c..723fa93 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1900,7 +1900,7 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
entry = iter->ent;
if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
- if (!trace_seq_printf(s, "%d %d %llu ",
+ if (!trace_seq_printf(s, " %6d %3d %20llu ",
entry->pid, iter->cpu, iter->ts))
goto partial;
}
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index eca09b3..023e0be 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -1033,6 +1033,66 @@ print_graph_function(struct trace_iterator *iter, int flags)
return TRACE_TYPE_HANDLED;
}
+static enum print_line_t
+print_graph_raw(struct trace_iterator *iter, int flags)
+{
+ struct trace_entry *entry = iter->ent;
+ struct trace_seq *s = &iter->seq;
+ int ret = 0;
+ int depth;
+ void *func;
+ char *io;
+
+ switch (entry->type) {
+ case TRACE_GRAPH_ENT: {
+ struct ftrace_graph_ent_entry *field;
+ trace_assign_type(field, entry);
+ depth = field->graph_ent.depth;
+ func = (void *) field->graph_ent.func;
+ io = "-->";
+ break;
+ }
+ case TRACE_GRAPH_RET: {
+ struct ftrace_graph_ret_entry *field;
+ trace_assign_type(field, entry);
+ depth = field->ret.depth;
+ func = (void *) field->ret.func;
+ io = "<--";
+ break;
+ }
+ default:
+ return print_graph_comment(s, entry, iter);
+ }
+
+ ret = trace_seq_printf(s, "%s%6d %6d %6d %4d %7d %20p %4s %ps\n",
+ trace_flags & TRACE_ITER_CONTEXT_INFO ? "" : " ",
+ depth,
+ entry->lock_depth,
+ entry->flags,
+ entry->preempt_count,
+ entry->pid,
+ entry,
+ io,
+ func);
+
+ if (!ret)
+ return TRACE_TYPE_PARTIAL_LINE;
+
+ return TRACE_TYPE_HANDLED;
+}
+
+static void print_graph_raw_header(struct seq_file *s)
+{
+ if (trace_flags & TRACE_ITER_CONTEXT_INFO)
+ seq_printf(s, "#%6s %3s %20s ", "pid", "cpu", "duration");
+ else
+ seq_printf(s, "#");
+
+ seq_printf(s, "%6s %6s %6s %4s %7s %20s %4s %s\n",
+ "depth", "ldepth", "flags", "pc", "pid",
+ "entry", "i/o", "function");
+}
+
static void print_lat_header(struct seq_file *s)
{
static const char spaces[] = " " /* 16 spaces */
@@ -1059,6 +1119,11 @@ void print_graph_headers(struct seq_file *s)
{
int lat = trace_flags & TRACE_ITER_LATENCY_FMT;
+ if (trace_flags & TRACE_ITER_RAW) {
+ print_graph_raw_header(s);
+ return;
+ }
+
if (lat)
print_lat_header(s);
@@ -1074,6 +1139,7 @@ void print_graph_headers(struct seq_file *s)
seq_printf(s, "|||||");
if (tracer_flags.val & TRACE_GRAPH_PRINT_DURATION)
seq_printf(s, " DURATION ");
+
seq_printf(s, " FUNCTION CALLS\n");
/* 2nd line */
@@ -1136,14 +1202,17 @@ void graph_trace_close(struct trace_iterator *iter)
}
}
+
static struct trace_event graph_trace_entry_event = {
.type = TRACE_GRAPH_ENT,
.trace = print_graph_function,
+ .raw = print_graph_raw,
};
static struct trace_event graph_trace_ret_event = {
.type = TRACE_GRAPH_RET,
.trace = print_graph_function,
+ .raw = print_graph_raw,
};
static struct tracer graph_trace __read_mostly = {
--
1.6.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers
2010-02-22 12:56 [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
` (3 preceding siblings ...)
2010-02-22 12:57 ` [PATCH 4/4] tracing: raw output for graph tracer Jiri Olsa
@ 2010-03-08 7:07 ` Jiri Olsa
2010-03-08 15:11 ` Steven Rostedt
4 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2010-03-08 7:07 UTC (permalink / raw)
To: mingo, rostedt, fweisbec; +Cc: linux-kernel
hi,
any feedback?
thanks,
jirka
On Mon, Feb 22, 2010 at 01:56:58PM +0100, Jiri Olsa wrote:
> hi,
>
> I'm sending reworked version of the graph output support for
> preemptirqsoff/preemptoff/irqsoff tracers.
>
> I made the graph output as an output event, so it could be shared
> within tracers - patch 1/4.
>
> I also added raw trace output for graph tracer. I have this one around
> for long time and it was quite handy for investigating graph tracer issues.
> (patch 4/4)
>
>
> attached patches:
> - 1/4 adding ftrace events for graph tracer
> - 2/4 graph output support for irqsoff tracer
> - 3/4 graph output support for preemptirqsoff/preemptoff tracers
> - 4/4 raw output for graph tracer
>
> wbr,
> jirka
> ---
> kernel/trace/trace.c | 2 +-
> kernel/trace/trace.h | 11 ++-
> kernel/trace/trace_functions_graph.c | 117 +++++++++++++++++++----
> kernel/trace/trace_irqsoff.c | 174 ++++++++++++++++++++++++++++++++--
> 4 files changed, 277 insertions(+), 27 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers
2010-03-08 7:07 ` [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
@ 2010-03-08 15:11 ` Steven Rostedt
0 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2010-03-08 15:11 UTC (permalink / raw)
To: Jiri Olsa; +Cc: mingo, fweisbec, linux-kernel
On Mon, 2010-03-08 at 08:07 +0100, Jiri Olsa wrote:
> hi,
> any feedback?
Ah, I forgot about this patch set. I'll take a look at it today.
Thanks,
-- Steve
>
> thanks,
> jirka
>
> On Mon, Feb 22, 2010 at 01:56:58PM +0100, Jiri Olsa wrote:
> > hi,
> >
> > I'm sending reworked version of the graph output support for
> > preemptirqsoff/preemptoff/irqsoff tracers.
> >
> > I made the graph output as an output event, so it could be shared
> > within tracers - patch 1/4.
> >
> > I also added raw trace output for graph tracer. I have this one around
> > for long time and it was quite handy for investigating graph tracer issues.
> > (patch 4/4)
> >
> >
> > attached patches:
> > - 1/4 adding ftrace events for graph tracer
> > - 2/4 graph output support for irqsoff tracer
> > - 3/4 graph output support for preemptirqsoff/preemptoff tracers
> > - 4/4 raw output for graph tracer
> >
> > wbr,
> > jirka
> > ---
> > kernel/trace/trace.c | 2 +-
> > kernel/trace/trace.h | 11 ++-
> > kernel/trace/trace_functions_graph.c | 117 +++++++++++++++++++----
> > kernel/trace/trace_irqsoff.c | 174 ++++++++++++++++++++++++++++++++--
> > 4 files changed, 277 insertions(+), 27 deletions(-)
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] tracing: adding ftrace events for graph tracer
2010-02-22 12:56 ` [PATCH 1/4] tracing: adding ftrace events for graph tracer Jiri Olsa
@ 2010-03-08 19:29 ` Steven Rostedt
2010-03-09 15:15 ` Jiri Olsa
0 siblings, 1 reply; 9+ messages in thread
From: Steven Rostedt @ 2010-03-08 19:29 UTC (permalink / raw)
To: Jiri Olsa; +Cc: mingo, fweisbec, linux-kernel
On Mon, 2010-02-22 at 13:56 +0100, Jiri Olsa wrote:
> hi,
>
> this patch adds ftrace events for graph tracer, so the graph output
> could be shared within other tracers.
>
Sorry but NAK to this,
What use to be:
2) + 25.633 us | }
3) ! 252.132 us | } /* do_softirq */
2) ! 898.211 us | } /* rcu_process_callbacks */
2) | /* softirq_exit: vec=9 [action=RCU] */
3) 5.534 us | rcu_irq_exit();
2) 6.405 us | preempt_schedule();
3) 5.221 us | idle_cpu();
2) 6.014 us | rcu_bh_qs();
3) ! 289.729 us | } /* irq_exit */
2) | /* softirq_entry: vec=1 [action=TIMER] */
3) ! 860.416 us | } /* smp_apic_timer_interrupt */
3) <========== |
2) 5.785 us | preempt_schedule();
Is now:
gdmgreeter-3382 [002] 119.609346: 2) + 25.633 us | }
pcscd-2849 [003] 119.609352: 3) ! 252.132 us | } /* do_softirq */
gdmgreeter-3382 [002] 119.609353: 2) ! 898.211 us | } /* rcu_process_callbacks */
gdmgreeter-3382 [002] 119.609357: softirq_exit: vec=9 [action=RCU]
pcscd-2849 [003] 119.609360: 3) 5.534 us | rcu_irq_exit();
gdmgreeter-3382 [002] 119.609363: 2) 6.405 us | preempt_schedule();
pcscd-2849 [003] 119.609370: 3) 5.221 us | idle_cpu();
gdmgreeter-3382 [002] 119.609376: 2) 6.014 us | rcu_bh_qs();
pcscd-2849 [003] 119.609383: 3) ! 289.729 us | } /* irq_exit */
gdmgreeter-3382 [002] 119.609387: softirq_entry: vec=1 [action=TIMER]
pcscd-2849 [003] 119.609389: 3) ! 860.416 us | } /* smp_apic_timer_interrupt */
3) <========== |
gdmgreeter-3382 [002] 119.609393: 2) 5.785 us | preempt_schedule();
Keep the function graph output as is. You can still add the event
callbacks but do not remove the print_line of the function graph tracer.
That simply breaks what we worked hard to format nicely.
-- Steve
>
> Signed-off-by: Jiri Olsa <jolsa@redhat.com>
> ---
> kernel/trace/trace.h | 3 ++-
> kernel/trace/trace_functions_graph.c | 25 ++++++++++++++++++++++---
> 2 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index b477fce..1feda87 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -490,7 +490,8 @@ 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(struct trace_iterator *iter,
> + int flags);
> extern enum print_line_t
> trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
>
> diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> index 616b135..41cec17 100644
> --- a/kernel/trace/trace_functions_graph.c
> +++ b/kernel/trace/trace_functions_graph.c
> @@ -38,7 +38,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 0x20
>
> static struct tracer_opt trace_opts[] = {
> /* Display overruns? (for self-debug purpose) */
> @@ -985,7 +985,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
>
>
> enum print_line_t
> -print_graph_function(struct trace_iterator *iter)
> +print_graph_function(struct trace_iterator *iter, int flags)
> {
> struct ftrace_graph_ent_entry *field;
> struct fgraph_data *data = iter->private;
> @@ -1143,6 +1143,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,
> +};
> +
> +static struct trace_event graph_trace_ret_event = {
> + .type = TRACE_GRAPH_RET,
> + .trace = print_graph_function,
> +};
> +
> static struct tracer graph_trace __read_mostly = {
> .name = "function_graph",
> .open = graph_trace_open,
> @@ -1152,7 +1162,6 @@ static struct tracer graph_trace __read_mostly = {
> .wait_pipe = poll_wait_pipe,
> .init = graph_trace_init,
> .reset = graph_trace_reset,
> - .print_line = print_graph_function,
> .print_header = print_graph_headers,
> .flags = &tracer_flags,
> #ifdef CONFIG_FTRACE_SELFTEST
> @@ -1164,6 +1173,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);
> }
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] tracing: adding ftrace events for graph tracer
2010-03-08 19:29 ` Steven Rostedt
@ 2010-03-09 15:15 ` Jiri Olsa
0 siblings, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2010-03-09 15:15 UTC (permalink / raw)
To: Steven Rostedt; +Cc: mingo, fweisbec, linux-kernel
On Mon, Mar 08, 2010 at 02:29:46PM -0500, Steven Rostedt wrote:
> On Mon, 2010-02-22 at 13:56 +0100, Jiri Olsa wrote:
> > hi,
> >
> > this patch adds ftrace events for graph tracer, so the graph output
> > could be shared within other tracers.
> >
>
> Sorry but NAK to this,
right, I haven't realized this to be a problem,
I'll send new version shortly
wbr,
jirka
>
> What use to be:
>
> 2) + 25.633 us | }
> 3) ! 252.132 us | } /* do_softirq */
> 2) ! 898.211 us | } /* rcu_process_callbacks */
> 2) | /* softirq_exit: vec=9 [action=RCU] */
> 3) 5.534 us | rcu_irq_exit();
> 2) 6.405 us | preempt_schedule();
> 3) 5.221 us | idle_cpu();
> 2) 6.014 us | rcu_bh_qs();
> 3) ! 289.729 us | } /* irq_exit */
> 2) | /* softirq_entry: vec=1 [action=TIMER] */
> 3) ! 860.416 us | } /* smp_apic_timer_interrupt */
> 3) <========== |
> 2) 5.785 us | preempt_schedule();
>
>
> Is now:
>
> gdmgreeter-3382 [002] 119.609346: 2) + 25.633 us | }
> pcscd-2849 [003] 119.609352: 3) ! 252.132 us | } /* do_softirq */
> gdmgreeter-3382 [002] 119.609353: 2) ! 898.211 us | } /* rcu_process_callbacks */
> gdmgreeter-3382 [002] 119.609357: softirq_exit: vec=9 [action=RCU]
> pcscd-2849 [003] 119.609360: 3) 5.534 us | rcu_irq_exit();
> gdmgreeter-3382 [002] 119.609363: 2) 6.405 us | preempt_schedule();
> pcscd-2849 [003] 119.609370: 3) 5.221 us | idle_cpu();
> gdmgreeter-3382 [002] 119.609376: 2) 6.014 us | rcu_bh_qs();
> pcscd-2849 [003] 119.609383: 3) ! 289.729 us | } /* irq_exit */
> gdmgreeter-3382 [002] 119.609387: softirq_entry: vec=1 [action=TIMER]
> pcscd-2849 [003] 119.609389: 3) ! 860.416 us | } /* smp_apic_timer_interrupt */
> 3) <========== |
> gdmgreeter-3382 [002] 119.609393: 2) 5.785 us | preempt_schedule();
>
>
> Keep the function graph output as is. You can still add the event
> callbacks but do not remove the print_line of the function graph tracer.
> That simply breaks what we worked hard to format nicely.
>
> -- Steve
>
>
> >
> > Signed-off-by: Jiri Olsa <jolsa@redhat.com>
> > ---
> > kernel/trace/trace.h | 3 ++-
> > kernel/trace/trace_functions_graph.c | 25 ++++++++++++++++++++++---
> > 2 files changed, 24 insertions(+), 4 deletions(-)
> >
> > diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> > index b477fce..1feda87 100644
> > --- a/kernel/trace/trace.h
> > +++ b/kernel/trace/trace.h
> > @@ -490,7 +490,8 @@ 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(struct trace_iterator *iter,
> > + int flags);
> > extern enum print_line_t
> > trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
> >
> > diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> > index 616b135..41cec17 100644
> > --- a/kernel/trace/trace_functions_graph.c
> > +++ b/kernel/trace/trace_functions_graph.c
> > @@ -38,7 +38,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 0x20
> >
> > static struct tracer_opt trace_opts[] = {
> > /* Display overruns? (for self-debug purpose) */
> > @@ -985,7 +985,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
> >
> >
> > enum print_line_t
> > -print_graph_function(struct trace_iterator *iter)
> > +print_graph_function(struct trace_iterator *iter, int flags)
> > {
> > struct ftrace_graph_ent_entry *field;
> > struct fgraph_data *data = iter->private;
> > @@ -1143,6 +1143,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,
> > +};
> > +
> > +static struct trace_event graph_trace_ret_event = {
> > + .type = TRACE_GRAPH_RET,
> > + .trace = print_graph_function,
> > +};
> > +
> > static struct tracer graph_trace __read_mostly = {
> > .name = "function_graph",
> > .open = graph_trace_open,
> > @@ -1152,7 +1162,6 @@ static struct tracer graph_trace __read_mostly = {
> > .wait_pipe = poll_wait_pipe,
> > .init = graph_trace_init,
> > .reset = graph_trace_reset,
> > - .print_line = print_graph_function,
> > .print_header = print_graph_headers,
> > .flags = &tracer_flags,
> > #ifdef CONFIG_FTRACE_SELFTEST
> > @@ -1164,6 +1173,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);
> > }
> >
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-03-09 15:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-22 12:56 [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
2010-02-22 12:56 ` [PATCH 1/4] tracing: adding ftrace events for graph tracer Jiri Olsa
2010-03-08 19:29 ` Steven Rostedt
2010-03-09 15:15 ` Jiri Olsa
2010-02-22 12:57 ` [PATCH 2/4] tracing: graph output support for irqsoff tracer Jiri Olsa
2010-02-22 12:57 ` [PATCH 3/4] tracing: graph output support for preemptirqsoff/preemptoff tracers Jiri Olsa
2010-02-22 12:57 ` [PATCH 4/4] tracing: raw output for graph tracer Jiri Olsa
2010-03-08 7:07 ` [PATCH 0/4] tracing: function graph output for preempt/irqs-off tracers Jiri Olsa
2010-03-08 15:11 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).