sessiond: add variant selector intervals
[lttng-tools.git] / doc / man / lttng-concepts.7.txt
CommitLineData
26f0c779
PP
1lttng-concepts(7)
2=================
e9711845 3:revdate: 14 June 2021
26f0c779 4:sect-event-rule: INSTRUMENTATION POINT, EVENT RULE, AND EVENT
e9711845 5:sect-session: RECORDING SESSION
26f0c779
PP
6:sect-domain: TRACING DOMAIN
7:sect-channel: CHANNEL AND RING BUFFER
8:sect-recording-event-rule: RECORDING EVENT RULE AND EVENT RECORD
9
10
11NAME
12----
13lttng-concepts - LTTng concepts
14
15
16DESCRIPTION
17-----------
18This manual page documents the concepts of LTTng.
19
20Many other LTTng manual pages refer to this one so that you can
21understand what are the various LTTng objects and how they relate to
22each other.
23
24The concepts of LTTng{nbsp}{lttng_version} are:
25
26* Instrumentation point, event rule, and event
27* Trigger
e9711845 28* Recording session
26f0c779
PP
29* Tracing domain
30* Channel and ring buffer
31* Recording event rule and event record
32
33
34[[event-rule]]
35{sect-event-rule}
36-----------------
37An _instrumentation point_ is a point, within a piece of software,
38which, when executed, creates an LTTng _event_.
39
40LTTng offers various types of instrumentation; see the
da39b67c
PP
41``<<inst-point-types,Instrumentation point types>>'' section below to
42learn about them.
26f0c779
PP
43
44An _event rule_ is a set of conditions to match a set of events.
45
46When LTTng creates an event{nbsp}__E__, an event rule{nbsp}__ER__ is
47said to __match__{nbsp}__E__ when{nbsp}__E__ satisfies *all* the
48conditions of{nbsp}__ER__. This concept is similar to a regular
49expression which matches a set of strings.
50
51When an event rule matches an event, LTTng _emits_ the event, therefore
52attempting to execute one or more actions.
53
54[IMPORTANT]
55====
56The event creation and emission processes are documentation concepts to
57help understand the journey from an instrumentation point to the
58execution of actions.
59
60The actual creation of an event can be costly because LTTng needs to
101b92da 61evaluate the arguments of the instrumentation point.
26f0c779
PP
62
63In practice, LTTng implements various optimizations for the Linux kernel
da39b67c
PP
64and user space tracing domains (see the ``<<domain,{sect-domain}>>''
65section below) to avoid actually creating an event when the tracer
66knows, thanks to properties which are independent from the event payload
67and current context, that it would never emit such an event. Those
68properties are:
26f0c779
PP
69
70* The instrumentation point type (see the
da39b67c 71 ``<<inst-point-types,Instrumentation point types>>'' section below).
26f0c779
PP
72
73* The instrumentation point name.
74
75* The instrumentation point log level.
76
77* For a recording event rule (see the
da39b67c 78 ``<<recording-event-rule,{sect-recording-event-rule}>>'' section
26f0c779
PP
79 below):
80** The status of the rule itself.
da39b67c
PP
81** The status of the channel (see the ``<<channel,{sect-channel}>>''
82 section below).
e9711845 83** The activity of the recording session (started or stopped; see
da39b67c 84 the ``<<session,{sect-session}>>'' section below).
26f0c779
PP
85** Whether or not the process for which LTTng would create the event is
86 allowed to record events (see man:lttng-track(1)).
87
88In other words: if, for a given instrumentation point{nbsp}__IP__, the
89LTTng tracer knows that it would never emit an event,
90executing{nbsp}__IP__ represents a simple boolean variable check and,
91for a Linux kernel recording event rule, a few process attribute checks.
92====
93
94As of LTTng{nbsp}{lttng_version}, there are two places where you can
95find an event rule:
96
97Recording event rule::
98 A specific type of event rule of which the action is to record the
99 matched event as an event record.
100+
da39b67c 101See the ``<<recording-event-rule,{sect-recording-event-rule}>>'' section
26f0c779
PP
102below.
103+
104Create or enable a recording event rule with the
105man:lttng-enable-event(1) command.
106+
e9711845 107List the recording event rules of a specific recording session
26f0c779
PP
108and/or channel with the man:lttng-list(1) and man:lttng-status(1)
109commands.
110
111``Event rule matches'' <<trigger,trigger>> condition (since LTTng{nbsp}2.13)::
112 When the event rule of the trigger condition matches an event, LTTng
113 can execute user-defined actions such as sending an LTTng
e9711845 114 notification, starting a recording session, and more.
26f0c779
PP
115+
116See man:lttng-add-trigger(1) and man:lttng-event-rule(7).
117
118For LTTng to emit an event{nbsp}__E__,{nbsp}__E__ must satisfy *all* the
119basic conditions of an event rule{nbsp}__ER__, that is:
120
121* The instrumentation point from which LTTng creates{nbsp}__E__ has a
122 specific type.
123+
da39b67c
PP
124See the ``<<inst-point-types,Instrumentation point types>>'' section
125below.
26f0c779
PP
126
127* A pattern matches the name of{nbsp}__E__ while another pattern
128 doesn't.
129
130* The log level of the instrumentation point from which LTTng
131 creates{nbsp}__E__ is at least as severe as some value, or is exactly
132 some value.
133
134* The fields of the payload of{nbsp}__E__ and the current context fields
135 satisfy a filter expression.
136
137A recording event rule has additional, implicit conditions to satisfy.
da39b67c 138See the ``<<recording-event-rule,{sect-recording-event-rule}>>'' section
26f0c779
PP
139below to learn more.
140
141
142[[inst-point-types]]
143Instrumentation point types
144~~~~~~~~~~~~~~~~~~~~~~~~~~~
145As of LTTng{nbsp}{lttng_version}, the available instrumentation point
146types are, depending on the tracing domain (see the
da39b67c 147``<<domain,{sect-domain}>>'' section below):
26f0c779
PP
148
149Linux kernel::
150 LTTng tracepoint:::
151 A statically defined point in the source code of the kernel
152 image or of a kernel module using the LTTng-modules macros.
153+
154List the available Linux kernel tracepoints with `lttng list --kernel`.
155See man:lttng-list(1) to learn more.
156
157 Linux kernel system call:::
158 Entry, exit, or both of a Linux kernel system call.
159+
160List the available Linux kernel system call instrumentation points with
161`lttng list --kernel --syscall`. See man:lttng-list(1) to learn more.
162
163 Linux kprobe:::
164 A single probe dynamically placed in the compiled kernel code.
165+
166When you create such an instrumentation point, you set its memory
167address or symbol name.
168
169 Linux user space probe:::
170 A single probe dynamically placed at the entry of a compiled
171 user space application/library function through the kernel.
172+
173When you create such an instrumentation point, you set:
174+
175--
176With the ELF method::
177 Its application/library path and its symbol name.
178
179With the USDT method::
180 Its application/library path, its provider name, and its probe name.
181+
182``USDT'' stands for SystemTap User-level Statically Defined Tracing,
183a DTrace-style marker.
184--
185+
186As of LTTng{nbsp}{lttng_version}, LTTng only supports USDT probes which
187are :not: reference-counted.
188
189 Linux kretprobe:::
190 Entry, exit, or both of a Linux kernel function.
191+
192When you create such an instrumentation point, you set the memory
193address or symbol name of its function.
194
195User space::
196 LTTng tracepoint:::
197 A statically defined point in the source code of a C/$$C++$$
198 application/library using the LTTng-UST macros.
199+
200List the available Linux kernel tracepoints with
201`lttng list --userspace`. See man:lttng-list(1) to learn more.
202
203`java.util.logging`, Apache log4j, and Python::
204 Java or Python logging statement:::
205 A method call on a Java or Python logger attached to an
206 LTTng-UST handler.
207+
208List the available Java and Python loggers with `lttng list --jul`,
209`lttng list --log4j`, and `lttng list --python`. See man:lttng-list(1)
210to learn more.
211
212
213[[trigger]]
214TRIGGER
215-------
216A _trigger_ associates a condition to one or more actions.
217
218When the condition of a trigger is satisfied, LTTng attempts to execute
219its actions.
220
221As of LTTng{nbsp}{lttng_version}, the available trigger conditions and
222actions are:
223
224Conditions::
225+
e9711845 226* The consumed buffer size of a given recording
da39b67c 227 session (see the ``<<session,{sect-session}>>'' section below)
26f0c779
PP
228 becomes greater than some value.
229
230* The buffer usage of a given channel (see the
da39b67c
PP
231 ``<<channel,{sect-channel}>>'' section below) becomes greater than
232 some value.
26f0c779
PP
233
234* The buffer usage of a given channel becomes less than some value.
235
e9711845
PP
236* There's an ongoing recording session rotation (see the
237 ``<<rotation,Recording session rotation>>'' section below).
26f0c779 238
e9711845 239* A recording session rotation becomes completed.
26f0c779
PP
240
241* An event rule matches an event.
242+
243As of LTTng{nbsp}{lttng_version}, this is the only available condition
244when you add a trigger with the man:lttng-add-trigger(1) command. The
245other ones are available through the liblttng-ctl C{nbsp}API.
246
247Actions::
248+
249* Send a notification to a user application.
e9711845
PP
250* Start a given recording session, like man:lttng-start(1) would do.
251* Stop a given recording session, like man:lttng-stop(1) would do.
252* Archive the current trace chunk of a given recording session (rotate),
26f0c779 253 like man:lttng-rotate(1) would do.
e9711845
PP
254* Take a snapshot of a given recording session, like
255 man:lttng-snapshot(1) would do.
26f0c779
PP
256
257A trigger belongs to a session daemon (see man:lttng-sessiond(8)), not
e9711845 258to a specific recording session. For a given session daemon, each Unix
26f0c779
PP
259user has its own, private triggers. Note, however, that the `root` Unix
260user may, for the root session daemon:
261
262* Add a trigger as another Unix user.
263
264* List all the triggers, regardless of their owner.
265
266* Remove a trigger which belongs to another Unix user.
267
268For a given session daemon and Unix user, a trigger has a unique name.
269
270Add a trigger to a session daemon with the man:lttng-add-trigger(1)
271command.
272
273List the triggers of your Unix user (or of all users if your
274Unix user is `root`) with the man:lttng-list-triggers(1) command.
275
276Remove a trigger with the man:lttng-remove-trigger(1) command.
277
278
279[[session]]
280{sect-session}
281--------------
e9711845
PP
282A _recording session_ (named ``tracing session'' prior to
283LTTng{nbsp}2.13) is a stateful dialogue between you and a session daemon
284(see man:lttng-sessiond(8)) for everything related to event recording.
26f0c779
PP
285
286Everything that you do when you control LTTng tracers to record events
e9711845 287happens within a recording session. In particular, a recording session:
26f0c779
PP
288
289* Has its own name, unique for a given session daemon.
290
291* Has its own set of trace files, if any.
292
293* Has its own state of activity (started or stopped).
294+
e9711845
PP
295An active recording session is an implicit recording event rule
296condition (see the
297``<<recording-event-rule,{sect-recording-event-rule}>>'' section below).
26f0c779
PP
298
299* Has its own mode (local, network streaming, snapshot, or live).
300+
e9711845 301See the ``<<session-modes,Recording session modes>>'' section below to
da39b67c 302learn more.
26f0c779 303
da39b67c 304* Has its own channels (see the ``<<channel,{sect-channel}>>'' section
26f0c779
PP
305 below) to which are attached their own recording event rules.
306
307* Has its own process attribute inclusion sets (see man:lttng-track(1)).
308
309Those attributes and objects are completely isolated between different
e9711845 310recording sessions.
26f0c779 311
e9711845 312A recording session is like an ATM session: the operations you do on the
26f0c779
PP
313banking system through the ATM don't alter the data of other users of
314the same system. In the case of the ATM, a session lasts as long as your
e9711845 315bank card is inside. In the case of LTTng, a recording session lasts from
26f0c779
PP
316the man:lttng-create(1) command to the man:lttng-destroy(1) command.
317
e9711845 318A recording session belongs to a session daemon (see
26f0c779 319man:lttng-sessiond(8)). For a given session daemon, each Unix user has
e9711845
PP
320its own, private recording sessions. Note, however, that the `root` Unix
321user may operate on or destroy another user's recording session.
26f0c779 322
e9711845 323Create a recording session with the man:lttng-create(1) command.
26f0c779 324
e9711845 325List the recording sessions of the connected session daemon with
26f0c779
PP
326the man:lttng-list(1) command.
327
e9711845 328Start and stop a recording session with the man:lttng-start(1) and
26f0c779
PP
329man:lttng-stop(1) commands.
330
e9711845 331Save and load a recording session with the man:lttng-save(1) and
26f0c779
PP
332man:lttng-load(1) commands.
333
e9711845 334Archive the current trace chunk of (rotate) a recording session with the
26f0c779
PP
335man:lttng-rotate(1) command.
336
e9711845 337Destroy a recording session with the man:lttng-destroy(1) command.
26f0c779
PP
338
339
e9711845 340Current recording session
26f0c779
PP
341~~~~~~~~~~~~~~~~~~~~~~~
342When you run the man:lttng-create(1) command, LTTng creates the
343`$LTTNG_HOME/.lttngrc` file if it doesn't exist (`$LTTNG_HOME` defaults
344to `$HOME`).
345
e9711845 346`$LTTNG_HOME/.lttngrc` contains the name of the _current recording
26f0c779
PP
347session_.
348
e9711845
PP
349When you create a new recording session with the `create` command, LTTng
350updates the current recording session.
26f0c779 351
e9711845 352The following man:lttng(1) commands select the current recording session
26f0c779
PP
353if you don't specify one:
354
355* man:lttng-add-context(1)
356* man:lttng-clear(1)
357* man:lttng-destroy(1)
358* man:lttng-disable-channel(1)
359* man:lttng-disable-event(1)
360* man:lttng-disable-rotation(1)
361* man:lttng-enable-channel(1)
362* man:lttng-enable-event(1)
363* man:lttng-enable-rotation(1)
364* man:lttng-regenerate(1)
365* man:lttng-rotate(1)
366* man:lttng-save(1)
367* man:lttng-snapshot(1)
368* man:lttng-start(1)
369* man:lttng-status(1)
370* man:lttng-stop(1)
371* man:lttng-track(1)
372* man:lttng-untrack(1)
373* man:lttng-view(1)
374
e9711845 375Set the current recording session manually with the
26f0c779
PP
376man:lttng-set-session(1) command, without having to edit the `.lttngrc`
377file.
378
379
380[[session-modes]]
e9711845
PP
381Recording session modes
382~~~~~~~~~~~~~~~~~~~~~~~
383LTTng offers four recording session modes:
26f0c779
PP
384
385Local mode::
386 Write the trace data to the local file system.
387
388Network streaming mode::
389 Send the trace data over the network to a listening relay daemon
390 (see man:lttng-relayd(8)).
391
392Snapshot mode::
393 Only write the trace data to the local file system or send it to a
394 listening relay daemon (man:lttng-relayd(8)) when LTTng takes a
395 snapshot.
396+
da39b67c 397LTTng forces all the channels (see the ``<<channel,{sect-channel}>>''
26f0c779
PP
398section below) to be created to be configured to be snapshot-ready.
399+
e9711845 400LTTng takes a snapshot of such a recording session when:
26f0c779
PP
401+
402--
403* You run the man:lttng-snapshot(1) command.
404
405* LTTng executes a `snapshot-session` trigger action (see the
da39b67c 406 ``<<trigger,TRIGGER>>'' section above).
26f0c779
PP
407--
408
409Live mode::
410 Send the trace data over the network to a listening relay daemon
411 (see man:lttng-relayd(8)) for live reading.
412+
413An LTTng live reader (for example, man:babeltrace2(1)) can connect to
e9711845 414the same relay daemon to receive trace data while the recording session is
26f0c779
PP
415active.
416
417
418[[rotation]]
e9711845
PP
419Recording session rotation
420~~~~~~~~~~~~~~~~~~~~~~~~~~
421A _recording session rotation_ is the action of archiving the current
422trace chunk of the recording session to the file system.
26f0c779
PP
423
424Once LTTng archives a trace chunk, it does :not: manage it anymore: you
425can read it, modify it, move it, or remove it.
426
427An _archived trace chunk_ is a collection of metadata and data stream
428files which form a self-contained LTTng trace. See the
da39b67c 429``<<trace-chunk-naming,Trace chunk naming>>'' section below to learn how
26f0c779
PP
430LTTng names a trace chunk archive directory.
431
e9711845 432The _current trace chunk_ of a given recording session includes:
26f0c779
PP
433
434* The stream files which LTTng already wrote to the file system, and
435 which are not part of a previously archived trace chunk, since the
436 most recent event amongst:
437
e9711845 438** The first time the recording session was started, either with the
26f0c779 439 man:lttng-start(1) command or with a `start-session` trigger action
da39b67c 440 (see the ``<<trigger,TRIGGER>>'' section above).
26f0c779
PP
441
442** The last rotation, performed with:
443
444*** An man:lttng-rotate(1) command.
445
446*** A rotation schedule previously set with
447 man:lttng-enable-rotation(1).
448
449*** An executed `rotate-session` trigger action (see the
da39b67c 450 ``<<trigger,TRIGGER>>'' section above).
26f0c779
PP
451
452* The content of all the non-flushed sub-buffers of the channels of the
e9711845 453 recording session.
26f0c779
PP
454
455
456[[trace-chunk-naming]]
457Trace chunk archive naming
458~~~~~~~~~~~~~~~~~~~~~~~~~~
459A trace chunk archive is a subdirectory of the `archives` subdirectory
e9711845 460within the output directory of a recording session (see the
26f0c779
PP
461nloption:--output option of the man:lttng-create(1) command and
462of man:lttng-relayd(8)).
463
464A trace chunk archive contains, through tracing domain and possibly
465UID/PID subdirectories, metadata and data stream files.
466
467A trace chunk archive is, at the same time:
468
469* A self-contained LTTng trace.
470
471* A member of a set of trace chunk archives which form the complete
e9711845 472 trace of a recording session.
26f0c779 473
e9711845 474In other words, an LTTng trace reader can read both the recording
26f0c779
PP
475session output directory (all the trace chunk archives), or a
476single trace chunk archive.
477
e9711845 478When LTTng performs a recording session rotation, it names the resulting
26f0c779 479trace chunk archive as such, relative to the output directory of the
e9711845 480recording session:
26f0c779
PP
481
482[verse]
483archives/__BEGIN__-__END__-__ID__
484
485__BEGIN__::
486 Date and time of the beginning of the trace chunk archive with
487 the ISO{nbsp}8601-compatible __YYYYmmddTHHMMSS±HHMM__ form, where
488 __YYYYmmdd__ is the date and __HHMMSS±HHMM__ is the time with the
489 time zone offset from UTC.
490+
491Example: `20171119T152407-0500`
492
493__END__::
494 Date and time of the end of the trace chunk archive with
495 the ISO{nbsp}8601-compatible __YYYYmmddTHHMMSS±HHMM__ form, where
496 __YYYYmmdd__ is the date and __HHMMSS±HHMM__ is the time with the
497 time zone offset from UTC.
498+
499Example: `20180118T152407+0930`
500
501__ID__::
e9711845 502 Unique numeric identifier of the trace chunk within its recording
26f0c779
PP
503 session.
504
505Trace chunk archive name example:
506
507----
508archives/20171119T152407-0500-20171119T151422-0500-3
509----
510
511
512[[domain]]
513{sect-domain}
514-------------
515A _tracing domain_ identifies a type of LTTng tracer.
516
517A tracing domain has its own properties and features.
518
519There are currently five available tracing domains:
520
521[options="header"]
522|===
523|Tracing domain |``Event rule matches'' trigger condition option |Option for other CLI commands
524
525|Linux kernel
a55e08e0 526|nloption:--type option starts with `kernel:`
26f0c779
PP
527|nloption:--kernel
528
529|User space
a55e08e0 530|nloption:--type option starts with `user:`
26f0c779
PP
531|nloption:--userspace
532
533|`java.util.logging` (JUL)
a55e08e0 534|nloption:--type option starts with `jul:`
26f0c779
PP
535|nloption:--jul
536
537|Apache log4j
a55e08e0 538|nloption:--type option starts with `log4j:`
26f0c779
PP
539|nloption:--log4j
540
541|Python
a55e08e0 542|nloption:--type option starts with `python:`
26f0c779
PP
543|nloption:--python
544|===
545
546You must specify a tracing domain to target a type of LTTng tracer when
7013e167
PP
547using some man:lttng(1) commands to avoid ambiguity. For example,
548because the Linux kernel and user space tracing domains support named
549tracepoints as instrumentation points (see the
da39b67c
PP
550``<<"event-rule","{sect-event-rule}">>'' section above), you need to
551specify a tracing domain when you create an event rule because both
552tracing domains could have tracepoints sharing the same name.
26f0c779 553
da39b67c 554You can create channels (see the ``<<channel,{sect-channel}>>'' section
26f0c779
PP
555below) in the Linux kernel and user space tracing domains. The other
556tracing domains have a single, default channel.
557
558
559[[channel]]
560{sect-channel}
561--------------
562A _channel_ is an object which is responsible for a set of ring buffers.
563
564Each ring buffer is divided into multiple _sub-buffers_. When a
565recording event rule (see the
da39b67c 566``<<recording-event-rule,{sect-recording-event-rule}>>'' section below)
26f0c779
PP
567matches an event, LTTng can record it to one or more sub-buffers of one
568or more channels.
569
570When you create a channel with the man:lttng-enable-channel(1) command,
571you set its final attributes, that is:
572
573* Its buffering scheme.
574+
da39b67c 575See the ``<<channel-buf-scheme,Buffering scheme>>'' section below.
26f0c779
PP
576
577* What to do when there's no
578 space left for a new event record because all sub-buffers are full.
579+
da39b67c
PP
580See the ``<<channel-er-loss-mode,Event record loss mode>>'' section
581below.
26f0c779
PP
582
583* The size of each ring buffer and how many sub-buffers a ring buffer
584 has.
585+
da39b67c
PP
586See the ``<<channel-sub-buf-size-count,Sub-buffer size and count>>''
587section below.
26f0c779
PP
588
589* The size of each trace file LTTng writes for this channel and the
590 maximum count of trace files.
591+
da39b67c
PP
592See the ``<<channel-max-trace-file-size-count,Maximum trace file size
593and count>>'' section below.
26f0c779
PP
594
595* The periods of its read, switch, and monitor timers.
596+
da39b67c 597See the ``<<channel-timers,Timers>>'' section below.
26f0c779
PP
598
599* For a Linux kernel channel: its output type (man:mmap(2) or
600 man:splice(2)).
601+
602See the nloption:--output option of the man:lttng-enable-channel(1)
603command.
604
605* For a user space channel: the value of its blocking timeout.
606+
607See the nloption:--blocking-timeout option of the
608man:lttng-enable-channel(1) command.
609
610Note that the man:lttng-enable-event(1) command can automatically create
611a default channel with sane defaults when no channel exists for the
612provided tracing domain.
613
614A channel is always associated to a tracing domain (see the
da39b67c
PP
615``<<domain,{sect-domain}>>'' section below). The `java.util.logging`
616(JUL), log4j, and Python tracing domains each have a default channel
617which you can't configure.
26f0c779
PP
618
619A channel owns recording event rules.
620
e9711845 621List the channels of a given recording session with the
26f0c779
PP
622man:lttng-list(1) and man:lttng-status(1) commands.
623
624Disable an enabled channel with the man:lttng-disable-channel(1)
625command.
626
627
628[[channel-buf-scheme]]
629Buffering scheme
630~~~~~~~~~~~~~~~~
631A channel has at least one ring buffer per CPU. LTTng always records an
632event to the ring buffer dedicated to the CPU which emits it.
633
634The buffering scheme of a user space channel determines what has its own
635set of per-CPU ring buffers:
636
637Per-user buffering (nloption:--buffers-uid option of the man:lttng-enable-channel(1) command)::
638 Allocate one set of ring buffers (one per CPU) shared by all the
639 instrumented processes of:
640 If your Unix user is `root`:::
641 Each Unix user.
642 Otherwise:::
643 Your Unix user.
644
645Per-process buffering (nloption:--buffers-pid option of the man:lttng-enable-channel(1) command)::
646 Allocate one set of ring buffers (one per CPU) for each instrumented
647 process of:
648 If your Unix user is `root`:::
649 All Unix users.
650 Otherwise:::
651 Your Unix user.
652
653The per-process buffering scheme tends to consume more memory than the
654per-user option because systems generally have more instrumented
655processes than Unix users running instrumented processes. However, the
656per-process buffering scheme ensures that one process having a high
657event throughput won't fill all the shared sub-buffers of the same Unix
658user, only its own.
659
660The buffering scheme of a Linux kernel channel is always to allocate a
661single set of ring buffers for the whole system. This scheme is similar
662to the per-user option, but with a single, global user ``running'' the
663kernel.
664
665
666[[channel-er-loss-mode]]
667Event record loss mode
668~~~~~~~~~~~~~~~~~~~~~~
669When LTTng emits an event, LTTng can record it to a specific, available
670sub-buffer within the ring buffers of specific channels. When there's no
671space left in a sub-buffer, the tracer marks it as consumable and
672another, available sub-buffer starts receiving the following event
673records. An LTTng consumer daemon eventually consumes the marked
674sub-buffer, which returns to the available state.
675
676In an ideal world, sub-buffers are consumed faster than they are filled.
677In the real world, however, all sub-buffers can be full at some point,
678leaving no space to record the following events.
679
680By default, LTTng-modules and LTTng-UST are _non-blocking_ tracers: when
681there's no available sub-buffer to record an event, it's acceptable to
682lose event records when the alternative would be to cause substantial
683delays in the execution of the instrumented application. LTTng
684privileges performance over integrity; it aims at perturbing the
685instrumented application as little as possible in order to make the
686detection of subtle race conditions and rare interrupt cascades
687possible.
688
689Since LTTng{nbsp}2.10, the LTTng user space tracer, LTTng-UST, supports
690a _blocking mode_. See the nloption:--blocking-timeout of the
691man:lttng-enable-channel(1) command to learn how to use the blocking
692mode.
693
694When it comes to losing event records because there's no available
695sub-buffer, or because the blocking timeout of the channel is
696reached, the _event record loss mode_ of the channel determines what to
697do. The available event record loss modes are:
698
699Discard mode::
700 Drop the newest event records until a sub-buffer becomes available.
701+
702This is the only available mode when you specify a blocking timeout.
703+
704With this mode, LTTng increments a count of lost event records when an
705event record is lost and saves this count to the trace. A trace reader
706can use the saved discarded event record count of the trace to decide
707whether or not to perform some analysis even if trace data is known to
708be missing.
709
710Overwrite mode::
711 Clear the sub-buffer containing the oldest event records and start
712 writing the newest event records there.
713+
714This mode is sometimes called _flight recorder mode_ because it's
715similar to a https://en.wikipedia.org/wiki/Flight_recorder[flight
716recorder]: always keep a fixed amount of the latest data. It's also
717similar to the roll mode of an oscilloscope.
718+
719Since LTTng{nbsp}2.8, with this mode, LTTng writes to a given sub-buffer
720its sequence number within its data stream. With a local, network
e9711845
PP
721streaming, or live recording session (see the
722``<<session-modes,Recording session modes>>'' section above), a trace
723reader can use such sequence numbers to report lost packets. A trace
724reader can use the saved discarded sub-buffer (packet) count of the
725trace to decide whether or not to perform some analysis even if trace
726data is known to be missing.
26f0c779
PP
727+
728With this mode, LTTng doesn't write to the trace the exact number of
729lost event records in the lost sub-buffers.
730
731Which mechanism you should choose depends on your context: prioritize
732the newest or the oldest event records in the ring buffer?
733
734Beware that, in overwrite mode, the tracer abandons a _whole sub-buffer_
735as soon as a there's no space left for a new event record, whereas in
736discard mode, the tracer only discards the event record that doesn't
737fit.
738
739Set the event record loss mode of a channel with the nloption:--discard
740and nloption:--overwrite options of the man:lttng-enable-channel(1)
741command.
742
743There are a few ways to decrease your probability of losing event
da39b67c
PP
744records. The ``<<channel-sub-buf-size-count,Sub-buffer size and
745count>>'' section below shows how to fine-tune the sub-buffer size and
746count of a channel to virtually stop losing event records, though at the
747cost of greater memory usage.
26f0c779
PP
748
749
750[[channel-sub-buf-size-count]]
751Sub-buffer size and count
752~~~~~~~~~~~~~~~~~~~~~~~~~
753A channel has one or more ring buffer for each CPU of the target system.
754
da39b67c
PP
755See the ``<<channel-buf-scheme,Buffering scheme>>'' section above to
756learn how many ring buffers of a given channel are dedicated to each CPU
26f0c779
PP
757depending on its buffering scheme.
758
759Set the size of each sub-buffer the ring buffers of a channel contain
760with the nloption:--subbuf-size option of the
761man:lttng-enable-channel(1) command.
762
763Set the number of sub-buffers each ring buffer of a channel contains
764with the nloption:--num-subbuf option of the man:lttng-enable-channel(1)
765command.
766
767Note that LTTng switching the current sub-buffer of a ring buffer
768(marking a full one as consumable and switching to an available one for
769LTTng to record the next events) introduces noticeable CPU overhead.
770Knowing this, the following list presents a few practical situations
771along with how to configure the sub-buffer size and count for them:
772
773High event throughput::
774 In general, prefer large sub-buffers to lower the risk of losing
775 event records.
776+
777Having larger sub-buffers also ensures a lower sub-buffer switching
da39b67c 778frequency (see the ``<<channel-timers,Timers>>'' section below).
26f0c779
PP
779+
780The sub-buffer count is only meaningful if you create the channel in
da39b67c
PP
781overwrite mode (see the ``<<channel-er-loss-mode,Event record loss
782mode>>'' section above): in this case, if LTTng overwrites a sub-buffer,
783then the other sub-buffers are left unaltered.
26f0c779
PP
784
785Low event throughput::
786 In general, prefer smaller sub-buffers since the risk of losing
787 event records is low.
788+
789Because LTTng emits events less frequently, the sub-buffer switching
790frequency should remain low and therefore the overhead of the tracer
791shouldn't be a problem.
792
793Low memory system::
794 If your target system has a low memory limit, prefer fewer first,
795 then smaller sub-buffers.
796+
797Even if the system is limited in memory, you want to keep the
798sub-buffers as large as possible to avoid a high sub-buffer switching
799frequency.
800
801Note that LTTng uses https://diamon.org/ctf/[CTF] as its trace format,
802which means event record data is very compact. For example, the average
803LTTng kernel event record weights about 32{nbsp}bytes. Therefore, a
804sub-buffer size of 1{nbsp}MiB is considered large.
805
806The previous scenarios highlight the major trade-off between a few large
807sub-buffers and more, smaller sub-buffers: sub-buffer switching
808frequency vs. how many event records are lost in overwrite mode.
809Assuming a constant event throughput and using the overwrite mode, the
810two following configurations have the same ring buffer total size:
811
812Two sub-buffers of 4{nbsp}MiB each::
813 Expect a very low sub-buffer switching frequency, but if LTTng
814 ever needs to overwrite a sub-buffer, half of the event records so
815 far (4{nbsp}MiB) are definitely lost.
816
817Eight sub-buffers of 1{nbsp}MiB each::
818 Expect four times the tracer overhead of the configuration above,
819 but if LTTng needs to overwrite a sub-buffer, only the eighth of
820 event records so far (1{nbsp}MiB) are definitely lost.
821
822In discard mode, the sub-buffer count parameter is pointless: use two
823sub-buffers and set their size according to your requirements.
824
825
826[[channel-max-trace-file-size-count]]
827Maximum trace file size and count
828~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
829By default, trace files can grow as large as needed.
830
831Set the maximum size of each trace file that LTTng writes of a given
832channel with the nloption:--tracefile-size option of the man:lttng-enable-channel(1)
833command.
834
835When the size of a trace file reaches the fixed maximum size of the
836channel, LTTng creates another file to contain the next event records.
837LTTng appends a file count to each trace file name in this case.
838
839If you set the trace file size attribute when you create a channel, the
840maximum number of trace files that LTTng creates is _unlimited_ by
841default. To limit them, use the nloption:--tracefile-count option of
842man:lttng-enable-channel(1). When the number of trace files reaches the
843fixed maximum count of the channel, LTTng overwrites the oldest trace
844file. This mechanism is called _trace file rotation_.
845
846[IMPORTANT]
847====
848Even if you don't limit the trace file count, always assume that LTTng
e9711845 849manages all the trace files of the recording session.
26f0c779
PP
850
851In other words, there's no safe way to know if LTTng still holds a given
852trace file open with the trace file rotation feature.
853
854The only way to obtain an unmanaged, self-contained LTTng trace before
e9711845
PP
855you destroy the recording session is with the recording session rotation
856feature (see the ``<<rotation,Recording session rotation>>'' section
da39b67c 857above), which is available since LTTng{nbsp}2.11.
26f0c779
PP
858====
859
860
861[[channel-timers]]
862Timers
863~~~~~~
864Each channel can have up to three optional timers:
865
866Switch timer::
867 When this timer expires, a sub-buffer switch happens: for each ring
868 buffer of the channel, LTTng marks the current sub-buffer as
869 consumable and switches to an available one to record the next
870 events.
871+
872A switch timer is useful to ensure that LTTng consumes and commits trace
873data to trace files or to a distant relay daemon (man:lttng-relayd(8))
874periodically in case of a low event throughput.
875+
876Such a timer is also convenient when you use large sub-buffers (see the
da39b67c
PP
877``<<channel-sub-buf-size-count,Sub-buffer size and count>>'' section
878above) to cope with a sporadic high event throughput, even if the
879throughput is otherwise low.
26f0c779
PP
880+
881Set the period of the switch timer of a channel, or disable the timer
882altogether, with the nloption:--switch-timer option of the
883man:lttng-enable-channel(1) command.
884
885Read timer::
886 When this timer expires, LTTng checks for full, consumable
887 sub-buffers.
888+
889By default, the LTTng tracers use an asynchronous message mechanism to
890signal a full sub-buffer so that a consumer daemon can consume it.
891+
892When such messages must be avoided, for example in real-time
893applications, use this timer instead.
894+
895Set the period of the read timer of a channel, or disable the timer
896altogether, with the nloption:--read-timer option of the
897man:lttng-enable-channel(1) command.
898
899Monitor timer::
900 When this timer expires, the consumer daemon samples some channel
26f0c779
PP
901 statistics to evaluate the following trigger conditions:
902+
903--
e9711845 904. The consumed buffer size of a given recording session becomes greater
26f0c779
PP
905 than some value.
906. The buffer usage of a given channel becomes greater than some value.
907. The buffer usage of a given channel becomes less than some value.
908--
909+
910If you disable the monitor timer of a channel{nbsp}__C__:
911+
912--
e9711845 913* The consumed buffer size value of the recording session of{nbsp}__C__
26f0c779
PP
914 could be wrong for trigger condition type{nbsp}1: the consumed buffer
915 size of{nbsp}__C__ won't be part of the grand total.
916
917* The buffer usage trigger conditions (types{nbsp}2 and{nbsp}3)
918 for{nbsp}__C__ will never be satisfied.
919--
920+
da39b67c
PP
921See the ``<<trigger,TRIGGER>>'' section above to learn more about
922triggers.
26f0c779
PP
923+
924Set the period of the monitor timer of a channel, or disable the timer
925altogether, with the nloption:--monitor-timer option of the
926man:lttng-enable-channel(1) command.
927
928
929[[recording-event-rule]]
930{sect-recording-event-rule}
931---------------------------
932A _recording event rule_ is a specific type of event rule (see the
da39b67c
PP
933``<<"event-rule","{sect-event-rule}">>'' section above) of which the
934action is to serialize and record the matched event as an _event
935record_.
26f0c779
PP
936
937Set the explicit conditions of a recording event rule when you create it
938with the man:lttng-enable-event(1) command. A recording event rule also
939has the following implicit conditions:
940
941* The recording event rule itself is enabled.
942+
943A recording event rule is enabled on creation.
944
945* The channel to which the recording event rule is attached is enabled.
946+
947A channel is enabled on creation.
948+
da39b67c 949See the ``<<channel,{sect-channel}>>'' section above.
26f0c779 950
e9711845 951* The recording session of the recording event rule is active (started).
26f0c779 952+
e9711845 953A recording session is inactive (stopped) on creation.
26f0c779 954+
da39b67c 955See the ``<<session,{sect-session}>>'' section above.
26f0c779
PP
956
957* The process for which LTTng creates an event to match is allowed to
958 record events.
959+
e9711845 960All processes are allowed to record events on recording session
26f0c779
PP
961creation.
962+
963Use the man:lttng-track(1) and man:lttng-untrack(1) commands to select
964which processes are allowed to record events based on specific process
965attributes.
966
967You always attach a recording event rule to a channel, which belongs to
e9711845 968a recording session, when you create it.
26f0c779
PP
969
970When a recording event rule{nbsp}__ER__ matches an event{nbsp}__E__,
971LTTng attempts to serialize and record{nbsp}__E__ to one of the
972available sub-buffers of the channel to which{nbsp}__E__ is attached.
973
974When multiple matching recording event rules are attached to the same
975channel, LTTng attempts to serialize and record the matched event
976_once_. In the following example, the second recording event rule is
977redundant when both are enabled:
978
979[role="term"]
980----
981$ lttng enable-event --userspace hello:world
4fc37e3e 982$ lttng enable-event --userspace hello:world --loglevel=INFO
26f0c779
PP
983----
984
e9711845 985List the recording event rules of a specific recording session
26f0c779
PP
986and/or channel with the man:lttng-list(1) and man:lttng-status(1)
987commands.
988
989Disable a recording event rule with the man:lttng-disable-event(1)
990command.
991
992As of LTTng{nbsp}{lttng_version}, you cannot remove a recording event
e9711845 993rule: it exists as long as its recording session exists.
26f0c779
PP
994
995
996include::common-footer.txt[]
997
998
999SEE ALSO
1000--------
1001man:lttng(1),
1002man:lttng-relayd(8),
1003man:lttng-sessiond(8)
This page took 0.070006 seconds and 5 git commands to generate.