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