aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace.c28
-rw-r--r--kernel/trace/trace.h4
-rw-r--r--kernel/trace/trace_functions_graph.c72
-rw-r--r--kernel/trace/trace_mmiotrace.c2
4 files changed, 97 insertions, 9 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 1bd9574404e5..ea38652d631c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3346,7 +3346,7 @@ static int mark_printk(const char *fmt, ...)
3346 int ret; 3346 int ret;
3347 va_list args; 3347 va_list args;
3348 va_start(args, fmt); 3348 va_start(args, fmt);
3349 ret = trace_vprintk(0, fmt, args); 3349 ret = trace_vprintk(0, -1, fmt, args);
3350 va_end(args); 3350 va_end(args);
3351 return ret; 3351 return ret;
3352} 3352}
@@ -3575,9 +3575,16 @@ static __init int tracer_init_debugfs(void)
3575 return 0; 3575 return 0;
3576} 3576}
3577 3577
3578int trace_vprintk(unsigned long ip, const char *fmt, va_list args) 3578int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args)
3579{ 3579{
3580 static DEFINE_SPINLOCK(trace_buf_lock); 3580 /*
3581 * Raw Spinlock because a normal spinlock would be traced here
3582 * and append an irrelevant couple spin_lock_irqsave/
3583 * spin_unlock_irqrestore traced by ftrace around this
3584 * TRACE_PRINTK trace.
3585 */
3586 static raw_spinlock_t trace_buf_lock =
3587 (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
3581 static char trace_buf[TRACE_BUF_SIZE]; 3588 static char trace_buf[TRACE_BUF_SIZE];
3582 3589
3583 struct ring_buffer_event *event; 3590 struct ring_buffer_event *event;
@@ -3598,7 +3605,8 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
3598 if (unlikely(atomic_read(&data->disabled))) 3605 if (unlikely(atomic_read(&data->disabled)))
3599 goto out; 3606 goto out;
3600 3607
3601 spin_lock_irqsave(&trace_buf_lock, flags); 3608 local_irq_save(flags);
3609 __raw_spin_lock(&trace_buf_lock);
3602 len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args); 3610 len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
3603 3611
3604 len = min(len, TRACE_BUF_SIZE-1); 3612 len = min(len, TRACE_BUF_SIZE-1);
@@ -3612,13 +3620,15 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
3612 tracing_generic_entry_update(&entry->ent, flags, pc); 3620 tracing_generic_entry_update(&entry->ent, flags, pc);
3613 entry->ent.type = TRACE_PRINT; 3621 entry->ent.type = TRACE_PRINT;
3614 entry->ip = ip; 3622 entry->ip = ip;
3623 entry->depth = depth;
3615 3624
3616 memcpy(&entry->buf, trace_buf, len); 3625 memcpy(&entry->buf, trace_buf, len);
3617 entry->buf[len] = 0; 3626 entry->buf[len] = 0;
3618 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 3627 ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
3619 3628
3620 out_unlock: 3629 out_unlock:
3621 spin_unlock_irqrestore(&trace_buf_lock, flags); 3630 __raw_spin_unlock(&trace_buf_lock);
3631 local_irq_restore(flags);
3622 3632
3623 out: 3633 out:
3624 preempt_enable_notrace(); 3634 preempt_enable_notrace();
@@ -3636,7 +3646,13 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...)
3636 return 0; 3646 return 0;
3637 3647
3638 va_start(ap, fmt); 3648 va_start(ap, fmt);
3639 ret = trace_vprintk(ip, fmt, ap); 3649
3650#ifdef CONFIG_FUNCTION_GRAPH_TRACER
3651 ret = trace_vprintk(ip, current->curr_ret_stack, fmt, ap);
3652#else
3653 ret = trace_vprintk(ip, -1, fmt, ap);
3654#endif
3655
3640 va_end(ap); 3656 va_end(ap);
3641 return ret; 3657 return ret;
3642} 3658}
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index b4b7b735184d..a71bbe0a3631 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -117,6 +117,7 @@ struct userstack_entry {
117struct print_entry { 117struct print_entry {
118 struct trace_entry ent; 118 struct trace_entry ent;
119 unsigned long ip; 119 unsigned long ip;
120 int depth;
120 char buf[]; 121 char buf[];
121}; 122};
122 123
@@ -498,7 +499,8 @@ seq_print_ip_sym(struct trace_seq *s, unsigned long ip,
498extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, 499extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
499 size_t cnt); 500 size_t cnt);
500extern long ns2usecs(cycle_t nsec); 501extern long ns2usecs(cycle_t nsec);
501extern int trace_vprintk(unsigned long ip, const char *fmt, va_list args); 502extern int
503trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args);
502 504
503extern unsigned long trace_flags; 505extern unsigned long trace_flags;
504 506
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index c66578f2fdc2..32b7fb9a19df 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -173,7 +173,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu)
173 173
174 */ 174 */
175 ret = trace_seq_printf(s, 175 ret = trace_seq_printf(s,
176 "\n ------------------------------------------\n |"); 176 " ------------------------------------------\n");
177 if (!ret) 177 if (!ret)
178 TRACE_TYPE_PARTIAL_LINE; 178 TRACE_TYPE_PARTIAL_LINE;
179 179
@@ -477,6 +477,71 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
477 return TRACE_TYPE_HANDLED; 477 return TRACE_TYPE_HANDLED;
478} 478}
479 479
480static enum print_line_t
481print_graph_comment(struct print_entry *trace, struct trace_seq *s,
482 struct trace_entry *ent, struct trace_iterator *iter)
483{
484 int i;
485 int ret;
486
487 /* Pid */
488 if (verif_pid(s, ent->pid, iter->cpu) == TRACE_TYPE_PARTIAL_LINE)
489 return TRACE_TYPE_PARTIAL_LINE;
490
491 /* Cpu */
492 if (tracer_flags.val & TRACE_GRAPH_PRINT_CPU) {
493 ret = print_graph_cpu(s, iter->cpu);
494 if (ret == TRACE_TYPE_PARTIAL_LINE)
495 return TRACE_TYPE_PARTIAL_LINE;
496 }
497
498 /* Proc */
499 if (tracer_flags.val & TRACE_GRAPH_PRINT_PROC) {
500 ret = print_graph_proc(s, ent->pid);
501 if (ret == TRACE_TYPE_PARTIAL_LINE)
502 return TRACE_TYPE_PARTIAL_LINE;
503
504 ret = trace_seq_printf(s, " | ");
505 if (!ret)
506 return TRACE_TYPE_PARTIAL_LINE;
507 }
508
509 /* No overhead */
510 if (tracer_flags.val & TRACE_GRAPH_PRINT_OVERHEAD) {
511 ret = trace_seq_printf(s, " ");
512 if (!ret)
513 return TRACE_TYPE_PARTIAL_LINE;
514 }
515
516 /* No time */
517 ret = trace_seq_printf(s, " | ");
518 if (!ret)
519 return TRACE_TYPE_PARTIAL_LINE;
520
521 /* Indentation */
522 if (trace->depth > 0)
523 for (i = 0; i < (trace->depth + 1) * TRACE_GRAPH_INDENT; i++) {
524 ret = trace_seq_printf(s, " ");
525 if (!ret)
526 return TRACE_TYPE_PARTIAL_LINE;
527 }
528
529 /* The comment */
530 ret = trace_seq_printf(s, "/* %s", trace->buf);
531 if (!ret)
532 return TRACE_TYPE_PARTIAL_LINE;
533
534 if (ent->flags & TRACE_FLAG_CONT)
535 trace_seq_print_cont(s, iter);
536
537 ret = trace_seq_printf(s, " */\n");
538 if (!ret)
539 return TRACE_TYPE_PARTIAL_LINE;
540
541 return TRACE_TYPE_HANDLED;
542}
543
544
480enum print_line_t 545enum print_line_t
481print_graph_function(struct trace_iterator *iter) 546print_graph_function(struct trace_iterator *iter)
482{ 547{
@@ -495,6 +560,11 @@ print_graph_function(struct trace_iterator *iter)
495 trace_assign_type(field, entry); 560 trace_assign_type(field, entry);
496 return print_graph_return(&field->ret, s, entry, iter->cpu); 561 return print_graph_return(&field->ret, s, entry, iter->cpu);
497 } 562 }
563 case TRACE_PRINT: {
564 struct print_entry *field;
565 trace_assign_type(field, entry);
566 return print_graph_comment(field, s, entry, iter);
567 }
498 default: 568 default:
499 return TRACE_TYPE_UNHANDLED; 569 return TRACE_TYPE_UNHANDLED;
500 } 570 }
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index 2a98a206acc2..2fb6da6523b3 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -366,5 +366,5 @@ void mmio_trace_mapping(struct mmiotrace_map *map)
366 366
367int mmio_trace_printk(const char *fmt, va_list args) 367int mmio_trace_printk(const char *fmt, va_list args)
368{ 368{
369 return trace_vprintk(0, fmt, args); 369 return trace_vprintk(0, -1, fmt, args);
370} 370}