Skip to content

Commit ffeb80f

Browse files
Jiri Olsarostedt
authored andcommitted
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: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1307113131-10045-3-git-send-email-jolsa@redhat.com Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 321e68b commit ffeb80f

1 file changed

Lines changed: 74 additions & 74 deletions

File tree

‎kernel/trace/trace_functions_graph.c‎

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ static struct tracer_flags tracer_flags = {
7474

7575
static struct trace_array *graph_array;
7676

77+
/*
78+
* DURATION column is being also used to display IRQ signs,
79+
* following values are used by print_graph_irq and others
80+
* to fill in space into DURATION column.
81+
*/
82+
enum {
83+
DURATION_FILL_FULL = -1,
84+
DURATION_FILL_START = -2,
85+
DURATION_FILL_END = -3,
86+
};
87+
88+
static enum print_line_t
89+
print_graph_duration(unsigned long long duration, struct trace_seq *s,
90+
u32 flags);
7791

7892
/* Add a function return address to the trace stack on thread info.*/
7993
int
@@ -577,32 +591,6 @@ get_return_for_leaf(struct trace_iterator *iter,
577591
return next;
578592
}
579593

580-
/* Signal a overhead of time execution to the output */
581-
static int
582-
print_graph_overhead(unsigned long long duration, struct trace_seq *s,
583-
u32 flags)
584-
{
585-
/* If duration disappear, we don't need anything */
586-
if (!(flags & TRACE_GRAPH_PRINT_DURATION))
587-
return 1;
588-
589-
/* Non nested entry or return */
590-
if (duration == -1)
591-
return trace_seq_printf(s, " ");
592-
593-
if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
594-
/* Duration exceeded 100 msecs */
595-
if (duration > 100000ULL)
596-
return trace_seq_printf(s, "! ");
597-
598-
/* Duration exceeded 10 msecs */
599-
if (duration > 10000ULL)
600-
return trace_seq_printf(s, "+ ");
601-
}
602-
603-
return trace_seq_printf(s, " ");
604-
}
605-
606594
static int print_graph_abs_time(u64 t, struct trace_seq *s)
607595
{
608596
unsigned long usecs_rem;
@@ -650,9 +638,9 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
650638
}
651639

652640
/* No overhead */
653-
ret = print_graph_overhead(-1, s, flags);
654-
if (!ret)
655-
return TRACE_TYPE_PARTIAL_LINE;
641+
ret = print_graph_duration(DURATION_FILL_START, s, flags);
642+
if (ret != TRACE_TYPE_HANDLED)
643+
return ret;
656644

657645
if (type == TRACE_GRAPH_ENT)
658646
ret = trace_seq_printf(s, "==========>");
@@ -662,9 +650,10 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
662650
if (!ret)
663651
return TRACE_TYPE_PARTIAL_LINE;
664652

665-
/* Don't close the duration column if haven't one */
666-
if (flags & TRACE_GRAPH_PRINT_DURATION)
667-
trace_seq_printf(s, " |");
653+
ret = print_graph_duration(DURATION_FILL_END, s, flags);
654+
if (ret != TRACE_TYPE_HANDLED)
655+
return ret;
656+
668657
ret = trace_seq_printf(s, "\n");
669658

670659
if (!ret)
@@ -716,9 +705,48 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
716705
}
717706

718707
static enum print_line_t
719-
print_graph_duration(unsigned long long duration, struct trace_seq *s)
708+
print_graph_duration(unsigned long long duration, struct trace_seq *s,
709+
u32 flags)
720710
{
721-
int ret;
711+
int ret = -1;
712+
713+
if (!(flags & TRACE_GRAPH_PRINT_DURATION))
714+
return TRACE_TYPE_HANDLED;
715+
716+
/* No real adata, just filling the column with spaces */
717+
switch (duration) {
718+
case DURATION_FILL_FULL:
719+
ret = trace_seq_printf(s, " | ");
720+
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
721+
case DURATION_FILL_START:
722+
ret = trace_seq_printf(s, " ");
723+
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
724+
case DURATION_FILL_END:
725+
ret = trace_seq_printf(s, " |");
726+
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
727+
}
728+
729+
/* Signal a overhead of time execution to the output */
730+
if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
731+
/* Duration exceeded 100 msecs */
732+
if (duration > 100000ULL)
733+
ret = trace_seq_printf(s, "! ");
734+
/* Duration exceeded 10 msecs */
735+
else if (duration > 10000ULL)
736+
ret = trace_seq_printf(s, "+ ");
737+
}
738+
739+
/*
740+
* The -1 means we either did not exceed the duration tresholds
741+
* or we dont want to print out the overhead. Either way we need
742+
* to fill out the space.
743+
*/
744+
if (ret == -1)
745+
ret = trace_seq_printf(s, " ");
746+
747+
/* Catching here any failure happenned above */
748+
if (!ret)
749+
return TRACE_TYPE_PARTIAL_LINE;
722750

