diff options
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index dc53ecb8058..9541c27c1cf 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -41,8 +41,6 @@ | |||
41 | #include "trace.h" | 41 | #include "trace.h" |
42 | #include "trace_output.h" | 42 | #include "trace_output.h" |
43 | 43 | ||
44 | #define TRACE_BUFFER_FLAGS (RB_FL_OVERWRITE) | ||
45 | |||
46 | /* | 44 | /* |
47 | * On boot up, the ring buffer is set to the minimum size, so that | 45 | * On boot up, the ring buffer is set to the minimum size, so that |
48 | * we do not waste memory on systems that are not using tracing. | 46 | * we do not waste memory on systems that are not using tracing. |
@@ -340,7 +338,7 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait); | |||
340 | /* trace_flags holds trace_options default values */ | 338 | /* trace_flags holds trace_options default values */ |
341 | unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | | 339 | unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | |
342 | TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME | | 340 | TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME | |
343 | TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD; | 341 | TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE; |
344 | 342 | ||
345 | static int trace_stop_count; | 343 | static int trace_stop_count; |
346 | static DEFINE_SPINLOCK(tracing_start_lock); | 344 | static DEFINE_SPINLOCK(tracing_start_lock); |
@@ -425,6 +423,7 @@ static const char *trace_options[] = { | |||
425 | "sleep-time", | 423 | "sleep-time", |
426 | "graph-time", | 424 | "graph-time", |
427 | "record-cmd", | 425 | "record-cmd", |
426 | "overwrite", | ||
428 | NULL | 427 | NULL |
429 | }; | 428 | }; |
430 | 429 | ||
@@ -780,6 +779,11 @@ __acquires(kernel_lock) | |||
780 | tracing_reset_online_cpus(tr); | 779 | tracing_reset_online_cpus(tr); |
781 | 780 | ||
782 | current_trace = type; | 781 | current_trace = type; |
782 | |||
783 | /* If we expanded the buffers, make sure the max is expanded too */ | ||
784 | if (ring_buffer_expanded && type->use_max_tr) | ||
785 | ring_buffer_resize(max_tr.buffer, trace_buf_size); | ||
786 | |||
783 | /* the test is responsible for initializing and enabling */ | 787 | /* the test is responsible for initializing and enabling */ |
784 | pr_info("Testing tracer %s: ", type->name); | 788 | pr_info("Testing tracer %s: ", type->name); |
785 | ret = type->selftest(type, tr); | 789 | ret = type->selftest(type, tr); |
@@ -792,6 +796,10 @@ __acquires(kernel_lock) | |||
792 | /* Only reset on passing, to avoid touching corrupted buffers */ | 796 | /* Only reset on passing, to avoid touching corrupted buffers */ |
793 | tracing_reset_online_cpus(tr); | 797 | tracing_reset_online_cpus(tr); |
794 | 798 | ||
799 | /* Shrink the max buffer again */ | ||
800 | if (ring_buffer_expanded && type->use_max_tr) | ||
801 | ring_buffer_resize(max_tr.buffer, 1); | ||
802 | |||
795 | printk(KERN_CONT "PASSED\n"); | 803 | printk(KERN_CONT "PASSED\n"); |
796 | } | 804 | } |
797 | #endif | 805 | #endif |
@@ -1102,7 +1110,6 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, | |||
1102 | 1110 | ||
1103 | entry->preempt_count = pc & 0xff; | 1111 | entry->preempt_count = pc & 0xff; |
1104 | entry->pid = (tsk) ? tsk->pid : 0; | 1112 | entry->pid = (tsk) ? tsk->pid : 0; |
1105 | entry->lock_depth = (tsk) ? tsk->lock_depth : 0; | ||
1106 | entry->flags = | 1113 | entry->flags = |
1107 | #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT | 1114 | #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT |
1108 | (irqs_disabled_flags(flags) ? TRACE_FLAG_IRQS_OFF : 0) | | 1115 | (irqs_disabled_flags(flags) ? TRACE_FLAG_IRQS_OFF : 0) | |
@@ -1749,10 +1756,9 @@ static void print_lat_help_header(struct seq_file *m) | |||
1749 | seq_puts(m, "# | / _----=> need-resched \n"); | 1756 | seq_puts(m, "# | / _----=> need-resched \n"); |
1750 | seq_puts(m, "# || / _---=> hardirq/softirq \n"); | 1757 | seq_puts(m, "# || / _---=> hardirq/softirq \n"); |
1751 | seq_puts(m, "# ||| / _--=> preempt-depth \n"); | 1758 | seq_puts(m, "# ||| / _--=> preempt-depth \n"); |
1752 | seq_puts(m, "# |||| /_--=> lock-depth \n"); | 1759 | seq_puts(m, "# |||| / delay \n"); |
1753 | seq_puts(m, "# |||||/ delay \n"); | 1760 | seq_puts(m, "# cmd pid ||||| time | caller \n"); |
1754 | seq_puts(m, "# cmd pid |||||| time | caller \n"); | 1761 | seq_puts(m, "# \\ / ||||| \\ | / \n"); |
1755 | seq_puts(m, "# \\ / |||||| \\ | / \n"); | ||
1756 | } | 1762 | } |
1757 | 1763 | ||
1758 | static void print_func_help_header(struct seq_file *m) | 1764 | static void print_func_help_header(struct seq_file *m) |
@@ -2529,6 +2535,9 @@ static void set_tracer_flags(unsigned int mask, int enabled) | |||
2529 | 2535 | ||
2530 | if (mask == TRACE_ITER_RECORD_CMD) | 2536 | if (mask == TRACE_ITER_RECORD_CMD) |
2531 | trace_event_enable_cmd_record(enabled); | 2537 | trace_event_enable_cmd_record(enabled); |
2538 | |||
2539 | if (mask == TRACE_ITER_OVERWRITE) | ||
2540 | ring_buffer_change_overwrite(global_trace.buffer, enabled); | ||
2532 | } | 2541 | } |
2533 | 2542 | ||
2534 | static ssize_t | 2543 | static ssize_t |
@@ -2710,6 +2719,10 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf, | |||
2710 | 2719 | ||
2711 | mutex_lock(&trace_types_lock); | 2720 | mutex_lock(&trace_types_lock); |
2712 | if (tracer_enabled ^ val) { | 2721 | if (tracer_enabled ^ val) { |
2722 | |||
2723 | /* Only need to warn if this is used to change the state */ | ||
2724 | WARN_ONCE(1, "tracing_enabled is deprecated. Use tracing_on"); | ||
2725 | |||
2713 | if (val) { | 2726 | if (val) { |
2714 | tracer_enabled = 1; | 2727 | tracer_enabled = 1; |
2715 | if (current_trace->start) | 2728 | if (current_trace->start) |
@@ -4551,9 +4564,11 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) | |||
4551 | __init static int tracer_alloc_buffers(void) | 4564 | __init static int tracer_alloc_buffers(void) |
4552 | { | 4565 | { |
4553 | int ring_buf_size; | 4566 | int ring_buf_size; |
4567 | enum ring_buffer_flags rb_flags; | ||
4554 | int i; | 4568 | int i; |
4555 | int ret = -ENOMEM; | 4569 | int ret = -ENOMEM; |
4556 | 4570 | ||
4571 | |||
4557 | if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) | 4572 | if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) |
4558 | goto out; | 4573 | goto out; |
4559 | 4574 | ||
@@ -4566,12 +4581,13 @@ __init static int tracer_alloc_buffers(void) | |||
4566 | else | 4581 | else |
4567 | ring_buf_size = 1; | 4582 | ring_buf_size = 1; |
4568 | 4583 | ||
4584 | rb_flags = trace_flags & TRACE_ITER_OVERWRITE ? RB_FL_OVERWRITE : 0; | ||
4585 | |||
4569 | cpumask_copy(tracing_buffer_mask, cpu_possible_mask); | 4586 | cpumask_copy(tracing_buffer_mask, cpu_possible_mask); |
4570 | cpumask_copy(tracing_cpumask, cpu_all_mask); | 4587 | cpumask_copy(tracing_cpumask, cpu_all_mask); |
4571 | 4588 | ||
4572 | /* TODO: make the number of buffers hot pluggable with CPUS */ | 4589 | /* TODO: make the number of buffers hot pluggable with CPUS */ |
4573 | global_trace.buffer = ring_buffer_alloc(ring_buf_size, | 4590 | global_trace.buffer = ring_buffer_alloc(ring_buf_size, rb_flags); |
4574 | TRACE_BUFFER_FLAGS); | ||
4575 | if (!global_trace.buffer) { | 4591 | if (!global_trace.buffer) { |
4576 | printk(KERN_ERR "tracer: failed to allocate ring buffer!\n"); | 4592 | printk(KERN_ERR "tracer: failed to allocate ring buffer!\n"); |
4577 | WARN_ON(1); | 4593 | WARN_ON(1); |
@@ -4581,7 +4597,7 @@ __init static int tracer_alloc_buffers(void) | |||
4581 | 4597 | ||
4582 | 4598 | ||
4583 | #ifdef CONFIG_TRACER_MAX_TRACE | 4599 | #ifdef CONFIG_TRACER_MAX_TRACE |
4584 | max_tr.buffer = ring_buffer_alloc(1, TRACE_BUFFER_FLAGS); | 4600 | max_tr.buffer = ring_buffer_alloc(1, rb_flags); |
4585 | if (!max_tr.buffer) { | 4601 | if (!max_tr.buffer) { |
4586 | printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); | 4602 | printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); |
4587 | WARN_ON(1); | 4603 | WARN_ON(1); |