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