Merge tag 'trace-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux...
[pandora-kernel.git] / kernel / trace / trace.c
index 426962b..ce11fa5 100644 (file)
@@ -155,10 +155,11 @@ __setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);
 
 static int __init stop_trace_on_warning(char *str)
 {
-       __disable_trace_on_warning = 1;
+       if ((strcmp(str, "=0") != 0 && strcmp(str, "=off") != 0))
+               __disable_trace_on_warning = 1;
        return 1;
 }
-__setup("traceoff_on_warning=", stop_trace_on_warning);
+__setup("traceoff_on_warning", stop_trace_on_warning);
 
 static int __init boot_alloc_snapshot(char *str)
 {
@@ -2158,9 +2159,7 @@ __trace_array_vprintk(struct ring_buffer *buffer,
                goto out;
        }
 
-       len = vsnprintf(tbuffer, TRACE_BUF_SIZE, fmt, args);
-       if (len > TRACE_BUF_SIZE)
-               goto out;
+       len = vscnprintf(tbuffer, TRACE_BUF_SIZE, fmt, args);
 
        local_save_flags(flags);
        size = sizeof(*entry) + len + 1;
@@ -2171,8 +2170,7 @@ __trace_array_vprintk(struct ring_buffer *buffer,
        entry = ring_buffer_event_data(event);
        entry->ip = ip;
 
-       memcpy(&entry->buf, tbuffer, len);
-       entry->buf[len] = '\0';
+       memcpy(&entry->buf, tbuffer, len + 1);
        if (!call_filter_check_discard(call, entry, buffer, event)) {
                __buffer_unlock_commit(buffer, event);
                ftrace_trace_stack(buffer, flags, 6, pc);
@@ -2509,14 +2507,14 @@ get_total_entries(struct trace_buffer *buf,
 
 static void print_lat_help_header(struct seq_file *m)
 {
-       seq_puts(m, "#                  _------=> CPU#            \n");
-       seq_puts(m, "#                 / _-----=> irqs-off        \n");
-       seq_puts(m, "#                | / _----=> need-resched    \n");
-       seq_puts(m, "#                || / _---=> hardirq/softirq \n");
-       seq_puts(m, "#                ||| / _--=> preempt-depth   \n");
-       seq_puts(m, "#                |||| /     delay             \n");
-       seq_puts(m, "#  cmd     pid   ||||| time  |   caller      \n");
-       seq_puts(m, "#     \\   /      |||||  \\    |   /           \n");
+       seq_puts(m, "#                  _------=> CPU#            \n"
+                   "#                 / _-----=> irqs-off        \n"
+                   "#                | / _----=> need-resched    \n"
+                   "#                || / _---=> hardirq/softirq \n"
+                   "#                ||| / _--=> preempt-depth   \n"
+                   "#                |||| /     delay            \n"
+                   "#  cmd     pid   ||||| time  |   caller      \n"
+                   "#     \\   /      |||||  \\    |   /         \n");
 }
 
 static void print_event_info(struct trace_buffer *buf, struct seq_file *m)
@@ -2533,20 +2531,20 @@ static void print_event_info(struct trace_buffer *buf, struct seq_file *m)
 static void print_func_help_header(struct trace_buffer *buf, struct seq_file *m)
 {
        print_event_info(buf, m);
-       seq_puts(m, "#           TASK-PID   CPU#      TIMESTAMP  FUNCTION\n");
-       seq_puts(m, "#              | |       |          |         |\n");
+       seq_puts(m, "#           TASK-PID   CPU#      TIMESTAMP  FUNCTION\n"
+                   "#              | |       |          |         |\n");
 }
 
 static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m)
 {
        print_event_info(buf, m);
-       seq_puts(m, "#                              _-----=> irqs-off\n");
-       seq_puts(m, "#                             / _----=> need-resched\n");
-       seq_puts(m, "#                            | / _---=> hardirq/softirq\n");
-       seq_puts(m, "#                            || / _--=> preempt-depth\n");
-       seq_puts(m, "#                            ||| /     delay\n");
-       seq_puts(m, "#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION\n");
-       seq_puts(m, "#              | |       |   ||||       |         |\n");
+       seq_puts(m, "#                              _-----=> irqs-off\n"
+                   "#                             / _----=> need-resched\n"
+                   "#                            | / _---=> hardirq/softirq\n"
+                   "#                            || / _--=> preempt-depth\n"
+                   "#                            ||| /     delay\n"
+                   "#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION\n"
+                   "#              | |       |   ||||       |         |\n");
 }
 
 void
@@ -2649,24 +2647,21 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
        event = ftrace_find_event(entry->type);
 
        if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
-               if (iter->iter_flags & TRACE_FILE_LAT_FMT) {
-                       if (!trace_print_lat_context(iter))
-                               goto partial;
-               } else {
-                       if (!trace_print_context(iter))
-                               goto partial;
-               }
+               if (iter->iter_flags & TRACE_FILE_LAT_FMT)
+                       trace_print_lat_context(iter);
+               else
+                       trace_print_context(iter);
        }
 
+       if (trace_seq_has_overflowed(s))
+               return TRACE_TYPE_PARTIAL_LINE;
+
        if (event)
                return event->funcs->trace(iter, sym_flags, event);
 
-       if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
-               goto partial;
+       trace_seq_printf(s, "Unknown type %d\n", entry->type);
 
-       return TRACE_TYPE_HANDLED;
-partial:
-       return TRACE_TYPE_PARTIAL_LINE;
+       return trace_handle_return(s);
 }
 
 static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
@@ -2677,22 +2672,20 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
 
        entry = iter->ent;
 
-       if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
-               if (!trace_seq_printf(s, "%d %d %llu ",
-                                     entry->pid, iter->cpu, iter->ts))
-                       goto partial;
-       }
+       if (trace_flags & TRACE_ITER_CONTEXT_INFO)
+               trace_seq_printf(s, "%d %d %llu ",
+                                entry->pid, iter->cpu, iter->ts);
+
+       if (trace_seq_has_overflowed(s))
+               return TRACE_TYPE_PARTIAL_LINE;
 
        event = ftrace_find_event(entry->type);
        if (event)
                return event->funcs->raw(iter, 0, event);
 
