These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / kernel / trace / trace_functions_graph.c
index a51e796..a663cbb 100644 (file)
@@ -83,13 +83,18 @@ static struct tracer_opt trace_opts[] = {
        { TRACER_OPT(funcgraph-irqs, TRACE_GRAPH_PRINT_IRQS) },
        /* Display function name after trailing } */
        { TRACER_OPT(funcgraph-tail, TRACE_GRAPH_PRINT_TAIL) },
+       /* Include sleep time (scheduled out) between entry and return */
+       { TRACER_OPT(sleep-time, TRACE_GRAPH_SLEEP_TIME) },
+       /* Include time within nested functions */
+       { TRACER_OPT(graph-time, TRACE_GRAPH_GRAPH_TIME) },
        { } /* Empty entry */
 };
 
 static struct tracer_flags tracer_flags = {
        /* Don't display overruns, proc, or tail by default */
        .val = TRACE_GRAPH_PRINT_CPU | TRACE_GRAPH_PRINT_OVERHEAD |
-              TRACE_GRAPH_PRINT_DURATION | TRACE_GRAPH_PRINT_IRQS,
+              TRACE_GRAPH_PRINT_DURATION | TRACE_GRAPH_PRINT_IRQS |
+              TRACE_GRAPH_SLEEP_TIME | TRACE_GRAPH_GRAPH_TIME,
        .opts = trace_opts
 };
 
@@ -107,8 +112,8 @@ enum {
 };
 
 static void
-print_graph_duration(unsigned long long duration, struct trace_seq *s,
-                    u32 flags);
+print_graph_duration(struct trace_array *tr, unsigned long long duration,
+                    struct trace_seq *s, u32 flags);
 
 /* Add a function return address to the trace stack on thread info.*/
 int
@@ -278,14 +283,11 @@ int __trace_graph_entry(struct trace_array *tr,
                                unsigned long flags,
                                int pc)
 {
-       struct ftrace_event_call *call = &event_funcgraph_entry;
+       struct trace_event_call *call = &event_funcgraph_entry;
        struct ring_buffer_event *event;
        struct ring_buffer *buffer = tr->trace_buffer.buffer;
        struct ftrace_graph_ent_entry *entry;
 
-       if (unlikely(__this_cpu_read(ftrace_cpu_disabled)))
-               return 0;
-
        event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT,
                                          sizeof(*entry), flags, pc);
        if (!event)
@@ -393,14 +395,11 @@ void __trace_graph_return(struct trace_array *tr,
                                unsigned long flags,
                                int pc)
 {
-       struct ftrace_event_call *call = &event_funcgraph_exit;
+       struct trace_event_call *call = &event_funcgraph_exit;
        struct ring_buffer_event *event;
        struct ring_buffer *buffer = tr->trace_buffer.buffer;
        struct ftrace_graph_ret_entry *entry;
 
-       if (unlikely(__this_cpu_read(ftrace_cpu_disabled)))
-               return;
-
        event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET,
                                          sizeof(*entry), flags, pc);
        if (!event)
@@ -653,6 +652,7 @@ static void
 print_graph_irq(struct trace_iterator *iter, unsigned long addr,
                enum trace_type type, int cpu, pid_t pid, u32 flags)
 {
+       struct trace_array *tr = iter->tr;
        struct trace_seq *s = &iter->seq;
        struct trace_entry *ent = iter->ent;
 
@@ -660,7 +660,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
                addr >= (unsigned long)__irqentry_text_end)
                return;
 
-       if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
+       if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) {
                /* Absolute time */
                if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
                        print_graph_abs_time(iter->ts, s);
@@ -676,19 +676,19 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
                }
 
                /* Latency format */
-               if (trace_flags & TRACE_ITER_LATENCY_FMT)
+               if (tr->trace_flags & TRACE_ITER_LATENCY_FMT)
                        print_graph_lat_fmt(s, ent);
        }
 
        /* No overhead */
-       print_graph_duration(0, s, flags | FLAGS_FILL_START);
+       print_graph_duration(tr, 0, s, flags | FLAGS_FILL_START);
 
        if (type == TRACE_GRAPH_ENT)
                trace_seq_puts(s, "==========>");
        else
                trace_seq_puts(s, "<==========");
 
-       print_graph_duration(0, s, flags | FLAGS_FILL_END);
+       print_graph_duration(tr, 0, s, flags | FLAGS_FILL_END);
        trace_seq_putc(s, '\n');
 }
 
@@ -715,22 +715,22 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
 
                snprintf(nsecs_str, slen, "%03lu", nsecs_rem);
                trace_seq_printf(s, ".%s", nsecs_str);
-               len += strlen(nsecs_str);
+               len += strlen(nsecs_str) + 1;
        }
 
        trace_seq_puts(s, " us ");
 
        /* Print remaining spaces to fit the row's width */
-       for (i = len; i < 7; i++)
+       for (i = len; i < 8; i++)
                trace_seq_putc(s, ' ');
 }
 
 static void
-print_graph_duration(unsigned long long duration, struct trace_seq *s,
-                    u32 flags)
+print_graph_duration(struct trace_array *tr, unsigned long long duration,
+                    struct trace_seq *s, u32 flags)
 {
        if (!(flags & TRACE_GRAPH_PRINT_DURATION) ||
-           !(trace_flags & TRACE_ITER_CONTEXT_INFO))
+           !(tr->trace_flags & TRACE_ITER_CONTEXT_INFO))
                return;
 
        /* No real adata, just filling the column with spaces */
