update compat
[lttv.git] / doc / developer / ust.html
CommitLineData
baec4c72 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head>
3<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
d4c85b6e 4
d4c85b6e 5
baec4c72 6 <title>LTTng User-space Tracing Design</title>
7</head><body>
d4c85b6e 8
baec4c72 9<h1>LTTng User-space Tracing Design</h1>
d4c85b6e 10
ca3fb06a 11<p>
baec4c72 12Earlier versions of LTTng contained simple, system call based, tracepoints and fast,
13user-space buffered, tracepoints for user-space tracing. During the kernel inclusion phase
14of LTTng, extensive rework and modularization of the kernel tracing portion was undertaken.
15This phase is well under way and several portions have been included already in the mainline kernel.
16The rework of the kernel tracing infrastructure will shortly thereafter be ported to fast user-space
17tracing.
18This fast user-space tracing scheme uses a direct function call to write events into buffers
14b9349e 19mapped in user-space. This should be an order of magnitude faster than the
20current Dtrace implementation (c.f.
9dd3d20d 21<a href="http://ltt.polymtl.ca/tracingwiki/index.php/DTrace">Dtrace information
22on the TracingWiki</a>) which uses a breakpoint to
14b9349e 23perform both dynamic and static user-space tracing. Performance comparison of
24a function call vs the int3 approach is available at
9dd3d20d 25<a href="http://sourceware.org/ml/systemtap/2006-q3/msg00793.html">Markers vs
26int3 performance comparison</a> (see "Conclusion").
e6f8d5e6 27
baec4c72 28</p><p>
29Libmarkers will provide applications with user-space Markers and Tracepoints
30declarations, such that programmers will be able to insert Markers and Tracepoints in their
31libraries and applications. User-space Tracepoints and Markers, analogous to Kernel Tracepoints and Markers,
32define program locations and arguments provided. Libmarkers will also
33provide utility functions to enumerate, activate and deactivate tracepoints and markers in the
34process, and to associate probes with any tracepoint or marker.
35<ul><li> Linux Kernel Tracepoints documentation: <a href="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=Documentation/tracepoints.txt" class="external text" title="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=Documentation/tracepoints.txt" rel="nofollow">Documentation/tracepoints.txt</a>
36</li><li> Linux Kernel Tracepoints example: <a href="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=samples/tracepoints" class="external text" title="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=samples/tracepoints" rel="nofollow">samples/tracepoints</a>
37</li><li> Linux Kernel Markers documentation: <a href="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=Documentation/markers.txt" class="external text" title="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=Documentation/markers.txt" rel="nofollow">Documentation/markers.txt</a>
38</li><li> Linux Kernel Markers example: <a href="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=samples/markers" class="external text" title="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=samples/markers" rel="nofollow">samples/markers</a>
39</ul>
40
41
42</p><p>
43Libtracing will provide the infrastructure to allocate buffers, define event types, write event
44metadata and data to the buffers, and get notification when buffers are full. The initial implementation
45will simply use one set of buffers per process. Subsequent more optimized versions will allocate one
46set of buffers per thread; one set of buffers per CPU would be desirable but user-space programs cannot check
47or control CPU migration without resorting to more costly bus locking operations or system calls. The library
48provides a generic probe for markers which, when connected, generates an event in the buffer each time the marker
49is encountered.
50
51<UL>
52</li><li> LTTng Linux Kernel Markers Efficicient API: <a href="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=ltt/probes/ltt-type-serializer.h" class="external text" title="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=ltt/probes/ltt-type-serializer.h" rel="nofollow">ltt/probes/ltt-type-serializer.h</a>
53</li><li> LTTng Linux Kernel Markers Efficicient API usage example: <a href="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=ltt/probes/kernel-trace.c" class="external text" title="http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=blob;f=ltt/probes/kernel-trace.c" rel="nofollow">ltt/probes/kernel-trace.c</a>
54</li>
55</UL>
56</p><p>
57Finally, libtracingcontrol opens a connection allowing a separate process (e.g. LTTng daemon, Eclipse, GDB) to control the
58tracing within the application. Through this connection, the remote process can:
59
60<UL>
61<li> list the available Markers and Tracepoints;
62</li><li> dynamically load a library (presumably containing probes to connect);
63</li><li> connect a probe to a Tracepoint or Marker;
64</li><li> activate a Tracepoint or Marker;
65</li><li> initialize the tracing buffers;
66</li><li> retrieve the content of the tracing buffers;
67</li><li> flush the tracing buffers;
68</li><li> finalize the tracing buffers;
69</li>
70</UL>
71
72In the first version, libtracingcontrol will simply contain the basic functionality
73required to generate a trace of the Markers encountered. Subsequent versions will interact with
74other probing mechanisms like GDB Tracepoints, user-space SystemTap and those defined by virtual
75machines (e.g. Java Virtual Machine, Python, Errlang...).
76</p><p>
e6f8d5e6 77Tracing of Java application is planned to be done through a JNI interface.
78Linking standard low-level C tracing library to the application within a JNI
79adaptation class will be required to trace Java events. This has been prototyped
3ceafa01 80in the past. The work is available
baec4c72 81<a href="http://ltt.polymtl.ca/svn/trunk/obsolete/ltt-usertrace/java/">here</a>
3ceafa01 82for older LTTng versions.
baec4c72 83<p></p>
84The principle of operation of libtracingcontrol is that
85when the instrumented application starts, a pipe is opened to allow external
86tracing control. Asynchronous notification is requested when commands arrive in
87the pipe, and a signal handler is installed for SIGIO (or a carefully chosen
88chainable signal number). Every time such signal is received, the runtime
89library checks for commands received on the external tracing control pipe.
90The application may also spontaneously provide information to the remote control process
91through the pipe:
92
93</p><ul></li><li> a buffer is full;
94</li><li> new tracepoints or markers are appearing or disappearing, because modules are
95 dynamically loaded or unloaded;
96</li></ul>
97<p>
98In addition, the tracing control application should be notified when the
99application exits (to save the content of buffers if the application is
100crashing) or forks (to trace the child as well if needed).
101Such notification may be obtained through utrace.
102
103</p><p>
104In summary, a user-space application linking with libmarkers may contain static
105instrumentation, Tracepoints and Markers, just like the kernel with Kernel Markers and Tracepoints.
106The application can exploit this instrumentation itself or link with libtracing and have tracing probes
107connected to each Marker. Other instrumentation mechanisms, like the GCC instrument-function option, or hooks
108inserted by a JIT compiler, can also use libtracing to define and write event to the trace buffers.
109Finally, libtracingcontrol, analogous to GDB stubs, allows the remote control of the tracing by remote
110monitoring or debugging frameworks.
e6f8d5e6 111
baec4c72 112</p></body></html>
This page took 0.04472 seconds and 4 git commands to generate.