-       if (!trace_seq_printf(s, "%d ?\n", entry->type))
-               goto partial;
+       trace_seq_printf(s, "%d ?\n", entry->type);
 
-       return TRACE_TYPE_HANDLED;
-partial:
-       return TRACE_TYPE_PARTIAL_LINE;
+       return trace_handle_return(s);
 }
 
 static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
@@ -2705,9 +2698,11 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
        entry = iter->ent;
 
        if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
-               SEQ_PUT_HEX_FIELD_RET(s, entry->pid);
-               SEQ_PUT_HEX_FIELD_RET(s, iter->cpu);
-               SEQ_PUT_HEX_FIELD_RET(s, iter->ts);
+               SEQ_PUT_HEX_FIELD(s, entry->pid);
+               SEQ_PUT_HEX_FIELD(s, iter->cpu);
+               SEQ_PUT_HEX_FIELD(s, iter->ts);
+               if (trace_seq_has_overflowed(s))
+                       return TRACE_TYPE_PARTIAL_LINE;
        }
 
        event = ftrace_find_event(entry->type);
@@ -2717,9 +2712,9 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
                        return ret;
        }
 
-       SEQ_PUT_FIELD_RET(s, newline);
+       SEQ_PUT_FIELD(s, newline);
 
-       return TRACE_TYPE_HANDLED;
+       return trace_handle_return(s);
 }
 
 static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
@@ -2731,9 +2726,11 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
        entry = iter->ent;
 
        if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
-               SEQ_PUT_FIELD_RET(s, entry->pid);
-               SEQ_PUT_FIELD_RET(s, iter->cpu);
-               SEQ_PUT_FIELD_RET(s, iter->ts);
+               SEQ_PUT_FIELD(s, entry->pid);
+               SEQ_PUT_FIELD(s, iter->cpu);
+               SEQ_PUT_FIELD(s, iter->ts);
+               if (trace_seq_has_overflowed(s))
+                       return TRACE_TYPE_PARTIAL_LINE;
        }
 
        event = ftrace_find_event(entry->type);
