Move event notifier and counter structures to private header
[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 <lttng/events.h>
12
13 enum lttng_enabler_format_type {
14 LTTNG_ENABLER_FORMAT_STAR_GLOB,
15 LTTNG_ENABLER_FORMAT_NAME,
16 };
17
18 /*
19 * Objects in a linked-list of enablers, owned by an event.
20 */
21 struct lttng_enabler_ref {
22 struct list_head node; /* enabler ref list */
23 struct lttng_enabler *ref; /* backward ref */
24 };
25
26 struct lttng_krp; /* Kretprobe handling */
27
28 struct lttng_uprobe_handler {
29 struct lttng_kernel_event_common *event;
30 loff_t offset;
31 struct uprobe_consumer up_consumer;
32 struct list_head node;
33 };
34
35 struct lttng_kprobe {
36 struct kprobe kp;
37 char *symbol_name;
38 };
39
40 struct lttng_uprobe {
41 struct inode *inode;
42 struct list_head head;
43 };
44
45 enum lttng_syscall_entryexit {
46 LTTNG_SYSCALL_ENTRY,
47 LTTNG_SYSCALL_EXIT,
48 };
49
50 enum lttng_syscall_abi {
51 LTTNG_SYSCALL_ABI_NATIVE,
52 LTTNG_SYSCALL_ABI_COMPAT,
53 };
54
55 struct lttng_kernel_event_common_private {
56 struct lttng_kernel_event_common *pub; /* Public event interface */
57
58 const struct lttng_kernel_event_desc *desc;
59 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
60 struct list_head enablers_ref_head;
61 int registered; /* has reg'd tracepoint probe */
62 uint64_t user_token;
63
64 int has_enablers_without_filter_bytecode;
65 /* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */
66 struct list_head filter_bytecode_runtime_head;
67 enum lttng_kernel_abi_instrumentation instrumentation;
68 /* Selected by instrumentation */
69 union {
70 struct lttng_kprobe kprobe;
71 struct lttng_uprobe uprobe;
72 struct {
73 struct lttng_krp *lttng_krp;
74 char *symbol_name;
75 } kretprobe;
76 struct {
77 enum lttng_syscall_entryexit entryexit;
78 enum lttng_syscall_abi abi;
79 struct hlist_node node; /* chain registered syscall event_notifier */
80 unsigned int syscall_id;
81 } syscall;
82 } u;
83 };
84
85 struct lttng_kernel_event_recorder_private {
86 struct lttng_kernel_event_common_private parent;
87
88 struct lttng_kernel_event_recorder *pub; /* Public event interface */
89 struct list_head node; /* Event recorder list */
90 struct hlist_node hlist; /* Hash table of event recorders */
91 struct lttng_kernel_ctx *ctx;
92 unsigned int id;
93 unsigned int metadata_dumped:1;
94 };
95
96 struct lttng_kernel_event_notifier_private {
97 struct lttng_kernel_event_common_private parent;
98
99 struct lttng_kernel_event_notifier *pub; /* Public event notifier interface */
100 struct lttng_event_notifier_group *group; /* weak ref */
101 size_t num_captures; /* Needed to allocate the msgpack array. */
102 uint64_t error_counter_index;
103 struct list_head node; /* Event notifier list */
104 struct hlist_node hlist; /* Hash table of event notifiers */
105 struct list_head capture_bytecode_runtime_head;
106
107 };
108
109 enum lttng_kernel_bytecode_interpreter_ret {
110 LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR = -1,
111 LTTNG_KERNEL_BYTECODE_INTERPRETER_OK = 0,
112 };
113
114 enum lttng_kernel_bytecode_filter_result {
115 LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT = 0,
116 LTTNG_KERNEL_BYTECODE_FILTER_REJECT = 1,
117 };
118
119 struct lttng_kernel_bytecode_filter_ctx {
120 enum lttng_kernel_bytecode_filter_result result;
121 };
122
123 struct lttng_interpreter_output;
124
125 enum lttng_kernel_bytecode_type {
126 LTTNG_KERNEL_BYTECODE_TYPE_FILTER,
127 LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE,
128 };
129
130 struct lttng_kernel_bytecode_node {
131 enum lttng_kernel_bytecode_type type;
132 struct list_head node;
133 struct lttng_enabler *enabler;
134 struct {
135 uint32_t len;
136 uint32_t reloc_offset;
137 uint64_t seqnum;
138 char data[];
139 } bc;
140 };
141
142 struct lttng_kernel_bytecode_runtime {
143 /* Associated bytecode */
144 enum lttng_kernel_bytecode_type type;
145 struct lttng_kernel_bytecode_node *bc;
146 int (*interpreter_func)(struct lttng_kernel_bytecode_runtime *kernel_bytecode,
147 const char *interpreter_stack_data,
148 struct lttng_kernel_probe_ctx *lttng_probe_ctx,
149 void *caller_ctx);
150 int link_failed;
151 struct list_head node; /* list of bytecode runtime in event */
152 struct lttng_kernel_ctx *ctx;
153 };
154
155 /*
156 * Enabler field, within whatever object is enabling an event. Target of
157 * backward reference.
158 */
159 struct lttng_enabler {
160 enum lttng_enabler_format_type format_type;
161
162 /* head list of struct lttng_kernel_bytecode_node */
163 struct list_head filter_bytecode_head;
164
165 struct lttng_kernel_abi_event event_param;
166 unsigned int enabled:1;
167
168 uint64_t user_token; /* User-provided token. */
169 };
170
171 struct lttng_event_enabler {
172 struct lttng_enabler base;
173 struct list_head node; /* per-session list of enablers */
174 struct lttng_channel *chan;
175 };
176
177 struct lttng_event_notifier_enabler {
178 struct lttng_enabler base;
179 uint64_t error_counter_index;
180 struct list_head node; /* List of event_notifier enablers */
181 struct lttng_event_notifier_group *group;
182
183 /* head list of struct lttng_kernel_bytecode_node */
184 struct list_head capture_bytecode_head;
185 uint64_t num_captures;
186 };
187
188 struct lttng_ctx_value {
189 union {
190 int64_t s64;
191 const char *str;
192 double d;
193 } u;
194 };
195
196 /*
197 * We need to keep this perf counter field separately from struct
198 * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses.
199 */
200 struct lttng_perf_counter_field {
201 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
202 struct lttng_cpuhp_node cpuhp_prepare;
203 struct lttng_cpuhp_node cpuhp_online;
204 #else
205 struct notifier_block nb;
206 int hp_enable;
207 #endif
208 struct perf_event_attr *attr;
209 struct perf_event **e; /* per-cpu array */
210 char *name;
211 struct lttng_kernel_event_field *event_field;
212 };
213
214 struct lttng_kernel_ctx_field {
215 const struct lttng_kernel_event_field *event_field;
216 size_t (*get_size)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
217 size_t offset);
218 void (*record)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
219 struct lttng_kernel_ring_buffer_ctx *ctx,
220 struct lttng_channel *chan);
221 void (*get_value)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
222 struct lttng_ctx_value *value);
223 void (*destroy)(void *priv);
224 void *priv;
225 };
226
227 struct lttng_kernel_ctx {
228 struct lttng_kernel_ctx_field *fields;
229 unsigned int nr_fields;
230 unsigned int allocated_fields;
231 size_t largest_align; /* in bytes */
232 };
233
234 struct lttng_metadata_cache {
235 char *data; /* Metadata cache */
236 unsigned int cache_alloc; /* Metadata allocated size (bytes) */
237 unsigned int metadata_written; /* Number of bytes written in metadata cache */
238 atomic_t producing; /* Metadata being produced (incomplete) */
239 struct kref refcount; /* Metadata cache usage */
240 struct list_head metadata_stream; /* Metadata stream list */
241 uuid_le uuid; /* Trace session unique ID (copy) */
242 struct mutex lock; /* Produce/consume lock */
243 uint64_t version; /* Current version of the metadata */
244 };
245
246 struct lttng_kernel_channel_buffer_ops_private {
247 struct lttng_kernel_channel_buffer_ops *pub; /* Public channel buffer ops interface */
248
249 struct channel *(*channel_create)(const char *name,
250 void *priv,
251 void *buf_addr,
252 size_t subbuf_size, size_t num_subbuf,
253 unsigned int switch_timer_interval,
254 unsigned int read_timer_interval);
255 void (*channel_destroy)(struct channel *chan);
256 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
257 int (*buffer_has_read_closed_stream)(struct channel *chan);
258 void (*buffer_read_close)(struct lib_ring_buffer *buf);
259 /*
260 * packet_avail_size returns the available size in the current
261 * packet. Note that the size returned is only a hint, since it
262 * may change due to concurrent writes.
263 */
264 size_t (*packet_avail_size)(struct channel *chan);
265 wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
266 wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
267 int (*is_finalized)(struct channel *chan);
268 int (*is_disabled)(struct channel *chan);
269 int (*timestamp_begin) (const struct lib_ring_buffer_config *config,
270 struct lib_ring_buffer *bufb,
271 uint64_t *timestamp_begin);
272 int (*timestamp_end) (const struct lib_ring_buffer_config *config,
273 struct lib_ring_buffer *bufb,
274 uint64_t *timestamp_end);
275 int (*events_discarded) (const struct lib_ring_buffer_config *config,
276 struct lib_ring_buffer *bufb,
277 uint64_t *events_discarded);
278 int (*content_size) (const struct lib_ring_buffer_config *config,
279 struct lib_ring_buffer *bufb,
280 uint64_t *content_size);
281 int (*packet_size) (const struct lib_ring_buffer_config *config,
282 struct lib_ring_buffer *bufb,
283 uint64_t *packet_size);
284 int (*stream_id) (const struct lib_ring_buffer_config *config,
285 struct lib_ring_buffer *bufb,
286 uint64_t *stream_id);
287 int (*current_timestamp) (const struct lib_ring_buffer_config *config,
288 struct lib_ring_buffer *bufb,
289 uint64_t *ts);
290 int (*sequence_number) (const struct lib_ring_buffer_config *config,
291 struct lib_ring_buffer *bufb,
292 uint64_t *seq);
293 int (*instance_id) (const struct lib_ring_buffer_config *config,
294 struct lib_ring_buffer *bufb,
295 uint64_t *id);
296 };
297
298 struct lttng_counter_ops {
299 struct lib_counter *(*counter_create)(size_t nr_dimensions,
300 const size_t *max_nr_elem, /* for each dimension */
301 int64_t global_sum_step);
302 void (*counter_destroy)(struct lib_counter *counter);
303 int (*counter_add)(struct lib_counter *counter, const size_t *dimension_indexes,
304 int64_t v);
305 /*
306 * counter_read reads a specific cpu's counter if @cpu >= 0, or
307 * the global aggregation counter if @cpu == -1.
308 */
309 int (*counter_read)(struct lib_counter *counter, const size_t *dimension_indexes, int cpu,
310 int64_t *value, bool *overflow, bool *underflow);
311 /*
312 * counter_aggregate returns the total sum of all per-cpu counters and
313 * the global aggregation counter.
314 */
315 int (*counter_aggregate)(struct lib_counter *counter, const size_t *dimension_indexes,
316 int64_t *value, bool *overflow, bool *underflow);
317 int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes);
318 };
319
320 struct lttng_counter {
321 struct file *file; /* File associated to counter. */
322 struct file *owner;
323 struct lttng_counter_transport *transport;
324 struct lib_counter *counter;
325 struct lttng_counter_ops *ops;
326 };
327
328 struct lttng_event_notifier_group {
329 struct file *file; /* File associated to event notifier group */
330 struct file *notif_file; /* File used to expose notifications to userspace. */
331 struct list_head node; /* event notifier group list */
332 struct list_head enablers_head; /* List of enablers */
333 struct list_head event_notifiers_head; /* List of event notifier */
334 struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */
335 struct lttng_kernel_channel_buffer_ops *ops;
336 struct lttng_transport *transport;
337 struct channel *chan; /* Ring buffer channel for event notifier group. */
338 struct lib_ring_buffer *buf; /* Ring buffer for event notifier group. */
339 wait_queue_head_t read_wait;
340 struct irq_work wakeup_pending; /* Pending wakeup irq work. */
341 struct lttng_kernel_event_notifier *sc_unknown; /* for unknown syscalls */
342 struct lttng_kernel_event_notifier *sc_compat_unknown;
343
344 struct lttng_syscall_filter *sc_filter;
345
346 struct hlist_head *event_notifier_syscall_dispatch;
347 struct hlist_head *event_notifier_compat_syscall_dispatch;
348 struct hlist_head *event_notifier_exit_syscall_dispatch;
349 struct hlist_head *event_notifier_exit_compat_syscall_dispatch;
350
351 struct hlist_head event_notifier_unknown_syscall_dispatch;
352 struct hlist_head event_notifier_compat_unknown_syscall_dispatch;
353 struct hlist_head event_notifier_exit_unknown_syscall_dispatch;
354 struct hlist_head event_notifier_exit_compat_unknown_syscall_dispatch;
355
356 int syscall_all_entry;
357 int syscall_all_exit;
358
359 unsigned int sys_enter_registered:1, sys_exit_registered:1;
360
361 struct lttng_counter *error_counter;
362 size_t error_counter_len;
363 };
364
365 struct lttng_transport {
366 char *name;
367 struct module *owner;
368 struct list_head node;
369 struct lttng_kernel_channel_buffer_ops ops;
370 };
371
372 struct lttng_counter_transport {
373 char *name;
374 struct module *owner;
375 struct list_head node;
376 struct lttng_counter_ops ops;
377 };
378
379 extern struct lttng_kernel_ctx *lttng_static_ctx;
380
381 static inline
382 const struct lttng_kernel_type_integer *lttng_kernel_get_type_integer(const struct lttng_kernel_type_common *type)
383 {
384 if (type->type != lttng_kernel_type_integer)
385 return NULL;
386 return container_of(type, const struct lttng_kernel_type_integer, parent);
387 }
388
389 static inline
390 const struct lttng_kernel_type_string *lttng_kernel_get_type_string(const struct lttng_kernel_type_common *type)
391 {
392 if (type->type != lttng_kernel_type_string)
393 return NULL;
394 return container_of(type, const struct lttng_kernel_type_string, parent);
395 }
396
397 static inline
398 const struct lttng_kernel_type_enum *lttng_kernel_get_type_enum(const struct lttng_kernel_type_common *type)
399 {
400 if (type->type != lttng_kernel_type_enum)
401 return NULL;
402 return container_of(type, const struct lttng_kernel_type_enum, parent);
403 }
404
405 static inline
406 const struct lttng_kernel_type_array *lttng_kernel_get_type_array(const struct lttng_kernel_type_common *type)
407 {
408 if (type->type != lttng_kernel_type_array)
409 return NULL;
410 return container_of(type, const struct lttng_kernel_type_array, parent);
411 }
412
413 static inline
414 const struct lttng_kernel_type_sequence *lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common *type)
415 {
416 if (type->type != lttng_kernel_type_sequence)
417 return NULL;
418 return container_of(type, const struct lttng_kernel_type_sequence, parent);
419 }
420
421 static inline
422 const struct lttng_kernel_type_struct *lttng_kernel_get_type_struct(const struct lttng_kernel_type_common *type)
423 {
424 if (type->type != lttng_kernel_type_struct)
425 return NULL;
426 return container_of(type, const struct lttng_kernel_type_struct, parent);
427 }
428
429 static inline
430 const struct lttng_kernel_type_variant *lttng_kernel_get_type_variant(const struct lttng_kernel_type_common *type)
431 {
432 if (type->type != lttng_kernel_type_variant)
433 return NULL;
434 return container_of(type, const struct lttng_kernel_type_variant, parent);
435 }
436
437 static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common *type)
438 {
439 const struct lttng_kernel_type_integer *type_integer = lttng_kernel_get_type_integer(type);
440
441 if (!type_integer)
442 return false;
443 switch (type_integer->size) {
444 case 8: /* Fall-through. */
445 case 16: /* Fall-through. */
446 case 32: /* Fall-through. */
447 case 64:
448 break;
449 default:
450 return false;
451 }
452 return true;
453 }
454
455 int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *event,
456 const char *interpreter_stack_data,
457 struct lttng_kernel_probe_ctx *probe_ctx,
458 void *event_filter_ctx);
459
460 static inline
461 struct lttng_enabler *lttng_event_enabler_as_enabler(
462 struct lttng_event_enabler *event_enabler)
463 {
464 return &event_enabler->base;
465 }
466
467 static inline
468 struct lttng_enabler *lttng_event_notifier_enabler_as_enabler(
469 struct lttng_event_notifier_enabler *event_notifier_enabler)
470 {
471 return &event_notifier_enabler->base;
472 }
473
474 int lttng_context_init(void);
475 void lttng_context_exit(void);
476 int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p,
477 const struct lttng_kernel_ctx_field *f);
478 void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p);
479 struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx,
480 size_t index);
481 int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name);
482 int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name);
483 void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx);
484 int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx);
485 int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx);
486 int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx);
487 int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx);
488 int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx);
489 int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx);
490 int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx);
491 int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx);
492 int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx);
493 int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx);
494 int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx);
495 int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx);
496 int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx);
497 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
498 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx);
499 #else
500 static inline
501 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx)
502 {
503 return -ENOSYS;
504 }
505 #endif
506 #ifdef CONFIG_PREEMPT_RT_FULL
507 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx);
508 #else
509 static inline
510 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx)
511 {
512 return -ENOSYS;
513 }
514 #endif
515
516 int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type);
517
518 #if defined(CONFIG_CGROUPS) && \
519 ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
520 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
521 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx);
522 #else
523 static inline
524 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx)
525 {
526 return -ENOSYS;
527 }
528 #endif
529
530 #if defined(CONFIG_IPC_NS) && \
531 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
532 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx);
533 #else
534 static inline
535 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx)
536 {
537 return -ENOSYS;
538 }
539 #endif
540
541 #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
542 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
543 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx);
544 #else
545 static inline
546 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx)
547 {
548 return -ENOSYS;
549 }
550 #endif
551
552 #if defined(CONFIG_NET_NS) && \
553 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
554 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx);
555 #else
556 static inline
557 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx)
558 {
559 return -ENOSYS;
560 }
561 #endif
562
563 #if defined(CONFIG_PID_NS) && \
564 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
565 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx);
566 #else
567 static inline
568 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx)
569 {
570 return -ENOSYS;
571 }
572 #endif
573
574 #if defined(CONFIG_USER_NS) && \
575 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
576 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx);
577 #else
578 static inline
579 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx)
580 {
581 return -ENOSYS;
582 }
583 #endif
584
585 #if defined(CONFIG_UTS_NS) && \
586 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
587 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx);
588 #else
589 static inline
590 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx)
591 {
592 return -ENOSYS;
593 }
594 #endif
595
596 #if defined(CONFIG_TIME_NS) && \
597 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0))
598 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx);
599 #else
600 static inline
601 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx)
602 {
603 return -ENOSYS;
604 }
605 #endif
606
607 int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx);
608 int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx);
609 int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx);
610 int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx);
611 int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx);
612 int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx);
613 int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx);
614 int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx);
615 int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx);
616 int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx);
617 int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx);
618 int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx);
619
620 #if defined(CONFIG_PERF_EVENTS)
621 int lttng_add_perf_counter_to_ctx(uint32_t type,
622 uint64_t config,
623 const char *name,
624 struct lttng_kernel_ctx **ctx);
625 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
626 struct lttng_cpuhp_node *node);
627 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
628 struct lttng_cpuhp_node *node);
629 #else
630 static inline
631 int lttng_add_perf_counter_to_ctx(uint32_t type,
632 uint64_t config,
633 const char *name,
634 struct lttng_kernel_ctx **ctx)
635 {
636 return -ENOSYS;
637 }
638 static inline
639 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
640 struct lttng_cpuhp_node *node)
641 {
642 return 0;
643 }
644 static inline
645 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
646 struct lttng_cpuhp_node *node)
647 {
648 return 0;
649 }
650 #endif
651
652 struct lttng_event_enabler *lttng_event_enabler_create(
653 enum lttng_enabler_format_type format_type,
654 struct lttng_kernel_abi_event *event_param,
655 struct lttng_channel *chan);
656
657 int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler);
658 int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler);
659 struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
660 struct lttng_event_notifier_group *event_notifier_group,
661 enum lttng_enabler_format_type format_type,
662 struct lttng_kernel_abi_event_notifier *event_notifier_param);
663
664 int lttng_event_notifier_enabler_enable(
665 struct lttng_event_notifier_enabler *event_notifier_enabler);
666 int lttng_event_notifier_enabler_disable(
667 struct lttng_event_notifier_enabler *event_notifier_enabler);
668
669 int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler,
670 struct lttng_kernel_abi_filter_bytecode __user *bytecode);
671 int lttng_event_notifier_enabler_attach_filter_bytecode(
672 struct lttng_event_notifier_enabler *event_notifier_enabler,
673 struct lttng_kernel_abi_filter_bytecode __user *bytecode);
674 int lttng_event_notifier_enabler_attach_capture_bytecode(
675 struct lttng_event_notifier_enabler *event_notifier_enabler,
676 struct lttng_kernel_abi_capture_bytecode __user *bytecode);
677
678 int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
679 struct lttng_enabler *enabler);
680
681 void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc,
682 struct lttng_kernel_ctx *ctx,
683 struct list_head *instance_bytecode_runtime_head,
684 struct list_head *enabler_bytecode_runtime_head);
685
686 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
687 int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler);
688 int lttng_syscalls_unregister_channel(struct lttng_channel *chan);
689 int lttng_syscalls_destroy_event(struct lttng_channel *chan);
690 int lttng_syscall_filter_enable_event(
691 struct lttng_channel *chan,
692 struct lttng_kernel_event_recorder *event);
693 int lttng_syscall_filter_disable_event(
694 struct lttng_channel *chan,
695 struct lttng_kernel_event_recorder *event);
696
697 long lttng_channel_syscall_mask(struct lttng_channel *channel,
698 struct lttng_kernel_abi_syscall_mask __user *usyscall_mask);
699
700 int lttng_syscalls_register_event_notifier(
701 struct lttng_event_notifier_enabler *event_notifier_enabler);
702 int lttng_syscalls_create_matching_event_notifiers(
703 struct lttng_event_notifier_enabler *event_notifier_enabler);
704 int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group *group);
705 int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
706 int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
707 #else
708 static inline int lttng_syscalls_register_event(
709 struct lttng_event_enabler *event_enabler)
710 {
711 return -ENOSYS;
712 }
713
714 static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan)
715 {
716 return 0;
717 }
718
719 static inline int lttng_syscalls_destroy(struct lttng_channel *chan)
720 {
721 return 0;
722 }
723
724 static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan,
725 struct lttng_kernel_event_recorder *event);
726 {
727 return -ENOSYS;
728 }
729
730 static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan,
731 struct lttng_kernel_event_recorder *event);
732 {
733 return -ENOSYS;
734 }
735
736 static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
737 struct lttng_kernel_syscall_mask __user *usyscall_mask)
738 {
739 return -ENOSYS;
740 }
741
742 static inline int lttng_syscalls_register_event_notifier(
743 struct lttng_event_notifier_group *group)
744 {
745 return -ENOSYS;
746 }
747
748 static inline int lttng_syscalls_unregister_event_notifier_group(
749 struct lttng_event_notifier_group *group)
750 {
751 return 0;
752 }
753
754 static inline int lttng_syscall_filter_enable_event_notifier(
755 struct lttng_event_notifier_group *group,
756 const char *name)
757 {
758 return -ENOSYS;
759 }
760
761 static inline int lttng_syscall_filter_disable_event_notifier(
762 struct lttng_event_notifier_group *group,
763 const char *name)
764 {
765 return -ENOSYS;
766 }
767
768 #endif
769
770 #ifdef CONFIG_KPROBES
771 int lttng_kprobes_register_event(const char *name,
772 const char *symbol_name,
773 uint64_t offset,
774 uint64_t addr,
775 struct lttng_kernel_event_recorder *event);
776 void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event);
777 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event);
778 int lttng_kprobes_register_event_notifier(const char *symbol_name,
779 uint64_t offset,
780 uint64_t addr,
781 struct lttng_kernel_event_notifier *event_notifier);
782 void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
783 void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier);
784 #else
785 static inline
786 int lttng_kprobes_register_event(const char *name,
787 const char *symbol_name,
788 uint64_t offset,
789 uint64_t addr,
790 struct lttng_kernel_event_recorder *event)
791 {
792 return -ENOSYS;
793 }
794
795 static inline
796 void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event)
797 {
798 }
799
800 static inline
801 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event)
802 {
803 }
804
805 static inline
806 int lttng_kprobes_register_event_notifier(const char *symbol_name,
807 uint64_t offset,
808 uint64_t addr,
809 struct lttng_kernel_event_notifier *event_notifier)
810 {
811 return -ENOSYS;
812 }
813
814 static inline
815 void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
816 {
817 }
818
819 static inline
820 void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier)
821 {
822 }
823 #endif
824
825 int lttng_event_add_callsite(struct lttng_kernel_event_common *event,
826 struct lttng_kernel_abi_event_callsite __user *callsite);
827
828 #ifdef CONFIG_UPROBES
829 int lttng_uprobes_register_event(const char *name,
830 int fd, struct lttng_kernel_event_recorder *event);
831 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
832 struct lttng_kernel_abi_event_callsite __user *callsite);
833 void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event);
834 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event);
835 int lttng_uprobes_register_event_notifier(const char *name,
836 int fd, struct lttng_kernel_event_notifier *event_notifier);
837 void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
838 void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier);
839 #else
840 static inline
841 int lttng_uprobes_register_event(const char *name,
842 int fd, struct lttng_kernel_event_recorder *event)
843 {
844 return -ENOSYS;
845 }
846
847 static inline
848 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
849 struct lttng_kernel_abi_event_callsite __user *callsite)
850 {
851 return -ENOSYS;
852 }
853
854 static inline
855 void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event)
856 {
857 }
858
859 static inline
860 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event)
861 {
862 }
863
864 static inline
865 int lttng_uprobes_register_event_notifier(const char *name,
866 int fd, struct lttng_kernel_event_notifier *event_notifier)
867 {
868 return -ENOSYS;
869 }
870
871 static inline
872 void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
873 {
874 }
875
876 static inline
877 void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier)
878 {
879 }
880 #endif
881
882 #ifdef CONFIG_KRETPROBES
883 int lttng_kretprobes_register(const char *name,
884 const char *symbol_name,
885 uint64_t offset,
886 uint64_t addr,
887 struct lttng_kernel_event_recorder *event_entry,
888 struct lttng_kernel_event_recorder *event_exit);
889 void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event);
890 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event);
891 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
892 int enable);
893 #else
894 static inline
895 int lttng_kretprobes_register(const char *name,
896 const char *symbol_name,
897 uint64_t offset,
898 uint64_t addr,
899 struct lttng_kernel_event_recorder *event_entry,
900 struct lttng_kernel_event_recorder *event_exit)
901 {
902 return -ENOSYS;
903 }
904
905 static inline
906 void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event)
907 {
908 }
909
910 static inline
911 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event)
912 {
913 }
914
915 static inline
916 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
917 int enable)
918 {
919 return -ENOSYS;
920 }
921 #endif
922
923 void lttng_lock_sessions(void);
924 void lttng_unlock_sessions(void);
925
926 struct list_head *lttng_get_probe_list_head(void);
927
928 int lttng_fix_pending_events(void);
929 int lttng_fix_pending_event_notifiers(void);
930 int lttng_session_active(void);
931 bool lttng_event_notifier_active(void);
932
933 struct lttng_session *lttng_session_create(void);
934 int lttng_session_enable(struct lttng_session *session);
935 int lttng_session_disable(struct lttng_session *session);
936 void lttng_session_destroy(struct lttng_session *session);
937 int lttng_session_metadata_regenerate(struct lttng_session *session);
938 int lttng_session_statedump(struct lttng_session *session);
939 void metadata_cache_destroy(struct kref *kref);
940
941 struct lttng_counter *lttng_kernel_counter_create(
942 const char *counter_transport_name, size_t number_dimensions,
943 const size_t *dimensions_sizes);
944 int lttng_kernel_counter_read(struct lttng_counter *counter,
945 const size_t *dimension_indexes, int32_t cpu,
946 int64_t *val, bool *overflow, bool *underflow);
947 int lttng_kernel_counter_aggregate(struct lttng_counter *counter,
948 const size_t *dimension_indexes, int64_t *val,
949 bool *overflow, bool *underflow);
950 int lttng_kernel_counter_clear(struct lttng_counter *counter,
951 const size_t *dimension_indexes);
952 struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
953 int lttng_event_notifier_group_create_error_counter(
954 struct file *event_notifier_group_file,
955 const struct lttng_kernel_abi_counter_conf *error_counter_conf);
956 void lttng_event_notifier_group_destroy(
957 struct lttng_event_notifier_group *event_notifier_group);
958
959 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
960 const char *transport_name,
961 void *buf_addr,
962 size_t subbuf_size, size_t num_subbuf,
963 unsigned int switch_timer_interval,
964 unsigned int read_timer_interval,
965 enum channel_type channel_type);
966 struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
967 int overwrite, void *buf_addr,
968 size_t subbuf_size, size_t num_subbuf,
969 unsigned int switch_timer_interval,
970 unsigned int read_timer_interval);
971
972 void lttng_metadata_channel_destroy(struct lttng_channel *chan);
973 struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_channel *chan,
974 struct lttng_kernel_abi_event *event_param,
975 const struct lttng_kernel_event_desc *event_desc,
976 enum lttng_kernel_abi_instrumentation itype);
977 struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_channel *chan,
978 struct lttng_kernel_abi_event *event_param,
979 const struct lttng_kernel_event_desc *event_desc,
980 enum lttng_kernel_abi_instrumentation itype);
981 struct lttng_kernel_event_recorder *lttng_event_compat_old_create(struct lttng_channel *chan,
982 struct lttng_kernel_abi_old_event *old_event_param,
983 const struct lttng_kernel_event_desc *internal_desc);
984
985 struct lttng_kernel_event_notifier *lttng_event_notifier_create(
986 const struct lttng_kernel_event_desc *event_notifier_desc,
987 uint64_t id,
988 uint64_t error_counter_idx,
989 struct lttng_event_notifier_group *event_notifier_group,
990 struct lttng_kernel_abi_event_notifier *event_notifier_param,
991 enum lttng_kernel_abi_instrumentation itype);
992 struct lttng_kernel_event_notifier *_lttng_event_notifier_create(
993 const struct lttng_kernel_event_desc *event_notifier_desc,
994 uint64_t id,
995 uint64_t error_counter_idx,
996 struct lttng_event_notifier_group *event_notifier_group,
997 struct lttng_kernel_abi_event_notifier *event_notifier_param,
998 enum lttng_kernel_abi_instrumentation itype);
999
1000 int lttng_channel_enable(struct lttng_channel *channel);
1001 int lttng_channel_disable(struct lttng_channel *channel);
1002 int lttng_event_enable(struct lttng_kernel_event_common *event);
1003 int lttng_event_disable(struct lttng_kernel_event_common *event);
1004
1005 void lttng_transport_register(struct lttng_transport *transport);
1006 void lttng_transport_unregister(struct lttng_transport *transport);
1007
1008 void lttng_counter_transport_register(struct lttng_counter_transport *transport);
1009 void lttng_counter_transport_unregister(struct lttng_counter_transport *transport);
1010
1011 void synchronize_trace(void);
1012 int lttng_abi_init(void);
1013 int lttng_abi_compat_old_init(void);
1014 void lttng_abi_exit(void);
1015 void lttng_abi_compat_old_exit(void);
1016
1017 const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name);
1018 void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc);
1019 int lttng_probes_init(void);
1020 void lttng_probes_exit(void);
1021
1022 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
1023 struct channel *chan, bool *coherent);
1024
1025 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
1026 int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf);
1027 void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu);
1028 int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id);
1029 int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id);
1030
1031 int lttng_session_track_id(struct lttng_session *session,
1032 enum tracker_type tracker_type, int id);
1033 int lttng_session_untrack_id(struct lttng_session *session,
1034 enum tracker_type tracker_type, int id);
1035
1036 int lttng_session_list_tracker_ids(struct lttng_session *session,
1037 enum tracker_type tracker_type);
1038
1039 void lttng_clock_ref(void);
1040 void lttng_clock_unref(void);
1041
1042 void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event);
1043
1044 int lttng_probes_init(void);
1045
1046 int lttng_logger_init(void);
1047 void lttng_logger_exit(void);
1048
1049 extern int lttng_statedump_start(struct lttng_session *session);
1050
1051 int lttng_calibrate(struct lttng_kernel_abi_calibrate *calibrate);
1052
1053 extern const struct file_operations lttng_tracepoint_list_fops;
1054 extern const struct file_operations lttng_syscall_list_fops;
1055
1056 #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \
1057 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \
1058 .event_field = (_event_field), \
1059 .get_size = (_get_size), \
1060 .record = (_record), \
1061 .get_value = (_get_value), \
1062 .destroy = (_destroy), \
1063 .priv = (_priv), \
1064 })
1065
1066 #endif /* _LTTNG_EVENTS_INTERNAL_H */
This page took 0.051185 seconds and 4 git commands to generate.