diff options
Diffstat (limited to 'Documentation/trace/ftrace.txt')
| -rw-r--r-- | Documentation/trace/ftrace.txt | 83 |
1 files changed, 83 insertions, 0 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 |
