Initial import
[lttng-docs.git] / contents / using-lttng / instrumenting / instrumenting-linux-kernel / intro.md
CommitLineData
5e0cbfb0
PP
1---
2id: instrumenting-linux-kernel
3---
4
5The Linux kernel can be instrumented for LTTng tracing, either its core
6source code or a kernel module. It has to be noted that Linux is
7readily traceable using LTTng since many parts of its source code are
8already instrumented: this is the job of the upstream
9<a href="http://git.lttng.org/?p=lttng-modules.git" class="ext">LTTng-modules</a>
10package. This section presents how to add LTTng instrumentation where it
11does not currently exist and how to instrument custom kernel modules.
12
13All LTTng instrumentation in the Linux kernel is based on an existing
14infrastructure which bears the name of its main macro, `TRACE_EVENT()`.
15This macro is used to define tracepoints,
16each tracepoint having a name, usually with the
17<code><em>subsys</em>_<em>name</em></code> format,
18<code><em>subsys</em></code> being the subsystem name and
19<code><em>name</em></code> the specific event name.
20
21Tracepoints defined with `TRACE_EVENT()` may be inserted anywhere in
22the Linux kernel source code, after what callbacks, called _probes_,
23may be registered to execute some action when a tracepoint is
24executed. This mechanism is directly used by ftrace and perf,
25but cannot be used as is by LTTng: an adaptation layer is added to
26satisfy LTTng's specific needs.
27
28With that in mind, this documentation does not cover the `TRACE_EVENT()`
29format and how to use it, but it is mandatory to understand it and use
30it to instrument Linux for LTTng. A series of
31<abbr title="Linux Weekly News">LWN</abbr> articles explain
32`TRACE_EVENT()` in details:
33<a href="http://lwn.net/Articles/379903/" class="ext">part 1</a>,
34<a href="http://lwn.net/Articles/381064/" class="ext">part 2</a>, and
35<a href="http://lwn.net/Articles/383362/" class="ext">part 3</a>.
36Once you master `TRACE_EVENT()` enough for your use case, continue
37reading this section so that you can add the LTTng adaptation layer of
38instrumentation.
39
40This section first discusses the general method of instrumenting the
41Linux kernel for LTTng. This method is then reused for the specific
42case of instrumenting a kernel module.
This page took 0.02327 seconds and 4 git commands to generate.