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