723751
ret = trace_print_graph_duration(duration, s);
724752
if (ret != TRACE_TYPE_HANDLED)
@@ -767,18 +795,11 @@ print_graph_entry_leaf(struct trace_iterator *iter,
767795
cpu_data->enter_funcs[call->depth] = 0;
768796
}
769797

770-
/* Overhead */
771-
ret = print_graph_overhead(duration, s, flags);
772-
if (!ret)
798+
/* Overhead and duration */
799+
ret = print_graph_duration(duration, s, flags);
800+
if (ret == TRACE_TYPE_PARTIAL_LINE)
773801
return TRACE_TYPE_PARTIAL_LINE;
774802

775-
/* Duration */
776-
if (flags & TRACE_GRAPH_PRINT_DURATION) {
777-
ret = print_graph_duration(duration, s);
778-
if (ret == TRACE_TYPE_PARTIAL_LINE)
779-
return TRACE_TYPE_PARTIAL_LINE;
780-
}
781-
782803
/* Function */
783804
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
784805
ret = trace_seq_printf(s, " ");
@@ -815,17 +836,10 @@ print_graph_entry_nested(struct trace_iterator *iter,
815836
cpu_data->enter_funcs[call->depth] = call->func;
816837
}
817838

818-
/* No overhead */
819-
ret = print_graph_overhead(-1, s, flags);
820-
if (!ret)
821-
return TRACE_TYPE_PARTIAL_LINE;
822-
823839
/* No time */
824-
if (flags & TRACE_GRAPH_PRINT_DURATION) {
825-
ret = trace_seq_printf(s, " | ");
826-
if (!ret)
827-
return TRACE_TYPE_PARTIAL_LINE;
828-
}
840+
ret = print_graph_duration(DURATION_FILL_FULL, s, flags);
841+
if (ret != TRACE_TYPE_HANDLED)
842+
return ret;
829843

830844
/* Function */
831845
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,
10781092
if (print_graph_prologue(iter, s, 0, 0, flags))
10791093
return TRACE_TYPE_PARTIAL_LINE;
10801094

1081-
/* Overhead */
1082-
ret = print_graph_overhead(duration, s, flags);
1083-
if (!ret)
1095+
/* Overhead and duration */
1096+
ret = print_graph_duration(duration, s, flags);
1097+
if (ret == TRACE_TYPE_PARTIAL_LINE)
10841098
return TRACE_TYPE_PARTIAL_LINE;
10851099

1086-
/* Duration */
1087-
if (flags & TRACE_GRAPH_PRINT_DURATION) {
1088-
ret = print_graph_duration(duration, s);
1089-
if (ret == TRACE_TYPE_PARTIAL_LINE)
1090-
return TRACE_TYPE_PARTIAL_LINE;
1091-
}
1092-
10931100
/* Closing brace */
10941101
for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) {
10951102
ret = trace_seq_printf(s, " ");
@@ -1146,17 +1153,10 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
11461153
if (print_graph_prologue(iter, s, 0, 0, flags))
11471154
return TRACE_TYPE_PARTIAL_LINE;
11481155

1149-
/* No overhead */
1150-
ret = print_graph_overhead(-1, s, flags);
1151-
if (!ret)
1152-
return TRACE_TYPE_PARTIAL_LINE;
1153-
11541156
/* No time */
1155-
if (flags & TRACE_GRAPH_PRINT_DURATION) {
1156-
ret = trace_seq_printf(s, " | ");
1157-
if (!ret)
1158-
return TRACE_TYPE_PARTIAL_LINE;
1159-
}
1157+
ret = print_graph_duration(DURATION_FILL_FULL, s, flags);
1158+
if (ret != TRACE_TYPE_HANDLED)
1159+
return ret;
11601160

11611161
/* Indentation */
11621162
if (depth > 0)

0 commit comments

Comments
 (0)