f141c52bdb7059876a42fbab72ffee8d91d91f08
[lttng-docs.git] /
1 ---
2 id: instrumenting-linux-kernel-tracing
3 ---
4
5 The [Controlling tracing](#doc-controlling-tracing) section explains
6 how to use the `lttng` tool to create and control tracing sessions.
7 Although the `lttng` tool will load the appropriate _known_ LTTng kernel
8 modules when needed (by launching `root`'s session daemon), it won't
9 load your custom `lttng-probe-hello` module by default. You need to
10 manually start an LTTng session daemon as `root` and use the
11 `--extra-kmod-probes` option to append your custom probe module to the
12 default list:
13
14 <pre class="term">
15 sudo pkill -u root lttng-sessiond
16 sudo lttng-sessiond --extra-kmod-probes=hello
17 </pre>
18
19 The first command makes sure any existing instance is killed. If
20 you're not interested in using the default probes, or if you only
21 want to use a few of them, you could use `--kmod-probes` instead,
22 which specifies an absolute list:
23
24 <pre class="term">
25 sudo lttng-sessiond --kmod-probes=hello,ext4,net,block,signal,sched
26 </pre>
27
28 Confirm the custom probe module is loaded:
29
30 <pre class="term">
31 lsmod | grep lttng_probe_hello
32 </pre>
33
34 The `hello_world` event should appear in the list when doing
35
36 <pre class="term">
37 lttng list --kernel | grep hello
38 </pre>
39
40 You may now create an LTTng tracing session, enable the `hello_world`
41 kernel event (and others if you wish) and start tracing:
42
43 <pre class="term">
44 sudo lttng create my-session
45 sudo lttng enable-event --kernel hello_world
46 sudo lttng start
47 </pre>
48
49 Plug a few USB devices, then stop tracing and inspect the trace (if
50 <a href="http://www.efficios.com/babeltrace" class="ext">Babeltrace</a>
51 is installed):
52
53 <pre class="term">
54 sudo lttng stop
55 sudo lttng view
56 </pre>
57
58 Here's a sample output:
59
60 ~~~ text
61 [15:30:34.835895035] (+?.?????????) hostname hello_world: { cpu_id = 1 }, { my_int = 8, char0 = 68, char1 = 97, product = "DataTraveler 2.0" }
62 [15:30:42.262781421] (+7.426886386) hostname hello_world: { cpu_id = 1 }, { my_int = 9, char0 = 80, char1 = 97, product = "Patriot Memory" }
63 [15:30:48.175621778] (+5.912840357) hostname hello_world: { cpu_id = 1 }, { my_int = 10, char0 = 68, char1 = 97, product = "DataTraveler 2.0" }
64 ~~~
65
66 Two USB flash drives were used for this test.
67
68 You may change your LTTng custom probe, rebuild it and reload it at
69 any time when not tracing. Make sure you remove the old module
70 (either by killing the root LTTng session daemon which loaded the
71 module in the first place, or by using `modprobe --remove` directly)
72 before loading the updated one.
This page took 0.030449 seconds and 3 git commands to generate.