@@ -764,6 +764,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
                struct trace_seq *s, u32 flags)
 {
        struct fgraph_data *data = iter->private;
+       struct trace_array *tr = iter->tr;
        struct ftrace_graph_ret *graph_ret;
        struct ftrace_graph_ent *call;
        unsigned long long duration;
@@ -792,7 +793,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
        }
 
        /* Overhead and duration */
-       print_graph_duration(duration, s, flags);
+       print_graph_duration(tr, duration, s, flags);
 
        /* Function */
        for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++)
@@ -810,6 +811,7 @@ print_graph_entry_nested(struct trace_iterator *iter,
 {
        struct ftrace_graph_ent *call = &entry->graph_ent;
        struct fgraph_data *data = iter->private;
+       struct trace_array *tr = iter->tr;
        int i;
 
        if (data) {
@@ -825,7 +827,7 @@ print_graph_entry_nested(struct trace_iterator *iter,
        }
 
        /* No time */
-       print_graph_duration(0, s, flags | FLAGS_FILL_FULL);
+       print_graph_duration(tr, 0, s, flags | FLAGS_FILL_FULL);
 
        /* Function */
        for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++)
@@ -849,6 +851,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
 {
        struct fgraph_data *data = iter->private;
        struct trace_entry *ent = iter->ent;
+       struct trace_array *tr = iter->tr;
        int cpu = iter->cpu;
 
        /* Pid */
@@ -858,7 +861,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
                /* Interrupt */
                print_graph_irq(iter, addr, type, cpu, ent->pid, flags);
 
-       if (!(trace_flags & TRACE_ITER_CONTEXT_INFO))
+       if (!(tr->trace_flags & TRACE_ITER_CONTEXT_INFO))
                return;
 
        /* Absolute time */
@@ -876,7 +879,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
        }
 
        /* Latency format */
-       if (trace_flags & TRACE_ITER_LATENCY_FMT)
+       if (tr->trace_flags & TRACE_ITER_LATENCY_FMT)
                print_graph_lat_fmt(s, ent);
 
        return;
@@ -1027,6 +1030,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
 {
        unsigned long long duration = trace->rettime - trace->calltime;
        struct fgraph_data *data = iter->private;
+       struct trace_array *tr = iter->tr;
        pid_t pid = ent->pid;
        int cpu = iter->cpu;
        int func_match = 1;
@@ -1058,7 +1062,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
        print_graph_prologue(iter, s, 0, 0, flags);
 
        /* Overhead and duration */
-       print_graph_duration(duration, s, flags);
+       print_graph_duration(tr, duration, s, flags);
 
        /* Closing brace */
        for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++)
@@ -1091,7 +1095,8 @@ static enum print_line_t
 print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
                    struct trace_iterator *iter, u32 flags)
 {
-       unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
+       struct trace_array *tr = iter->tr;
+       unsigned long sym_flags = (tr->trace_flags & TRACE_ITER_SYM_MASK);
        struct fgraph_data *data = iter->private;
        struct trace_event *event;
        int depth = 0;
@@ -1104,7 +1109,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
        print_graph_prologue(iter, s, 0, 0, flags);
 
        /* No time */
-       print_graph_duration(0, s, flags | FLAGS_FILL_FULL);
+       print_graph_duration(tr, 0, s, flags | FLAGS_FILL_FULL);
 
        /* Indentation */
        if (depth > 0)
@@ -1245,9 +1250,10 @@ static void print_lat_header(struct seq_file *s, u32 flags)
        seq_printf(s, "#%.*s||| /                      \n", size, spaces);
 }
 
-static void __print_graph_headers_flags(struct seq_file *s, u32 flags)
+static void __print_graph_headers_flags(struct trace_array *tr,
+                                       struct seq_file *s, u32 flags)
 {
-       int lat = trace_flags & TRACE_ITER_LATENCY_FMT;
+       int lat = tr->trace_flags & TRACE_ITER_LATENCY_FMT;
 
        if (lat)
                print_lat_header(s, flags);
@@ -1289,11 +1295,12 @@ static void print_graph_headers(struct seq_file *s)
 void print_graph_headers_flags(struct seq_file *s, u32 flags)
 {
        struct trace_iterator *iter = s->private;
+       struct trace_array *tr = iter->tr;
 
-       if (!(trace_flags & TRACE_ITER_CONTEXT_INFO))
+       if (!(tr->trace_flags & TRACE_ITER_CONTEXT_INFO))
                return;
 
-       if (trace_flags & TRACE_ITER_LATENCY_FMT) {
+       if (tr->trace_flags & TRACE_ITER_LATENCY_FMT) {
                /* print nothing if the buffers are empty */
                if (trace_empty(iter))
                        return;
@@ -1301,7 +1308,7 @@ void print_graph_headers_flags(struct seq_file *s, u32 flags)
                print_trace_header(s, iter);
        }
 
-       __print_graph_headers_flags(s, flags);
+       __print_graph_headers_flags(tr, s, flags);
 }
 
 void graph_trace_open(struct trace_iterator *iter)
@@ -1362,6 +1369,12 @@ func_graph_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
        if (bit == TRACE_GRAPH_PRINT_IRQS)
                ftrace_graph_skip_irqs = !set;
 
+       if (bit == TRACE_GRAPH_SLEEP_TIME)
+               ftrace_graph_sleep_time_control(set);
+
+       if (bit == TRACE_GRAPH_GRAPH_TIME)
+               ftrace_graph_graph_time_control(set);
+
        return 0;
 }
 
@@ -1454,12 +1467,12 @@ 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)) {
+       if (!register_trace_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)) {
+       if (!register_trace_event(&graph_trace_ret_event)) {
                pr_warning("Warning: could not register graph trace events\n");
                return 1;
        }