Fix: timer_expire_entry changed in 4.19.312
[lttng-modules.git] / lttng-events.h
CommitLineData
9f36eaed
MJ
1/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
a90917c3 3 * lttng-events.h
4e3c1b9b 4 *
4e3c1b9b 5 * Holds LTTng per-session event registry.
17baffe2 6 *
886d51a3 7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4e3c1b9b
MD
8 */
9
9f36eaed
MJ
10#ifndef _LTTNG_EVENTS_H
11#define _LTTNG_EVENTS_H
12
2d042821 13#include <lttng-kernel-version.h>
4e3c1b9b 14#include <linux/list.h>
d6d808f3 15#include <linux/kprobes.h>
d83004aa 16#include <linux/kref.h>
1e367326 17#include <lttng-cpuhotplug.h>
41f229dc 18#include <linux/uuid.h>
67f4eaf8 19#include <linux/irq_work.h>
149b9a9d 20#include <wrapper/uprobes.h>
f64dd4be 21#include <lttng-tracer.h>
bbd023d6
MD
22#include <lttng-abi.h>
23#include <lttng-abi-old.h>
4e3c1b9b 24
4d879d23 25#define lttng_is_signed_type(type) (((type) -1) < (type) 1)
9e7e4892 26
a90917c3
MD
27struct lttng_channel;
28struct lttng_session;
d83004aa 29struct lttng_metadata_cache;
1c25284c 30struct lib_ring_buffer_ctx;
ba1f5986 31struct perf_event;
833ad6a0 32struct perf_event_attr;
3b731ab1 33struct lib_ring_buffer_config;
4e3c1b9b 34
c0edae1d
MD
35/* Type description */
36
c0edae1d
MD
37enum abstract_types {
38 atype_integer,
39 atype_enum,
40 atype_array,
41 atype_sequence,
42 atype_string,
f513b2bf
MD
43 atype_struct,
44 atype_array_compound, /* Array of compound types. */
45 atype_sequence_compound, /* Sequence of compound types. */
65c85aa6 46 atype_variant,
3834b99f
MD
47 atype_array_bitfield,
48 atype_sequence_bitfield,
c0edae1d
MD
49 NR_ABSTRACT_TYPES,
50};
51
c0edae1d 52enum lttng_string_encodings {
e0a7a7c4
MD
53 lttng_encode_none = 0,
54 lttng_encode_UTF8 = 1,
55 lttng_encode_ASCII = 2,
c0edae1d
MD
56 NR_STRING_ENCODINGS,
57};
58
d83004aa
JD
59enum channel_type {
60 PER_CPU_CHANNEL,
61 METADATA_CHANNEL,
62};
63
141ddf28
MD
64struct lttng_enum_value {
65 unsigned long long value;
66 unsigned int signedness:1;
67};
68
c0edae1d 69struct lttng_enum_entry {
141ddf28 70 struct lttng_enum_value start, end; /* start and end are inclusive */
c0edae1d 71 const char *string;
08ad1061
PP
72 struct {
73 unsigned int is_auto:1;
74 } options;
c0edae1d
MD
75};
76
43803cf2 77#define __type_integer(_type, _size, _alignment, _signedness, \
79282ffd 78 _byte_order, _user, _base, _encoding) \
c099397a
MD
79 { \
80 .atype = atype_integer, \
81 .u.basic.integer = \
82 { \
43803cf2
MD
83 .size = (_size) ? : sizeof(_type) * CHAR_BIT, \
84 .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \
85 .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \
79282ffd
MD
86 .reverse_byte_order = (_byte_order) != __BYTE_ORDER, \
87 .base = (_base), \
88 .user = (_user), \
64c796d8 89 .encoding = lttng_encode_##_encoding, \
c099397a
MD
90 }, \
91 } \
92
93struct lttng_integer_type {
94 unsigned int size; /* in bits */
95 unsigned short alignment; /* in bits */
9cccf98a 96 unsigned int signedness:1,
79282ffd
MD
97 reverse_byte_order:1,
98 user:1; /* fetch from user-space */
e0a7a7c4
MD
99 unsigned int base; /* 2, 8, 10, 16, for pretty print */
100 enum lttng_string_encodings encoding;
c099397a
MD
101};
102
103union _lttng_basic_type {
104 struct lttng_integer_type integer;
105 struct {
141ddf28
MD
106 const struct lttng_enum_desc *desc; /* Enumeration mapping */
107 struct lttng_integer_type container_type;
c099397a
MD
108 } enumeration;
109 struct {
110 enum lttng_string_encodings encoding;
79282ffd 111 unsigned int user:1; /* fetch from user-space */
c099397a
MD
112 } string;
113};
114
115struct lttng_basic_type {
116 enum abstract_types atype;
117 union {
118 union _lttng_basic_type basic;
119 } u;
c0edae1d
MD
120};
121
122struct lttng_type {
123 enum abstract_types atype;
c0edae1d 124 union {
c099397a 125 union _lttng_basic_type basic;
c0edae1d 126 struct {
c099397a 127 struct lttng_basic_type elem_type;
c0edae1d 128 unsigned int length; /* num. elems. */
43803cf2 129 unsigned int elem_alignment; /* alignment override */
c0edae1d
MD
130 } array;
131 struct {
c099397a
MD
132 struct lttng_basic_type length_type;
133 struct lttng_basic_type elem_type;
43803cf2 134 unsigned int elem_alignment; /* alignment override */
c0edae1d 135 } sequence;
f513b2bf
MD
136 struct {
137 uint32_t nr_fields;
138 struct lttng_event_field *fields; /* Array of fields. */
139 } _struct;
140 struct {
141 struct lttng_type *elem_type;
142 unsigned int length; /* num. elems. */
143 } array_compound;
144 struct {
145 struct lttng_type *elem_type;
146 const char *length_name;
147 } sequence_compound;
65c85aa6
MD
148 struct {
149 const char *tag_name;
150 struct lttng_event_field *choices; /* Array of fields. */
151 uint32_t nr_choices;
152 } variant;
c0edae1d 153 } u;
c099397a
MD
154};
155
141ddf28 156struct lttng_enum_desc {
c099397a 157 const char *name;
c099397a 158 const struct lttng_enum_entry *entries;
141ddf28 159 unsigned int nr_entries;
c099397a 160};
c0edae1d
MD
161
162/* Event field description */
163
164struct lttng_event_field {
165 const char *name;
f17701fb 166 struct lttng_type type;
79282ffd 167 unsigned int nowrite:1; /* do not write into trace */
c0edae1d
MD
168};
169
07dfc1d0
MD
170union lttng_ctx_value {
171 int64_t s64;
172 const char *str;
173 double d;
174};
175
2001023e
MD
176/*
177 * We need to keep this perf counter field separately from struct
178 * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
179 */
180struct lttng_perf_counter_field {
2d042821 181#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
1e367326
MD
182 struct lttng_cpuhp_node cpuhp_prepare;
183 struct lttng_cpuhp_node cpuhp_online;
184#else
2001023e
MD
185 struct notifier_block nb;
186 int hp_enable;
1e367326 187#endif
2001023e
MD
188 struct perf_event_attr *attr;
189 struct perf_event **e; /* per-cpu array */
190};
191
79150a49
JD
192struct lttng_probe_ctx {
193 struct lttng_event *event;
194 uint8_t interruptible;
195};
196
ba1f5986 197struct lttng_ctx_field {
8070f5c0 198 struct lttng_event_field event_field;
f1676205 199 size_t (*get_size)(size_t offset);
1474c8e2
FG
200 size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field,
201 struct lib_ring_buffer_ctx *ctx,
202 struct lttng_channel *chan);
f1676205
MD
203 void (*record)(struct lttng_ctx_field *field,
204 struct lib_ring_buffer_ctx *ctx,
a90917c3 205 struct lttng_channel *chan);
07dfc1d0 206 void (*get_value)(struct lttng_ctx_field *field,
79150a49 207 struct lttng_probe_ctx *lttng_probe_ctx,
07dfc1d0 208 union lttng_ctx_value *value);
ba1f5986 209 union {
2001023e 210 struct lttng_perf_counter_field *perf_counter;
ba1f5986 211 } u;
2dccf128 212 void (*destroy)(struct lttng_ctx_field *field);
3c1a57e8
MD
213 /*
214 * Private data to keep state between get_size and record.
215 * User must perform its own synchronization to protect against
216 * concurrent and reentrant contexts.
217 */
218 void *priv;
ba1f5986
MD
219};
220
221struct lttng_ctx {
833ad6a0 222 struct lttng_ctx_field *fields;
0d1a681e 223 unsigned int nr_fields;
ba1f5986 224 unsigned int allocated_fields;
a9dd15da 225 size_t largest_align; /* in bytes */
0d1a681e
MD
226};
227
228struct lttng_event_desc {
a26a7e4f
MD
229 const char *name; /* lttng-modules name */
230 const char *kname; /* Linux kernel name (tracepoints) */
c0edae1d 231 void *probe_callback;
0d1a681e
MD
232 const struct lttng_event_ctx *ctx; /* context */
233 const struct lttng_event_field *fields; /* event payload */
c0edae1d 234 unsigned int nr_fields;
dc7f600a 235 struct module *owner;
c0edae1d
MD
236};
237
85a9ca7f 238struct lttng_probe_desc {
3c997079 239 const char *provider;
f7bdf4db 240 const struct lttng_event_desc **event_desc;
85a9ca7f
MD
241 unsigned int nr_events;
242 struct list_head head; /* chain registered probes */
3c997079
MD
243 struct list_head lazy_init_head;
244 int lazy; /* lazy registration */
85a9ca7f
MD
245};
246
7371f44c
MD
247struct lttng_krp; /* Kretprobe handling */
248
3c997079
MD
249enum lttng_event_type {
250 LTTNG_TYPE_EVENT = 0,
251 LTTNG_TYPE_ENABLER = 1,
252};
253
07dfc1d0
MD
254struct lttng_filter_bytecode_node {
255 struct list_head node;
256 struct lttng_enabler *enabler;
257 /*
258 * struct lttng_kernel_filter_bytecode has var. sized array, must be
259 * last field.
260 */
261 struct lttng_kernel_filter_bytecode bc;
262};
263
264/*
265 * Filter return value masks.
266 */
267enum lttng_filter_ret {
268 LTTNG_FILTER_DISCARD = 0,
269 LTTNG_FILTER_RECORD_FLAG = (1ULL << 0),
270 /* Other bits are kept for future use. */
271};
272
273struct lttng_bytecode_runtime {
274 /* Associated bytecode */
275 struct lttng_filter_bytecode_node *bc;
79150a49
JD
276 uint64_t (*filter)(void *filter_data, struct lttng_probe_ctx *lttng_probe_ctx,
277 const char *filter_stack_data);
07dfc1d0
MD
278 int link_failed;
279 struct list_head node; /* list of bytecode runtime in event */
3834b99f 280 struct lttng_event *event;
07dfc1d0
MD
281};
282
3c997079
MD
283/*
284 * Objects in a linked-list of enablers, owned by an event.
285 */
286struct lttng_enabler_ref {
287 struct list_head node; /* enabler ref list */
288 struct lttng_enabler *ref; /* backward ref */
289};
290
3aed4dca
FD
291struct lttng_uprobe_handler {
292 struct lttng_event *event;
293 loff_t offset;
294 struct uprobe_consumer up_consumer;
295 struct list_head node;
296};
297
ad594e3a
MD
298enum lttng_syscall_entryexit {
299 LTTNG_SYSCALL_ENTRY,
300 LTTNG_SYSCALL_EXIT,
301};
302
303enum lttng_syscall_abi {
304 LTTNG_SYSCALL_ABI_NATIVE,
305 LTTNG_SYSCALL_ABI_COMPAT,
306};
307
85a9ca7f 308/*
a90917c3 309 * lttng_event structure is referred to by the tracing fast path. It must be
85a9ca7f
MD
310 * kept small.
311 */
a90917c3 312struct lttng_event {
3c997079 313 enum lttng_event_type evtype; /* First field. */
85a9ca7f 314 unsigned int id;
a90917c3 315 struct lttng_channel *chan;
e64957da 316 int enabled;
d3dbe23c 317 const struct lttng_event_desc *desc;
85a9ca7f 318 void *filter;
f1676205 319 struct lttng_ctx *ctx;
38d024ae 320 enum lttng_kernel_instrumentation instrumentation;
d6d808f3
MD
321 union {
322 struct {
323 struct kprobe kp;
324 char *symbol_name;
325 } kprobe;
7371f44c
MD
326 struct {
327 struct lttng_krp *lttng_krp;
328 char *symbol_name;
329 } kretprobe;
149b9a9d 330 struct {
149b9a9d 331 struct inode *inode;
3aed4dca 332 struct list_head head;
149b9a9d 333 } uprobe;
ad594e3a
MD
334 struct {
335 char *syscall_name;
336 enum lttng_syscall_entryexit entryexit;
337 enum lttng_syscall_abi abi;
338 } syscall;
d6d808f3 339 } u;
3c997079 340 struct list_head list; /* Event list in session */
9cccf98a 341 unsigned int metadata_dumped:1;
3c997079
MD
342
343 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
344 struct list_head enablers_ref_head;
345 struct hlist_node hlist; /* session ht of events */
346 int registered; /* has reg'd tracepoint probe */
07dfc1d0
MD
347 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
348 struct list_head bytecode_runtime_head;
349 int has_enablers_without_bytecode;
3c997079
MD
350};
351
352enum lttng_enabler_type {
4993071a 353 LTTNG_ENABLER_STAR_GLOB,
3c997079
MD
354 LTTNG_ENABLER_NAME,
355};
356
357/*
358 * Enabler field, within whatever object is enabling an event. Target of
359 * backward reference.
360 */
361struct lttng_enabler {
362 enum lttng_event_type evtype; /* First field. */
363
364 enum lttng_enabler_type type;
365
366 struct list_head node; /* per-session list of enablers */
07dfc1d0
MD
367 /* head list of struct lttng_ust_filter_bytecode_node */
368 struct list_head filter_bytecode_head;
3c997079
MD
369
370 struct lttng_kernel_event event_param;
371 struct lttng_channel *chan;
372 struct lttng_ctx *ctx;
373 unsigned int enabled:1;
85a9ca7f
MD
374};
375
a90917c3 376struct lttng_channel_ops {
85a9ca7f 377 struct channel *(*channel_create)(const char *name,
a90917c3 378 struct lttng_channel *lttng_chan,
85a9ca7f
MD
379 void *buf_addr,
380 size_t subbuf_size, size_t num_subbuf,
381 unsigned int switch_timer_interval,
382 unsigned int read_timer_interval);
383 void (*channel_destroy)(struct channel *chan);
384 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
f71ecafa 385 int (*buffer_has_read_closed_stream)(struct channel *chan);
85a9ca7f 386 void (*buffer_read_close)(struct lib_ring_buffer *buf);
4e1f08f4 387 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
64c796d8 388 uint32_t event_id);
85a9ca7f
MD
389 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
390 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
391 size_t len);
4ea00e4f
JD
392 void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx,
393 const void *src, size_t len);
58aa5d24
MD
394 void (*event_memset)(struct lib_ring_buffer_ctx *ctx,
395 int c, size_t len);
16f78f3a
MD
396 void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src,
397 size_t len);
398 void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx,
399 const char __user *src, size_t len);
1ec3f75a
MD
400 /*
401 * packet_avail_size returns the available size in the current
402 * packet. Note that the size returned is only a hint, since it
403 * may change due to concurrent writes.
404 */
405 size_t (*packet_avail_size)(struct channel *chan);
71c1d843 406 wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
24cedcfe
MD
407 wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
408 int (*is_finalized)(struct channel *chan);
254ec7bc 409 int (*is_disabled)(struct channel *chan);
3b731ab1
JD
410 int (*timestamp_begin) (const struct lib_ring_buffer_config *config,
411 struct lib_ring_buffer *bufb,
412 uint64_t *timestamp_begin);
413 int (*timestamp_end) (const struct lib_ring_buffer_config *config,
414 struct lib_ring_buffer *bufb,
415 uint64_t *timestamp_end);
416 int (*events_discarded) (const struct lib_ring_buffer_config *config,
417 struct lib_ring_buffer *bufb,
418 uint64_t *events_discarded);
419 int (*content_size) (const struct lib_ring_buffer_config *config,
420 struct lib_ring_buffer *bufb,
421 uint64_t *content_size);
422 int (*packet_size) (const struct lib_ring_buffer_config *config,
423 struct lib_ring_buffer *bufb,
424 uint64_t *packet_size);
425 int (*stream_id) (const struct lib_ring_buffer_config *config,
426 struct lib_ring_buffer *bufb,
427 uint64_t *stream_id);
2348ca17
JD
428 int (*current_timestamp) (const struct lib_ring_buffer_config *config,
429 struct lib_ring_buffer *bufb,
430 uint64_t *ts);
5b3cf4f9
JD
431 int (*sequence_number) (const struct lib_ring_buffer_config *config,
432 struct lib_ring_buffer *bufb,
433 uint64_t *seq);
5594698f
JD
434 int (*instance_id) (const struct lib_ring_buffer_config *config,
435 struct lib_ring_buffer *bufb,
436 uint64_t *id);
85a9ca7f
MD
437};
438
a90917c3 439struct lttng_transport {
a33c9927
MD
440 char *name;
441 struct module *owner;
442 struct list_head node;
a90917c3 443 struct lttng_channel_ops ops;
a33c9927
MD
444};
445
80f87dd2
MD
446struct lttng_syscall_filter;
447
3c997079
MD
448#define LTTNG_EVENT_HT_BITS 12
449#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
450
451struct lttng_event_ht {
452 struct hlist_head table[LTTNG_EVENT_HT_SIZE];
453};
454
a90917c3 455struct lttng_channel {
c099397a 456 unsigned int id;
85a9ca7f 457 struct channel *chan; /* Channel buffers */
e64957da 458 int enabled;
f1676205 459 struct lttng_ctx *ctx;
85a9ca7f 460 /* Event ID management */
a90917c3 461 struct lttng_session *session;
85a9ca7f
MD
462 struct file *file; /* File associated to channel */
463 unsigned int free_event_id; /* Next event ID to allocate */
464 struct list_head list; /* Channel list */
a90917c3
MD
465 struct lttng_channel_ops *ops;
466 struct lttng_transport *transport;
467 struct lttng_event **sc_table; /* for syscall tracing */
468 struct lttng_event **compat_sc_table;
5b7ac358
MD
469 struct lttng_event **sc_exit_table; /* for syscall exit tracing */
470 struct lttng_event **compat_sc_exit_table;
a90917c3
MD
471 struct lttng_event *sc_unknown; /* for unknown syscalls */
472 struct lttng_event *sc_compat_unknown;
5b7ac358
MD
473 struct lttng_event *sc_exit_unknown;
474 struct lttng_event *compat_sc_exit_unknown;
80f87dd2 475 struct lttng_syscall_filter *sc_filter;
9115fbdc 476 int header_type; /* 0: unset, 1: compact, 2: large */
d83004aa 477 enum channel_type channel_type;
ad594e3a 478 int syscall_all;
80f87dd2
MD
479 unsigned int metadata_dumped:1,
480 sys_enter_registered:1,
481 sys_exit_registered:1,
3c997079 482 tstate:1; /* Transient enable state */
85a9ca7f
MD
483};
484
d83004aa
JD
485struct lttng_metadata_stream {
486 void *priv; /* Ring buffer private data */
487 struct lttng_metadata_cache *metadata_cache;
f613e3e6
MD
488 unsigned int metadata_in; /* Bytes read from the cache */
489 unsigned int metadata_out; /* Bytes consumed from stream */
d83004aa
JD
490 int finalized; /* Has channel been finalized */
491 wait_queue_head_t read_wait; /* Reader buffer-level wait queue */
492 struct list_head list; /* Stream list */
b3b8072b 493 struct lttng_transport *transport;
9616f0bf 494 uint64_t version; /* Current version of the metadata cache */
122c63cb 495 bool coherent; /* Stream in a coherent state */
d83004aa
JD
496};
497
114667d5
MD
498#define LTTNG_DYNAMIC_LEN_STACK_SIZE 128
499
500struct lttng_dynamic_len_stack {
501 size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE];
502 size_t offset;
503};
504
505DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack);
e0130fab
MD
506
507/*
d1f652f8 508 * struct lttng_id_tracker declared in header due to deferencing of *v
e0130fab
MD
509 * in RCU_INITIALIZER(v).
510 */
d1f652f8
MD
511#define LTTNG_ID_HASH_BITS 6
512#define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS)
e0130fab 513
d1f652f8
MD
514enum tracker_type {
515 TRACKER_PID,
516 TRACKER_VPID,
517 TRACKER_UID,
518 TRACKER_VUID,
519 TRACKER_GID,
520 TRACKER_VGID,
521
522 TRACKER_UNKNOWN,
523};
524
525struct lttng_id_tracker_rcu {
526 struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE];
527};
528
529struct lttng_id_tracker {
530 struct lttng_session *session;
531 enum tracker_type tracker_type;
532 struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */
e0130fab
MD
533};
534
d1f652f8 535struct lttng_id_hash_node {
7e6f9ef6 536 struct hlist_node hlist;
d1f652f8 537 int id;
7e6f9ef6
MD
538};
539
a90917c3 540struct lttng_session {
85a9ca7f 541 int active; /* Is trace session active ? */
8070f5c0 542 int been_active; /* Has trace session been active ? */
85a9ca7f
MD
543 struct file *file; /* File associated to session */
544 struct list_head chan; /* Channel list head */
545 struct list_head events; /* Event list head */
546 struct list_head list; /* Session list */
c099397a 547 unsigned int free_chan_id; /* Next chan ID to allocate */
d793d5e1 548 uuid_le uuid; /* Trace session unique ID */
d83004aa 549 struct lttng_metadata_cache *metadata_cache;
d1f652f8
MD
550 struct lttng_id_tracker pid_tracker;
551 struct lttng_id_tracker vpid_tracker;
552 struct lttng_id_tracker uid_tracker;
553 struct lttng_id_tracker vuid_tracker;
554 struct lttng_id_tracker gid_tracker;
555 struct lttng_id_tracker vgid_tracker;
3c997079
MD
556 unsigned int metadata_dumped:1,
557 tstate:1; /* Transient enable state */
558 /* List of enablers */
559 struct list_head enablers_head;
560 /* Hash table of events */
561 struct lttng_event_ht events_ht;
7f859fbf 562 char name[LTTNG_KERNEL_SESSION_NAME_LEN];
1c88f269 563 char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
85a9ca7f
MD
564};
565
d83004aa
JD
566struct lttng_metadata_cache {
567 char *data; /* Metadata cache */
568 unsigned int cache_alloc; /* Metadata allocated size (bytes) */
569 unsigned int metadata_written; /* Number of bytes written in metadata cache */
3780dda9 570 atomic_t producing; /* Metadata being produced (incomplete) */
d83004aa
JD
571 struct kref refcount; /* Metadata cache usage */
572 struct list_head metadata_stream; /* Metadata stream list */
a36580d5 573 uuid_le uuid; /* Trace session unique ID (copy) */
9616f0bf
JD
574 struct mutex lock; /* Produce/consume lock */
575 uint64_t version; /* Current version of the metadata */
d83004aa
JD
576};
577
3c997079
MD
578void lttng_lock_sessions(void);
579void lttng_unlock_sessions(void);
580
581struct list_head *lttng_get_probe_list_head(void);
582
583struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type,
584 struct lttng_kernel_event *event_param,
585 struct lttng_channel *chan);
586
587int lttng_enabler_enable(struct lttng_enabler *enabler);
588int lttng_enabler_disable(struct lttng_enabler *enabler);
589int lttng_fix_pending_events(void);
590int lttng_session_active(void);
591
a90917c3
MD
592struct lttng_session *lttng_session_create(void);
593int lttng_session_enable(struct lttng_session *session);
594int lttng_session_disable(struct lttng_session *session);
595void lttng_session_destroy(struct lttng_session *session);
9616f0bf 596int lttng_session_metadata_regenerate(struct lttng_session *session);
601252cf 597int lttng_session_statedump(struct lttng_session *session);
d83004aa 598void metadata_cache_destroy(struct kref *kref);
4e3c1b9b 599
a90917c3 600struct lttng_channel *lttng_channel_create(struct lttng_session *session,
5dbbdb43
MD
601 const char *transport_name,
602 void *buf_addr,
603 size_t subbuf_size, size_t num_subbuf,
604 unsigned int switch_timer_interval,
d83004aa
JD
605 unsigned int read_timer_interval,
606 enum channel_type channel_type);
a90917c3 607struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
4e3c1b9b
MD
608 int overwrite, void *buf_addr,
609 size_t subbuf_size, size_t num_subbuf,
610 unsigned int switch_timer_interval,
611 unsigned int read_timer_interval);
4e3c1b9b 612
d83004aa 613void lttng_metadata_channel_destroy(struct lttng_channel *chan);
a90917c3 614struct lttng_event *lttng_event_create(struct lttng_channel *chan,
3c997079
MD
615 struct lttng_kernel_event *event_param,
616 void *filter,
617 const struct lttng_event_desc *event_desc,
618 enum lttng_kernel_instrumentation itype);
33a39a3c
MD
619struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
620 struct lttng_kernel_event *event_param,
621 void *filter,
622 const struct lttng_event_desc *event_desc,
623 enum lttng_kernel_instrumentation itype);
6dccd6c1
JD
624struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
625 struct lttng_kernel_old_event *old_event_param,
626 void *filter,
627 const struct lttng_event_desc *internal_desc);
c0e31d2e 628
a90917c3
MD
629int lttng_channel_enable(struct lttng_channel *channel);
630int lttng_channel_disable(struct lttng_channel *channel);
631int lttng_event_enable(struct lttng_event *event);
632int lttng_event_disable(struct lttng_event *event);
e64957da 633
a90917c3
MD
634void lttng_transport_register(struct lttng_transport *transport);
635void lttng_transport_unregister(struct lttng_transport *transport);
11b5a3c2 636
360f38ea 637void synchronize_trace(void);
80996790 638int lttng_abi_init(void);
6dccd6c1 639int lttng_abi_compat_old_init(void);
80996790 640void lttng_abi_exit(void);
6dccd6c1 641void lttng_abi_compat_old_exit(void);
1c25284c 642
a90917c3
MD
643int lttng_probe_register(struct lttng_probe_desc *desc);
644void lttng_probe_unregister(struct lttng_probe_desc *desc);
645const struct lttng_event_desc *lttng_event_get(const char *name);
646void lttng_event_put(const struct lttng_event_desc *desc);
647int lttng_probes_init(void);
648void lttng_probes_exit(void);
1ec65de1 649
b3b8072b 650int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
122c63cb 651 struct channel *chan, bool *coherent);
d83004aa 652
d1f652f8
MD
653int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
654int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf);
655void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu);
656bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id);
657int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id);
658int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id);
e0130fab 659
d1f652f8
MD
660int lttng_session_track_id(struct lttng_session *session,
661 enum tracker_type tracker_type, int id);
662int lttng_session_untrack_id(struct lttng_session *session,
663 enum tracker_type tracker_type, int id);
e0130fab 664
d1f652f8
MD
665int lttng_session_list_tracker_ids(struct lttng_session *session,
666 enum tracker_type tracker_type);
7e6f9ef6 667
2754583e
MD
668void lttng_clock_ref(void);
669void lttng_clock_unref(void);
670
3a523f5b 671#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
a90917c3
MD
672int lttng_syscalls_register(struct lttng_channel *chan, void *filter);
673int lttng_syscalls_unregister(struct lttng_channel *chan);
ad594e3a 674int lttng_syscalls_destroy(struct lttng_channel *chan);
80f87dd2 675int lttng_syscall_filter_enable(struct lttng_channel *chan,
ad594e3a 676 struct lttng_event *event);
80f87dd2 677int lttng_syscall_filter_disable(struct lttng_channel *chan,
ad594e3a 678 struct lttng_event *event);
12e579db
MD
679long lttng_channel_syscall_mask(struct lttng_channel *channel,
680 struct lttng_kernel_syscall_mask __user *usyscall_mask);
1ec65de1 681#else
a90917c3 682static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
1ec65de1
MD
683{
684 return -ENOSYS;
685}
686
a90917c3 687static inline int lttng_syscalls_unregister(struct lttng_channel *chan)
1ec65de1
MD
688{
689 return 0;
690}
80f87dd2 691
ad594e3a
MD
692static inline int lttng_syscalls_destroy(struct lttng_channel *chan)
693{
694 return 0;
695}
696
f127e61e 697static inline int lttng_syscall_filter_enable(struct lttng_channel *chan,
5fecce37 698 struct lttng_event *event)
80f87dd2
MD
699{
700 return -ENOSYS;
701}
702
f127e61e 703static inline int lttng_syscall_filter_disable(struct lttng_channel *chan,
5fecce37 704 struct lttng_event *event)
80f87dd2
MD
705{
706 return -ENOSYS;
707}
12e579db 708
f127e61e 709static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
12e579db
MD
710 struct lttng_kernel_syscall_mask __user *usyscall_mask)
711{
712 return -ENOSYS;
713}
1ec65de1
MD
714#endif
715
07dfc1d0
MD
716void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
717int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
718 struct lttng_kernel_filter_bytecode __user *bytecode);
f127e61e
MD
719void lttng_enabler_event_link_bytecode(struct lttng_event *event,
720 struct lttng_enabler *enabler);
b3fdf78b 721void lttng_free_event_filter_runtime(struct lttng_event *event);
07dfc1d0 722
114667d5
MD
723int lttng_probes_init(void);
724
07dfc1d0
MD
725extern struct lttng_ctx *lttng_static_ctx;
726
727int lttng_context_init(void);
728void lttng_context_exit(void);
2dccf128 729struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
a9dd15da 730void lttng_context_update(struct lttng_ctx *ctx);
44252f0f 731int lttng_find_context(struct lttng_ctx *ctx, const char *name);
07dfc1d0 732int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
8289661d
MD
733void lttng_remove_context_field(struct lttng_ctx **ctx,
734 struct lttng_ctx_field *field);
2dccf128 735void lttng_destroy_context(struct lttng_ctx *ctx);
8070f5c0 736int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
b3699d90 737int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
a2563e83 738int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
a8ad3613 739int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
53f1f0ca 740int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
b64bc438
MD
741int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
742int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
743int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
744int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
745int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
975da2c0 746int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
79150a49
JD
747int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx);
748int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx);
749#if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
750int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx);
751#else
752static inline
753int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
754{
755 return -ENOSYS;
756}
757#endif
758#ifdef CONFIG_PREEMPT_RT_FULL
759int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx);
760#else
761static inline
762int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
763{
764 return -ENOSYS;
765}
766#endif
2fa2d39a
FG
767
768int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type);
769
a6cf40a4 770#if defined(CONFIG_CGROUPS) && \
2d042821 771 ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
a6cf40a4
MJ
772 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
773int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx);
774#else
775static inline
776int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx)
777{
778 return -ENOSYS;
779}
780#endif
781
782#if defined(CONFIG_IPC_NS) && \
2d042821 783 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
a6cf40a4
MJ
784int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx);
785#else
786static inline
787int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx)
788{
789 return -ENOSYS;
790}
791#endif
792
793#if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
2d042821 794 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
a6cf40a4
MJ
795int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx);
796#else
797static inline
798int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx)
799{
800 return -ENOSYS;
801}
802#endif
803
804#if defined(CONFIG_NET_NS) && \
2d042821 805 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
a6cf40a4
MJ
806int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx);
807#else
808static inline
809int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx)
810{
811 return -ENOSYS;
812}
813#endif
814
815#if defined(CONFIG_PID_NS) && \
2d042821 816 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
a6cf40a4
MJ
817int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx);
818#else
819static inline
820int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx)
821{
822 return -ENOSYS;
823}
824#endif
825
826#if defined(CONFIG_USER_NS) && \
2d042821 827 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
a6cf40a4
MJ
828int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx);
829#else
830static inline
831int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx)
832{
833 return -ENOSYS;
834}
835#endif
836
837#if defined(CONFIG_UTS_NS) && \
2d042821 838 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
a6cf40a4
MJ
839int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx);
840#else
841static inline
842int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
843{
844 return -ENOSYS;
845}
846#endif
847
dc923e75
MJ
848int lttng_add_uid_to_ctx(struct lttng_ctx **ctx);
849int lttng_add_euid_to_ctx(struct lttng_ctx **ctx);
850int lttng_add_suid_to_ctx(struct lttng_ctx **ctx);
851int lttng_add_gid_to_ctx(struct lttng_ctx **ctx);
852int lttng_add_egid_to_ctx(struct lttng_ctx **ctx);
853int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx);
854int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx);
855int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx);
856int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx);
857int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx);
858int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx);
859int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx);
860
8a3af9ee 861#if defined(CONFIG_PERF_EVENTS)
c24a0d71
MD
862int lttng_add_perf_counter_to_ctx(uint32_t type,
863 uint64_t config,
864 const char *name,
865 struct lttng_ctx **ctx);
1e367326
MD
866int lttng_cpuhp_perf_counter_online(unsigned int cpu,
867 struct lttng_cpuhp_node *node);
868int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
869 struct lttng_cpuhp_node *node);
1d443b34
MD
870#else
871static inline
872int lttng_add_perf_counter_to_ctx(uint32_t type,
873 uint64_t config,
874 const char *name,
875 struct lttng_ctx **ctx)
876{
877 return -ENOSYS;
878}
1e367326
MD
879static inline
880int lttng_cpuhp_perf_counter_online(unsigned int cpu,
881 struct lttng_cpuhp_node *node)
882{
883 return 0;
884}
885static inline
886int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
887 struct lttng_cpuhp_node *node)
888{
889 return 0;
890}
1d443b34 891#endif
02119ee5 892
0c956676
MD
893int lttng_logger_init(void);
894void lttng_logger_exit(void);
895
c337ddc2
MD
896extern int lttng_statedump_start(struct lttng_session *session);
897
acd614cc 898#ifdef CONFIG_KPROBES
f17701fb
MD
899int lttng_kprobes_register(const char *name,
900 const char *symbol_name,
901 uint64_t offset,
902 uint64_t addr,
a90917c3
MD
903 struct lttng_event *event);
904void lttng_kprobes_unregister(struct lttng_event *event);
905void lttng_kprobes_destroy_private(struct lttng_event *event);
acd614cc
MD
906#else
907static inline
908int lttng_kprobes_register(const char *name,
909 const char *symbol_name,
910 uint64_t offset,
911 uint64_t addr,
a90917c3 912 struct lttng_event *event)
acd614cc
MD
913{
914 return -ENOSYS;
915}
916
25f53c39 917static inline
a90917c3 918void lttng_kprobes_unregister(struct lttng_event *event)
acd614cc
MD
919{
920}
edeb3137
MD
921
922static inline
a90917c3 923void lttng_kprobes_destroy_private(struct lttng_event *event)
edeb3137
MD
924{
925}
acd614cc 926#endif
d6d808f3 927
3aed4dca
FD
928int lttng_event_add_callsite(struct lttng_event *event,
929 struct lttng_kernel_event_callsite *callsite);
e33fc900 930
149b9a9d
YB
931#ifdef CONFIG_UPROBES
932int lttng_uprobes_register(const char *name,
3aed4dca
FD
933 int fd, struct lttng_event *event);
934int lttng_uprobes_add_callsite(struct lttng_event *event,
935 struct lttng_kernel_event_callsite *callsite);
149b9a9d
YB
936void lttng_uprobes_unregister(struct lttng_event *event);
937void lttng_uprobes_destroy_private(struct lttng_event *event);
938#else
939static inline
940int lttng_uprobes_register(const char *name,
3aed4dca
FD
941 int fd, struct lttng_event *event)
942{
943 return -ENOSYS;
944}
945
946static inline
947int lttng_uprobes_add_callsite(struct lttng_event *event,
e33fc900 948 struct lttng_kernel_event_callsite *callsite)
149b9a9d
YB
949{
950 return -ENOSYS;
951}
952
953static inline
954void lttng_uprobes_unregister(struct lttng_event *event)
955{
956}
957
958static inline
959void lttng_uprobes_destroy_private(struct lttng_event *event)
960{
961}
962#endif
963
7371f44c
MD
964#ifdef CONFIG_KRETPROBES
965int lttng_kretprobes_register(const char *name,
966 const char *symbol_name,
967 uint64_t offset,
968 uint64_t addr,
a90917c3
MD
969 struct lttng_event *event_entry,
970 struct lttng_event *event_exit);
971void lttng_kretprobes_unregister(struct lttng_event *event);
972void lttng_kretprobes_destroy_private(struct lttng_event *event);
a0493bef
MD
973int lttng_kretprobes_event_enable_state(struct lttng_event *event,
974 int enable);
7371f44c
MD
975#else
976static inline
977int lttng_kretprobes_register(const char *name,
978 const char *symbol_name,
979 uint64_t offset,
980 uint64_t addr,
a90917c3
MD
981 struct lttng_event *event_entry,
982 struct lttng_event *event_exit)
7371f44c
MD
983{
984 return -ENOSYS;
985}
986
987static inline
a90917c3 988void lttng_kretprobes_unregister(struct lttng_event *event)
7371f44c
MD
989{
990}
991
992static inline
a90917c3 993void lttng_kretprobes_destroy_private(struct lttng_event *event)
7371f44c
MD
994{
995}
a0493bef
MD
996
997static inline
998int lttng_kretprobes_event_enable_state(struct lttng_event *event,
999 int enable)
1000{
1001 return -ENOSYS;
1002}
7371f44c
MD
1003#endif
1004
3db41b2c 1005int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
57105fc2 1006
271b6681 1007extern const struct file_operations lttng_tracepoint_list_fops;
2d2464bd 1008extern const struct file_operations lttng_syscall_list_fops;
271b6681 1009
ef200626 1010#define TRACEPOINT_HAS_DATA_ARG
ef200626 1011
a90917c3 1012#endif /* _LTTNG_EVENTS_H */
This page took 0.10194 seconds and 4 git commands to generate.