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