aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_functions_graph.c
diff options
context:
space:
mode:
authorChangbin Du <changbin.du@gmail.com>2019-01-01 10:46:10 -0500
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-02-06 11:56:18 -0500
commit9acd8de69d107537a68d010c9149fa9d9aba91f4 (patch)
tree38d0a608a4b6c4364d176d1be82dff5ee1b186e9 /kernel/trace/trace_functions_graph.c
parent8834f5600cf3c8db365e18a3d5cac2c2780c81e5 (diff)
function_graph: Support displaying relative timestamp
When function_graph is used for latency tracers, relative timestamp is more straightforward than absolute timestamp as function trace does. This change adds relative timestamp support to function_graph and applies to latency tracers (wakeup and irqsoff). Instead of: # tracer: irqsoff # # irqsoff latency trace v1.1.5 on 5.0.0-rc1-test # -------------------------------------------------------------------- # latency: 521 us, #1125/1125, CPU#2 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:8) # ----------------- # | task: swapper/2-0 (uid:0 nice:0 policy:0 rt_prio:0) # ----------------- # => started at: __schedule # => ended at: _raw_spin_unlock_irq # # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / # TIME CPU TASK/PID |||| DURATION FUNCTION CALLS # | | | | |||| | | | | | | 124.974306 | 2) systemd-693 | d..1 0.000 us | __schedule(); 124.974307 | 2) systemd-693 | d..1 | rcu_note_context_switch() { 124.974308 | 2) systemd-693 | d..1 0.487 us | rcu_preempt_deferred_qs(); 124.974309 | 2) systemd-693 | d..1 0.451 us | rcu_qs(); 124.974310 | 2) systemd-693 | d..1 2.301 us | } [..] 124.974826 | 2) <idle>-0 | d..2 | finish_task_switch() { 124.974826 | 2) <idle>-0 | d..2 | _raw_spin_unlock_irq() { 124.974827 | 2) <idle>-0 | d..2 0.000 us | _raw_spin_unlock_irq(); 124.974828 | 2) <idle>-0 | d..2 0.000 us | tracer_hardirqs_on(); <idle>-0 2d..2 552us : <stack trace> => __schedule => schedule_idle => do_idle => cpu_startup_entry => start_secondary => secondary_startup_64 Show: # tracer: irqsoff # # irqsoff latency trace v1.1.5 on 5.0.0-rc1-test+ # -------------------------------------------------------------------- # latency: 511 us, #1053/1053, CPU#7 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:8) # ----------------- # | task: swapper/7-0 (uid:0 nice:0 policy:0 rt_prio:0) # ----------------- # => started at: __schedule # => ended at: _raw_spin_unlock_irq # # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / # REL TIME CPU TASK/PID |||| DURATION FUNCTION CALLS # | | | | |||| | | | | | | 0 us | 7) sshd-1704 | d..1 0.000 us | __schedule(); 1 us | 7) sshd-1704 | d..1 | rcu_note_context_switch() { 1 us | 7) sshd-1704 | d..1 0.611 us | rcu_preempt_deferred_qs(); 2 us | 7) sshd-1704 | d..1 0.484 us | rcu_qs(); 3 us | 7) sshd-1704 | d..1 2.599 us | } [..] 509 us | 7) <idle>-0 | d..2 | finish_task_switch() { 510 us | 7) <idle>-0 | d..2 | _raw_spin_unlock_irq() { 510 us | 7) <idle>-0 | d..2 0.000 us | _raw_spin_unlock_irq(); 512 us | 7) <idle>-0 | d..2 0.000 us | tracer_hardirqs_on(); <idle>-0 7d..2 543us : <stack trace> => __schedule => schedule_idle => do_idle => cpu_startup_entry => start_secondary => secondary_startup_64 Link: http://lkml.kernel.org/r/20190101154614.8887-2-changbin.du@gmail.com Signed-off-by: Changbin Du <changbin.du@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_functions_graph.c')
-rw-r--r--kernel/trace/trace_functions_graph.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index c2af1560e856..16ebbdd7b22e 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -501,6 +501,17 @@ static void print_graph_abs_time(u64 t, struct trace_seq *s)
501} 501}
502 502
503static void 503static void
504print_graph_rel_time(struct trace_iterator *iter, struct trace_seq *s)
505{
506 unsigned long long usecs;
507
508 usecs = iter->ts - iter->trace_buffer->time_start;
509 do_div(usecs, NSEC_PER_USEC);
510
511 trace_seq_printf(s, "%9llu us | ", usecs);
512}
513
514static void
504print_graph_irq(struct trace_iterator *iter, unsigned long addr, 515print_graph_irq(struct trace_iterator *iter, unsigned long addr,
505 enum trace_type type, int cpu, pid_t pid, u32 flags) 516 enum trace_type type, int cpu, pid_t pid, u32 flags)
506{ 517{
@@ -517,6 +528,10 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
517 if (flags & TRACE_GRAPH_PRINT_ABS_TIME) 528 if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
518 print_graph_abs_time(iter->ts, s); 529 print_graph_abs_time(iter->ts, s);
519 530
531 /* Relative time */
532 if (flags & TRACE_GRAPH_PRINT_REL_TIME)
533 print_graph_rel_time(iter, s);
534
520 /* Cpu */ 535 /* Cpu */
521 if (flags & TRACE_GRAPH_PRINT_CPU) 536 if (flags & TRACE_GRAPH_PRINT_CPU)
522 print_graph_cpu(s, cpu); 537 print_graph_cpu(s, cpu);
@@ -725,6 +740,10 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
725 if (flags & TRACE_GRAPH_PRINT_ABS_TIME) 740 if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
726 print_graph_abs_time(iter->ts, s); 741 print_graph_abs_time(iter->ts, s);
727 742
743 /* Relative time */
744 if (flags & TRACE_GRAPH_PRINT_REL_TIME)
745 print_graph_rel_time(iter, s);
746
728 /* Cpu */ 747 /* Cpu */
729 if (flags & TRACE_GRAPH_PRINT_CPU) 748 if (flags & TRACE_GRAPH_PRINT_CPU)
730 print_graph_cpu(s, cpu); 749 print_graph_cpu(s, cpu);
@@ -1101,6 +1120,8 @@ static void print_lat_header(struct seq_file *s, u32 flags)
1101 1120
1102 if (flags & TRACE_GRAPH_PRINT_ABS_TIME) 1121 if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
1103 size += 16; 1122 size += 16;
1123 if (flags & TRACE_GRAPH_PRINT_REL_TIME)
1124 size += 16;
1104 if (flags & TRACE_GRAPH_PRINT_CPU) 1125 if (flags & TRACE_GRAPH_PRINT_CPU)
1105 size += 4; 1126 size += 4;
1106 if (flags & TRACE_GRAPH_PRINT_PROC) 1127 if (flags & TRACE_GRAPH_PRINT_PROC)
@@ -1125,6 +1146,8 @@ static void __print_graph_headers_flags(struct trace_array *tr,
1125 seq_putc(s, '#'); 1146 seq_putc(s, '#');
1126 if (flags & TRACE_GRAPH_PRINT_ABS_TIME) 1147 if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
1127 seq_puts(s, " TIME "); 1148 seq_puts(s, " TIME ");
1149 if (flags & TRACE_GRAPH_PRINT_REL_TIME)
1150 seq_puts(s, " REL TIME ");
1128 if (flags & TRACE_GRAPH_PRINT_CPU) 1151 if (flags & TRACE_GRAPH_PRINT_CPU)
1129 seq_puts(s, " CPU"); 1152 seq_puts(s, " CPU");
1130 if (flags & TRACE_GRAPH_PRINT_PROC) 1153 if (flags & TRACE_GRAPH_PRINT_PROC)
@@ -1139,6 +1162,8 @@ static void __print_graph_headers_flags(struct trace_array *tr,
1139 seq_putc(s, '#'); 1162 seq_putc(s, '#');
1140 if (flags & TRACE_GRAPH_PRINT_ABS_TIME) 1163 if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
1141 seq_puts(s, " | "); 1164 seq_puts(s, " | ");
1165 if (flags & TRACE_GRAPH_PRINT_REL_TIME)
1166 seq_puts(s, " | ");
1142 if (flags & TRACE_GRAPH_PRINT_CPU) 1167 if (flags & TRACE_GRAPH_PRINT_CPU)
1143 seq_puts(s, " | "); 1168 seq_puts(s, " | ");
1144 if (flags & TRACE_GRAPH_PRINT_PROC) 1169 if (flags & TRACE_GRAPH_PRINT_PROC)