sequence and variant types: use previous field for length/tag if NULL
[lttng-modules.git] / include / lttng / events.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9f36eaed 2 *
2df37e95 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
5f4c791e 13#include <lttng/kernel-version.h>
4e3c1b9b 14#include <linux/list.h>
d6d808f3 15#include <linux/kprobes.h>
d83004aa 16#include <linux/kref.h>
41f229dc 17#include <linux/uuid.h>
754d534a 18#include <linux/irq_work.h>
149b9a9d 19#include <wrapper/uprobes.h>
2df37e95
MD
20#include <lttng/cpuhotplug.h>
21#include <lttng/tracer.h>
22#include <lttng/abi.h>
23#include <lttng/abi-old.h>
24#include <lttng/endian.h>
4e3c1b9b 25
e97dc605 26#define lttng_is_signed_type(type) (((type) -1) < (type) 1)
9e7e4892 27
a90917c3
MD
28struct lttng_channel;
29struct lttng_session;
d83004aa 30struct lttng_metadata_cache;
1c25284c 31struct lib_ring_buffer_ctx;
ba1f5986 32struct perf_event;
833ad6a0 33struct perf_event_attr;
3b731ab1 34struct lib_ring_buffer_config;
4e3c1b9b 35
c0edae1d
MD
36/* Type description */
37
12bb2edb
MD
38enum lttng_kernel_type {
39 lttng_kernel_type_integer,
40 lttng_kernel_type_string,
437d5aa5
MD
41 lttng_kernel_type_enum,
42 lttng_kernel_type_array,
43 lttng_kernel_type_sequence,
44 lttng_kernel_type_struct,
45 lttng_kernel_type_variant,
12bb2edb 46 NR_LTTNG_KERNEL_TYPES,
c0edae1d
MD
47};
48
28cbcb59
MD
49enum lttng_kernel_string_encoding {
50 lttng_kernel_string_encoding_none = 0,
51 lttng_kernel_string_encoding_UTF8 = 1,
52 lttng_kernel_string_encoding_ASCII = 2,
53 NR_LTTNG_KERNEL_STRING_ENCODING,
c0edae1d
MD
54};
55
d83004aa
JD
56enum channel_type {
57 PER_CPU_CHANNEL,
58 METADATA_CHANNEL,
59};
60
a28cc520 61struct lttng_kernel_enum_value {
141ddf28
MD
62 unsigned long long value;
63 unsigned int signedness:1;
64};
65
a28cc520
MD
66struct lttng_kernel_enum_entry {
67 struct lttng_kernel_enum_value start, end; /* start and end are inclusive */
c0edae1d 68 const char *string;
08ad1061
PP
69 struct {
70 unsigned int is_auto:1;
71 } options;
c0edae1d
MD
72};
73
437d5aa5
MD
74/*
75 * struct lttng_kernel_type_common is fixed-size. Its children inherits
76 * from it by embedding struct lttng_kernel_type_common as its first field.
77 */
78struct lttng_kernel_type_common {
79 enum lttng_kernel_type type;
80};
81
82struct lttng_kernel_type_integer {
83 struct lttng_kernel_type_common parent;
c099397a
MD
84 unsigned int size; /* in bits */
85 unsigned short alignment; /* in bits */
9cccf98a
MD
86 unsigned int signedness:1,
87 reverse_byte_order:1;
e0a7a7c4 88 unsigned int base; /* 2, 8, 10, 16, for pretty print */
437d5aa5
MD
89};
90
91struct lttng_kernel_type_string {
92 struct lttng_kernel_type_common parent;
28cbcb59 93 enum lttng_kernel_string_encoding encoding;
c099397a
MD
94};
95
437d5aa5
MD
96struct lttng_kernel_type_enum {
97 struct lttng_kernel_type_common parent;
98 const struct lttng_kernel_enum_desc *desc; /* Enumeration mapping */
99 const struct lttng_kernel_type_common *container_type;
100};
101
102struct lttng_kernel_type_array {
103 struct lttng_kernel_type_common parent;
104 const struct lttng_kernel_type_common *elem_type;
105 unsigned int length; /* Num. elems. */
106 unsigned int alignment;
107 enum lttng_kernel_string_encoding encoding;
108};
109
110struct lttng_kernel_type_sequence {
111 struct lttng_kernel_type_common parent;
51ef4536 112 const char *length_name; /* Length field name. If NULL, use previous field. */
437d5aa5
MD
113 const struct lttng_kernel_type_common *elem_type;
114 unsigned int alignment; /* Alignment before elements. */
115 enum lttng_kernel_string_encoding encoding;
116};
117
118struct lttng_kernel_type_struct {
119 struct lttng_kernel_type_common parent;
120 unsigned int nr_fields;
121 const struct lttng_kernel_event_field **fields; /* Array of pointers to fields. */
122 unsigned int alignment;
123};
124
125struct lttng_kernel_type_variant {
126 struct lttng_kernel_type_common parent;
51ef4536 127 const char *tag_name; /* Tag field name. If NULL, use previous field. */
437d5aa5
MD
128 const struct lttng_kernel_event_field **choices; /* Array of pointers to fields. */
129 unsigned int nr_choices;
130 unsigned int alignment;
c099397a
MD
131};
132
d96a4a7a 133struct lttng_kernel_enum_desc {
c099397a 134 const char *name;
437d5aa5 135 const struct lttng_kernel_enum_entry **entries;
141ddf28 136 unsigned int nr_entries;
c099397a 137};
c0edae1d
MD
138
139/* Event field description */
140
437d5aa5 141struct lttng_kernel_event_field {
c0edae1d 142 const char *name;
437d5aa5 143 const struct lttng_kernel_type_common *type;
f127e61e 144 unsigned int nowrite:1, /* do not write into trace */
ceabb767
MD
145 user:1, /* fetch from user-space */
146 nofilter:1; /* do not consider for filter */
c0edae1d
MD
147};
148
437d5aa5
MD
149#define lttng_kernel_static_type_integer(_size, _alignment, _signedness, _byte_order, _base) \
150 ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_integer, { \
151 .parent = { \
152 .type = lttng_kernel_type_integer, \
153 }, \
154 .size = (_size), \
155 .alignment = (_alignment), \
156 .signedness = (_signedness), \
157 .reverse_byte_order = (_byte_order) != __BYTE_ORDER, \
158 .base = (_base), \
159 }))
160
161#define lttng_kernel_static_type_integer_from_type(_type, _byte_order, _base) \
162 lttng_kernel_static_type_integer(sizeof(_type) * CHAR_BIT, \
163 lttng_alignof(_type) * CHAR_BIT, \
164 lttng_is_signed_type(_type), \
165 _byte_order, \
166 _base)
167
168#define lttng_kernel_static_type_enum(_desc, _container_type) \
169 ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_enum, { \
170 .parent = { \
171 .type = lttng_kernel_type_enum, \
172 }, \
173 .desc = (_desc), \
174 .container_type = (_container_type), \
175 }))
176
177#define lttng_kernel_static_type_array(_length, _elem_type, _alignment, _encoding) \
178 ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_array, { \
179 .parent = { \
180 .type = lttng_kernel_type_array, \
181 }, \
182 .length = (_length), \
183 .alignment = (_alignment), \
184 .encoding = lttng_kernel_string_encoding_##_encoding, \
185 .elem_type = (_elem_type), \
186 }))
187
188#define lttng_kernel_static_type_array_text(_length) \
189 lttng_kernel_static_type_array(_length, \
190 lttng_kernel_static_type_integer(sizeof(char) * CHAR_BIT, \
191 lttng_alignof(char) * CHAR_BIT, lttng_is_signed_type(char), \
192 __BYTE_ORDER, 10), \
193 0, UTF8)
194
195#define lttng_kernel_static_type_sequence(_length_name, _elem_type, _alignment, _encoding) \
196 ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_sequence, { \
197 .parent = { \
198 .type = lttng_kernel_type_sequence, \
199 }, \
200 .length_name = (_length_name), \
201 .alignment = (_alignment), \
202 .encoding = lttng_kernel_string_encoding_##_encoding, \
203 .elem_type = (_elem_type), \
204 }))
205
206#define lttng_kernel_static_type_string(_encoding) \
207 ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_string, { \
208 .parent = { \
209 .type = lttng_kernel_type_string, \
210 }, \
211 .encoding = lttng_kernel_string_encoding_##_encoding, \
212 }))
213
214#define lttng_kernel_static_type_struct(_nr_fields, _fields, _alignment) \
215 ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_struct, { \
216 .parent = { \
217 .type = lttng_kernel_type_struct, \
218 }, \
219 .nr_fields = (_nr_fields), \
220 .fields = _fields, \
221 .alignment = (_alignment), \
222 }))
223
224#define lttng_kernel_static_type_variant(_nr_choices, _choices, _tag_name, _alignment) \
225 ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_variant, { \
226 .parent = { \
227 .type = lttng_kernel_type_variant, \
228 }, \
229 .tag_name = (_tag_name), \
230 .choices = _choices, \
231 .nr_choices = (_nr_choices), \
232 .alignment = (_alignment), \
233 }))
234
235#define lttng_kernel_static_event_field(_name, _type, _nowrite, _user, _nofilter) \
236 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_event_field, { \
237 .name = (_name), \
238 .type = (_type), \
239 .nowrite = (_nowrite), \
240 .user = (_user), \
241 .nofilter = (_nofilter), \
242 })
243
244#define lttng_kernel_static_event_field_array(_fields...) \
245 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_event_field *, \
246 _fields \
247 )
248
249#define lttng_kernel_static_ctx_field(_event_field, _get_size, _get_size_arg, _record, _get_value, _destroy, _priv) \
250 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \
251 .event_field = (_event_field), \
252 .get_size = (_get_size), \
253 .get_size_arg = (_get_size_arg), \
254 .record = (_record), \
255 .get_value = (_get_value), \
256 .destroy = (_destroy), \
257 .priv = (_priv), \
258 })
259
260#define lttng_kernel_static_enum_entry_value(_string, _value) \
261 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \
262 .start = { \
263 .signedness = lttng_is_signed_type(__typeof__(_value)), \
264 .value = lttng_is_signed_type(__typeof__(_value)) ? \
265 (long long) (_value) : (_value), \
266 }, \
267 .end = { \
268 .signedness = lttng_is_signed_type(__typeof__(_value)), \
269 .value = lttng_is_signed_type(__typeof__(_value)) ? \
270 (long long) (_value) : (_value), \
271 }, \
272 .string = (_string), \
273 }),
274
275#define lttng_kernel_static_enum_entry_range(_string, _range_start, _range_end) \
276 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \
277 .start = { \
278 .signedness = lttng_is_signed_type(__typeof__(_range_start)), \
279 .value = lttng_is_signed_type(__typeof__(_range_start)) ? \
280 (long long) (_range_start) : (_range_start), \
281 }, \
282 .end = { \
283 .signedness = lttng_is_signed_type(__typeof__(_range_end)), \
284 .value = lttng_is_signed_type(__typeof__(_range_end)) ? \
285 (long long) (_range_end) : (_range_end), \
286 }, \
287 .string = (_string), \
288 }),
289
290#define lttng_kernel_static_enum_entry_auto(_string) \
291 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \
292 .start = { \
293 .signedness = -1, \
294 .value = -1, \
295 }, \
296 .end = { \
297 .signedness = -1, \
298 .value = -1, \
299 }, \
300 .string = (_string), \
301 .options = { \
302 .is_auto = 1, \
303 } \
304 }),
305
07dfc1d0
MD
306union lttng_ctx_value {
307 int64_t s64;
308 const char *str;
309 double d;
310};
311
2001023e
MD
312/*
313 * We need to keep this perf counter field separately from struct
437d5aa5 314 * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses.
2001023e
MD
315 */
316struct lttng_perf_counter_field {
5f4c791e 317#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
1e367326
MD
318 struct lttng_cpuhp_node cpuhp_prepare;
319 struct lttng_cpuhp_node cpuhp_online;
320#else
2001023e
MD
321 struct notifier_block nb;
322 int hp_enable;
1e367326 323#endif
2001023e
MD
324 struct perf_event_attr *attr;
325 struct perf_event **e; /* per-cpu array */
437d5aa5
MD
326 char *name;
327 struct lttng_kernel_event_field *event_field;
2001023e
MD
328};
329
79150a49 330struct lttng_probe_ctx {
e2d5dbc7 331 struct lttng_kernel_event_common *event;
79150a49
JD
332 uint8_t interruptible;
333};
334
437d5aa5
MD
335struct lttng_kernel_ctx_field {
336 const struct lttng_kernel_event_field *event_field;
f1676205 337 size_t (*get_size)(size_t offset);
437d5aa5 338 size_t (*get_size_arg)(size_t offset, struct lttng_kernel_ctx_field *field,
1474c8e2
FG
339 struct lib_ring_buffer_ctx *ctx,
340 struct lttng_channel *chan);
437d5aa5 341 void (*record)(struct lttng_kernel_ctx_field *field,
f1676205 342 struct lib_ring_buffer_ctx *ctx,
a90917c3 343 struct lttng_channel *chan);
437d5aa5 344 void (*get_value)(struct lttng_kernel_ctx_field *field,
79150a49 345 struct lttng_probe_ctx *lttng_probe_ctx,
07dfc1d0 346 union lttng_ctx_value *value);
437d5aa5 347 void (*destroy)(struct lttng_kernel_ctx_field *field);
3c1a57e8 348 void *priv;
ba1f5986
MD
349};
350
437d5aa5
MD
351struct lttng_kernel_ctx {
352 struct lttng_kernel_ctx_field *fields;
0d1a681e 353 unsigned int nr_fields;
ba1f5986 354 unsigned int allocated_fields;
a9dd15da 355 size_t largest_align; /* in bytes */
0d1a681e
MD
356};
357
437d5aa5
MD
358struct lttng_kernel_event_desc {
359 const char *event_name; /* lttng-modules name */
360 const char *event_kname; /* Linux kernel name (tracepoints) */
361 const struct lttng_kernel_probe_desc *probe_desc;
362 void (*probe_callback)(void);
363 const struct lttng_kernel_event_field **fields; /* event payload */
c0edae1d 364 unsigned int nr_fields;
dc7f600a 365 struct module *owner;
c0edae1d
MD
366};
367
437d5aa5
MD
368struct lttng_kernel_probe_desc {
369 const char *provider_name;
370 const struct lttng_kernel_event_desc **event_desc;
85a9ca7f
MD
371 unsigned int nr_events;
372 struct list_head head; /* chain registered probes */
3c997079
MD
373 struct list_head lazy_init_head;
374 int lazy; /* lazy registration */
85a9ca7f
MD
375};
376
7371f44c
MD
377struct lttng_krp; /* Kretprobe handling */
378
8a445457
MD
379enum lttng_kernel_bytecode_type {
380 LTTNG_KERNEL_BYTECODE_TYPE_FILTER,
381 LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE,
89ec2b91
FD
382};
383
384struct lttng_bytecode_node {
8a445457 385 enum lttng_kernel_bytecode_type type;
07dfc1d0
MD
386 struct list_head node;
387 struct lttng_enabler *enabler;
89ec2b91
FD
388 struct {
389 uint32_t len;
390 uint32_t reloc_offset;
391 uint64_t seqnum;
392 char data[];
393 } bc;
07dfc1d0
MD
394};
395
99d223ad
FD
396struct lttng_interpreter_output;
397
07dfc1d0
MD
398struct lttng_bytecode_runtime {
399 /* Associated bytecode */
8a445457 400 enum lttng_kernel_bytecode_type type;
89ec2b91 401 struct lttng_bytecode_node *bc;
8a445457
MD
402 int (*interpreter_func)(struct lttng_bytecode_runtime *kernel_bytecode,
403 const char *interpreter_stack_data,
a775608d 404 struct lttng_probe_ctx *lttng_probe_ctx,
8a445457 405 void *caller_ctx);
07dfc1d0
MD
406 int link_failed;
407 struct list_head node; /* list of bytecode runtime in event */
437d5aa5 408 struct lttng_kernel_ctx *ctx;
07dfc1d0
MD
409};
410
3c997079
MD
411/*
412 * Objects in a linked-list of enablers, owned by an event.
413 */
414struct lttng_enabler_ref {
415 struct list_head node; /* enabler ref list */
416 struct lttng_enabler *ref; /* backward ref */
417};
418
3aed4dca 419struct lttng_uprobe_handler {
e2d5dbc7 420 struct lttng_kernel_event_common *event;
3aed4dca
FD
421 loff_t offset;
422 struct uprobe_consumer up_consumer;
423 struct list_head node;
424};
425
8bf17deb
FD
426struct lttng_kprobe {
427 struct kprobe kp;
428 char *symbol_name;
429};
430
83b802dc
FD
431struct lttng_uprobe {
432 struct inode *inode;
433 struct list_head head;
434};
435
badfe9f5
MD
436enum lttng_syscall_entryexit {
437 LTTNG_SYSCALL_ENTRY,
438 LTTNG_SYSCALL_EXIT,
439};
440
441enum lttng_syscall_abi {
442 LTTNG_SYSCALL_ABI_NATIVE,
443 LTTNG_SYSCALL_ABI_COMPAT,
444};
445
8a445457
MD
446/*
447 * Result of the run_filter() callback.
448 */
449enum lttng_kernel_event_filter_result {
450 LTTNG_KERNEL_EVENT_FILTER_ACCEPT = 0,
451 LTTNG_KERNEL_EVENT_FILTER_REJECT = 1,
452};
453
a67ba386
MD
454struct lttng_kernel_event_common_private;
455
456enum lttng_kernel_event_type {
457 LTTNG_KERNEL_EVENT_TYPE_RECORDER = 0,
458 LTTNG_KERNEL_EVENT_TYPE_NOTIFIER = 1,
459};
460
461struct lttng_kernel_event_common {
462 struct lttng_kernel_event_common_private *priv; /* Private event interface */
463
464 enum lttng_kernel_event_type type;
465 /* Get child with container_of(). */
466
e64957da 467 int enabled;
a67ba386 468 int eval_filter; /* Need to evaluate filters */
8a445457 469 int (*run_filter)(const struct lttng_kernel_event_common *event,
a67ba386 470 const char *stack_data,
8a445457 471 struct lttng_probe_ctx *probe_ctx,
a67ba386 472 void *filter_ctx);
3c997079
MD
473};
474
a67ba386
MD
475struct lttng_kernel_event_recorder_private;
476
477struct lttng_kernel_event_recorder {
478 struct lttng_kernel_event_common parent;
479 struct lttng_kernel_event_recorder_private *priv; /* Private event record interface */
480
481 struct lttng_channel *chan;
c3eddb2e
MD
482};
483
a67ba386
MD
484struct lttng_kernel_notification_ctx {
485 int eval_capture; /* Capture evaluation available. */
486};
dffef45d 487
a67ba386 488struct lttng_kernel_event_notifier_private;
8a8ac9a8 489
a67ba386
MD
490struct lttng_kernel_event_notifier {
491 struct lttng_kernel_event_common parent;
492 struct lttng_kernel_event_notifier_private *priv; /* Private event notifier interface */
dffef45d 493
a67ba386
MD
494 int eval_capture; /* Need to evaluate capture */
495 void (*notification_send)(struct lttng_kernel_event_notifier *event_notifier,
a67ba386 496 const char *stack_data,
a775608d 497 struct lttng_probe_ctx *probe_ctx,
a67ba386 498 struct lttng_kernel_notification_ctx *notif_ctx);
dffef45d
FD
499};
500
3b861b22
FD
501enum lttng_enabler_format_type {
502 LTTNG_ENABLER_FORMAT_STAR_GLOB,
503 LTTNG_ENABLER_FORMAT_NAME,
3c997079
MD
504};
505
506/*
507 * Enabler field, within whatever object is enabling an event. Target of
508 * backward reference.
509 */
510struct lttng_enabler {
3b861b22 511 enum lttng_enabler_format_type format_type;
3c997079 512
608ab495 513 /* head list of struct lttng_bytecode_node */
07dfc1d0 514 struct list_head filter_bytecode_head;
3c997079 515
606828e4 516 struct lttng_kernel_abi_event event_param;
b2bc0bc8 517 unsigned int enabled:1;
dffef45d
FD
518
519 uint64_t user_token; /* User-provided token. */
b2bc0bc8
FD
520};
521
522struct lttng_event_enabler {
523 struct lttng_enabler base;
524 struct list_head node; /* per-session list of enablers */
3c997079 525 struct lttng_channel *chan;
85a9ca7f
MD
526};
527
dffef45d
FD
528struct lttng_event_notifier_enabler {
529 struct lttng_enabler base;
99f52fcc 530 uint64_t error_counter_index;
dffef45d
FD
531 struct list_head node; /* List of event_notifier enablers */
532 struct lttng_event_notifier_group *group;
99d223ad
FD
533
534 /* head list of struct lttng_bytecode_node */
535 struct list_head capture_bytecode_head;
536 uint64_t num_captures;
dffef45d
FD
537};
538
99d223ad 539
b2bc0bc8
FD
540static inline
541struct lttng_enabler *lttng_event_enabler_as_enabler(
542 struct lttng_event_enabler *event_enabler)
543{
544 return &event_enabler->base;
545}
546
dffef45d
FD
547static inline
548struct lttng_enabler *lttng_event_notifier_enabler_as_enabler(
549 struct lttng_event_notifier_enabler *event_notifier_enabler)
550{
551 return &event_notifier_enabler->base;
552}
b2bc0bc8 553
a90917c3 554struct lttng_channel_ops {
85a9ca7f 555 struct channel *(*channel_create)(const char *name,
5cf4b87c 556 void *priv,
85a9ca7f
MD
557 void *buf_addr,
558 size_t subbuf_size, size_t num_subbuf,
559 unsigned int switch_timer_interval,
560 unsigned int read_timer_interval);
561 void (*channel_destroy)(struct channel *chan);
562 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
f71ecafa 563 int (*buffer_has_read_closed_stream)(struct channel *chan);
85a9ca7f 564 void (*buffer_read_close)(struct lib_ring_buffer *buf);
4e1f08f4 565 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
64c796d8 566 uint32_t event_id);
85a9ca7f
MD
567 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
568 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
569 size_t len);
4ea00e4f
JD
570 void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx,
571 const void *src, size_t len);
58aa5d24
MD
572 void (*event_memset)(struct lib_ring_buffer_ctx *ctx,
573 int c, size_t len);
16f78f3a
MD
574 void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src,
575 size_t len);
576 void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx,
577 const char __user *src, size_t len);
1ec3f75a
MD
578 /*
579 * packet_avail_size returns the available size in the current
580 * packet. Note that the size returned is only a hint, since it
581 * may change due to concurrent writes.
582 */
583 size_t (*packet_avail_size)(struct channel *chan);
71c1d843 584 wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
24cedcfe
MD
585 wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
586 int (*is_finalized)(struct channel *chan);
254ec7bc 587 int (*is_disabled)(struct channel *chan);
3b731ab1
JD
588 int (*timestamp_begin) (const struct lib_ring_buffer_config *config,
589 struct lib_ring_buffer *bufb,
590 uint64_t *timestamp_begin);
591 int (*timestamp_end) (const struct lib_ring_buffer_config *config,
592 struct lib_ring_buffer *bufb,
593 uint64_t *timestamp_end);
594 int (*events_discarded) (const struct lib_ring_buffer_config *config,
595 struct lib_ring_buffer *bufb,
596 uint64_t *events_discarded);
597 int (*content_size) (const struct lib_ring_buffer_config *config,
598 struct lib_ring_buffer *bufb,
599 uint64_t *content_size);
600 int (*packet_size) (const struct lib_ring_buffer_config *config,
601 struct lib_ring_buffer *bufb,
602 uint64_t *packet_size);
603 int (*stream_id) (const struct lib_ring_buffer_config *config,
604 struct lib_ring_buffer *bufb,
605 uint64_t *stream_id);
2348ca17
JD
606 int (*current_timestamp) (const struct lib_ring_buffer_config *config,
607 struct lib_ring_buffer *bufb,
608 uint64_t *ts);
5b3cf4f9
JD
609 int (*sequence_number) (const struct lib_ring_buffer_config *config,
610 struct lib_ring_buffer *bufb,
611 uint64_t *seq);
5594698f
JD
612 int (*instance_id) (const struct lib_ring_buffer_config *config,
613 struct lib_ring_buffer *bufb,
614 uint64_t *id);
85a9ca7f
MD
615};
616
a101fa10
MD
617struct lttng_counter_ops {
618 struct lib_counter *(*counter_create)(size_t nr_dimensions,
619 const size_t *max_nr_elem, /* for each dimension */
620 int64_t global_sum_step);
621 void (*counter_destroy)(struct lib_counter *counter);
622 int (*counter_add)(struct lib_counter *counter, const size_t *dimension_indexes,
623 int64_t v);
624 /*
625 * counter_read reads a specific cpu's counter if @cpu >= 0, or
626 * the global aggregation counter if @cpu == -1.
627 */
628 int (*counter_read)(struct lib_counter *counter, const size_t *dimension_indexes, int cpu,
629 int64_t *value, bool *overflow, bool *underflow);
630 /*
631 * counter_aggregate returns the total sum of all per-cpu counters and
632 * the global aggregation counter.
633 */
634 int (*counter_aggregate)(struct lib_counter *counter, const size_t *dimension_indexes,
635 int64_t *value, bool *overflow, bool *underflow);
636 int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes);
637};
638
a90917c3 639struct lttng_transport {
a33c9927
MD
640 char *name;
641 struct module *owner;
642 struct list_head node;
a90917c3 643 struct lttng_channel_ops ops;
a33c9927
MD
644};
645
a101fa10
MD
646struct lttng_counter_transport {
647 char *name;
648 struct module *owner;
649 struct list_head node;
650 struct lttng_counter_ops ops;
651};
652
80f87dd2
MD
653struct lttng_syscall_filter;
654
3c997079
MD
655#define LTTNG_EVENT_HT_BITS 12
656#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
657
658struct lttng_event_ht {
659 struct hlist_head table[LTTNG_EVENT_HT_SIZE];
660};
661
dffef45d
FD
662#define LTTNG_EVENT_NOTIFIER_HT_BITS 12
663#define LTTNG_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_EVENT_NOTIFIER_HT_BITS)
664
665struct lttng_event_notifier_ht {
666 struct hlist_head table[LTTNG_EVENT_NOTIFIER_HT_SIZE];
667};
668
a90917c3 669struct lttng_channel {
c099397a 670 unsigned int id;
85a9ca7f 671 struct channel *chan; /* Channel buffers */
e64957da 672 int enabled;
437d5aa5 673 struct lttng_kernel_ctx *ctx;
85a9ca7f 674 /* Event ID management */
a90917c3 675 struct lttng_session *session;
85a9ca7f
MD
676 struct file *file; /* File associated to channel */
677 unsigned int free_event_id; /* Next event ID to allocate */
678 struct list_head list; /* Channel list */
a90917c3
MD
679 struct lttng_channel_ops *ops;
680 struct lttng_transport *transport;
3b82c4e1
MD
681 struct hlist_head *sc_table; /* for syscall tracing */
682 struct hlist_head *compat_sc_table;
683 struct hlist_head *sc_exit_table; /* for syscall exit tracing */
684 struct hlist_head *compat_sc_exit_table;
685 struct hlist_head sc_unknown; /* for unknown syscalls */
686 struct hlist_head sc_compat_unknown;
687 struct hlist_head sc_exit_unknown;
688 struct hlist_head compat_sc_exit_unknown;
80f87dd2 689 struct lttng_syscall_filter *sc_filter;
9115fbdc 690 int header_type; /* 0: unset, 1: compact, 2: large */
d83004aa 691 enum channel_type channel_type;
3b82c4e1
MD
692 int syscall_all_entry;
693 int syscall_all_exit;
80f87dd2
MD
694 unsigned int metadata_dumped:1,
695 sys_enter_registered:1,
696 sys_exit_registered:1,
3c997079 697 tstate:1; /* Transient enable state */
85a9ca7f
MD
698};
699
d83004aa
JD
700struct lttng_metadata_stream {
701 void *priv; /* Ring buffer private data */
702 struct lttng_metadata_cache *metadata_cache;
f613e3e6
MD
703 unsigned int metadata_in; /* Bytes read from the cache */
704 unsigned int metadata_out; /* Bytes consumed from stream */
d83004aa
JD
705 int finalized; /* Has channel been finalized */
706 wait_queue_head_t read_wait; /* Reader buffer-level wait queue */
707 struct list_head list; /* Stream list */
b3b8072b 708 struct lttng_transport *transport;
9616f0bf 709 uint64_t version; /* Current version of the metadata cache */
8b97fd42 710 bool coherent; /* Stream in a coherent state */
d83004aa
JD
711};
712
114667d5
MD
713#define LTTNG_DYNAMIC_LEN_STACK_SIZE 128
714
715struct lttng_dynamic_len_stack {
716 size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE];
717 size_t offset;
718};
719
720DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack);
e0130fab
MD
721
722/*
d1f652f8 723 * struct lttng_id_tracker declared in header due to deferencing of *v
e0130fab
MD
724 * in RCU_INITIALIZER(v).
725 */
d1f652f8
MD
726#define LTTNG_ID_HASH_BITS 6
727#define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS)
e0130fab 728
d1f652f8
MD
729enum tracker_type {
730 TRACKER_PID,
731 TRACKER_VPID,
732 TRACKER_UID,
733 TRACKER_VUID,
734 TRACKER_GID,
735 TRACKER_VGID,
736
737 TRACKER_UNKNOWN,
738};
739
740struct lttng_id_tracker_rcu {
741 struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE];
742};
743
744struct lttng_id_tracker {
745 struct lttng_session *session;
746 enum tracker_type tracker_type;
747 struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */
e0130fab
MD
748};
749
d1f652f8 750struct lttng_id_hash_node {
7e6f9ef6 751 struct hlist_node hlist;
d1f652f8 752 int id;
7e6f9ef6
MD
753};
754
a90917c3 755struct lttng_session {
85a9ca7f 756 int active; /* Is trace session active ? */
8070f5c0 757 int been_active; /* Has trace session been active ? */
85a9ca7f
MD
758 struct file *file; /* File associated to session */
759 struct list_head chan; /* Channel list head */
760 struct list_head events; /* Event list head */
761 struct list_head list; /* Session list */
c099397a 762 unsigned int free_chan_id; /* Next chan ID to allocate */
d793d5e1 763 uuid_le uuid; /* Trace session unique ID */
d83004aa 764 struct lttng_metadata_cache *metadata_cache;
d1f652f8
MD
765 struct lttng_id_tracker pid_tracker;
766 struct lttng_id_tracker vpid_tracker;
767 struct lttng_id_tracker uid_tracker;
768 struct lttng_id_tracker vuid_tracker;
769 struct lttng_id_tracker gid_tracker;
770 struct lttng_id_tracker vgid_tracker;
3c997079
MD
771 unsigned int metadata_dumped:1,
772 tstate:1; /* Transient enable state */
b2bc0bc8 773 /* List of event enablers */
3c997079
MD
774 struct list_head enablers_head;
775 /* Hash table of events */
776 struct lttng_event_ht events_ht;
606828e4
MD
777 char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
778 char creation_time[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
85a9ca7f
MD
779};
780
99f52fcc
FD
781struct lttng_counter {
782 struct file *file; /* File associated to counter. */
783 struct file *owner;
784 struct lttng_counter_transport *transport;
785 struct lib_counter *counter;
786 struct lttng_counter_ops *ops;
787};
788
750b05f2
FD
789struct lttng_event_notifier_group {
790 struct file *file; /* File associated to event notifier group */
21f58fb7 791 struct file *notif_file; /* File used to expose notifications to userspace. */
750b05f2 792 struct list_head node; /* event notifier group list */
dffef45d
FD
793 struct list_head enablers_head; /* List of enablers */
794 struct list_head event_notifiers_head; /* List of event notifier */
795 struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */
750b05f2
FD
796 struct lttng_channel_ops *ops;
797 struct lttng_transport *transport;
798 struct channel *chan; /* Ring buffer channel for event notifier group. */
799 struct lib_ring_buffer *buf; /* Ring buffer for event notifier group. */
21f58fb7
FD
800 wait_queue_head_t read_wait;
801 struct irq_work wakeup_pending; /* Pending wakeup irq work. */
a67ba386
MD
802 struct lttng_kernel_event_notifier *sc_unknown; /* for unknown syscalls */
803 struct lttng_kernel_event_notifier *sc_compat_unknown;
8a8ac9a8
FD
804
805 struct lttng_syscall_filter *sc_filter;
806
807 struct hlist_head *event_notifier_syscall_dispatch;
808 struct hlist_head *event_notifier_compat_syscall_dispatch;
809 struct hlist_head *event_notifier_exit_syscall_dispatch;
810 struct hlist_head *event_notifier_exit_compat_syscall_dispatch;
811
812 struct hlist_head event_notifier_unknown_syscall_dispatch;
813 struct hlist_head event_notifier_compat_unknown_syscall_dispatch;
814 struct hlist_head event_notifier_exit_unknown_syscall_dispatch;
815 struct hlist_head event_notifier_exit_compat_unknown_syscall_dispatch;
816
817 int syscall_all_entry;
818 int syscall_all_exit;
819
820 unsigned int sys_enter_registered:1, sys_exit_registered:1;
821
822 struct lttng_counter *error_counter;
823 size_t error_counter_len;
750b05f2
FD
824};
825
d83004aa
JD
826struct lttng_metadata_cache {
827 char *data; /* Metadata cache */
828 unsigned int cache_alloc; /* Metadata allocated size (bytes) */
829 unsigned int metadata_written; /* Number of bytes written in metadata cache */
3e75e2a7 830 atomic_t producing; /* Metadata being produced (incomplete) */
d83004aa
JD
831 struct kref refcount; /* Metadata cache usage */
832 struct list_head metadata_stream; /* Metadata stream list */
a36580d5 833 uuid_le uuid; /* Trace session unique ID (copy) */
9616f0bf
JD
834 struct mutex lock; /* Produce/consume lock */
835 uint64_t version; /* Current version of the metadata */
d83004aa
JD
836};
837
3c997079
MD
838void lttng_lock_sessions(void);
839void lttng_unlock_sessions(void);
840
841struct list_head *lttng_get_probe_list_head(void);
842
b2bc0bc8
FD
843struct lttng_event_enabler *lttng_event_enabler_create(
844 enum lttng_enabler_format_type format_type,
606828e4 845 struct lttng_kernel_abi_event *event_param,
3c997079
MD
846 struct lttng_channel *chan);
847
b2bc0bc8
FD
848int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler);
849int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler);
dffef45d
FD
850struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
851 struct lttng_event_notifier_group *event_notifier_group,
852 enum lttng_enabler_format_type format_type,
606828e4 853 struct lttng_kernel_abi_event_notifier *event_notifier_param);
dffef45d
FD
854
855int lttng_event_notifier_enabler_enable(
856 struct lttng_event_notifier_enabler *event_notifier_enabler);
857int lttng_event_notifier_enabler_disable(
858 struct lttng_event_notifier_enabler *event_notifier_enabler);
3c997079 859int lttng_fix_pending_events(void);
b01155ba 860int lttng_fix_pending_event_notifiers(void);
3c997079 861int lttng_session_active(void);
b01155ba 862bool lttng_event_notifier_active(void);
3c997079 863
a90917c3
MD
864struct lttng_session *lttng_session_create(void);
865int lttng_session_enable(struct lttng_session *session);
866int lttng_session_disable(struct lttng_session *session);
867void lttng_session_destroy(struct lttng_session *session);
9616f0bf 868int lttng_session_metadata_regenerate(struct lttng_session *session);
601252cf 869int lttng_session_statedump(struct lttng_session *session);
d83004aa 870void metadata_cache_destroy(struct kref *kref);
4e3c1b9b 871
99f52fcc
FD
872struct lttng_counter *lttng_kernel_counter_create(
873 const char *counter_transport_name, size_t number_dimensions,
874 const size_t *dimensions_sizes);
875int lttng_kernel_counter_read(struct lttng_counter *counter,
876 const size_t *dimension_indexes, int32_t cpu,
877 int64_t *val, bool *overflow, bool *underflow);
878int lttng_kernel_counter_aggregate(struct lttng_counter *counter,
879 const size_t *dimension_indexes, int64_t *val,
880 bool *overflow, bool *underflow);
881int lttng_kernel_counter_clear(struct lttng_counter *counter,
882 const size_t *dimension_indexes);
883
884
750b05f2 885struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
99f52fcc
FD
886int lttng_event_notifier_group_create_error_counter(
887 struct file *event_notifier_group_file,
606828e4 888 const struct lttng_kernel_abi_counter_conf *error_counter_conf);
750b05f2
FD
889void lttng_event_notifier_group_destroy(
890 struct lttng_event_notifier_group *event_notifier_group);
891
a90917c3 892struct lttng_channel *lttng_channel_create(struct lttng_session *session,
5dbbdb43
MD
893 const char *transport_name,
894 void *buf_addr,
895 size_t subbuf_size, size_t num_subbuf,
896 unsigned int switch_timer_interval,
d83004aa
JD
897 unsigned int read_timer_interval,
898 enum channel_type channel_type);
a90917c3 899struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
4e3c1b9b
MD
900 int overwrite, void *buf_addr,
901 size_t subbuf_size, size_t num_subbuf,
902 unsigned int switch_timer_interval,
903 unsigned int read_timer_interval);
4e3c1b9b 904
d83004aa 905void lttng_metadata_channel_destroy(struct lttng_channel *chan);
a67ba386 906struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_channel *chan,
606828e4 907 struct lttng_kernel_abi_event *event_param,
437d5aa5 908 const struct lttng_kernel_event_desc *event_desc,
606828e4 909 enum lttng_kernel_abi_instrumentation itype);
a67ba386 910struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_channel *chan,
606828e4 911 struct lttng_kernel_abi_event *event_param,
437d5aa5 912 const struct lttng_kernel_event_desc *event_desc,
606828e4 913 enum lttng_kernel_abi_instrumentation itype);
a67ba386 914struct lttng_kernel_event_recorder *lttng_event_compat_old_create(struct lttng_channel *chan,
606828e4 915 struct lttng_kernel_abi_old_event *old_event_param,
437d5aa5 916 const struct lttng_kernel_event_desc *internal_desc);
c0e31d2e 917
a67ba386 918struct lttng_kernel_event_notifier *lttng_event_notifier_create(
437d5aa5 919 const struct lttng_kernel_event_desc *event_notifier_desc,
dffef45d 920 uint64_t id,
99f52fcc 921 uint64_t error_counter_idx,
dffef45d 922 struct lttng_event_notifier_group *event_notifier_group,
606828e4 923 struct lttng_kernel_abi_event_notifier *event_notifier_param,
606828e4 924 enum lttng_kernel_abi_instrumentation itype);
a67ba386 925struct lttng_kernel_event_notifier *_lttng_event_notifier_create(
437d5aa5 926 const struct lttng_kernel_event_desc *event_notifier_desc,
dffef45d 927 uint64_t id,
99f52fcc 928 uint64_t error_counter_idx,
dffef45d 929 struct lttng_event_notifier_group *event_notifier_group,
606828e4 930 struct lttng_kernel_abi_event_notifier *event_notifier_param,
606828e4 931 enum lttng_kernel_abi_instrumentation itype);
dffef45d 932
a90917c3
MD
933int lttng_channel_enable(struct lttng_channel *channel);
934int lttng_channel_disable(struct lttng_channel *channel);
9d993668
MD
935int lttng_event_enable(struct lttng_kernel_event_common *event);
936int lttng_event_disable(struct lttng_kernel_event_common *event);
2b16f0c9 937
a90917c3
MD
938void lttng_transport_register(struct lttng_transport *transport);
939void lttng_transport_unregister(struct lttng_transport *transport);
11b5a3c2 940
a101fa10
MD
941void lttng_counter_transport_register(struct lttng_counter_transport *transport);
942void lttng_counter_transport_unregister(struct lttng_counter_transport *transport);
943
360f38ea 944void synchronize_trace(void);
80996790 945int lttng_abi_init(void);
6dccd6c1 946int lttng_abi_compat_old_init(void);
80996790 947void lttng_abi_exit(void);
6dccd6c1 948void lttng_abi_compat_old_exit(void);
1c25284c 949
437d5aa5
MD
950int lttng_probe_register(struct lttng_kernel_probe_desc *desc);
951void lttng_probe_unregister(struct lttng_kernel_probe_desc *desc);
952const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name);
953void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc);
a90917c3
MD
954int lttng_probes_init(void);
955void lttng_probes_exit(void);
1ec65de1 956
b3b8072b 957int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
8b97fd42 958 struct channel *chan, bool *coherent);
d83004aa 959
d1f652f8
MD
960int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
961int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf);
962void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu);
963bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id);
964int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id);
965int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id);
e0130fab 966
d1f652f8
MD
967int lttng_session_track_id(struct lttng_session *session,
968 enum tracker_type tracker_type, int id);
969int lttng_session_untrack_id(struct lttng_session *session,
970 enum tracker_type tracker_type, int id);
e0130fab 971
d1f652f8
MD
972int lttng_session_list_tracker_ids(struct lttng_session *session,
973 enum tracker_type tracker_type);
7e6f9ef6 974
2754583e
MD
975void lttng_clock_ref(void);
976void lttng_clock_unref(void);
977
437d5aa5 978int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
8a8ac9a8
FD
979 struct lttng_enabler *enabler);
980
3a523f5b 981#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
a67ba386 982int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler);
3b82c4e1 983int lttng_syscalls_unregister_channel(struct lttng_channel *chan);
2d6d88c6 984int lttng_syscalls_destroy_event(struct lttng_channel *chan);
ade8a729
FD
985int lttng_syscall_filter_enable_event(
986 struct lttng_channel *chan,
a67ba386 987 struct lttng_kernel_event_recorder *event);
ade8a729
FD
988int lttng_syscall_filter_disable_event(
989 struct lttng_channel *chan,
a67ba386 990 struct lttng_kernel_event_recorder *event);
ade8a729 991
12e579db 992long lttng_channel_syscall_mask(struct lttng_channel *channel,
606828e4 993 struct lttng_kernel_abi_syscall_mask __user *usyscall_mask);
2d6d88c6 994
8a8ac9a8 995int lttng_syscalls_register_event_notifier(
a67ba386
MD
996 struct lttng_event_notifier_enabler *event_notifier_enabler);
997int lttng_syscalls_create_matching_event_notifiers(
998 struct lttng_event_notifier_enabler *event_notifier_enabler);
3b82c4e1 999int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group *group);
a67ba386
MD
1000int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
1001int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
1ec65de1 1002#else
2d6d88c6 1003static inline int lttng_syscalls_register_event(
a67ba386 1004 struct lttng_event_enabler *event_enabler)
1ec65de1
MD
1005{
1006 return -ENOSYS;
1007}
1008
3b82c4e1 1009static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan)
1ec65de1
MD
1010{
1011 return 0;
1012}
80f87dd2 1013
badfe9f5
MD
1014static inline int lttng_syscalls_destroy(struct lttng_channel *chan)
1015{
1016 return 0;
1017}
1018
2d6d88c6 1019static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan,
a67ba386 1020 struct lttng_kernel_event_recorder *event);
80f87dd2
MD
1021{
1022 return -ENOSYS;
1023}
1024
2d6d88c6 1025static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan,
a67ba386 1026 struct lttng_kernel_event_recorder *event);
80f87dd2
MD
1027{
1028 return -ENOSYS;
1029}
12e579db 1030
f127e61e 1031static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
12e579db
MD
1032 struct lttng_kernel_syscall_mask __user *usyscall_mask)
1033{
1034 return -ENOSYS;
1035}
dffef45d 1036
8a8ac9a8 1037static inline int lttng_syscalls_register_event_notifier(
a67ba386 1038 struct lttng_event_notifier_group *group)
8a8ac9a8
FD
1039{
1040 return -ENOSYS;
1041}
1042
3b82c4e1 1043static inline int lttng_syscalls_unregister_event_notifier_group(
8a8ac9a8
FD
1044 struct lttng_event_notifier_group *group)
1045{
1046 return 0;
1047}
1048
1049static inline int lttng_syscall_filter_enable_event_notifier(
1050 struct lttng_event_notifier_group *group,
1051 const char *name)
1052{
1053 return -ENOSYS;
1054}
1055
1056static inline int lttng_syscall_filter_disable_event_notifier(
1057 struct lttng_event_notifier_group *group,
1058 const char *name)
1059{
1060 return -ENOSYS;
1061}
1062
1ec65de1
MD
1063#endif
1064
183e8b3a 1065int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler,
606828e4 1066 struct lttng_kernel_abi_filter_bytecode __user *bytecode);
183e8b3a 1067int lttng_event_notifier_enabler_attach_filter_bytecode(
dffef45d 1068 struct lttng_event_notifier_enabler *event_notifier_enabler,
606828e4 1069 struct lttng_kernel_abi_filter_bytecode __user *bytecode);
99d223ad
FD
1070int lttng_event_notifier_enabler_attach_capture_bytecode(
1071 struct lttng_event_notifier_enabler *event_notifier_enabler,
606828e4 1072 struct lttng_kernel_abi_capture_bytecode __user *bytecode);
2dfda770 1073
437d5aa5
MD
1074void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc,
1075 struct lttng_kernel_ctx *ctx,
60206944
FD
1076 struct list_head *instance_bytecode_runtime_head,
1077 struct list_head *enabler_bytecode_runtime_head);
0648898e 1078void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event);
07dfc1d0 1079
114667d5
MD
1080int lttng_probes_init(void);
1081
437d5aa5 1082extern struct lttng_kernel_ctx *lttng_static_ctx;
07dfc1d0
MD
1083
1084int lttng_context_init(void);
1085void lttng_context_exit(void);
437d5aa5
MD
1086int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p,
1087 const struct lttng_kernel_ctx_field *f);
1088void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p);
1089struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx,
c02eb859 1090 size_t index);
437d5aa5
MD
1091int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name);
1092int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name);
1093void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx);
1094int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx);
1095int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx);
1096int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx);
1097int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx);
1098int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx);
1099int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx);
1100int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx);
1101int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx);
1102int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx);
1103int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx);
1104int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx);
1105int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx);
1106int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx);
79150a49 1107#if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
437d5aa5 1108int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx);
79150a49
JD
1109#else
1110static inline
437d5aa5 1111int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx)
79150a49
JD
1112{
1113 return -ENOSYS;
1114}
1115#endif
1116#ifdef CONFIG_PREEMPT_RT_FULL
437d5aa5 1117int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx);
79150a49
JD
1118#else
1119static inline
437d5aa5 1120int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx)
79150a49
JD
1121{
1122 return -ENOSYS;
1123}
1124#endif
2fa2d39a 1125
437d5aa5 1126int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type);
2fa2d39a 1127
a6cf40a4 1128#if defined(CONFIG_CGROUPS) && \
5f4c791e 1129 ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
a6cf40a4 1130 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
437d5aa5 1131int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx);
a6cf40a4
MJ
1132#else
1133static inline
437d5aa5 1134int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx)
a6cf40a4
MJ
1135{
1136 return -ENOSYS;
1137}
1138#endif
1139
1140#if defined(CONFIG_IPC_NS) && \
5f4c791e 1141 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
437d5aa5 1142int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx);
a6cf40a4
MJ
1143#else
1144static inline
437d5aa5 1145int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx)
a6cf40a4
MJ
1146{
1147 return -ENOSYS;
1148}
1149#endif
1150
1151#if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
5f4c791e 1152 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
437d5aa5 1153int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx);
a6cf40a4
MJ
1154#else
1155static inline
437d5aa5 1156int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx)
a6cf40a4
MJ
1157{
1158 return -ENOSYS;
1159}
1160#endif
1161
1162#if defined(CONFIG_NET_NS) && \
5f4c791e 1163 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
437d5aa5 1164int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx);
a6cf40a4
MJ
1165#else
1166static inline
437d5aa5 1167int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx)
a6cf40a4
MJ
1168{
1169 return -ENOSYS;
1170}
1171#endif
1172
1173#if defined(CONFIG_PID_NS) && \
5f4c791e 1174 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
437d5aa5 1175int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx);
a6cf40a4
MJ
1176#else
1177static inline
437d5aa5 1178int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx)
a6cf40a4
MJ
1179{
1180 return -ENOSYS;
1181}
1182#endif
1183
1184#if defined(CONFIG_USER_NS) && \
5f4c791e 1185 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
437d5aa5 1186int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx);
a6cf40a4
MJ
1187#else
1188static inline
437d5aa5 1189int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx)
a6cf40a4
MJ
1190{
1191 return -ENOSYS;
1192}
1193#endif
1194
1195#if defined(CONFIG_UTS_NS) && \
5f4c791e 1196 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
437d5aa5 1197int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx);
a6cf40a4
MJ
1198#else
1199static inline
437d5aa5 1200int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx)
a6cf40a4
MJ
1201{
1202 return -ENOSYS;
1203}
1204#endif
1205
876e2e92 1206#if defined(CONFIG_TIME_NS) && \
5f4c791e 1207 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0))
437d5aa5 1208int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx);
876e2e92
MJ
1209#else
1210static inline
437d5aa5 1211int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx)
876e2e92
MJ
1212{
1213 return -ENOSYS;
1214}
1215#endif
1216
437d5aa5
MD
1217int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx);
1218int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx);
1219int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx);
1220int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx);
1221int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx);
1222int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx);
1223int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx);
1224int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx);
1225int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx);
1226int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx);
1227int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx);
1228int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx);
dc923e75 1229
8a3af9ee 1230#if defined(CONFIG_PERF_EVENTS)
c24a0d71
MD
1231int lttng_add_perf_counter_to_ctx(uint32_t type,
1232 uint64_t config,
1233 const char *name,
437d5aa5 1234 struct lttng_kernel_ctx **ctx);
1e367326
MD
1235int lttng_cpuhp_perf_counter_online(unsigned int cpu,
1236 struct lttng_cpuhp_node *node);
1237int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
1238 struct lttng_cpuhp_node *node);
1d443b34
MD
1239#else
1240static inline
1241int lttng_add_perf_counter_to_ctx(uint32_t type,
1242 uint64_t config,
1243 const char *name,
437d5aa5 1244 struct lttng_kernel_ctx **ctx)
1d443b34
MD
1245{
1246 return -ENOSYS;
1247}
1e367326
MD
1248static inline
1249int lttng_cpuhp_perf_counter_online(unsigned int cpu,
1250 struct lttng_cpuhp_node *node)
1251{
1252 return 0;
1253}
1254static inline
1255int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
1256 struct lttng_cpuhp_node *node)
1257{
1258 return 0;
1259}
1d443b34 1260#endif
02119ee5 1261
0c956676
MD
1262int lttng_logger_init(void);
1263void lttng_logger_exit(void);
1264
c337ddc2
MD
1265extern int lttng_statedump_start(struct lttng_session *session);
1266
acd614cc 1267#ifdef CONFIG_KPROBES
8bf17deb 1268int lttng_kprobes_register_event(const char *name,
f17701fb
MD
1269 const char *symbol_name,
1270 uint64_t offset,
1271 uint64_t addr,
a67ba386
MD
1272 struct lttng_kernel_event_recorder *event);
1273void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event);
1274void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event);
2b16f0c9
FD
1275int lttng_kprobes_register_event_notifier(const char *symbol_name,
1276 uint64_t offset,
1277 uint64_t addr,
a67ba386
MD
1278 struct lttng_kernel_event_notifier *event_notifier);
1279void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
1280void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier);
acd614cc
MD
1281#else
1282static inline
8bf17deb 1283int lttng_kprobes_register_event(const char *name,
acd614cc
MD
1284 const char *symbol_name,
1285 uint64_t offset,
1286 uint64_t addr,
a67ba386 1287 struct lttng_kernel_event_recorder *event)
acd614cc
MD
1288{
1289 return -ENOSYS;
1290}
1291
25f53c39 1292static inline
a67ba386 1293void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event)
8bf17deb
FD
1294{
1295}
1296
1297static inline
a67ba386 1298void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event)
acd614cc
MD
1299{
1300}
edeb3137
MD
1301
1302static inline
2b16f0c9
FD
1303int lttng_kprobes_register_event_notifier(const char *symbol_name,
1304 uint64_t offset,
1305 uint64_t addr,
a67ba386 1306 struct lttng_kernel_event_notifier *event_notifier)
2b16f0c9
FD
1307{
1308 return -ENOSYS;
1309}
1310
1311static inline
a67ba386 1312void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
2b16f0c9
FD
1313{
1314}
1315
1316static inline
a67ba386 1317void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier)
edeb3137
MD
1318{
1319}
acd614cc 1320#endif
d6d808f3 1321
e2d5dbc7 1322int lttng_event_add_callsite(struct lttng_kernel_event_common *event,
606828e4 1323 struct lttng_kernel_abi_event_callsite __user *callsite);
9de67196 1324
149b9a9d 1325#ifdef CONFIG_UPROBES
83b802dc 1326int lttng_uprobes_register_event(const char *name,
a67ba386 1327 int fd, struct lttng_kernel_event_recorder *event);
e2d5dbc7 1328int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
606828e4 1329 struct lttng_kernel_abi_event_callsite __user *callsite);
a67ba386
MD
1330void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event);
1331void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event);
9de67196 1332int lttng_uprobes_register_event_notifier(const char *name,
a67ba386 1333 int fd, struct lttng_kernel_event_notifier *event_notifier);
a67ba386
MD
1334void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
1335void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier);
149b9a9d
YB
1336#else
1337static inline
83b802dc 1338int lttng_uprobes_register_event(const char *name,
a67ba386 1339 int fd, struct lttng_kernel_event_recorder *event)
3aed4dca
FD
1340{
1341 return -ENOSYS;
1342}
1343
1344static inline
e2d5dbc7 1345int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
606828e4 1346 struct lttng_kernel_abi_event_callsite __user *callsite)
149b9a9d
YB
1347{
1348 return -ENOSYS;
1349}
1350
1351static inline
a67ba386 1352void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event)
149b9a9d
YB
1353{
1354}
1355
1356static inline
a67ba386 1357void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event)
149b9a9d
YB
1358{
1359}
9de67196
FD
1360
1361static inline
1362int lttng_uprobes_register_event_notifier(const char *name,
a67ba386 1363 int fd, struct lttng_kernel_event_notifier *event_notifier)
9de67196
FD
1364{
1365 return -ENOSYS;
1366}
1367
9de67196 1368static inline
a67ba386 1369void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
9de67196
FD
1370{
1371}
1372
1373static inline
a67ba386 1374void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier)
9de67196
FD
1375{
1376}
149b9a9d
YB
1377#endif
1378
7371f44c
MD
1379#ifdef CONFIG_KRETPROBES
1380int lttng_kretprobes_register(const char *name,
1381 const char *symbol_name,
1382 uint64_t offset,
1383 uint64_t addr,
a67ba386
MD
1384 struct lttng_kernel_event_recorder *event_entry,
1385 struct lttng_kernel_event_recorder *event_exit);
1386void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event);
1387void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event);
e2d5dbc7 1388int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
a0493bef 1389 int enable);
7371f44c
MD
1390#else
1391static inline
1392int lttng_kretprobes_register(const char *name,
1393 const char *symbol_name,
1394 uint64_t offset,
1395 uint64_t addr,
a67ba386
MD
1396 struct lttng_kernel_event_recorder *event_entry,
1397 struct lttng_kernel_event_recorder *event_exit)
7371f44c
MD
1398{
1399 return -ENOSYS;
1400}
1401
1402static inline
a67ba386 1403void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event)
7371f44c
MD
1404{
1405}
1406
1407static inline
a67ba386 1408void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event)
7371f44c
MD
1409{
1410}
a0493bef
MD
1411
1412static inline
e2d5dbc7 1413int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
a0493bef
MD
1414 int enable)
1415{
1416 return -ENOSYS;
1417}
7371f44c
MD
1418#endif
1419
606828e4 1420int lttng_calibrate(struct lttng_kernel_abi_calibrate *calibrate);
57105fc2 1421
271b6681 1422extern const struct file_operations lttng_tracepoint_list_fops;
2d2464bd 1423extern const struct file_operations lttng_syscall_list_fops;
271b6681 1424
ef200626 1425#define TRACEPOINT_HAS_DATA_ARG
ef200626 1426
a90917c3 1427#endif /* _LTTNG_EVENTS_H */
This page took 0.13051 seconds and 4 git commands to generate.