提交 ffeb80fc 编写于 作者: J Jiri Olsa 提交者: Steven Rostedt

tracing, function_graph: Merge overhead and duration display functions

Functions print_graph_overhead() and print_graph_duration() displays
data for one field - DURATION.

I merged them into single function print_graph_duration(),
and added a way to display the empty parts of the field.

This way the print_graph_irq() function can use this column to display
the IRQ signs if needed and the DURATION field details stays inside
the print_graph_duration() function.
Signed-off-by: NJiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1307113131-10045-3-git-send-email-jolsa@redhat.comSigned-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 321e68b0
...@@ -74,6 +74,20 @@ static struct tracer_flags tracer_flags = { ...@@ -74,6 +74,20 @@ static struct tracer_flags tracer_flags = {
static struct trace_array *graph_array; static struct trace_array *graph_array;
/*
* DURATION column is being also used to display IRQ signs,
* following values are used by print_graph_irq and others
* to fill in space into DURATION column.
*/
enum {
DURATION_FILL_FULL = -1,
DURATION_FILL_START = -2,
DURATION_FILL_END = -3,
};
static enum print_line_t
print_graph_duration(unsigned long long duration, struct trace_seq *s,
u32 flags);
/* Add a function return address to the trace stack on thread info.*/ /* Add a function return address to the trace stack on thread info.*/
int int
...@@ -577,32 +591,6 @@ get_return_for_leaf(struct trace_iterator *iter, ...@@ -577,32 +591,6 @@ get_return_for_leaf(struct trace_iterator *iter,
return next; return next;
} }
/* Signal a overhead of time execution to the output */
static int
print_graph_overhead(unsigned long long duration, struct trace_seq *s,
u32 flags)
{
/* If duration disappear, we don't need anything */
if (!(flags & TRACE_GRAPH_PRINT_DURATION))
return 1;
/* Non nested entry or return */
if (duration == -1)
return trace_seq_printf(s, " ");
if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
/* Duration exceeded 100 msecs */
if (duration > 100000ULL)
return trace_seq_printf(s, "! ");
/* Duration exceeded 10 msecs */
if (duration > 10000ULL)
return trace_seq_printf(s, "+ ");
}
return trace_seq_printf(s, " ");
}
static int print_graph_abs_time(u64 t, struct trace_seq *s) static int print_graph_abs_time(u64 t, struct trace_seq *s)
{ {
unsigned long usecs_rem; unsigned long usecs_rem;
...@@ -650,9 +638,9 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr, ...@@ -650,9 +638,9 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
} }
/* No overhead */ /* No overhead */
ret = print_graph_overhead(-1, s, flags); ret = print_graph_duration(DURATION_FILL_START, s, flags);
if (!ret) if (ret != TRACE_TYPE_HANDLED)
return TRACE_TYPE_PARTIAL_LINE; return ret;
if (type == TRACE_GRAPH_ENT) if (type == TRACE_GRAPH_ENT)
ret = trace_seq_printf(s, "==========>"); ret = trace_seq_printf(s, "==========>");
...@@ -662,9 +650,10 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr, ...@@ -662,9 +650,10 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
if (!ret) if (!ret)
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
/* Don't close the duration column if haven't one */ ret = print_graph_duration(DURATION_FILL_END, s, flags);
if (flags & TRACE_GRAPH_PRINT_DURATION) if (ret != TRACE_TYPE_HANDLED)
trace_seq_printf(s, " |"); return ret;
ret = trace_seq_printf(s, "\n"); ret = trace_seq_printf(s, "\n");
if (!ret) if (!ret)
...@@ -716,9 +705,48 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s) ...@@ -716,9 +705,48 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
} }
static enum print_line_t static enum print_line_t
print_graph_duration(unsigned long long duration, struct trace_seq *s) print_graph_duration(unsigned long long duration, struct trace_seq *s,
u32 flags)
{ {
int ret; int ret = -1;
if (!(flags & TRACE_GRAPH_PRINT_DURATION))
return TRACE_TYPE_HANDLED;
/* No real adata, just filling the column with spaces */
switch (duration) {
case DURATION_FILL_FULL:
ret = trace_seq_printf(s, " | ");
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
case DURATION_FILL_START:
ret = trace_seq_printf(s, " ");
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
case DURATION_FILL_END:
ret = trace_seq_printf(s, " |");
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
}
/* Signal a overhead of time execution to the output */
if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
/* Duration exceeded 100 msecs */
if (duration > 100000ULL)
ret = trace_seq_printf(s, "! ");
/* Duration exceeded 10 msecs */
else if (duration > 10000ULL)
ret = trace_seq_printf(s, "+ ");
}
/*
* The -1 means we either did not exceed the duration tresholds
* or we dont want to print out the overhead. Either way we need
* to fill out the space.
*/
if (ret == -1)
ret = trace_seq_printf(s, " ");
/* Catching here any failure happenned above */
if (!ret)
return TRACE_TYPE_PARTIAL_LINE;
ret = trace_print_graph_duration(duration, s); ret = trace_print_graph_duration(duration, s);
if (ret != TRACE_TYPE_HANDLED) if (ret != TRACE_TYPE_HANDLED)
...@@ -767,18 +795,11 @@ print_graph_entry_leaf(struct trace_iterator *iter, ...@@ -767,18 +795,11 @@ print_graph_entry_leaf(struct trace_iterator *iter,
cpu_data->enter_funcs[call->depth] = 0; cpu_data->enter_funcs[call->depth] = 0;
} }
/* Overhead */ /* Overhead and duration */
ret = print_graph_overhead(duration, s, flags); ret = print_graph_duration(duration, s, flags);
if (!ret) if (ret == TRACE_TYPE_PARTIAL_LINE)
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
/* Duration */
if (flags & TRACE_GRAPH_PRINT_DURATION) {
ret = print_graph_duration(duration, s);
if (ret == TRACE_TYPE_PARTIAL_LINE)
return TRACE_TYPE_PARTIAL_LINE;
}
/* Function */ /* Function */
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
ret = trace_seq_printf(s, " "); ret = trace_seq_printf(s, " ");
...@@ -815,17 +836,10 @@ print_graph_entry_nested(struct trace_iterator *iter, ...@@ -815,17 +836,10 @@ print_graph_entry_nested(struct trace_iterator *iter,
cpu_data->enter_funcs[call->depth] = call->func; cpu_data->enter_funcs[call->depth] = call->func;
} }
/* No overhead */
ret = print_graph_overhead(-1, s, flags);
if (!ret)
return TRACE_TYPE_PARTIAL_LINE;
/* No time */ /* No time */
if (flags & TRACE_GRAPH_PRINT_DURATION) { ret = print_graph_duration(DURATION_FILL_FULL, s, flags);
ret = trace_seq_printf(s, " | "); if (ret != TRACE_TYPE_HANDLED)
if (!ret) return ret;
return TRACE_TYPE_PARTIAL_LINE;
}
/* Function */ /* Function */
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
...@@ -1078,18 +1092,11 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s, ...@@ -1078,18 +1092,11 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
if (print_graph_prologue(iter, s, 0, 0, flags)) if (print_graph_prologue(iter, s, 0, 0, flags))
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
/* Overhead */ /* Overhead and duration */
ret = print_graph_overhead(duration, s, flags); ret = print_graph_duration(duration, s, flags);
if (!ret) if (ret == TRACE_TYPE_PARTIAL_LINE)
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
/* Duration */
if (flags & TRACE_GRAPH_PRINT_DURATION) {
ret = print_graph_duration(duration, s);
if (ret == TRACE_TYPE_PARTIAL_LINE)
return TRACE_TYPE_PARTIAL_LINE;
}
/* Closing brace */ /* Closing brace */
for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) { for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) {
ret = trace_seq_printf(s, " "); ret = trace_seq_printf(s, " ");
...@@ -1146,17 +1153,10 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent, ...@@ -1146,17 +1153,10 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
if (print_graph_prologue(iter, s, 0, 0, flags)) if (print_graph_prologue(iter, s, 0, 0, flags))
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
/* No overhead */
ret = print_graph_overhead(-1, s, flags);
if (!ret)
return TRACE_TYPE_PARTIAL_LINE;
/* No time */ /* No time */
if (flags & TRACE_GRAPH_PRINT_DURATION) { ret = print_graph_duration(DURATION_FILL_FULL, s, flags);
ret = trace_seq_printf(s, " | "); if (ret != TRACE_TYPE_HANDLED)
if (!ret) return ret;
return TRACE_TYPE_PARTIAL_LINE;
}
/* Indentation */ /* Indentation */
if (depth > 0) if (depth > 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册