diff options
| -rw-r--r-- | kernel/trace/trace.c | 38 | ||||
| -rw-r--r-- | kernel/trace/trace.h | 1 | ||||
| -rw-r--r-- | kernel/trace/trace_irqsoff.c | 3 | ||||
| -rw-r--r-- | kernel/trace/trace_sched_wakeup.c | 2 |
4 files changed, 38 insertions, 6 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index af9042977c08..f7488f44d26b 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -660,6 +660,10 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) | |||
| 660 | return; | 660 | return; |
| 661 | 661 | ||
| 662 | WARN_ON_ONCE(!irqs_disabled()); | 662 | WARN_ON_ONCE(!irqs_disabled()); |
| 663 | if (!current_trace->use_max_tr) { | ||
| 664 | WARN_ON_ONCE(1); | ||
| 665 | return; | ||
| 666 | } | ||
| 663 | arch_spin_lock(&ftrace_max_lock); | 667 | arch_spin_lock(&ftrace_max_lock); |
| 664 | 668 | ||
| 665 | tr->buffer = max_tr.buffer; | 669 | tr->buffer = max_tr.buffer; |
| @@ -686,6 +690,11 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu) | |||
| 686 | return; | 690 | return; |
| 687 | 691 | ||
| 688 | WARN_ON_ONCE(!irqs_disabled()); | 692 | WARN_ON_ONCE(!irqs_disabled()); |
| 693 | if (!current_trace->use_max_tr) { | ||
| 694 | WARN_ON_ONCE(1); | ||
| 695 | return; | ||
| 696 | } | ||
| 697 | |||
| 689 | arch_spin_lock(&ftrace_max_lock); | 698 | arch_spin_lock(&ftrace_max_lock); |
| 690 | 699 | ||
| 691 | ftrace_disable_cpu(); | 700 | ftrace_disable_cpu(); |
| @@ -2801,6 +2810,9 @@ static int tracing_resize_ring_buffer(unsigned long size) | |||
| 2801 | if (ret < 0) | 2810 | if (ret < 0) |
| 2802 | return ret; | 2811 | return ret; |
| 2803 | 2812 | ||
| 2813 | if (!current_trace->use_max_tr) | ||
| 2814 | goto out; | ||
| 2815 | |||
| 2804 | ret = ring_buffer_resize(max_tr.buffer, size); | 2816 | ret = ring_buffer_resize(max_tr.buffer, size); |
| 2805 | if (ret < 0) { | 2817 | if (ret < 0) { |
| 2806 | int r; | 2818 | int r; |
| @@ -2828,11 +2840,14 @@ static int tracing_resize_ring_buffer(unsigned long size) | |||
| 2828 | return ret; | 2840 | return ret; |
| 2829 | } | 2841 | } |
| 2830 | 2842 | ||
| 2843 | max_tr.entries = size; | ||
| 2844 | out: | ||
| 2831 | global_trace.entries = size; | 2845 | global_trace.entries = size; |
| 2832 | 2846 | ||
| 2833 | return ret; | 2847 | return ret; |
| 2834 | } | 2848 | } |
| 2835 | 2849 | ||
| 2850 | |||
| 2836 | /** | 2851 | /** |
| 2837 | * tracing_update_buffers - used by tracing facility to expand ring buffers | 2852 | * tracing_update_buffers - used by tracing facility to expand ring buffers |
| 2838 | * | 2853 | * |
| @@ -2893,12 +2908,26 @@ static int tracing_set_tracer(const char *buf) | |||
| 2893 | trace_branch_disable(); | 2908 | trace_branch_disable(); |
| 2894 | if (current_trace && current_trace->reset) | 2909 | if (current_trace && current_trace->reset) |
| 2895 | current_trace->reset(tr); | 2910 | current_trace->reset(tr); |
| 2896 | 2911 | if (current_trace && current_trace->use_max_tr) { | |
| 2912 | /* | ||
| 2913 | * We don't free the ring buffer. instead, resize it because | ||
| 2914 | * The max_tr ring buffer has some state (e.g. ring->clock) and | ||
| 2915 | * we want preserve it. | ||
| 2916 | */ | ||
| 2917 | ring_buffer_resize(max_tr.buffer, 1); | ||
| 2918 | max_tr.entries = 1; | ||
| 2919 | } | ||
| 2897 | destroy_trace_option_files(topts); | 2920 | destroy_trace_option_files(topts); |
| 2898 | 2921 | ||
| 2899 | current_trace = t; | 2922 | current_trace = t; |
| 2900 | 2923 | ||
| 2901 | topts = create_trace_option_files(current_trace); | 2924 | topts = create_trace_option_files(current_trace); |
| 2925 | if (current_trace->use_max_tr) { | ||
| 2926 | ret = ring_buffer_resize(max_tr.buffer, global_trace.entries); | ||
| 2927 | if (ret < 0) | ||
| 2928 | goto out; | ||
| 2929 | max_tr.entries = global_trace.entries; | ||
| 2930 | } | ||
| 2902 | 2931 | ||
| 2903 | if (t->init) { | 2932 | if (t->init) { |
| 2904 | ret = tracer_init(t, tr); | 2933 | ret = tracer_init(t, tr); |
| @@ -3480,7 +3509,6 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
| 3480 | } | 3509 | } |
| 3481 | 3510 | ||
| 3482 | tracing_start(); | 3511 | tracing_start(); |
| 3483 | max_tr.entries = global_trace.entries; | ||
| 3484 | mutex_unlock(&trace_types_lock); | 3512 | mutex_unlock(&trace_types_lock); |
| 3485 | 3513 | ||
| 3486 | return cnt; | 3514 | return cnt; |
| @@ -4578,16 +4606,14 @@ __init static int tracer_alloc_buffers(void) | |||
| 4578 | 4606 | ||
| 4579 | 4607 | ||
| 4580 | #ifdef CONFIG_TRACER_MAX_TRACE | 4608 | #ifdef CONFIG_TRACER_MAX_TRACE |
| 4581 | max_tr.buffer = ring_buffer_alloc(ring_buf_size, | 4609 | max_tr.buffer = ring_buffer_alloc(1, TRACE_BUFFER_FLAGS); |
| 4582 | TRACE_BUFFER_FLAGS); | ||
| 4583 | if (!max_tr.buffer) { | 4610 | if (!max_tr.buffer) { |
| 4584 | printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); | 4611 | printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); |
| 4585 | WARN_ON(1); | 4612 | WARN_ON(1); |
| 4586 | ring_buffer_free(global_trace.buffer); | 4613 | ring_buffer_free(global_trace.buffer); |
| 4587 | goto out_free_cpumask; | 4614 | goto out_free_cpumask; |
| 4588 | } | 4615 | } |
| 4589 | max_tr.entries = ring_buffer_size(max_tr.buffer); | 4616 | max_tr.entries = 1; |
| 4590 | WARN_ON(max_tr.entries != global_trace.entries); | ||
| 4591 | #endif | 4617 | #endif |
| 4592 | 4618 | ||
| 4593 | /* Allocate the first page for all buffers */ | 4619 | /* Allocate the first page for all buffers */ |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 7778f067fc8b..cb629b3b108c 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
| @@ -276,6 +276,7 @@ struct tracer { | |||
| 276 | struct tracer *next; | 276 | struct tracer *next; |
| 277 | int print_max; | 277 | int print_max; |
| 278 | struct tracer_flags *flags; | 278 | struct tracer_flags *flags; |
| 279 | int use_max_tr; | ||
| 279 | }; | 280 | }; |
| 280 | 281 | ||
| 281 | 282 | ||
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c index 6fd486e0cef4..73a6b0601f2e 100644 --- a/kernel/trace/trace_irqsoff.c +++ b/kernel/trace/trace_irqsoff.c | |||
| @@ -649,6 +649,7 @@ static struct tracer irqsoff_tracer __read_mostly = | |||
| 649 | #endif | 649 | #endif |
| 650 | .open = irqsoff_trace_open, | 650 | .open = irqsoff_trace_open, |
| 651 | .close = irqsoff_trace_close, | 651 | .close = irqsoff_trace_close, |
| 652 | .use_max_tr = 1, | ||
| 652 | }; | 653 | }; |
| 653 | # define register_irqsoff(trace) register_tracer(&trace) | 654 | # define register_irqsoff(trace) register_tracer(&trace) |
| 654 | #else | 655 | #else |
| @@ -681,6 +682,7 @@ static struct tracer preemptoff_tracer __read_mostly = | |||
| 681 | #endif | 682 | #endif |
| 682 | .open = irqsoff_trace_open, | 683 | .open = irqsoff_trace_open, |
| 683 | .close = irqsoff_trace_close, | 684 | .close = irqsoff_trace_close, |
| 685 | .use_max_tr = 1, | ||
| 684 | }; | 686 | }; |
| 685 | # define register_preemptoff(trace) register_tracer(&trace) | 687 | # define register_preemptoff(trace) register_tracer(&trace) |
| 686 | #else | 688 | #else |
| @@ -715,6 +717,7 @@ static struct tracer preemptirqsoff_tracer __read_mostly = | |||
| 715 | #endif | 717 | #endif |
| 716 | .open = irqsoff_trace_open, | 718 | .open = irqsoff_trace_open, |
| 717 | .close = irqsoff_trace_close, | 719 | .close = irqsoff_trace_close, |
| 720 | .use_max_tr = 1, | ||
| 718 | }; | 721 | }; |
| 719 | 722 | ||
| 720 | # define register_preemptirqsoff(trace) register_tracer(&trace) | 723 | # define register_preemptirqsoff(trace) register_tracer(&trace) |
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c index c9fd5bd02036..4086eae6e81b 100644 --- a/kernel/trace/trace_sched_wakeup.c +++ b/kernel/trace/trace_sched_wakeup.c | |||
| @@ -382,6 +382,7 @@ static struct tracer wakeup_tracer __read_mostly = | |||
| 382 | #ifdef CONFIG_FTRACE_SELFTEST | 382 | #ifdef CONFIG_FTRACE_SELFTEST |
| 383 | .selftest = trace_selftest_startup_wakeup, | 383 | .selftest = trace_selftest_startup_wakeup, |
| 384 | #endif | 384 | #endif |
| 385 | .use_max_tr = 1, | ||
| 385 | }; | 386 | }; |
| 386 | 387 | ||
| 387 | static struct tracer wakeup_rt_tracer __read_mostly = | 388 | static struct tracer wakeup_rt_tracer __read_mostly = |
| @@ -396,6 +397,7 @@ static struct tracer wakeup_rt_tracer __read_mostly = | |||
| 396 | #ifdef CONFIG_FTRACE_SELFTEST | 397 | #ifdef CONFIG_FTRACE_SELFTEST |
| 397 | .selftest = trace_selftest_startup_wakeup, | 398 | .selftest = trace_selftest_startup_wakeup, |
| 398 | #endif | 399 | #endif |
| 400 | .use_max_tr = 1, | ||
| 399 | }; | 401 | }; |
| 400 | 402 | ||
| 401 | __init static int init_wakeup_tracer(void) | 403 | __init static int init_wakeup_tracer(void) |
