diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 16:35:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 16:35:07 -0400 |
commit | 92b29b86fe2e183d44eb467e5e74a5f718ef2e43 (patch) | |
tree | 1bac8a1aa11d47322b66d10ec3a370016d843d06 /Documentation | |
parent | b9d7ccf56be1ac77b71a284a1c0e6337f9a7aff0 (diff) | |
parent | 98d9c66ab07471006fd7910cb16453581c41a3e7 (diff) |
Merge branch 'tracing-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'tracing-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (131 commits)
tracing/fastboot: improve help text
tracing/stacktrace: improve help text
tracing/fastboot: fix initcalls disposition in bootgraph.pl
tracing/fastboot: fix bootgraph.pl initcall name regexp
tracing/fastboot: fix issues and improve output of bootgraph.pl
tracepoints: synchronize unregister static inline
tracepoints: tracepoint_synchronize_unregister()
ftrace: make ftrace_test_p6nop disassembler-friendly
markers: fix synchronize marker unregister static inline
tracing/fastboot: add better resolution to initcall debug/tracing
trace: add build-time check to avoid overrunning hex buffer
ftrace: fix hex output mode of ftrace
tracing/fastboot: fix initcalls disposition in bootgraph.pl
tracing/fastboot: fix printk format typo in boot tracer
ftrace: return an error when setting a nonexistent tracer
ftrace: make some tracers reentrant
ring-buffer: make reentrant
ring-buffer: move page indexes into page headers
tracing/fastboot: only trace non-module initcalls
ftrace: move pc counter in irqtrace
...
Manually fix conflicts:
- init/main.c: initcall tracing
- kernel/module.c: verbose level vs tracepoints
- scripts/bootgraph.pl: fallout from cherry-picking commits.
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/markers.txt | 10 | ||||
-rw-r--r-- | Documentation/tracepoints.txt | 101 | ||||
-rw-r--r-- | Documentation/tracers/mmiotrace.txt | 5 |
3 files changed, 109 insertions, 7 deletions
diff --git a/Documentation/markers.txt b/Documentation/markers.txt index d9f50a19fa0..089f6138fcd 100644 --- a/Documentation/markers.txt +++ b/Documentation/markers.txt | |||
@@ -50,10 +50,12 @@ Connecting a function (probe) to a marker is done by providing a probe (function | |||
50 | to call) for the specific marker through marker_probe_register() and can be | 50 | to call) for the specific marker through marker_probe_register() and can be |
51 | activated by calling marker_arm(). Marker deactivation can be done by calling | 51 | activated by calling marker_arm(). Marker deactivation can be done by calling |
52 | marker_disarm() as many times as marker_arm() has been called. Removing a probe | 52 | marker_disarm() as many times as marker_arm() has been called. Removing a probe |
53 | is done through marker_probe_unregister(); it will disarm the probe and make | 53 | is done through marker_probe_unregister(); it will disarm the probe. |
54 | sure there is no caller left using the probe when it returns. Probe removal is | 54 | marker_synchronize_unregister() must be called before the end of the module exit |
55 | preempt-safe because preemption is disabled around the probe call. See the | 55 | function to make sure there is no caller left using the probe. This, and the |
56 | "Probe example" section below for a sample probe module. | 56 | fact that preemption is disabled around the probe call, make sure that probe |
57 | removal and module unload are safe. See the "Probe example" section below for a | ||
58 | sample probe module. | ||
57 | 59 | ||
58 | The marker mechanism supports inserting multiple instances of the same marker. | 60 | The marker mechanism supports inserting multiple instances of the same marker. |
59 | Markers can be put in inline functions, inlined static functions, and | 61 | Markers can be put in inline functions, inlined static functions, and |
diff --git a/Documentation/tracepoints.txt b/Documentation/tracepoints.txt new file mode 100644 index 00000000000..5d354e16749 --- /dev/null +++ b/Documentation/tracepoints.txt | |||
@@ -0,0 +1,101 @@ | |||
1 | Using the Linux Kernel Tracepoints | ||
2 | |||
3 | Mathieu Desnoyers | ||
4 | |||
5 | |||
6 | This document introduces Linux Kernel Tracepoints and their use. It provides | ||
7 | examples of how to insert tracepoints in the kernel and connect probe functions | ||
8 | to them and provides some examples of probe functions. | ||
9 | |||
10 | |||
11 | * Purpose of tracepoints | ||
12 | |||
13 | A tracepoint placed in code provides a hook to call a function (probe) that you | ||
14 | can provide at runtime. A tracepoint can be "on" (a probe is connected to it) or | ||
15 | "off" (no probe is attached). When a tracepoint is "off" it has no effect, | ||
16 | except for adding a tiny time penalty (checking a condition for a branch) and | ||
17 | space penalty (adding a few bytes for the function call at the end of the | ||
18 | instrumented function and adds a data structure in a separate section). When a | ||
19 | tracepoint is "on", the function you provide is called each time the tracepoint | ||
20 | is executed, in the execution context of the caller. When the function provided | ||
21 | ends its execution, it returns to the caller (continuing from the tracepoint | ||
22 | site). | ||
23 | |||
24 | You can put tracepoints at important locations in the code. They are | ||
25 | lightweight hooks that can pass an arbitrary number of parameters, | ||
26 | which prototypes are described in a tracepoint declaration placed in a header | ||
27 | file. | ||
28 | |||
29 | They can be used for tracing and performance accounting. | ||
30 | |||
31 | |||
32 | * Usage | ||
33 | |||
34 | Two elements are required for tracepoints : | ||
35 | |||
36 | - A tracepoint definition, placed in a header file. | ||
37 | - The tracepoint statement, in C code. | ||
38 | |||
39 | In order to use tracepoints, you should include linux/tracepoint.h. | ||
40 | |||
41 | In include/trace/subsys.h : | ||
42 | |||
43 | #include <linux/tracepoint.h> | ||
44 | |||
45 | DEFINE_TRACE(subsys_eventname, | ||
46 | TPPTOTO(int firstarg, struct task_struct *p), | ||
47 | TPARGS(firstarg, p)); | ||
48 | |||
49 | In subsys/file.c (where the tracing statement must be added) : | ||
50 | |||
51 | #include <trace/subsys.h> | ||
52 | |||
53 | void somefct(void) | ||
54 | { | ||
55 | ... | ||
56 | trace_subsys_eventname(arg, task); | ||
57 | ... | ||
58 | } | ||
59 | |||
60 | Where : | ||
61 | - subsys_eventname is an identifier unique to your event | ||
62 | - subsys is the name of your subsystem. | ||
63 | - eventname is the name of the event to trace. | ||
64 | - TPPTOTO(int firstarg, struct task_struct *p) is the prototype of the function | ||
65 | called by this tracepoint. | ||
66 | - TPARGS(firstarg, p) are the parameters names, same as found in the prototype. | ||
67 | |||
68 | Connecting a function (probe) to a tracepoint is done by providing a probe | ||
69 | (function to call) for the specific tracepoint through | ||
70 | register_trace_subsys_eventname(). Removing a probe is done through | ||
71 | unregister_trace_subsys_eventname(); it will remove the probe sure there is no | ||
72 | caller left using the probe when it returns. Probe removal is preempt-safe | ||
73 | because preemption is disabled around the probe call. See the "Probe example" | ||
74 | section below for a sample probe module. | ||
75 | |||
76 | The tracepoint mechanism supports inserting multiple instances of the same | ||
77 | tracepoint, but a single definition must be made of a given tracepoint name over | ||
78 | all the kernel to make sure no type conflict will occur. Name mangling of the | ||
79 | tracepoints is done using the prototypes to make sure typing is correct. | ||
80 | Verification of probe type correctness is done at the registration site by the | ||
81 | compiler. Tracepoints can be put in inline functions, inlined static functions, | ||
82 | and unrolled loops as well as regular functions. | ||
83 | |||
84 | The naming scheme "subsys_event" is suggested here as a convention intended | ||
85 | to limit collisions. Tracepoint names are global to the kernel: they are | ||
86 | considered as being the same whether they are in the core kernel image or in | ||
87 | modules. | ||
88 | |||
89 | |||
90 | * Probe / tracepoint example | ||
91 | |||
92 | See the example provided in samples/tracepoints/src | ||
93 | |||
94 | Compile them with your kernel. | ||
95 | |||
96 | Run, as root : | ||
97 | modprobe tracepoint-example (insmod order is not important) | ||
98 | modprobe tracepoint-probe-example | ||
99 | cat /proc/tracepoint-example (returns an expected error) | ||
100 | rmmod tracepoint-example tracepoint-probe-example | ||
101 | dmesg | ||
diff --git a/Documentation/tracers/mmiotrace.txt b/Documentation/tracers/mmiotrace.txt index a4afb560a45..5bbbe209622 100644 --- a/Documentation/tracers/mmiotrace.txt +++ b/Documentation/tracers/mmiotrace.txt | |||
@@ -36,7 +36,7 @@ $ mount -t debugfs debugfs /debug | |||
36 | $ echo mmiotrace > /debug/tracing/current_tracer | 36 | $ echo mmiotrace > /debug/tracing/current_tracer |
37 | $ cat /debug/tracing/trace_pipe > mydump.txt & | 37 | $ cat /debug/tracing/trace_pipe > mydump.txt & |
38 | Start X or whatever. | 38 | Start X or whatever. |
39 | $ echo "X is up" > /debug/tracing/marker | 39 | $ echo "X is up" > /debug/tracing/trace_marker |
40 | $ echo none > /debug/tracing/current_tracer | 40 | $ echo none > /debug/tracing/current_tracer |
41 | Check for lost events. | 41 | Check for lost events. |
42 | 42 | ||
@@ -59,9 +59,8 @@ The 'cat' process should stay running (sleeping) in the background. | |||
59 | Load the driver you want to trace and use it. Mmiotrace will only catch MMIO | 59 | Load the driver you want to trace and use it. Mmiotrace will only catch MMIO |
60 | accesses to areas that are ioremapped while mmiotrace is active. | 60 | accesses to areas that are ioremapped while mmiotrace is active. |
61 | 61 | ||
62 | [Unimplemented feature:] | ||
63 | During tracing you can place comments (markers) into the trace by | 62 | During tracing you can place comments (markers) into the trace by |
64 | $ echo "X is up" > /debug/tracing/marker | 63 | $ echo "X is up" > /debug/tracing/trace_marker |
65 | This makes it easier to see which part of the (huge) trace corresponds to | 64 | This makes it easier to see which part of the (huge) trace corresponds to |
66 | which action. It is recommended to place descriptive markers about what you | 65 | which action. It is recommended to place descriptive markers about what you |
67 | do. | 66 | do. |