Fix: scsi: sd: Atomic write support added in 6.11-rc1
[lttng-modules.git] / include / lttng / events-internal.h
1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
2 *
3 * lttng/events-internal.h
4 *
5 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 */
7
8 #ifndef _LTTNG_EVENTS_INTERNAL_H
9 #define _LTTNG_EVENTS_INTERNAL_H
10
11 #include <wrapper/compiler_attributes.h>
12 #include <wrapper/uuid.h>
13
14 #include <lttng/events.h>
15
16 struct lttng_syscall_filter;
17 struct lttng_metadata_cache;
18 struct perf_event;
19 struct perf_event_attr;
20 struct lttng_kernel_ring_buffer_config;
21 struct lttng_kernel_counter_dimension;
22
23 enum lttng_enabler_format_type {
24 LTTNG_ENABLER_FORMAT_STAR_GLOB,
25 LTTNG_ENABLER_FORMAT_NAME,
26 };
27
28 enum lttng_kernel_event_enabler_type {
29 LTTNG_EVENT_ENABLER_TYPE_RECORDER,
30 LTTNG_EVENT_ENABLER_TYPE_NOTIFIER,
31 LTTNG_EVENT_ENABLER_TYPE_COUNTER,
32 };
33
34 enum channel_type {
35 PER_CPU_CHANNEL,
36 METADATA_CHANNEL,
37 };
38
39 /*
40 * Objects in a linked-list of enablers, owned by an event.
41 */
42 struct lttng_enabler_ref {
43 struct list_head node; /* enabler ref list */
44 struct lttng_event_enabler_common *ref; /* backward ref */
45 };
46
47 struct lttng_krp; /* Kretprobe handling */
48
49 struct lttng_uprobe_handler {
50 struct lttng_kernel_event_common *event;
51 loff_t offset;
52 struct uprobe_consumer up_consumer;
53 struct list_head node;
54 };
55
56 struct lttng_kprobe {
57 struct kprobe kp;
58 char *symbol_name;
59 uint64_t addr;
60 uint64_t offset;
61 kprobe_pre_handler_t pre_handler;
62 };
63
64 struct lttng_uprobe {
65 struct inode *inode;
66 struct list_head head;
67 };
68
69 enum lttng_syscall_entryexit {
70 LTTNG_SYSCALL_ENTRY,
71 LTTNG_SYSCALL_EXIT,
72 };
73
74 enum lttng_syscall_abi {
75 LTTNG_SYSCALL_ABI_NATIVE,
76 LTTNG_SYSCALL_ABI_COMPAT,
77 };
78
79 enum lttng_kretprobe_entryexit {
80 LTTNG_KRETPROBE_ENTRY,
81 LTTNG_KRETPROBE_EXIT,
82
83 NR_LTTNG_KRETPROBE_ENTRYEXIT,
84 };
85
86 struct lttng_kernel_event_common_private {
87 struct lttng_kernel_event_common *pub; /* Public event interface */
88
89 const struct lttng_kernel_event_desc *desc;
90 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
91 struct list_head enablers_ref_head;
92 int registered; /* has reg'd tracepoint probe */
93 uint64_t user_token;
94
95 int has_enablers_without_filter_bytecode;
96 /* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */
97 struct list_head filter_bytecode_runtime_head;
98
99 struct hlist_node hlist_name_node; /* node in events name hash table */
100 struct list_head node; /* node in event list */
101
102 enum lttng_kernel_abi_instrumentation instrumentation;
103 /* Selected by instrumentation */
104 union {
105 struct lttng_kprobe kprobe;
106 struct lttng_uprobe uprobe;
107 struct {
108 enum lttng_kretprobe_entryexit entryexit;
109 struct lttng_krp *lttng_krp;
110 char *symbol_name;
111 } kretprobe;
112 struct {
113 enum lttng_syscall_entryexit entryexit;
114 enum lttng_syscall_abi abi;
115 struct hlist_node node; /* chain registered syscall event_notifier */
116 unsigned int syscall_id;
117 } syscall;
118 } u;
119 };
120
121 struct lttng_kernel_event_session_common_private {
122 struct lttng_kernel_event_common_private parent;
123
124 struct lttng_kernel_channel_common *chan;
125 uint64_t id; /* Event id */
126 };
127
128 struct lttng_kernel_event_recorder_private {
129 struct lttng_kernel_event_session_common_private parent;
130
131 struct lttng_kernel_event_recorder *pub; /* Public event interface */
132 unsigned int metadata_dumped:1;
133 };
134
135 #define LTTNG_KERNEL_COUNTER_KEY_LEN 256
136
137 enum lttng_event_counter_action {
138 LTTNG_EVENT_COUNTER_ACTION_INCREMENT = 0,
139 };
140
141 struct lttng_kernel_event_counter_private {
142 struct lttng_kernel_event_session_common_private parent;
143
144 struct lttng_kernel_event_counter *pub; /* Public event interface */
145 struct hlist_node hlist_key_node; /* node in events key hash table */
146 enum lttng_event_counter_action action;
147 char key[LTTNG_KERNEL_COUNTER_KEY_LEN];
148 };
149
150 struct lttng_kernel_event_notifier_private {
151 struct lttng_kernel_event_common_private parent;
152
153 struct lttng_kernel_event_notifier *pub; /* Public event notifier interface */
154 struct lttng_event_notifier_group *group; /* weak ref */
155 size_t num_captures; /* Needed to allocate the msgpack array. */
156 uint64_t error_counter_index;
157 struct list_head capture_bytecode_runtime_head;
158 };
159
160 struct lttng_kernel_syscall_table {
161 unsigned int sys_enter_registered:1,
162 sys_exit_registered:1;
163
164 struct hlist_head *syscall_dispatch; /* for syscall tracing */
165 struct hlist_head *compat_syscall_dispatch;
166 struct hlist_head *syscall_exit_dispatch; /* for syscall exit tracing */
167 struct hlist_head *compat_syscall_exit_dispatch;
168
169 /*
170 * Combining all unknown syscall events works as long as they
171 * are only matched by "all" syscalls enablers, but will require
172 * a design change when we allow matching by syscall number, for
173 * instance by allocating sc_tables accomodating NR_syscalls
174 * entries.
175 */
176 struct hlist_head unknown_syscall_dispatch; /* for unknown syscalls */
177 struct hlist_head compat_unknown_syscall_dispatch;
178 struct hlist_head unknown_syscall_exit_dispatch;
179 struct hlist_head compat_unknown_syscall_exit_dispatch;
180
181 struct lttng_syscall_filter *sc_filter;
182 int syscall_all_entry;
183 int syscall_all_exit;
184 };
185
186 struct lttng_kernel_channel_common_private {
187 struct lttng_kernel_channel_common *pub;
188
189 struct file *file; /* File associated to channel */
190 unsigned int tstate:1; /* Transient enable state */
191 bool coalesce_hits;
192
193 struct list_head node; /* Channel list in session */
194
195 struct lttng_kernel_syscall_table syscall_table;
196 };
197
198 struct lttng_kernel_channel_buffer_private {
199 struct lttng_kernel_channel_common_private parent;
200
201 struct lttng_kernel_channel_buffer *pub;
202
203 unsigned int id; /* Channel ID */
204 unsigned int free_event_id; /* Next event ID to allocate */
205 int header_type; /* 0: unset, 1: compact, 2: large */
206
207 enum channel_type channel_type;
208 struct lttng_kernel_ctx *ctx;
209 struct lttng_kernel_ring_buffer_channel *rb_chan; /* Ring buffer channel */
210 unsigned int metadata_dumped:1;
211 struct lttng_transport *transport;
212 };
213
214 struct lttng_kernel_channel_counter_ops_private {
215 struct lttng_kernel_channel_counter_ops *pub; /* Public channel counter ops interface */
216
217 struct lttng_kernel_channel_counter *(*counter_create)(size_t nr_dimensions,
218 const struct lttng_kernel_counter_dimension *dimensions,
219 int64_t global_sum_step);
220 void (*counter_destroy)(struct lttng_kernel_channel_counter *counter);
221 int (*counter_add)(struct lttng_kernel_channel_counter *counter,
222 const size_t *dimension_indexes, int64_t v);
223 /*
224 * counter_read reads a specific cpu's counter if @cpu >= 0, or
225 * the global aggregation counter if @cpu == -1.
226 */
227 int (*counter_read)(struct lttng_kernel_channel_counter *counter,
228 const size_t *dimension_indexes, int cpu,
229 int64_t *value, bool *overflow, bool *underflow);
230 /*
231 * counter_aggregate returns the total sum of all per-cpu counters and
232 * the global aggregation counter.
233 */
234 int (*counter_aggregate)(struct lttng_kernel_channel_counter *counter,
235 const size_t *dimension_indexes, int64_t *value,
236 bool *overflow, bool *underflow);
237 int (*counter_clear)(struct lttng_kernel_channel_counter *counter,
238 const size_t *dimension_indexes);
239 int (*counter_get_nr_dimensions)(struct lttng_kernel_channel_counter *counter,
240 size_t *nr_dimensions);
241 int (*counter_get_max_nr_elem)(struct lttng_kernel_channel_counter *counter,
242 size_t *max_nr_elem); /* array of size nr_dimensions */
243 };
244
245 struct lttng_counter_map_descriptor {
246 uint64_t user_token;
247 size_t array_index;
248 char key[LTTNG_KERNEL_COUNTER_KEY_LEN];
249 };
250
251 struct lttng_counter_map {
252 struct lttng_counter_map_descriptor *descriptors;
253 size_t nr_descriptors;
254 size_t alloc_len;
255 struct mutex lock; /* counter map lock */
256 };
257
258 struct lttng_kernel_channel_counter_private {
259 struct lttng_kernel_channel_common_private parent;
260
261 struct lttng_kernel_channel_counter *pub; /* Public channel counter interface */
262 struct lib_counter *counter;
263 struct lttng_kernel_channel_counter_ops *ops;
264
265 struct lttng_counter_map map;
266
267 /* Owned either by session or event notifier group. */
268
269 /* Session or event notifier group file owner. */
270 struct file *owner;
271
272 /* Event notifier group owner. */
273 struct lttng_event_notifier_group *event_notifier_group;
274
275 /* Session owner. */
276 size_t free_index; /* Next index to allocate */
277 struct lttng_counter_transport *transport;
278 };
279
280 enum lttng_kernel_bytecode_interpreter_ret {
281 LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR = -1,
282 LTTNG_KERNEL_BYTECODE_INTERPRETER_OK = 0,
283 };
284
285 enum lttng_kernel_bytecode_filter_result {
286 LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT = 0,
287 LTTNG_KERNEL_BYTECODE_FILTER_REJECT = 1,
288 };
289
290 struct lttng_kernel_bytecode_filter_ctx {
291 enum lttng_kernel_bytecode_filter_result result;
292 };
293
294 struct lttng_interpreter_output;
295
296 enum lttng_kernel_bytecode_type {
297 LTTNG_KERNEL_BYTECODE_TYPE_FILTER,
298 LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE,
299 };
300
301 struct lttng_kernel_bytecode_node {
302 enum lttng_kernel_bytecode_type type;
303 struct list_head node;
304 struct lttng_event_enabler_common *enabler;
305 struct {
306 uint32_t len;
307 uint32_t reloc_offset;
308 uint64_t seqnum;
309 char data[];
310 } bc;
311 };
312
313 struct lttng_kernel_bytecode_runtime {
314 /* Associated bytecode */
315 enum lttng_kernel_bytecode_type type;
316 struct lttng_kernel_bytecode_node *bc;
317 int (*interpreter_func)(struct lttng_kernel_bytecode_runtime *kernel_bytecode,
318 const char *interpreter_stack_data,
319 struct lttng_kernel_probe_ctx *lttng_probe_ctx,
320 void *caller_ctx);
321 int link_failed;
322 struct list_head node; /* list of bytecode runtime in event */
323 struct lttng_kernel_ctx *ctx;
324 };
325
326 /*
327 * Enabler field, within whatever object is enabling an event. Target of
328 * backward reference.
329 */
330 struct lttng_event_enabler_common {
331 enum lttng_kernel_event_enabler_type enabler_type;
332 enum lttng_enabler_format_type format_type;
333
334 /* head list of struct lttng_kernel_bytecode_node */
335 struct list_head filter_bytecode_head;
336
337 struct lttng_kernel_abi_event event_param;
338 unsigned int enabled:1;
339
340 uint64_t user_token; /* User-provided token. */
341
342 struct list_head node; /* list of enablers */
343 bool published; /* published in list. */
344 };
345
346 struct lttng_event_enabler_session_common {
347 struct lttng_event_enabler_common parent;
348 struct lttng_kernel_channel_common *chan;
349 };
350
351 struct lttng_event_recorder_enabler {
352 struct lttng_event_enabler_session_common parent;
353 struct lttng_kernel_channel_buffer *chan;
354 };
355
356 struct lttng_event_counter_enabler {
357 struct lttng_event_enabler_session_common parent;
358 struct lttng_kernel_channel_counter *chan;
359 struct lttng_kernel_counter_key *key;
360
361 enum lttng_event_counter_action action;
362 };
363
364 struct lttng_event_notifier_enabler {
365 struct lttng_event_enabler_common parent;
366 uint64_t error_counter_index;
367 struct lttng_event_notifier_group *group;
368
369 /* head list of struct lttng_kernel_bytecode_node */
370 struct list_head capture_bytecode_head;
371 uint64_t num_captures;
372 };
373
374 struct lttng_ctx_value {
375 union {
376 int64_t s64;
377 const char *str;
378 double d;
379 } u;
380 };
381
382 /*
383 * We need to keep this perf counter field separately from struct
384 * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses.
385 */
386 struct lttng_perf_counter_field {
387 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
388 struct lttng_cpuhp_node cpuhp_prepare;
389 struct lttng_cpuhp_node cpuhp_online;
390 #else
391 struct notifier_block nb;
392 int hp_enable;
393 #endif
394 struct perf_event_attr *attr;
395 struct perf_event **e; /* per-cpu array */
396 char *name;
397 struct lttng_kernel_event_field *event_field;
398 };
399
400 struct lttng_kernel_ctx_field {
401 const struct lttng_kernel_event_field *event_field;
402 size_t (*get_size)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
403 size_t offset);
404 void (*record)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
405 struct lttng_kernel_ring_buffer_ctx *ctx,
406 struct lttng_kernel_channel_buffer *chan);
407 void (*get_value)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
408 struct lttng_ctx_value *value);
409 void (*destroy)(void *priv);
410 void *priv;
411 };
412
413 struct lttng_kernel_ctx {
414 struct lttng_kernel_ctx_field *fields;
415 unsigned int nr_fields;
416 unsigned int allocated_fields;
417 size_t largest_align; /* in bytes */
418 };
419
420 struct lttng_metadata_cache {
421 char *data; /* Metadata cache */
422 unsigned int cache_alloc; /* Metadata allocated size (bytes) */
423 unsigned int metadata_written; /* Number of bytes written in metadata cache */
424 atomic_t producing; /* Metadata being produced (incomplete) */
425 struct kref refcount; /* Metadata cache usage */
426 struct list_head metadata_stream; /* Metadata stream list */
427 guid_t uuid; /* Trace session unique ID (copy) */
428 struct mutex lock; /* Produce/consume lock */
429 uint64_t version; /* Current version of the metadata */
430 };
431
432 struct lttng_metadata_stream {
433 void *priv; /* Ring buffer private data */
434 struct lttng_metadata_cache *metadata_cache;
435 unsigned int metadata_in; /* Bytes read from the cache */
436 unsigned int metadata_out; /* Bytes consumed from stream */
437 int finalized; /* Has channel been finalized */
438 wait_queue_head_t read_wait; /* Reader buffer-level wait queue */
439 struct list_head node; /* Stream list */
440 struct lttng_transport *transport;
441 uint64_t version; /* Current version of the metadata cache */
442 bool coherent; /* Stream in a coherent state */
443 };
444
445 struct lttng_kernel_event_pair {
446 /* Input */
447 char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
448 struct lttng_krp *krp;
449 bool check_ids;
450 enum lttng_kretprobe_entryexit entryexit;
451 };
452
453 struct lttng_kernel_channel_buffer_ops_private {
454 struct lttng_kernel_channel_buffer_ops *pub; /* Public channel buffer ops interface */
455
456 struct lttng_kernel_ring_buffer_channel *(*channel_create)(const char *name,
457 void *priv,
458 void *buf_addr,
459 size_t subbuf_size, size_t num_subbuf,
460 unsigned int switch_timer_interval,
461 unsigned int read_timer_interval);
462 void (*channel_destroy)(struct lttng_kernel_ring_buffer_channel *chan);
463 struct lttng_kernel_ring_buffer *(*buffer_read_open)(struct lttng_kernel_ring_buffer_channel *chan);
464 int (*buffer_has_read_closed_stream)(struct lttng_kernel_ring_buffer_channel *chan);
465 void (*buffer_read_close)(struct lttng_kernel_ring_buffer *buf);
466 /*
467 * packet_avail_size returns the available size in the current
468 * packet. Note that the size returned is only a hint, since it
469 * may change due to concurrent writes.
470 */
471 size_t (*packet_avail_size)(struct lttng_kernel_ring_buffer_channel *chan);
472 wait_queue_head_t *(*get_writer_buf_wait_queue)(struct lttng_kernel_ring_buffer_channel *chan, int cpu);
473 wait_queue_head_t *(*get_hp_wait_queue)(struct lttng_kernel_ring_buffer_channel *chan);
474 int (*is_finalized)(struct lttng_kernel_ring_buffer_channel *chan);
475 int (*is_disabled)(struct lttng_kernel_ring_buffer_channel *chan);
476 int (*timestamp_begin) (const struct lttng_kernel_ring_buffer_config *config,
477 struct lttng_kernel_ring_buffer *bufb,
478 uint64_t *timestamp_begin);
479 int (*timestamp_end) (const struct lttng_kernel_ring_buffer_config *config,
480 struct lttng_kernel_ring_buffer *bufb,
481 uint64_t *timestamp_end);
482 int (*events_discarded) (const struct lttng_kernel_ring_buffer_config *config,
483 struct lttng_kernel_ring_buffer *bufb,
484 uint64_t *events_discarded);
485 int (*content_size) (const struct lttng_kernel_ring_buffer_config *config,
486 struct lttng_kernel_ring_buffer *bufb,
487 uint64_t *content_size);
488 int (*packet_size) (const struct lttng_kernel_ring_buffer_config *config,
489 struct lttng_kernel_ring_buffer *bufb,
490 uint64_t *packet_size);
491 int (*stream_id) (const struct lttng_kernel_ring_buffer_config *config,
492 struct lttng_kernel_ring_buffer *bufb,
493 uint64_t *stream_id);
494 int (*current_timestamp) (const struct lttng_kernel_ring_buffer_config *config,
495 struct lttng_kernel_ring_buffer *bufb,
496 uint64_t *ts);
497 int (*sequence_number) (const struct lttng_kernel_ring_buffer_config *config,
498 struct lttng_kernel_ring_buffer *bufb,
499 uint64_t *seq);
500 int (*instance_id) (const struct lttng_kernel_ring_buffer_config *config,
501 struct lttng_kernel_ring_buffer *bufb,
502 uint64_t *id);
503 };
504
505 #define LTTNG_EVENT_HT_BITS 12
506 #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
507
508 struct lttng_event_ht {
509 struct hlist_head table[LTTNG_EVENT_HT_SIZE];
510 };
511
512 struct lttng_event_notifier_group {
513 struct file *file; /* File associated to event notifier group */
514 struct file *notif_file; /* File used to expose notifications to userspace. */
515 struct list_head node; /* event notifier group list */
516 struct list_head enablers_head; /* List of enablers */
517 struct list_head event_notifiers_head; /* List of event notifier */
518 struct lttng_event_ht events_name_ht; /* Hash table of event notifiers, indexed by name */
519 struct lttng_kernel_channel_buffer_ops *ops;
520 struct lttng_transport *transport;
521 struct lttng_kernel_ring_buffer_channel *chan; /* Ring buffer channel for event notifier group. */
522 struct lttng_kernel_ring_buffer *buf; /* Ring buffer for event notifier group. */
523 wait_queue_head_t read_wait;
524 struct irq_work wakeup_pending; /* Pending wakeup irq work. */
525
526 struct lttng_kernel_syscall_table syscall_table;
527
528 struct lttng_kernel_channel_counter *error_counter;
529 size_t error_counter_len;
530 };
531
532 struct lttng_transport {
533 char *name;
534 struct module *owner;
535 struct list_head node;
536 struct lttng_kernel_channel_buffer_ops ops;
537 };
538
539 struct lttng_counter_transport {
540 char *name;
541 struct module *owner;
542 struct list_head node;
543 struct lttng_kernel_channel_counter_ops ops;
544 };
545
546 struct lttng_kernel_session_private {
547 struct lttng_kernel_session *pub; /* Public session interface */
548
549 int been_active; /* Has trace session been active ? */
550 struct file *file; /* File associated to session */
551 struct list_head chan_head; /* Channel list head */
552 struct list_head events_head; /* Event list head */
553 struct list_head enablers_head; /* List of event enablers */
554
555 struct lttng_event_ht events_name_ht; /* Hash table of events, indexed by name */
556 struct lttng_event_ht events_key_ht; /* Hash table of events, indexed by key */
557
558 struct list_head node; /* Session list */
559 unsigned int free_chan_id; /* Next chan ID to allocate */
560 guid_t uuid; /* Trace session unique ID */
561 struct lttng_metadata_cache *metadata_cache;
562 unsigned int metadata_dumped:1,
563 tstate:1; /* Transient enable state */
564
565 char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
566 char creation_time[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
567 };
568
569 struct lttng_id_hash_node {
570 struct hlist_node hlist;
571 int id;
572 };
573
574 enum tracker_type {
575 TRACKER_PID,
576 TRACKER_VPID,
577 TRACKER_UID,
578 TRACKER_VUID,
579 TRACKER_GID,
580 TRACKER_VGID,
581
582 TRACKER_UNKNOWN,
583 };
584
585 struct lttng_kernel_id_tracker_private {
586 struct lttng_kernel_id_tracker *pub; /* Public interface */
587
588 struct lttng_kernel_session *session;
589 enum tracker_type tracker_type;
590 };
591
592 enum lttng_kernel_counter_dimension_flags {
593 LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_UNDERFLOW = (1 << 0),
594 LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_OVERFLOW = (1 << 1),
595 };
596
597 enum lttng_kernel_counter_conf_flags {
598 LTTNG_KERNEL_COUNTER_CONF_FLAG_COALESCE_HITS = (1 << 0),
599 };
600
601 enum lttng_kernel_counter_arithmetic {
602 LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR = 0,
603 };
604
605 enum lttng_kernel_counter_bitness {
606 LTTNG_KERNEL_COUNTER_BITNESS_32 = 0,
607 LTTNG_KERNEL_COUNTER_BITNESS_64 = 1,
608 };
609
610 /* Internally, only 1 dimension is supported fow now. */
611 #define LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS 1
612 /* Internally, only 16 tokens are supported for now. */
613 #define LTTNG_KERNEL_COUNTER_MAX_TOKENS 16
614
615 struct lttng_kernel_counter_dimension {
616 uint32_t flags; /* enum lttng_kernel_counter_dimension_flags */
617 uint64_t size; /* dimension size */
618 uint64_t underflow_index;
619 uint64_t overflow_index;
620 };
621
622 struct lttng_kernel_counter_conf {
623 uint32_t flags; /* enum lttng_kernel_counter_conf_flags */
624 uint32_t arithmetic; /* enum lttng_kernel_counter_arithmetic */
625 uint32_t bitness; /* enum lttng_kernel_counter_bitness */
626 int64_t global_sum_step;
627 struct lttng_kernel_counter_dimension dimension_array[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS];
628 };
629
630 enum lttng_key_token_type {
631 LTTNG_KEY_TOKEN_UNKNOWN = 0, /* Uninitialized. */
632
633 LTTNG_KEY_TOKEN_STRING = 1,
634 LTTNG_KEY_TOKEN_EVENT_NAME = 2,
635 };
636
637 struct lttng_key_token {
638 enum lttng_key_token_type type;
639 char *str;
640 };
641
642 struct lttng_kernel_counter_key_dimension {
643 size_t nr_key_tokens;
644 struct lttng_key_token *token_array;
645 };
646
647 struct lttng_kernel_counter_key {
648 size_t nr_dimensions;
649 struct lttng_kernel_counter_key_dimension dimension_array[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS];
650 };
651
652 struct lttng_kernel_counter_event {
653 struct lttng_kernel_abi_event event_param;
654 struct lttng_kernel_abi_event_ext event_param_ext;
655
656 struct lttng_kernel_counter_key *counter_key;
657 };
658
659 extern struct lttng_kernel_ctx *lttng_static_ctx;
660
661 static inline
662 const struct lttng_kernel_type_integer *lttng_kernel_get_type_integer(const struct lttng_kernel_type_common *type)
663 {
664 if (type->type != lttng_kernel_type_integer)
665 return NULL;
666 return container_of(type, const struct lttng_kernel_type_integer, parent);
667 }
668
669 static inline
670 const struct lttng_kernel_type_string *lttng_kernel_get_type_string(const struct lttng_kernel_type_common *type)
671 {
672 if (type->type != lttng_kernel_type_string)
673 return NULL;
674 return container_of(type, const struct lttng_kernel_type_string, parent);
675 }
676
677 static inline
678 const struct lttng_kernel_type_enum *lttng_kernel_get_type_enum(const struct lttng_kernel_type_common *type)
679 {
680 if (type->type != lttng_kernel_type_enum)
681 return NULL;
682 return container_of(type, const struct lttng_kernel_type_enum, parent);
683 }
684
685 static inline
686 const struct lttng_kernel_type_array *lttng_kernel_get_type_array(const struct lttng_kernel_type_common *type)
687 {
688 if (type->type != lttng_kernel_type_array)
689 return NULL;
690 return container_of(type, const struct lttng_kernel_type_array, parent);
691 }
692
693 static inline
694 const struct lttng_kernel_type_sequence *lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common *type)
695 {
696 if (type->type != lttng_kernel_type_sequence)
697 return NULL;
698 return container_of(type, const struct lttng_kernel_type_sequence, parent);
699 }
700
701 static inline
702 const struct lttng_kernel_type_struct *lttng_kernel_get_type_struct(const struct lttng_kernel_type_common *type)
703 {
704 if (type->type != lttng_kernel_type_struct)
705 return NULL;
706 return container_of(type, const struct lttng_kernel_type_struct, parent);
707 }
708
709 static inline
710 const struct lttng_kernel_type_variant *lttng_kernel_get_type_variant(const struct lttng_kernel_type_common *type)
711 {
712 if (type->type != lttng_kernel_type_variant)
713 return NULL;
714 return container_of(type, const struct lttng_kernel_type_variant, parent);
715 }
716
717 static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common *type)
718 {
719 const struct lttng_kernel_type_integer *type_integer = lttng_kernel_get_type_integer(type);
720
721 if (!type_integer)
722 return false;
723 switch (type_integer->size) {
724 case 8:
725 lttng_fallthrough;
726 case 16:
727 lttng_fallthrough;
728 case 32:
729 lttng_fallthrough;
730 case 64:
731 break;
732 default:
733 return false;
734 }
735 return true;
736 }
737
738 int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *event,
739 const char *interpreter_stack_data,
740 struct lttng_kernel_probe_ctx *probe_ctx,
741 void *event_filter_ctx);
742
743 static inline
744 struct lttng_event_enabler_common *lttng_event_notifier_enabler_as_enabler(
745 struct lttng_event_notifier_enabler *event_notifier_enabler)
746 {
747 return &event_notifier_enabler->parent;
748 }
749
750 static inline
751 struct lttng_event_ht *lttng_get_events_name_ht_from_enabler(struct lttng_event_enabler_common *event_enabler)
752 {
753 switch (event_enabler->enabler_type) {
754 case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
755 lttng_fallthrough;
756 case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
757 {
758 struct lttng_event_enabler_session_common *event_enabler_session =
759 container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
760 return &event_enabler_session->chan->session->priv->events_name_ht;
761 }
762 case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
763 {
764 struct lttng_event_notifier_enabler *event_notifier_enabler =
765 container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
766 return &event_notifier_enabler->group->events_name_ht;
767 }
768 default:
769 return NULL;
770 }
771 }
772
773 static inline
774 struct lttng_event_ht *lttng_get_events_key_ht_from_enabler(struct lttng_event_enabler_common *event_enabler)
775 {
776 switch (event_enabler->enabler_type) {
777 case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
778 lttng_fallthrough;
779 case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
780 {
781 struct lttng_event_enabler_session_common *event_enabler_session =
782 container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
783 return &event_enabler_session->chan->session->priv->events_key_ht;
784 }
785 case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
786 lttng_fallthrough;
787 default:
788 return NULL;
789 }
790 }
791
792 static inline
793 struct list_head *lttng_get_event_list_head_from_enabler(struct lttng_event_enabler_common *event_enabler)
794 {
795 switch (event_enabler->enabler_type) {
796 case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
797 lttng_fallthrough;
798 case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
799 {
800 struct lttng_event_enabler_session_common *event_enabler_session =
801 container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
802 return &event_enabler_session->chan->session->priv->events_head;
803 }
804 case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
805 {
806 struct lttng_event_notifier_enabler *event_notifier_enabler =
807 container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
808 return &event_notifier_enabler->group->event_notifiers_head;
809 }
810 default:
811 return NULL;
812 }
813 }
814
815 int lttng_context_init(void);
816 void lttng_context_exit(void);
817 int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p,
818 const struct lttng_kernel_ctx_field *f);
819 void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p);
820 struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx,
821 size_t index);
822 int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name);
823 int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name);
824 void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx);
825 int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx);
826 int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx);
827 int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx);
828 int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx);
829 int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx);
830 int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx);
831 int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx);
832 int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx);
833 int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx);
834 int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx);
835 int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx);
836 int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx);
837 int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx);
838 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
839 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx);
840 #else
841 static inline
842 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx)
843 {
844 return -ENOSYS;
845 }
846 #endif
847 #ifdef CONFIG_PREEMPT_RT_FULL
848 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx);
849 #else
850 static inline
851 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx)
852 {
853 return -ENOSYS;
854 }
855 #endif
856
857 int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type);
858
859 #if defined(CONFIG_CGROUPS) && \
860 ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
861 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
862 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx);
863 #else
864 static inline
865 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx)
866 {
867 return -ENOSYS;
868 }
869 #endif
870
871 #if defined(CONFIG_IPC_NS) && \
872 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
873 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx);
874 #else
875 static inline
876 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx)
877 {
878 return -ENOSYS;
879 }
880 #endif
881
882 #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
883 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
884 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx);
885 #else
886 static inline
887 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx)
888 {
889 return -ENOSYS;
890 }
891 #endif
892
893 #if defined(CONFIG_NET_NS) && \
894 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
895 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx);
896 #else
897 static inline
898 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx)
899 {
900 return -ENOSYS;
901 }
902 #endif
903
904 #if defined(CONFIG_PID_NS) && \
905 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
906 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx);
907 #else
908 static inline
909 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx)
910 {
911 return -ENOSYS;
912 }
913 #endif
914
915 #if defined(CONFIG_USER_NS) && \
916 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
917 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx);
918 #else
919 static inline
920 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx)
921 {
922 return -ENOSYS;
923 }
924 #endif
925
926 #if defined(CONFIG_UTS_NS) && \
927 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
928 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx);
929 #else
930 static inline
931 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx)
932 {
933 return -ENOSYS;
934 }
935 #endif
936
937 #if defined(CONFIG_TIME_NS) && \
938 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0) || \
939 LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0))
940 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx);
941 #else
942 static inline
943 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx)
944 {
945 return -ENOSYS;
946 }
947 #endif
948
949 int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx);
950 int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx);
951 int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx);
952 int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx);
953 int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx);
954 int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx);
955 int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx);
956 int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx);
957 int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx);
958 int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx);
959 int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx);
960 int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx);
961
962 #if defined(CONFIG_PERF_EVENTS)
963 int lttng_add_perf_counter_to_ctx(uint32_t type,
964 uint64_t config,
965 const char *name,
966 struct lttng_kernel_ctx **ctx);
967 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
968 struct lttng_cpuhp_node *node);
969 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
970 struct lttng_cpuhp_node *node);
971 #else
972 static inline
973 int lttng_add_perf_counter_to_ctx(uint32_t type,
974 uint64_t config,
975 const char *name,
976 struct lttng_kernel_ctx **ctx)
977 {
978 return -ENOSYS;
979 }
980 static inline
981 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
982 struct lttng_cpuhp_node *node)
983 {
984 return 0;
985 }
986 static inline
987 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
988 struct lttng_cpuhp_node *node)
989 {
990 return 0;
991 }
992 #endif
993
994 struct lttng_event_recorder_enabler *lttng_event_recorder_enabler_create(
995 enum lttng_enabler_format_type format_type,
996 struct lttng_kernel_abi_event *event_param,
997 struct lttng_kernel_channel_buffer *chan);
998 void lttng_event_enabler_session_add(struct lttng_kernel_session *session,
999 struct lttng_event_enabler_session_common *event_enabler);
1000
1001 struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
1002 enum lttng_enabler_format_type format_type,
1003 struct lttng_kernel_abi_event_notifier *event_notifier_param,
1004 struct lttng_event_notifier_group *event_notifier_group);
1005 void lttng_event_notifier_enabler_group_add(struct lttng_event_notifier_group *event_notifier_group,
1006 struct lttng_event_notifier_enabler *event_notifier_enabler);
1007 int lttng_event_notifier_enabler_attach_capture_bytecode(
1008 struct lttng_event_notifier_enabler *event_notifier_enabler,
1009 struct lttng_kernel_abi_capture_bytecode __user *bytecode);
1010
1011 int lttng_event_enabler_enable(struct lttng_event_enabler_common *event_enabler);
1012 int lttng_event_enabler_disable(struct lttng_event_enabler_common *event_enabler);
1013 int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler_common *event_enabler,
1014 struct lttng_kernel_abi_filter_bytecode __user *bytecode);
1015 void lttng_event_enabler_destroy(struct lttng_event_enabler_common *event_enabler);
1016
1017 bool lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
1018 struct lttng_event_enabler_common *enabler);
1019 bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_enabler,
1020 struct lttng_kernel_event_common *event);
1021
1022 void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc,
1023 struct lttng_kernel_ctx *ctx,
1024 struct list_head *instance_bytecode_runtime_head,
1025 struct list_head *enabler_bytecode_runtime_head);
1026
1027 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
1028 int lttng_event_enabler_create_syscall_events_if_missing(struct lttng_event_enabler_common *event_enabler);
1029 int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common *event);
1030 int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common *event);
1031
1032 int lttng_syscalls_unregister_syscall_table(struct lttng_kernel_syscall_table *syscall_table);
1033 int lttng_syscalls_destroy_syscall_table(struct lttng_kernel_syscall_table *syscall_table);
1034
1035 long lttng_syscall_table_get_active_mask(struct lttng_kernel_syscall_table *syscall_table,
1036 struct lttng_kernel_abi_syscall_mask __user *usyscall_mask);
1037
1038 void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler);
1039 #else
1040 static inline int lttng_event_enabler_create_syscall_events_if_missing(struct lttng_event_enabler_common *event_enabler)
1041 {
1042 return -ENOSYS;
1043 }
1044
1045 static inline int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common *event)
1046 {
1047 return -ENOSYS;
1048 }
1049
1050 static inline int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common *event)
1051 {
1052 return -ENOSYS;
1053 }
1054
1055 static inline int lttng_syscalls_unregister_syscall_table(struct lttng_kernel_syscall_table *syscall_table)
1056 {
1057 return 0;
1058 }
1059
1060 static inline int lttng_syscalls_destroy_syscall_table(struct lttng_kernel_syscall_table *syscall_table)
1061 {
1062 return 0;
1063 }
1064
1065 static inline long lttng_syscall_table_get_active_mask(struct lttng_kernel_syscall_table *syscall_table,
1066 struct lttng_kernel_abi_syscall_mask __user *usyscall_mask)
1067 {
1068 return -ENOSYS;
1069 }
1070
1071 static inline int lttng_syscalls_create_matching_event_notifiers(struct lttng_event_notifier_enabler *event_notifier_enabler)
1072 {
1073 return -ENOSYS;
1074 }
1075
1076 static inline void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler)
1077 {
1078 }
1079 #endif
1080
1081 #ifdef CONFIG_KPROBES
1082 int lttng_kprobes_init_event(const char *name,
1083 const char *symbol_name,
1084 uint64_t offset,
1085 uint64_t addr,
1086 struct lttng_kernel_event_common *event);
1087 int lttng_kprobes_register_event(struct lttng_kernel_event_common *event);
1088 void lttng_kprobes_unregister_event(struct lttng_kernel_event_common *event);
1089 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event);
1090 int lttng_kprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr);
1091
1092 #else
1093 static inline
1094 int lttng_kprobes_init_event(const char *name,
1095 const char *symbol_name,
1096 uint64_t offset,
1097 uint64_t addr,
1098 struct lttng_kernel_event_common *event)
1099 {
1100 return -ENOSYS;
1101 }
1102 static inline
1103 int lttng_kprobes_register_event(struct lttng_kernel_event_common *event)
1104 {
1105 return -ENOSYS;
1106 }
1107
1108 static inline
1109 void lttng_kprobes_unregister_event(struct lttng_kernel_event_common *event)
1110 {
1111 }
1112
1113 static inline
1114 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event)
1115 {
1116 }
1117 static inline
1118 int lttng_kprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr)
1119 {
1120 return -ENOENT;
1121 }
1122 #endif
1123
1124 int lttng_event_add_callsite(struct lttng_kernel_event_common *event,
1125 struct lttng_kernel_abi_event_callsite __user *callsite);
1126
1127 #ifdef CONFIG_UPROBES
1128 int lttng_uprobes_register_event(const char *name,
1129 int fd, struct lttng_kernel_event_common *event);
1130 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
1131 struct lttng_kernel_abi_event_callsite __user *callsite);
1132 void lttng_uprobes_unregister_event(struct lttng_kernel_event_common *event);
1133 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_common *event);
1134 #else
1135 static inline
1136 int lttng_uprobes_register_event(const char *name,
1137 int fd, struct lttng_kernel_event_common *event)
1138 {
1139 return -ENOSYS;
1140 }
1141
1142 static inline
1143 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
1144 struct lttng_kernel_abi_event_callsite __user *callsite)
1145 {
1146 return -ENOSYS;
1147 }
1148
1149 static inline
1150 void lttng_uprobes_unregister_event(struct lttng_kernel_event_common *event)
1151 {
1152 }
1153
1154 static inline
1155 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_common *event)
1156 {
1157 }
1158 #endif
1159
1160 #ifdef CONFIG_KRETPROBES
1161 struct lttng_krp *lttng_kretprobes_create_krp(const char *symbol_name,
1162 uint64_t offset, uint64_t addr);
1163 void lttng_kretprobes_put_krp(struct lttng_krp *krp);
1164 int lttng_kretprobes_init_event(const char *name,
1165 enum lttng_kretprobe_entryexit entryexit,
1166 struct lttng_kernel_event_common *event,
1167 struct lttng_krp *krp);
1168 int lttng_kretprobes_register_event(struct lttng_kernel_event_common *event);
1169 void lttng_kretprobes_unregister_event(struct lttng_kernel_event_common *event);
1170 void lttng_kretprobes_destroy_event_private(struct lttng_kernel_event_common *event);
1171 int lttng_kretprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr);
1172 #else
1173 static inline
1174 struct lttng_krp *lttng_kretprobes_create_krp(const char *symbol_name,
1175 uint64_t offset, uint64_t addr)
1176 {
1177 return NULL;
1178 }
1179
1180 static inline
1181 void lttng_kretprobes_put_krp(struct lttng_krp *krp)
1182 {
1183 }
1184
1185 static inline
1186 int lttng_kretprobes_init_event(const char *name,
1187 enum lttng_kretprobe_entryexit entryexit,
1188 struct lttng_kernel_event_common *event,
1189 struct lttng_krp *krp)
1190 {
1191 return -ENOSYS;
1192 }
1193
1194 static inline
1195 int lttng_kretprobes_register_event(struct lttng_kernel_event_common *event)
1196 {
1197 return -ENOSYS;
1198 }
1199
1200 static inline
1201 void lttng_kretprobes_unregister_event(struct lttng_kernel_event_common *event)
1202 {
1203 }
1204
1205 static inline
1206 void lttng_kretprobes_destroy_event_private(struct lttng_kernel_event_common *event)
1207 {
1208 }
1209
1210 static inline
1211 int lttng_kretprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr)
1212 {
1213 return -ENOENT;
1214 }
1215
1216 static inline
1217 struct lttng_kernel_event_desc *lttng_create_kretprobes_event_desc(const char *name)
1218 {
1219 return NULL;
1220 }
1221
1222 static inline
1223 int lttng_kretprobes_register(const char *symbol_name,
1224 uint64_t offset,
1225 uint64_t addr,
1226 struct lttng_kernel_event_common *event_entry,
1227 struct lttng_kernel_event_common *event_exit)
1228 {
1229 return -ENOSYS;
1230 }
1231 #endif
1232
1233 void lttng_lock_sessions(void);
1234 void lttng_unlock_sessions(void);
1235
1236 struct list_head *lttng_get_probe_list_head(void);
1237
1238 int lttng_fix_pending_events(void);
1239 int lttng_fix_pending_event_notifiers(void);
1240 int lttng_session_active(void);
1241 bool lttng_event_notifier_active(void);
1242
1243 struct lttng_kernel_session *lttng_session_create(void);
1244 int lttng_session_enable(struct lttng_kernel_session *session);
1245 int lttng_session_disable(struct lttng_kernel_session *session);
1246 void lttng_session_destroy(struct lttng_kernel_session *session);
1247 int lttng_session_metadata_regenerate(struct lttng_kernel_session *session);
1248 int lttng_session_statedump(struct lttng_kernel_session *session);
1249 void metadata_cache_destroy(struct kref *kref);
1250
1251 struct lttng_kernel_channel_counter *lttng_kernel_counter_create(
1252 const char *counter_transport_name,
1253 size_t number_dimensions,
1254 const struct lttng_kernel_counter_dimension *dimensions,
1255 int64_t global_sum_step,
1256 bool coalesce_hits);
1257 int lttng_kernel_counter_read(struct lttng_kernel_channel_counter *counter,
1258 const size_t *dimension_indexes, int32_t cpu,
1259 int64_t *val, bool *overflow, bool *underflow);
1260 int lttng_kernel_counter_aggregate(struct lttng_kernel_channel_counter *counter,
1261 const size_t *dimension_indexes, int64_t *val,
1262 bool *overflow, bool *underflow);
1263 int lttng_kernel_counter_clear(struct lttng_kernel_channel_counter *counter,
1264 const size_t *dimension_indexes);
1265 int lttng_kernel_counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter,
1266 size_t *nr_dimensions);
1267 int lttng_kernel_counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter,
1268 size_t *max_nr_elem);
1269 struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
1270 void lttng_event_notifier_group_destroy(
1271 struct lttng_event_notifier_group *event_notifier_group);
1272
1273 struct lttng_kernel_channel_buffer *lttng_channel_buffer_create(struct lttng_kernel_session *session,
1274 const char *transport_name,
1275 void *buf_addr,
1276 size_t subbuf_size, size_t num_subbuf,
1277 unsigned int switch_timer_interval,
1278 unsigned int read_timer_interval,
1279 enum channel_type channel_type);
1280 struct lttng_kernel_channel_buffer *lttng_global_channel_create(struct lttng_kernel_session *session,
1281 int overwrite, void *buf_addr,
1282 size_t subbuf_size, size_t num_subbuf,
1283 unsigned int switch_timer_interval,
1284 unsigned int read_timer_interval);
1285
1286 void lttng_metadata_channel_buffer_destroy(struct lttng_kernel_channel_buffer *chan);
1287 struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_enabler_common *event_enabler,
1288 const struct lttng_kernel_event_desc *event_desc,
1289 struct lttng_kernel_event_pair *event_pair);
1290 struct lttng_kernel_event_common *lttng_kernel_event_create(struct lttng_event_enabler_common *event_enabler,
1291 const struct lttng_kernel_event_desc *event_desc,
1292 struct lttng_kernel_event_pair *event_pair);
1293
1294 int lttng_channel_enable(struct lttng_kernel_channel_common *channel);
1295 int lttng_channel_disable(struct lttng_kernel_channel_common *channel);
1296 int lttng_event_enable(struct lttng_kernel_event_common *event);
1297 int lttng_event_disable(struct lttng_kernel_event_common *event);
1298
1299 void lttng_transport_register(struct lttng_transport *transport);
1300 void lttng_transport_unregister(struct lttng_transport *transport);
1301
1302 void lttng_counter_transport_register(struct lttng_counter_transport *transport);
1303 void lttng_counter_transport_unregister(struct lttng_counter_transport *transport);
1304
1305 void synchronize_trace(void);
1306 int lttng_abi_init(void);
1307 int lttng_abi_compat_old_init(void);
1308 void lttng_abi_exit(void);
1309 void lttng_abi_compat_old_exit(void);
1310
1311 const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name);
1312 void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc);
1313 int lttng_probes_init(void);
1314 void lttng_probes_exit(void);
1315
1316 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
1317 struct lttng_kernel_ring_buffer_channel *chan, bool *coherent);
1318
1319 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
1320 int lttng_id_tracker_empty_set(struct lttng_kernel_id_tracker *lf);
1321 int lttng_id_tracker_init(struct lttng_kernel_id_tracker *lf,
1322 struct lttng_kernel_session *session,
1323 enum tracker_type type);
1324 void lttng_id_tracker_fini(struct lttng_kernel_id_tracker *lf);
1325 void lttng_id_tracker_destroy(struct lttng_kernel_id_tracker *lf, bool rcu);
1326 int lttng_id_tracker_add(struct lttng_kernel_id_tracker *lf, int id);
1327 int lttng_id_tracker_del(struct lttng_kernel_id_tracker *lf, int id);
1328
1329 int lttng_session_track_id(struct lttng_kernel_session *session,
1330 enum tracker_type tracker_type, int id);
1331 int lttng_session_untrack_id(struct lttng_kernel_session *session,
1332 enum tracker_type tracker_type, int id);
1333
1334 int lttng_session_list_tracker_ids(struct lttng_kernel_session *session,
1335 enum tracker_type tracker_type);
1336
1337 void lttng_clock_ref(void);
1338 void lttng_clock_unref(void);
1339
1340 void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event);
1341
1342 int lttng_probes_init(void);
1343
1344 int lttng_logger_init(void);
1345 void lttng_logger_exit(void);
1346
1347 extern int lttng_statedump_start(struct lttng_kernel_session *session);
1348
1349 int lttng_calibrate(struct lttng_kernel_abi_calibrate *calibrate);
1350
1351 extern const struct file_operations lttng_tracepoint_list_fops;
1352 extern const struct file_operations lttng_syscall_list_fops;
1353
1354 struct lttng_kernel_channel_buffer *lttng_kernel_alloc_channel_buffer(void);
1355 struct lttng_kernel_channel_counter *lttng_kernel_alloc_channel_counter(void);
1356 void lttng_kernel_free_channel_common(struct lttng_kernel_channel_common *chan);
1357
1358 int format_event_key(struct lttng_event_enabler_common *event_enabler, char *key_string,
1359 const char *event_name);
1360 bool lttng_event_enabler_event_name_key_match_event(struct lttng_event_enabler_common *event_enabler,
1361 const char *event_name, const char *key_string, struct lttng_kernel_event_common *event);
1362 struct lttng_event_counter_enabler *lttng_event_counter_enabler_create(
1363 enum lttng_enabler_format_type format_type,
1364 struct lttng_kernel_abi_event *event_param,
1365 struct lttng_kernel_counter_key *counter_key,
1366 struct lttng_kernel_channel_counter *chan);
1367
1368 int create_counter_key_from_kernel(struct lttng_kernel_counter_key **counter_key,
1369 const struct lttng_kernel_counter_key *key);
1370 void destroy_counter_key(struct lttng_kernel_counter_key *counter_key);
1371
1372 #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \
1373 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \
1374 .event_field = (_event_field), \
1375 .get_size = (_get_size), \
1376 .record = (_record), \
1377 .get_value = (_get_value), \
1378 .destroy = (_destroy), \
1379 .priv = (_priv), \
1380 })
1381
1382 #endif /* _LTTNG_EVENTS_INTERNAL_H */
This page took 0.101852 seconds and 5 git commands to generate.