Move metadata cache structure to internal 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 lib_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 extern struct lttng_kernel_ctx *lttng_static_ctx;
247
248 static inline
249 const struct lttng_kernel_type_integer *lttng_kernel_get_type_integer(const struct lttng_kernel_type_common *type)
250 {
251 if (type->type != lttng_kernel_type_integer)
252 return NULL;
253 return container_of(type, const struct lttng_kernel_type_integer, parent);
254 }
255
256 static inline
257 const struct lttng_kernel_type_string *lttng_kernel_get_type_string(const struct lttng_kernel_type_common *type)
258 {
259 if (type->type != lttng_kernel_type_string)
260 return NULL;
261 return container_of(type, const struct lttng_kernel_type_string, parent);
262 }
263
264 static inline
265 const struct lttng_kernel_type_enum *lttng_kernel_get_type_enum(const struct lttng_kernel_type_common *type)
266 {
267 if (type->type != lttng_kernel_type_enum)
268 return NULL;
269 return container_of(type, const struct lttng_kernel_type_enum, parent);
270 }
271
272 static inline
273 const struct lttng_kernel_type_array *lttng_kernel_get_type_array(const struct lttng_kernel_type_common *type)
274 {
275 if (type->type != lttng_kernel_type_array)
276 return NULL;
277 return container_of(type, const struct lttng_kernel_type_array, parent);
278 }
279
280 static inline
281 const struct lttng_kernel_type_sequence *lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common *type)
282 {
283 if (type->type != lttng_kernel_type_sequence)
284 return NULL;
285 return container_of(type, const struct lttng_kernel_type_sequence, parent);
286 }
287
288 static inline
289 const struct lttng_kernel_type_struct *lttng_kernel_get_type_struct(const struct lttng_kernel_type_common *type)
290 {
291 if (type->type != lttng_kernel_type_struct)
292 return NULL;
293 return container_of(type, const struct lttng_kernel_type_struct, parent);
294 }
295
296 static inline
297 const struct lttng_kernel_type_variant *lttng_kernel_get_type_variant(const struct lttng_kernel_type_common *type)
298 {
299 if (type->type != lttng_kernel_type_variant)
300 return NULL;
301 return container_of(type, const struct lttng_kernel_type_variant, parent);
302 }
303
304 static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common *type)
305 {
306 const struct lttng_kernel_type_integer *type_integer = lttng_kernel_get_type_integer(type);
307
308 if (!type_integer)
309 return false;
310 switch (type_integer->size) {
311 case 8: /* Fall-through. */
312 case 16: /* Fall-through. */
313 case 32: /* Fall-through. */
314 case 64:
315 break;
316 default:
317 return false;
318 }
319 return true;
320 }
321
322 int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *event,
323 const char *interpreter_stack_data,
324 struct lttng_kernel_probe_ctx *probe_ctx,
325 void *event_filter_ctx);
326
327 static inline
328 struct lttng_enabler *lttng_event_enabler_as_enabler(
329 struct lttng_event_enabler *event_enabler)
330 {
331 return &event_enabler->base;
332 }
333
334 static inline
335 struct lttng_enabler *lttng_event_notifier_enabler_as_enabler(
336 struct lttng_event_notifier_enabler *event_notifier_enabler)
337 {
338 return &event_notifier_enabler->base;
339 }
340
341 int lttng_context_init(void);
342 void lttng_context_exit(void);
343 int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p,
344 const struct lttng_kernel_ctx_field *f);
345 void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p);
346 struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx,
347 size_t index);
348 int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name);
349 int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name);
350 void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx);
351 int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx);
352 int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx);
353 int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx);
354 int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx);
355 int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx);
356 int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx);
357 int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx);
358 int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx);
359 int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx);
360 int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx);
361 int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx);
362 int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx);
363 int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx);
364 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
365 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx);
366 #else
367 static inline
368 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx)
369 {
370 return -ENOSYS;
371 }
372 #endif
373 #ifdef CONFIG_PREEMPT_RT_FULL
374 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx);
375 #else
376 static inline
377 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx)
378 {
379 return -ENOSYS;
380 }
381 #endif
382
383 int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type);
384
385 #if defined(CONFIG_CGROUPS) && \
386 ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
387 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
388 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx);
389 #else
390 static inline
391 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx)
392 {
393 return -ENOSYS;
394 }
395 #endif
396
397 #if defined(CONFIG_IPC_NS) && \
398 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
399 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx);
400 #else
401 static inline
402 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx)
403 {
404 return -ENOSYS;
405 }
406 #endif
407
408 #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
409 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
410 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx);
411 #else
412 static inline
413 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx)
414 {
415 return -ENOSYS;
416 }
417 #endif
418
419 #if defined(CONFIG_NET_NS) && \
420 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
421 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx);
422 #else
423 static inline
424 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx)
425 {
426 return -ENOSYS;
427 }
428 #endif
429
430 #if defined(CONFIG_PID_NS) && \
431 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
432 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx);
433 #else
434 static inline
435 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx)
436 {
437 return -ENOSYS;
438 }
439 #endif
440
441 #if defined(CONFIG_USER_NS) && \
442 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
443 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx);
444 #else
445 static inline
446 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx)
447 {
448 return -ENOSYS;
449 }
450 #endif
451
452 #if defined(CONFIG_UTS_NS) && \
453 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
454 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx);
455 #else
456 static inline
457 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx)
458 {
459 return -ENOSYS;
460 }
461 #endif
462
463 #if defined(CONFIG_TIME_NS) && \
464 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0))
465 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx);
466 #else
467 static inline
468 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx)
469 {
470 return -ENOSYS;
471 }
472 #endif
473
474 int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx);
475 int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx);
476 int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx);
477 int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx);
478 int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx);
479 int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx);
480 int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx);
481 int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx);
482 int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx);
483 int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx);
484 int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx);
485 int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx);
486
487 #if defined(CONFIG_PERF_EVENTS)
488 int lttng_add_perf_counter_to_ctx(uint32_t type,
489 uint64_t config,
490 const char *name,
491 struct lttng_kernel_ctx **ctx);
492 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
493 struct lttng_cpuhp_node *node);
494 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
495 struct lttng_cpuhp_node *node);
496 #else
497 static inline
498 int lttng_add_perf_counter_to_ctx(uint32_t type,
499 uint64_t config,
500 const char *name,
501 struct lttng_kernel_ctx **ctx)
502 {
503 return -ENOSYS;
504 }
505 static inline
506 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
507 struct lttng_cpuhp_node *node)
508 {
509 return 0;
510 }
511 static inline
512 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
513 struct lttng_cpuhp_node *node)
514 {
515 return 0;
516 }
517 #endif
518
519 struct lttng_event_enabler *lttng_event_enabler_create(
520 enum lttng_enabler_format_type format_type,
521 struct lttng_kernel_abi_event *event_param,
522 struct lttng_channel *chan);
523
524 int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler);
525 int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler);
526 struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
527 struct lttng_event_notifier_group *event_notifier_group,
528 enum lttng_enabler_format_type format_type,
529 struct lttng_kernel_abi_event_notifier *event_notifier_param);
530
531 int lttng_event_notifier_enabler_enable(
532 struct lttng_event_notifier_enabler *event_notifier_enabler);
533 int lttng_event_notifier_enabler_disable(
534 struct lttng_event_notifier_enabler *event_notifier_enabler);
535
536 int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler,
537 struct lttng_kernel_abi_filter_bytecode __user *bytecode);
538 int lttng_event_notifier_enabler_attach_filter_bytecode(
539 struct lttng_event_notifier_enabler *event_notifier_enabler,
540 struct lttng_kernel_abi_filter_bytecode __user *bytecode);
541 int lttng_event_notifier_enabler_attach_capture_bytecode(
542 struct lttng_event_notifier_enabler *event_notifier_enabler,
543 struct lttng_kernel_abi_capture_bytecode __user *bytecode);
544
545 int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
546 struct lttng_enabler *enabler);
547
548 void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc,
549 struct lttng_kernel_ctx *ctx,
550 struct list_head *instance_bytecode_runtime_head,
551 struct list_head *enabler_bytecode_runtime_head);
552
553 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
554 int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler);
555 int lttng_syscalls_unregister_channel(struct lttng_channel *chan);
556 int lttng_syscalls_destroy_event(struct lttng_channel *chan);
557 int lttng_syscall_filter_enable_event(
558 struct lttng_channel *chan,
559 struct lttng_kernel_event_recorder *event);
560 int lttng_syscall_filter_disable_event(
561 struct lttng_channel *chan,
562 struct lttng_kernel_event_recorder *event);
563
564 long lttng_channel_syscall_mask(struct lttng_channel *channel,
565 struct lttng_kernel_abi_syscall_mask __user *usyscall_mask);
566
567 int lttng_syscalls_register_event_notifier(
568 struct lttng_event_notifier_enabler *event_notifier_enabler);
569 int lttng_syscalls_create_matching_event_notifiers(
570 struct lttng_event_notifier_enabler *event_notifier_enabler);
571 int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group *group);
572 int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
573 int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
574 #else
575 static inline int lttng_syscalls_register_event(
576 struct lttng_event_enabler *event_enabler)
577 {
578 return -ENOSYS;
579 }
580
581 static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan)
582 {
583 return 0;
584 }
585
586 static inline int lttng_syscalls_destroy(struct lttng_channel *chan)
587 {
588 return 0;
589 }
590
591 static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan,
592 struct lttng_kernel_event_recorder *event);
593 {
594 return -ENOSYS;
595 }
596
597 static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan,
598 struct lttng_kernel_event_recorder *event);
599 {
600 return -ENOSYS;
601 }
602
603 static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
604 struct lttng_kernel_syscall_mask __user *usyscall_mask)
605 {
606 return -ENOSYS;
607 }
608
609 static inline int lttng_syscalls_register_event_notifier(
610 struct lttng_event_notifier_group *group)
611 {
612 return -ENOSYS;
613 }
614
615 static inline int lttng_syscalls_unregister_event_notifier_group(
616 struct lttng_event_notifier_group *group)
617 {
618 return 0;
619 }
620
621 static inline int lttng_syscall_filter_enable_event_notifier(
622 struct lttng_event_notifier_group *group,
623 const char *name)
624 {
625 return -ENOSYS;
626 }
627
628 static inline int lttng_syscall_filter_disable_event_notifier(
629 struct lttng_event_notifier_group *group,
630 const char *name)
631 {
632 return -ENOSYS;
633 }
634
635 #endif
636
637 #ifdef CONFIG_KPROBES
638 int lttng_kprobes_register_event(const char *name,
639 const char *symbol_name,
640 uint64_t offset,
641 uint64_t addr,
642 struct lttng_kernel_event_recorder *event);
643 void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event);
644 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event);
645 int lttng_kprobes_register_event_notifier(const char *symbol_name,
646 uint64_t offset,
647 uint64_t addr,
648 struct lttng_kernel_event_notifier *event_notifier);
649 void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
650 void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier);
651 #else
652 static inline
653 int lttng_kprobes_register_event(const char *name,
654 const char *symbol_name,
655 uint64_t offset,
656 uint64_t addr,
657 struct lttng_kernel_event_recorder *event)
658 {
659 return -ENOSYS;
660 }
661
662 static inline
663 void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event)
664 {
665 }
666
667 static inline
668 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event)
669 {
670 }
671
672 static inline
673 int lttng_kprobes_register_event_notifier(const char *symbol_name,
674 uint64_t offset,
675 uint64_t addr,
676 struct lttng_kernel_event_notifier *event_notifier)
677 {
678 return -ENOSYS;
679 }
680
681 static inline
682 void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
683 {
684 }
685
686 static inline
687 void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier)
688 {
689 }
690 #endif
691
692 int lttng_event_add_callsite(struct lttng_kernel_event_common *event,
693 struct lttng_kernel_abi_event_callsite __user *callsite);
694
695 #ifdef CONFIG_UPROBES
696 int lttng_uprobes_register_event(const char *name,
697 int fd, struct lttng_kernel_event_recorder *event);
698 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
699 struct lttng_kernel_abi_event_callsite __user *callsite);
700 void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event);
701 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event);
702 int lttng_uprobes_register_event_notifier(const char *name,
703 int fd, struct lttng_kernel_event_notifier *event_notifier);
704 void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
705 void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier);
706 #else
707 static inline
708 int lttng_uprobes_register_event(const char *name,
709 int fd, struct lttng_kernel_event_recorder *event)
710 {
711 return -ENOSYS;
712 }
713
714 static inline
715 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
716 struct lttng_kernel_abi_event_callsite __user *callsite)
717 {
718 return -ENOSYS;
719 }
720
721 static inline
722 void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event)
723 {
724 }
725
726 static inline
727 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event)
728 {
729 }
730
731 static inline
732 int lttng_uprobes_register_event_notifier(const char *name,
733 int fd, struct lttng_kernel_event_notifier *event_notifier)
734 {
735 return -ENOSYS;
736 }
737
738 static inline
739 void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
740 {
741 }
742
743 static inline
744 void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier)
745 {
746 }
747 #endif
748
749 #ifdef CONFIG_KRETPROBES
750 int lttng_kretprobes_register(const char *name,
751 const char *symbol_name,
752 uint64_t offset,
753 uint64_t addr,
754 struct lttng_kernel_event_recorder *event_entry,
755 struct lttng_kernel_event_recorder *event_exit);
756 void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event);
757 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event);
758 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
759 int enable);
760 #else
761 static inline
762 int lttng_kretprobes_register(const char *name,
763 const char *symbol_name,
764 uint64_t offset,
765 uint64_t addr,
766 struct lttng_kernel_event_recorder *event_entry,
767 struct lttng_kernel_event_recorder *event_exit)
768 {
769 return -ENOSYS;
770 }
771
772 static inline
773 void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event)
774 {
775 }
776
777 static inline
778 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event)
779 {
780 }
781
782 static inline
783 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
784 int enable)
785 {
786 return -ENOSYS;
787 }
788 #endif
789
790 void lttng_lock_sessions(void);
791 void lttng_unlock_sessions(void);
792
793 struct list_head *lttng_get_probe_list_head(void);
794
795 int lttng_fix_pending_events(void);
796 int lttng_fix_pending_event_notifiers(void);
797 int lttng_session_active(void);
798 bool lttng_event_notifier_active(void);
799
800 struct lttng_session *lttng_session_create(void);
801 int lttng_session_enable(struct lttng_session *session);
802 int lttng_session_disable(struct lttng_session *session);
803 void lttng_session_destroy(struct lttng_session *session);
804 int lttng_session_metadata_regenerate(struct lttng_session *session);
805 int lttng_session_statedump(struct lttng_session *session);
806 void metadata_cache_destroy(struct kref *kref);
807
808 struct lttng_counter *lttng_kernel_counter_create(
809 const char *counter_transport_name, size_t number_dimensions,
810 const size_t *dimensions_sizes);
811 int lttng_kernel_counter_read(struct lttng_counter *counter,
812 const size_t *dimension_indexes, int32_t cpu,
813 int64_t *val, bool *overflow, bool *underflow);
814 int lttng_kernel_counter_aggregate(struct lttng_counter *counter,
815 const size_t *dimension_indexes, int64_t *val,
816 bool *overflow, bool *underflow);
817 int lttng_kernel_counter_clear(struct lttng_counter *counter,
818 const size_t *dimension_indexes);
819 struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
820 int lttng_event_notifier_group_create_error_counter(
821 struct file *event_notifier_group_file,
822 const struct lttng_kernel_abi_counter_conf *error_counter_conf);
823 void lttng_event_notifier_group_destroy(
824 struct lttng_event_notifier_group *event_notifier_group);
825
826 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
827 const char *transport_name,
828 void *buf_addr,
829 size_t subbuf_size, size_t num_subbuf,
830 unsigned int switch_timer_interval,
831 unsigned int read_timer_interval,
832 enum channel_type channel_type);
833 struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
834 int overwrite, void *buf_addr,
835 size_t subbuf_size, size_t num_subbuf,
836 unsigned int switch_timer_interval,
837 unsigned int read_timer_interval);
838
839 void lttng_metadata_channel_destroy(struct lttng_channel *chan);
840 struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_channel *chan,
841 struct lttng_kernel_abi_event *event_param,
842 const struct lttng_kernel_event_desc *event_desc,
843 enum lttng_kernel_abi_instrumentation itype);
844 struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_channel *chan,
845 struct lttng_kernel_abi_event *event_param,
846 const struct lttng_kernel_event_desc *event_desc,
847 enum lttng_kernel_abi_instrumentation itype);
848 struct lttng_kernel_event_recorder *lttng_event_compat_old_create(struct lttng_channel *chan,
849 struct lttng_kernel_abi_old_event *old_event_param,
850 const struct lttng_kernel_event_desc *internal_desc);
851
852 struct lttng_kernel_event_notifier *lttng_event_notifier_create(
853 const struct lttng_kernel_event_desc *event_notifier_desc,
854 uint64_t id,
855 uint64_t error_counter_idx,
856 struct lttng_event_notifier_group *event_notifier_group,
857 struct lttng_kernel_abi_event_notifier *event_notifier_param,
858 enum lttng_kernel_abi_instrumentation itype);
859 struct lttng_kernel_event_notifier *_lttng_event_notifier_create(
860 const struct lttng_kernel_event_desc *event_notifier_desc,
861 uint64_t id,
862 uint64_t error_counter_idx,
863 struct lttng_event_notifier_group *event_notifier_group,
864 struct lttng_kernel_abi_event_notifier *event_notifier_param,
865 enum lttng_kernel_abi_instrumentation itype);
866
867 int lttng_channel_enable(struct lttng_channel *channel);
868 int lttng_channel_disable(struct lttng_channel *channel);
869 int lttng_event_enable(struct lttng_kernel_event_common *event);
870 int lttng_event_disable(struct lttng_kernel_event_common *event);
871
872 void lttng_transport_register(struct lttng_transport *transport);
873 void lttng_transport_unregister(struct lttng_transport *transport);
874
875 void lttng_counter_transport_register(struct lttng_counter_transport *transport);
876 void lttng_counter_transport_unregister(struct lttng_counter_transport *transport);
877
878 void synchronize_trace(void);
879 int lttng_abi_init(void);
880 int lttng_abi_compat_old_init(void);
881 void lttng_abi_exit(void);
882 void lttng_abi_compat_old_exit(void);
883
884 const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name);
885 void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc);
886 int lttng_probes_init(void);
887 void lttng_probes_exit(void);
888
889 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
890 struct channel *chan, bool *coherent);
891
892 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
893 int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf);
894 void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu);
895 int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id);
896 int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id);
897
898 int lttng_session_track_id(struct lttng_session *session,
899 enum tracker_type tracker_type, int id);
900 int lttng_session_untrack_id(struct lttng_session *session,
901 enum tracker_type tracker_type, int id);
902
903 int lttng_session_list_tracker_ids(struct lttng_session *session,
904 enum tracker_type tracker_type);
905
906 void lttng_clock_ref(void);
907 void lttng_clock_unref(void);
908
909 void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event);
910
911 int lttng_probes_init(void);
912
913 int lttng_logger_init(void);
914 void lttng_logger_exit(void);
915
916 extern int lttng_statedump_start(struct lttng_session *session);
917
918 int lttng_calibrate(struct lttng_kernel_abi_calibrate *calibrate);
919
920 extern const struct file_operations lttng_tracepoint_list_fops;
921 extern const struct file_operations lttng_syscall_list_fops;
922
923 #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \
924 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \
925 .event_field = (_event_field), \
926 .get_size = (_get_size), \
927 .record = (_record), \
928 .get_value = (_get_value), \
929 .destroy = (_destroy), \
930 .priv = (_priv), \
931 })
932
933 #endif /* _LTTNG_EVENTS_INTERNAL_H */
This page took 0.084032 seconds and 4 git commands to generate.