Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191447
b: refs/heads/master
c: e330b3b
h: refs/heads/master
i:
  191445: 66ddcae
  191443: 84fc9ae
  191439: 286ecc0
v: v3
  • Loading branch information
Chase Douglas authored and Steven Rostedt committed Apr 27, 2010
1 parent 254a8ec commit 077c476
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 07271aa42d13378e67ebd79ea9ca1c4a5e2ad46f
refs/heads/master: e330b3bcd83199dd63a819d8d12e40f9edae6c77
24 changes: 21 additions & 3 deletions trunk/kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ struct ftrace_profile {
unsigned long counter;
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
unsigned long long time;
unsigned long long time_squared;
#endif
};

Expand Down Expand Up @@ -366,9 +367,9 @@ static int function_stat_headers(struct seq_file *m)
{
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
seq_printf(m, " Function "
"Hit Time Avg\n"
"Hit Time Avg s^2\n"
" -------- "
"--- ---- ---\n");
"--- ---- --- ---\n");
#else
seq_printf(m, " Function Hit\n"
" -------- ---\n");
Expand All @@ -384,6 +385,7 @@ static int function_stat_show(struct seq_file *m, void *v)
static DEFINE_MUTEX(mutex);
static struct trace_seq s;
unsigned long long avg;
unsigned long long stddev;
#endif

kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
Expand All @@ -394,11 +396,25 @@ static int function_stat_show(struct seq_file *m, void *v)
avg = rec->time;
do_div(avg, rec->counter);

/* Sample standard deviation (s^2) */
if (rec->counter <= 1)
stddev = 0;
else {
stddev = rec->time_squared - rec->counter * avg * avg;
/*
* Divide only 1000 for ns^2 -> us^2 conversion.
* trace_print_graph_duration will divide 1000 again.
*/
do_div(stddev, (rec->counter - 1) * 1000);
}

mutex_lock(&mutex);
trace_seq_init(&s);
trace_print_graph_duration(rec->time, &s);
trace_seq_puts(&s, " ");
trace_print_graph_duration(avg, &s);
trace_seq_puts(&s, " ");
trace_print_graph_duration(stddev, &s);
trace_print_seq(m, &s);
mutex_unlock(&mutex);
#endif
Expand Down Expand Up @@ -668,8 +684,10 @@ static void profile_graph_return(struct ftrace_graph_ret *trace)
}

rec = ftrace_find_profiled_func(stat, trace->func);
if (rec)
if (rec) {
rec->time += calltime;
rec->time_squared += calltime * calltime;
}

out:
local_irq_restore(flags);
Expand Down

0 comments on commit 077c476

Please sign in to comment.