diff options
| author | Ingo Molnar <mingo@kernel.org> | 2013-02-03 05:14:06 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2013-02-03 05:14:06 -0500 |
| commit | f7355a5e7c722452e2cd80d6b83acb2f4423c4a2 (patch) | |
| tree | 2ee172a5607de2baf25b8e9b99acd181a34676a6 | |
| parent | 9c4c5fd9e6207f04dbf59c5a9699fded144542e6 (diff) | |
| parent | d840f718d28715a9833c1a8f46c2493ff3fd219b (diff) | |
Merge branch 'tip/perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into perf/core
Pull tracing updated from Steve Rostedt.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | Documentation/trace/ftrace.txt | 83 | ||||
| -rw-r--r-- | include/linux/ftrace_event.h | 3 | ||||
| -rw-r--r-- | include/linux/ring_buffer.h | 1 | ||||
| -rw-r--r-- | kernel/trace/Kconfig | 10 | ||||
| -rw-r--r-- | kernel/trace/ring_buffer.c | 18 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 222 | ||||
| -rw-r--r-- | kernel/trace/trace.h | 1 | ||||
| -rw-r--r-- | kernel/trace/trace_clock.c | 2 | ||||
| -rw-r--r-- | kernel/trace/trace_functions_graph.c | 8 | ||||
| -rw-r--r-- | samples/Kconfig | 6 | ||||
| -rw-r--r-- | samples/Makefile | 2 | ||||
| -rw-r--r-- | samples/tracepoints/Makefile | 6 | ||||
| -rw-r--r-- | samples/tracepoints/tp-samples-trace.h | 11 | ||||
| -rw-r--r-- | samples/tracepoints/tracepoint-probe-sample.c | 57 | ||||
| -rw-r--r-- | samples/tracepoints/tracepoint-probe-sample2.c | 44 | ||||
| -rw-r--r-- | samples/tracepoints/tracepoint-sample.c | 57 |
16 files changed, 288 insertions, 243 deletions
diff --git a/Documentation/trace/ftrace.txt b/Documentation/trace/ftrace.txt index 6f51fed45f2d..53d6a3c51d87 100644 --- a/Documentation/trace/ftrace.txt +++ b/Documentation/trace/ftrace.txt | |||
| @@ -1842,6 +1842,89 @@ an error. | |||
| 1842 | # cat buffer_size_kb | 1842 | # cat buffer_size_kb |
| 1843 | 85 | 1843 | 85 |
| 1844 | 1844 | ||
| 1845 | Snapshot | ||
| 1846 | -------- | ||
| 1847 | CONFIG_TRACER_SNAPSHOT makes a generic snapshot feature | ||
| 1848 | available to all non latency tracers. (Latency tracers which | ||
| 1849 | record max latency, such as "irqsoff" or "wakeup", can't use | ||
| 1850 | this feature, since those are already using the snapshot | ||
| 1851 | mechanism internally.) | ||
| 1852 | |||
| 1853 | Snapshot preserves a current trace buffer at a particular point | ||
| 1854 | in time without stopping tracing. Ftrace swaps the current | ||
| 1855 | buffer with a spare buffer, and tracing continues in the new | ||
| 1856 | current (=previous spare) buffer. | ||
| 1857 | |||
| 1858 | The following debugfs files in "tracing" are related to this | ||
| 1859 | feature: | ||
| 1860 | |||
| 1861 | snapshot: | ||
| 1862 | |||
| 1863 | This is used to take a snapshot and to read the output | ||
| 1864 | of the snapshot. Echo 1 into this file to allocate a | ||
| 1865 | spare buffer and to take a snapshot (swap), then read | ||
| 1866 | the snapshot from this file in the same format as | ||
| 1867 | "trace" (described above in the section "The File | ||
| 1868 | System"). Both reads snapshot and tracing are executable | ||
| 1869 | in parallel. When the spare buffer is allocated, echoing | ||
| 1870 | 0 frees it, and echoing else (positive) values clear the | ||
| 1871 | snapshot contents. | ||
| 1872 | More details are shown in the table below. | ||
| 1873 | |||
| 1874 | status\input | 0 | 1 | else | | ||
| 1875 | --------------+------------+------------+------------+ | ||
| 1876 | not allocated |(do nothing)| alloc+swap | EINVAL | | ||
| 1877 | --------------+------------+------------+------------+ | ||
| 1878 | allocated | free | swap | clear | | ||
| 1879 | --------------+------------+------------+------------+ | ||
| 1880 | |||
| 1881 | Here is an example of using the snapshot feature. | ||
| 1882 | |||
| 1883 | # echo 1 > events/sched/enable | ||
| 1884 | # echo 1 > snapshot | ||
| 1885 | # cat snapshot | ||
| 1886 | # tracer: nop | ||
| 1887 | # | ||
| 1888 | # entries-in-buffer/entries-written: 71/71 #P:8 | ||
| 1889 | # | ||
| 1890 | # _-----=> irqs-off | ||
| 1891 | # / _----=> need-resched | ||
| 1892 | # | / _---=> hardirq/softirq | ||
| 1893 | # || / _--=> preempt-depth | ||
| 1894 | # ||| / delay | ||
| 1895 | # TASK-PID CPU# |||| TIMESTAMP FUNCTION | ||
| 1896 | # | | | |||| | | | ||
| 1897 | <idle>-0 [005] d... 2440.603828: sched_switch: prev_comm=swapper/5 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=snapshot-test-2 next_pid=2242 next_prio=120 | ||
| 1898 | sleep-2242 [005] d... 2440.603846: sched_switch: prev_comm=snapshot-test-2 prev_pid=2242 prev_prio=120 prev_state=R ==> next_comm=kworker/5:1 next_pid=60 next_prio=120 | ||
| 1899 | [...] | ||
| 1900 | <idle>-0 [002] d... 2440.707230: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=snapshot-test-2 next_pid=2229 next_prio=120 | ||
| 1901 | |||
| 1902 | # cat trace | ||
| 1903 | # tracer: nop | ||
| 1904 | # | ||
| 1905 | # entries-in-buffer/entries-written: 77/77 #P:8 | ||
| 1906 | # | ||
| 1907 | # _-----=> irqs-off | ||
| 1908 | # / _----=> need-resched | ||
| 1909 | # | / _---=> hardirq/softirq | ||
| 1910 | # || / _--=> preempt-depth | ||
| 1911 | # ||| / delay | ||
| 1912 | # TASK-PID CPU# |||| TIMESTAMP FUNCTION | ||
| 1913 | # | | | |||| | | | ||
| 1914 | <idle>-0 [007] d... 2440.707395: sched_switch: prev_comm=swapper/7 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=snapshot-test-2 next_pid=2243 next_prio=120 | ||
| 1915 | snapshot-test-2-2229 [002] d... 2440.707438: sched_switch: prev_comm=snapshot-test-2 prev_pid=2229 prev_prio=120 prev_state=S ==> next_comm=swapper/2 next_pid=0 next_prio=120 | ||
| 1916 | [...] | ||
| 1917 | |||
| 1918 | |||
| 1919 | If you try to use this snapshot feature when current tracer is | ||
| 1920 | one of the latency tracers, you will get the following results. | ||
| 1921 | |||
| 1922 | # echo wakeup > current_tracer | ||
| 1923 | # echo 1 > snapshot | ||
| 1924 | bash: echo: write error: Device or resource busy | ||
| 1925 | # cat snapshot | ||
| 1926 | cat: snapshot: Device or resource busy | ||
| 1927 | |||
| 1845 | ----------- | 1928 | ----------- |
| 1846 | 1929 | ||
| 1847 | More details can be found in the source code, in the | 1930 | More details can be found in the source code, in the |
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 6f8d0b77006b..13a54d0bdfa8 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
| @@ -83,6 +83,9 @@ struct trace_iterator { | |||
| 83 | long idx; | 83 | long idx; |
| 84 | 84 | ||
| 85 | cpumask_var_t started; | 85 | cpumask_var_t started; |
| 86 | |||
| 87 | /* it's true when current open file is snapshot */ | ||
| 88 | bool snapshot; | ||
| 86 | }; | 89 | }; |
| 87 | 90 | ||
| 88 | enum trace_iter_flags { | 91 | enum trace_iter_flags { |
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h index 519777e3fa01..1342e69542f3 100644 --- a/include/linux/ring_buffer.h +++ b/include/linux/ring_buffer.h | |||
| @@ -167,6 +167,7 @@ unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu); | |||
| 167 | unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu); | 167 | unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu); |
| 168 | unsigned long ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu); | 168 | unsigned long ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu); |
| 169 | unsigned long ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu); | 169 | unsigned long ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu); |
| 170 | unsigned long ring_buffer_read_events_cpu(struct ring_buffer *buffer, int cpu); | ||
| 170 | 171 | ||
| 171 | u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu); | 172 | u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu); |
| 172 | void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer, | 173 | void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer, |
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index cdc9d284d24e..36567564e221 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig | |||
| @@ -253,6 +253,16 @@ config FTRACE_SYSCALLS | |||
| 253 | help | 253 | help |
| 254 | Basic tracer to catch the syscall entry and exit events. | 254 | Basic tracer to catch the syscall entry and exit events. |
| 255 | 255 | ||
| 256 | config TRACER_SNAPSHOT | ||
| 257 | bool "Create a snapshot trace buffer" | ||
| 258 | select TRACER_MAX_TRACE | ||
| 259 | help | ||
| 260 | Allow tracing users to take snapshot of the current buffer using the | ||
| 261 | ftrace interface, e.g.: | ||
| 262 | |||
| 263 | echo 1 > /sys/kernel/debug/tracing/snapshot | ||
| 264 | cat snapshot | ||
| 265 | |||
| 256 | config TRACE_BRANCH_PROFILING | 266 | config TRACE_BRANCH_PROFILING |
| 257 | bool | 267 | bool |
| 258 | select GENERIC_TRACER | 268 | select GENERIC_TRACER |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 13950d9027cb..7244acde77b0 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
| @@ -3103,6 +3103,24 @@ ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu) | |||
| 3103 | EXPORT_SYMBOL_GPL(ring_buffer_dropped_events_cpu); | 3103 | EXPORT_SYMBOL_GPL(ring_buffer_dropped_events_cpu); |
| 3104 | 3104 | ||
| 3105 | /** | 3105 | /** |
| 3106 | * ring_buffer_read_events_cpu - get the number of events successfully read | ||
| 3107 | * @buffer: The ring buffer | ||
| 3108 | * @cpu: The per CPU buffer to get the number of events read | ||
| 3109 | */ | ||
| 3110 | unsigned long | ||
| 3111 | ring_buffer_read_events_cpu(struct ring_buffer *buffer, int cpu) | ||
| 3112 | { | ||
| 3113 | struct ring_buffer_per_cpu *cpu_buffer; | ||
| 3114 | |||
| 3115 | if (!cpumask_test_cpu(cpu, buffer->cpumask)) | ||
| 3116 | return 0; | ||
| 3117 | |||
| 3118 | cpu_buffer = buffer->buffers[cpu]; | ||
| 3119 | return cpu_buffer->read; | ||
| 3120 | } | ||
