aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorHiraku Toyooka <hiraku.toyooka.gu@hitachi.com>2012-12-25 21:53:09 -0500
committerSteven Rostedt <rostedt@goodmis.org>2013-01-30 11:02:07 -0500
commitc1043fcda1b9e8e5144cfdaee7be262c50dbdead (patch)
treea6f782ed93e322768875c4bc8c5be84809dc62f5 /Documentation
parentdebdd57f5145f3c6a4b3f8d0126abd1a2def7fc6 (diff)
tracing: Add documentation of snapshot utility
This patch adds snapshot description in ftrace documentation. This description includes what the snapshot is and how to use it. Link: http://lkml.kernel.org/r/20121226025309.3252.150.stgit@liselsia Cc: Rob Landley <rob@landley.net> Signed-off-by: Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/trace/ftrace.txt83
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
184385 184385
1844 1844
1845Snapshot
1846--------
1847CONFIG_TRACER_SNAPSHOT makes a generic snapshot feature
1848available to all non latency tracers. (Latency tracers which
1849record max latency, such as "irqsoff" or "wakeup", can't use
1850this feature, since those are already using the snapshot
1851mechanism internally.)
1852
1853Snapshot preserves a current trace buffer at a particular point
1854in time without stopping tracing. Ftrace swaps the current
1855buffer with a spare buffer, and tracing continues in the new
1856current (=previous spare) buffer.
1857
1858The following debugfs files in "tracing" are related to this
1859feature:
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
1881Here 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
1919If you try to use this snapshot feature when current tracer is
1920one of the latency tracers, you will get the following results.
1921
1922 # echo wakeup > current_tracer
1923 # echo 1 > snapshot
1924bash: echo: write error: Device or resource busy
1925 # cat snapshot
1926cat: snapshot: Device or resource busy
1927
1845----------- 1928-----------
1846 1929
1847More details can be found in the source code, in the 1930More details can be found in the source code, in the