1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
3 * lttng/events-internal.h
5 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 #ifndef _LTTNG_EVENTS_INTERNAL_H
9 #define _LTTNG_EVENTS_INTERNAL_H
11 #include <lttng/events.h>
13 enum lttng_enabler_format_type
{
14 LTTNG_ENABLER_FORMAT_STAR_GLOB
,
15 LTTNG_ENABLER_FORMAT_NAME
,
19 * Objects in a linked-list of enablers, owned by an event.
21 struct lttng_enabler_ref
{
22 struct list_head node
; /* enabler ref list */
23 struct lttng_enabler
*ref
; /* backward ref */
26 struct lttng_krp
; /* Kretprobe handling */
28 struct lttng_uprobe_handler
{
29 struct lttng_kernel_event_common
*event
;
31 struct uprobe_consumer up_consumer
;
32 struct list_head node
;
42 struct list_head head
;
45 enum lttng_syscall_entryexit
{
50 enum lttng_syscall_abi
{
51 LTTNG_SYSCALL_ABI_NATIVE
,
52 LTTNG_SYSCALL_ABI_COMPAT
,
55 struct lttng_kernel_event_common_private
{
56 struct lttng_kernel_event_common
*pub
; /* Public event interface */
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 */
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 */
70 struct lttng_kprobe kprobe
;
71 struct lttng_uprobe uprobe
;
73 struct lttng_krp
*lttng_krp
;
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
;
85 struct lttng_kernel_event_recorder_private
{
86 struct lttng_kernel_event_common_private parent
;
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
;
93 unsigned int metadata_dumped
:1;
96 struct lttng_kernel_event_notifier_private
{
97 struct lttng_kernel_event_common_private parent
;
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
;
109 enum lttng_kernel_bytecode_interpreter_ret
{
110 LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR
= -1,
111 LTTNG_KERNEL_BYTECODE_INTERPRETER_OK
= 0,
114 enum lttng_kernel_bytecode_filter_result
{
115 LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT
= 0,
116 LTTNG_KERNEL_BYTECODE_FILTER_REJECT
= 1,
119 struct lttng_kernel_bytecode_filter_ctx
{
120 enum lttng_kernel_bytecode_filter_result result
;
123 struct lttng_interpreter_output
;
125 enum lttng_kernel_bytecode_type
{
126 LTTNG_KERNEL_BYTECODE_TYPE_FILTER
,
127 LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE
,
130 struct lttng_kernel_bytecode_node
{
131 enum lttng_kernel_bytecode_type type
;
132 struct list_head node
;
133 struct lttng_enabler
*enabler
;
136 uint32_t reloc_offset
;
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
,
151 struct list_head node
; /* list of bytecode runtime in event */
152 struct lttng_kernel_ctx
*ctx
;
156 * Enabler field, within whatever object is enabling an event. Target of
157 * backward reference.
159 struct lttng_enabler
{
160 enum lttng_enabler_format_type format_type
;
162 /* head list of struct lttng_kernel_bytecode_node */
163 struct list_head filter_bytecode_head
;
165 struct lttng_kernel_abi_event event_param
;
166 unsigned int enabled
:1;
168 uint64_t user_token
; /* User-provided token. */
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
;
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
;
183 /* head list of struct lttng_kernel_bytecode_node */
184 struct list_head capture_bytecode_head
;
185 uint64_t num_captures
;
188 struct lttng_ctx_value
{
197 * We need to keep this perf counter field separately from struct
198 * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses.
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
;
205 struct notifier_block nb
;
208 struct perf_event_attr
*attr
;
209 struct perf_event
**e
; /* per-cpu array */
211 struct lttng_kernel_event_field
*event_field
;
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
,
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
);
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 */
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 */
246 extern struct lttng_kernel_ctx
*lttng_static_ctx
;
249 const struct lttng_kernel_type_integer
*lttng_kernel_get_type_integer(const struct lttng_kernel_type_common
*type
)
251 if (type
->type
!= lttng_kernel_type_integer
)
253 return container_of(type
, const struct lttng_kernel_type_integer
, parent
);
257 const struct lttng_kernel_type_string
*lttng_kernel_get_type_string(const struct lttng_kernel_type_common
*type
)
259 if (type
->type
!= lttng_kernel_type_string
)
261 return container_of(type
, const struct lttng_kernel_type_string
, parent
);
265 const struct lttng_kernel_type_enum
*lttng_kernel_get_type_enum(const struct lttng_kernel_type_common
*type
)
267 if (type
->type
!= lttng_kernel_type_enum
)
269 return container_of(type
, const struct lttng_kernel_type_enum
, parent
);
273 const struct lttng_kernel_type_array
*lttng_kernel_get_type_array(const struct lttng_kernel_type_common
*type
)
275 if (type
->type
!= lttng_kernel_type_array
)
277 return container_of(type
, const struct lttng_kernel_type_array
, parent
);
281 const struct lttng_kernel_type_sequence
*lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common
*type
)
283 if (type
->type
!= lttng_kernel_type_sequence
)
285 return container_of(type
, const struct lttng_kernel_type_sequence
, parent
);
289 const struct lttng_kernel_type_struct
*lttng_kernel_get_type_struct(const struct lttng_kernel_type_common
*type
)
291 if (type
->type
!= lttng_kernel_type_struct
)
293 return container_of(type
, const struct lttng_kernel_type_struct
, parent
);
297 const struct lttng_kernel_type_variant
*lttng_kernel_get_type_variant(const struct lttng_kernel_type_common
*type
)
299 if (type
->type
!= lttng_kernel_type_variant
)
301 return container_of(type
, const struct lttng_kernel_type_variant
, parent
);
304 static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common
*type
)
306 const struct lttng_kernel_type_integer
*type_integer
= lttng_kernel_get_type_integer(type
);
310 switch (type_integer
->size
) {
311 case 8: /* Fall-through. */
312 case 16: /* Fall-through. */
313 case 32: /* Fall-through. */
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
);
328 struct lttng_enabler
*lttng_event_enabler_as_enabler(
329 struct lttng_event_enabler
*event_enabler
)
331 return &event_enabler
->base
;
335 struct lttng_enabler
*lttng_event_notifier_enabler_as_enabler(
336 struct lttng_event_notifier_enabler
*event_notifier_enabler
)
338 return &event_notifier_enabler
->base
;
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
,
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
);
368 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx
**ctx
)
373 #ifdef CONFIG_PREEMPT_RT_FULL
374 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx
**ctx
);
377 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx
**ctx
)
383 int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx
**ctx
, int type
);
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
);
391 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
402 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
413 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
424 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
435 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
446 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
457 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
468 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
487 #if defined(CONFIG_PERF_EVENTS)
488 int lttng_add_perf_counter_to_ctx(uint32_t type
,
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
);
498 int lttng_add_perf_counter_to_ctx(uint32_t type
,
501 struct lttng_kernel_ctx
**ctx
)
506 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
507 struct lttng_cpuhp_node
*node
)
512 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
513 struct lttng_cpuhp_node
*node
)
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
);
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
);
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
);
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
);
545 int lttng_desc_match_enabler(const struct lttng_kernel_event_desc
*desc
,
546 struct lttng_enabler
*enabler
);
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
);
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
);
564 long lttng_channel_syscall_mask(struct lttng_channel
*channel
,
565 struct lttng_kernel_abi_syscall_mask __user
*usyscall_mask
);
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
);
575 static inline int lttng_syscalls_register_event(
576 struct lttng_event_enabler
*event_enabler
)
581 static inline int lttng_syscalls_unregister_channel(struct lttng_channel
*chan
)
586 static inline int lttng_syscalls_destroy(struct lttng_channel
*chan
)
591 static inline int lttng_syscall_filter_enable_event(struct lttng_channel
*chan
,
592 struct lttng_kernel_event_recorder
*event
);
597 static inline int lttng_syscall_filter_disable_event(struct lttng_channel
*chan
,
598 struct lttng_kernel_event_recorder
*event
);
603 static inline long lttng_channel_syscall_mask(struct lttng_channel
*channel
,
604 struct lttng_kernel_syscall_mask __user
*usyscall_mask
)
609 static inline int lttng_syscalls_register_event_notifier(
610 struct lttng_event_notifier_group
*group
)
615 static inline int lttng_syscalls_unregister_event_notifier_group(
616 struct lttng_event_notifier_group
*group
)
621 static inline int lttng_syscall_filter_enable_event_notifier(
622 struct lttng_event_notifier_group
*group
,
628 static inline int lttng_syscall_filter_disable_event_notifier(
629 struct lttng_event_notifier_group
*group
,
637 #ifdef CONFIG_KPROBES
638 int lttng_kprobes_register_event(const char *name
,
639 const char *symbol_name
,
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
,
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
);
653 int lttng_kprobes_register_event(const char *name
,
654 const char *symbol_name
,
657 struct lttng_kernel_event_recorder
*event
)
663 void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder
*event
)
668 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder
*event
)
673 int lttng_kprobes_register_event_notifier(const char *symbol_name
,
676 struct lttng_kernel_event_notifier
*event_notifier
)
682 void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
)
687 void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier
*event_notifier
)
692 int lttng_event_add_callsite(struct lttng_kernel_event_common
*event
,
693 struct lttng_kernel_abi_event_callsite __user
*callsite
);
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
);
708 int lttng_uprobes_register_event(const char *name
,
709 int fd
, struct lttng_kernel_event_recorder
*event
)
715 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common
*event
,
716 struct lttng_kernel_abi_event_callsite __user
*callsite
)
722 void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder
*event
)
727 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder
*event
)
732 int lttng_uprobes_register_event_notifier(const char *name
,
733 int fd
, struct lttng_kernel_event_notifier
*event_notifier
)
739 void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
)
744 void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier
*event_notifier
)
749 #ifdef CONFIG_KRETPROBES
750 int lttng_kretprobes_register(const char *name
,
751 const char *symbol_name
,
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
,
762 int lttng_kretprobes_register(const char *name
,
763 const char *symbol_name
,
766 struct lttng_kernel_event_recorder
*event_entry
,
767 struct lttng_kernel_event_recorder
*event_exit
)
773 void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder
*event
)
778 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder
*event
)
783 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common
*event
,
790 void lttng_lock_sessions(void);
791 void lttng_unlock_sessions(void);
793 struct list_head
*lttng_get_probe_list_head(void);
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);
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
);
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
);
826 struct lttng_channel
*lttng_channel_create(struct lttng_session
*session
,
827 const char *transport_name
,
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
);
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
);
852 struct lttng_kernel_event_notifier
*lttng_event_notifier_create(
853 const struct lttng_kernel_event_desc
*event_notifier_desc
,
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
,
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
);
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
);
872 void lttng_transport_register(struct lttng_transport
*transport
);
873 void lttng_transport_unregister(struct lttng_transport
*transport
);
875 void lttng_counter_transport_register(struct lttng_counter_transport
*transport
);
876 void lttng_counter_transport_unregister(struct lttng_counter_transport
*transport
);
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);
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);
889 int lttng_metadata_output_channel(struct lttng_metadata_stream
*stream
,
890 struct channel
*chan
, bool *coherent
);
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
);
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
);
903 int lttng_session_list_tracker_ids(struct lttng_session
*session
,
904 enum tracker_type tracker_type
);
906 void lttng_clock_ref(void);
907 void lttng_clock_unref(void);
909 void lttng_free_event_filter_runtime(struct lttng_kernel_event_common
*event
);
911 int lttng_probes_init(void);
913 int lttng_logger_init(void);
914 void lttng_logger_exit(void);
916 extern int lttng_statedump_start(struct lttng_session
*session
);
918 int lttng_calibrate(struct lttng_kernel_abi_calibrate
*calibrate
);
920 extern const struct file_operations lttng_tracepoint_list_fops
;
921 extern const struct file_operations lttng_syscall_list_fops
;
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), \
933 #endif /* _LTTNG_EVENTS_INTERNAL_H */