diff options
-rw-r--r-- | kernel/trace/trace.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 18256cd7ad2c..57e9c546bebb 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -894,23 +894,8 @@ int __trace_bputs(unsigned long ip, const char *str) | |||
894 | EXPORT_SYMBOL_GPL(__trace_bputs); | 894 | EXPORT_SYMBOL_GPL(__trace_bputs); |
895 | 895 | ||
896 | #ifdef CONFIG_TRACER_SNAPSHOT | 896 | #ifdef CONFIG_TRACER_SNAPSHOT |
897 | /** | 897 | static void tracing_snapshot_instance(struct trace_array *tr) |
898 | * trace_snapshot - take a snapshot of the current buffer. | ||
899 | * | ||
900 | * This causes a swap between the snapshot buffer and the current live | ||
901 | * tracing buffer. You can use this to take snapshots of the live | ||
902 | * trace when some condition is triggered, but continue to trace. | ||
903 | * | ||
904 | * Note, make sure to allocate the snapshot with either | ||
905 | * a tracing_snapshot_alloc(), or by doing it manually | ||
906 | * with: echo 1 > /sys/kernel/debug/tracing/snapshot | ||
907 | * | ||
908 | * If the snapshot buffer is not allocated, it will stop tracing. | ||
909 | * Basically making a permanent snapshot. | ||
910 | */ | ||
911 | void tracing_snapshot(void) | ||
912 | { | 898 | { |
913 | struct trace_array *tr = &global_trace; | ||
914 | struct tracer *tracer = tr->current_trace; | 899 | struct tracer *tracer = tr->current_trace; |
915 | unsigned long flags; | 900 | unsigned long flags; |
916 | 901 | ||
@@ -938,6 +923,27 @@ void tracing_snapshot(void) | |||
938 | update_max_tr(tr, current, smp_processor_id()); | 923 | update_max_tr(tr, current, smp_processor_id()); |
939 | local_irq_restore(flags); | 924 | local_irq_restore(flags); |
940 | } | 925 | } |
926 | |||
927 | /** | ||
928 | * trace_snapshot - take a snapshot of the current buffer. | ||
929 | * | ||
930 | * This causes a swap between the snapshot buffer and the current live | ||
931 | * tracing buffer. You can use this to take snapshots of the live | ||
932 | * trace when some condition is triggered, but continue to trace. | ||
933 | * | ||
934 | * Note, make sure to allocate the snapshot with either | ||
935 | * a tracing_snapshot_alloc(), or by doing it manually | ||
936 | * with: echo 1 > /sys/kernel/debug/tracing/snapshot | ||
937 | * | ||
938 | * If the snapshot buffer is not allocated, it will stop tracing. | ||
939 | * Basically making a permanent snapshot. | ||
940 | */ | ||
941 | void tracing_snapshot(void) | ||
942 | { | ||
943 | struct trace_array *tr = &global_trace; | ||
944 | |||
945 | tracing_snapshot_instance(tr); | ||
946 | } | ||
941 | EXPORT_SYMBOL_GPL(tracing_snapshot); | 947 | EXPORT_SYMBOL_GPL(tracing_snapshot); |
942 | 948 | ||
943 | static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf, | 949 | static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf, |
@@ -6739,7 +6745,7 @@ ftrace_snapshot(unsigned long ip, unsigned long parent_ip, | |||
6739 | struct trace_array *tr, struct ftrace_probe_ops *ops, | 6745 | struct trace_array *tr, struct ftrace_probe_ops *ops, |
6740 | void *data) | 6746 | void *data) |
6741 | { | 6747 | { |
6742 | tracing_snapshot(); | 6748 | tracing_snapshot_instance(tr); |
6743 | } | 6749 | } |
6744 | 6750 | ||
6745 | static void | 6751 | static void |
@@ -6761,7 +6767,7 @@ ftrace_count_snapshot(unsigned long ip, unsigned long parent_ip, | |||
6761 | (*count)--; | 6767 | (*count)--; |
6762 | } | 6768 | } |
6763 | 6769 | ||
6764 | tracing_snapshot(); | 6770 | tracing_snapshot_instance(tr); |
6765 | } | 6771 | } |
6766 | 6772 | ||
6767 | static int | 6773 | static int |
@@ -6868,7 +6874,7 @@ ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash, | |||
6868 | ret = register_ftrace_function_probe(glob, tr, ops, count); | 6874 | ret = register_ftrace_function_probe(glob, tr, ops, count); |
6869 | 6875 | ||
6870 | if (ret >= 0) | 6876 | if (ret >= 0) |
6871 | alloc_snapshot(&global_trace); | 6877 | alloc_snapshot(tr); |
6872 | 6878 | ||
6873 | return ret < 0 ? ret : 0; | 6879 | return ret < 0 ? ret : 0; |
6874 | } | 6880 | } |