@@ -2779,10 +2776,12 @@ enum print_line_t print_trace_line(struct trace_iterator *iter)
 {
        enum print_line_t ret;
 
-       if (iter->lost_events &&
-           !trace_seq_printf(&iter->seq, "CPU:%d [LOST %lu EVENTS]\n",
-                                iter->cpu, iter->lost_events))
-               return TRACE_TYPE_PARTIAL_LINE;
+       if (iter->lost_events) {
+               trace_seq_printf(&iter->seq, "CPU:%d [LOST %lu EVENTS]\n",
+                                iter->cpu, iter->lost_events);
+               if (trace_seq_has_overflowed(&iter->seq))
+                       return TRACE_TYPE_PARTIAL_LINE;
+       }
 
        if (iter->trace && iter->trace->print_line) {
                ret = iter->trace->print_line(iter);
@@ -2860,44 +2859,44 @@ static void test_ftrace_alive(struct seq_file *m)
 {
        if (!ftrace_is_dead())
                return;
-       seq_printf(m, "# WARNING: FUNCTION TRACING IS CORRUPTED\n");
-       seq_printf(m, "#          MAY BE MISSING FUNCTION EVENTS\n");
+       seq_puts(m, "# WARNING: FUNCTION TRACING IS CORRUPTED\n"
+                   "#          MAY BE MISSING FUNCTION EVENTS\n");
 }
 
 #ifdef CONFIG_TRACER_MAX_TRACE
 static void show_snapshot_main_help(struct seq_file *m)
 {
-       seq_printf(m, "# echo 0 > snapshot : Clears and frees snapshot buffer\n");
-       seq_printf(m, "# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n");
-       seq_printf(m, "#                      Takes a snapshot of the main buffer.\n");
-       seq_printf(m, "# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)\n");
-       seq_printf(m, "#                      (Doesn't have to be '2' works with any number that\n");
-       seq_printf(m, "#                       is not a '0' or '1')\n");
+       seq_puts(m, "# echo 0 > snapshot : Clears and frees snapshot buffer\n"
+                   "# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n"
+                   "#                      Takes a snapshot of the main buffer.\n"
+                   "# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)\n"
+                   "#                      (Doesn't have to be '2' works with any number that\n"
+                   "#                       is not a '0' or '1')\n");
 }
 
 static void show_snapshot_percpu_help(struct seq_file *m)
 {
-       seq_printf(m, "# echo 0 > snapshot : Invalid for per_cpu snapshot file.\n");
+       seq_puts(m, "# echo 0 > snapshot : Invalid for per_cpu snapshot file.\n");
 #ifdef CONFIG_RING_BUFFER_ALLOW_SWAP
-       seq_printf(m, "# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n");
-       seq_printf(m, "#                      Takes a snapshot of the main buffer for this cpu.\n");
+       seq_puts(m, "# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n"
+                   "#                      Takes a snapshot of the main buffer for this cpu.\n");
 #else
-       seq_printf(m, "# echo 1 > snapshot : Not supported with this kernel.\n");
-       seq_printf(m, "#                     Must use main snapshot file to allocate.\n");
+       seq_puts(m, "# echo 1 > snapshot : Not supported with this kernel.\n"
+                   "#                     Must use main snapshot file to allocate.\n");
 #endif
-       seq_printf(m, "# echo 2 > snapshot : Clears this cpu's snapshot buffer (but does not allocate)\n");
-       seq_printf(m, "#                      (Doesn't have to be '2' works with any number that\n");
-       seq_printf(m, "#                       is not a '0' or '1')\n");
+       seq_puts(m, "# echo 2 > snapshot : Clears this cpu's snapshot buffer (but does not allocate)\n"
+                   "#                      (Doesn't have to be '2' works with any number that\n"
+                   "#                       is not a '0' or '1')\n");
 }
 
 static void print_snapshot_help(struct seq_file *m, struct trace_iterator *iter)
 {
        if (iter->tr->allocated_snapshot)
-               seq_printf(m, "#\n# * Snapshot is allocated *\n#\n");
+               seq_puts(m, "#\n# * Snapshot is allocated *\n#\n");
        else
-               seq_printf(m, "#\n# * Snapshot is freed *\n#\n");
+               seq_puts(m, "#\n# * Snapshot is freed *\n#\n");
 
-       seq_printf(m, "# Snapshot commands:\n");
+       seq_puts(m, "# Snapshot commands:\n");
        if (iter->cpu_file == RING_BUFFER_ALL_CPUS)
                show_snapshot_main_help(m);
        else
@@ -3251,7 +3250,7 @@ static int t_show(struct seq_file *m, void *v)
        if (!t)
                return 0;
 
-       seq_printf(m, "%s", t->name);
+       seq_puts(m, t->name);
        if (t->next)
                seq_putc(m, ' ');
        else
@@ -5749,10 +5748,10 @@ ftrace_snapshot_print(struct seq_file *m, unsigned long ip,
 
        seq_printf(m, "%ps:", (void *)ip);
 
-       seq_printf(m, "snapshot");
+       seq_puts(m, "snapshot");
 
        if (count == -1)
-               seq_printf(m, ":unlimited\n");
+               seq_puts(m, ":unlimited\n");
        else
                seq_printf(m, ":count=%ld\n", count);