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 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
);
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 struct lttng_kernel_channel_buffer_ops_private
{
247 struct lttng_kernel_channel_buffer_ops
*pub
; /* Public channel buffer ops interface */
249 struct channel
*(*channel_create
)(const char *name
,
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
);
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.
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
,
290 int (*sequence_number
) (const struct lib_ring_buffer_config
*config
,
291 struct lib_ring_buffer
*bufb
,
293 int (*instance_id
) (const struct lib_ring_buffer_config
*config
,
294 struct lib_ring_buffer
*bufb
,
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
,
306 * counter_read reads a specific cpu's counter if @cpu >= 0, or
307 * the global aggregation counter if @cpu == -1.
309 int (*counter_read
)(struct lib_counter
*counter
, const size_t *dimension_indexes
, int cpu
,
310 int64_t *value
, bool *overflow
, bool *underflow
);
312 * counter_aggregate returns the total sum of all per-cpu counters and
313 * the global aggregation counter.
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
);
320 struct lttng_counter
{
321 struct file
*file
; /* File associated to counter. */
323 struct lttng_counter_transport
*transport
;
324 struct lib_counter
*counter
;
325 struct lttng_counter_ops
*ops
;
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
;
344 struct lttng_syscall_filter
*sc_filter
;
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
;
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
;
356 int syscall_all_entry
;
357 int syscall_all_exit
;
359 unsigned int sys_enter_registered
:1, sys_exit_registered
:1;
361 struct lttng_counter
*error_counter
;
362 size_t error_counter_len
;
365 struct lttng_transport
{
367 struct module
*owner
;
368 struct list_head node
;
369 struct lttng_kernel_channel_buffer_ops ops
;
372 struct lttng_counter_transport
{
374 struct module
*owner
;
375 struct list_head node
;
376 struct lttng_counter_ops ops
;
379 extern struct lttng_kernel_ctx
*lttng_static_ctx
;
382 const struct lttng_kernel_type_integer
*lttng_kernel_get_type_integer(const struct lttng_kernel_type_common
*type
)
384 if (type
->type
!= lttng_kernel_type_integer
)
386 return container_of(type
, const struct lttng_kernel_type_integer
, parent
);
390 const struct lttng_kernel_type_string
*lttng_kernel_get_type_string(const struct lttng_kernel_type_common
*type
)
392 if (type
->type
!= lttng_kernel_type_string
)
394 return container_of(type
, const struct lttng_kernel_type_string
, parent
);
398 const struct lttng_kernel_type_enum
*lttng_kernel_get_type_enum(const struct lttng_kernel_type_common
*type
)
400 if (type
->type
!= lttng_kernel_type_enum
)
402 return container_of(type
, const struct lttng_kernel_type_enum
, parent
);
406 const struct lttng_kernel_type_array
*lttng_kernel_get_type_array(const struct lttng_kernel_type_common
*type
)
408 if (type
->type
!= lttng_kernel_type_array
)
410 return container_of(type
, const struct lttng_kernel_type_array
, parent
);
414 const struct lttng_kernel_type_sequence
*lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common
*type
)
416 if (type
->type
!= lttng_kernel_type_sequence
)
418 return container_of(type
, const struct lttng_kernel_type_sequence
, parent
);
422 const struct lttng_kernel_type_struct
*lttng_kernel_get_type_struct(const struct lttng_kernel_type_common
*type
)
424 if (type
->type
!= lttng_kernel_type_struct
)
426 return container_of(type
, const struct lttng_kernel_type_struct
, parent
);
430 const struct lttng_kernel_type_variant
*lttng_kernel_get_type_variant(const struct lttng_kernel_type_common
*type
)
432 if (type
->type
!= lttng_kernel_type_variant
)
434 return container_of(type
, const struct lttng_kernel_type_variant
, parent
);
437 static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common
*type
)
439 const struct lttng_kernel_type_integer
*type_integer
= lttng_kernel_get_type_integer(type
);
443 switch (type_integer
->size
) {
444 case 8: /* Fall-through. */
445 case 16: /* Fall-through. */
446 case 32: /* Fall-through. */
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
);
461 struct lttng_enabler
*lttng_event_enabler_as_enabler(
462 struct lttng_event_enabler
*event_enabler
)
464 return &event_enabler
->base
;
468 struct lttng_enabler
*lttng_event_notifier_enabler_as_enabler(
469 struct lttng_event_notifier_enabler
*event_notifier_enabler
)
471 return &event_notifier_enabler
->base
;
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
,
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
);
501 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx
**ctx
)
506 #ifdef CONFIG_PREEMPT_RT_FULL
507 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx
**ctx
);
510 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx
**ctx
)
516 int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx
**ctx
, int type
);
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
);
524 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
535 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
546 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
557 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
568 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
579 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
590 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
601 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
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
);
620 #if defined(CONFIG_PERF_EVENTS)
621 int lttng_add_perf_counter_to_ctx(uint32_t type
,
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
);
631 int lttng_add_perf_counter_to_ctx(uint32_t type
,
634 struct lttng_kernel_ctx
**ctx
)
639 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
640 struct lttng_cpuhp_node
*node
)
645 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
646 struct lttng_cpuhp_node
*node
)
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
);
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
);
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
);
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
);
678 int lttng_desc_match_enabler(const struct lttng_kernel_event_desc
*desc
,
679 struct lttng_enabler
*enabler
);
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
);
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
);
697 long lttng_channel_syscall_mask(struct lttng_channel
*channel
,
698 struct lttng_kernel_abi_syscall_mask __user
*usyscall_mask
);
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
);
708 static inline int lttng_syscalls_register_event(
709 struct lttng_event_enabler
*event_enabler
)
714 static inline int lttng_syscalls_unregister_channel(struct lttng_channel
*chan
)
719 static inline int lttng_syscalls_destroy(struct lttng_channel
*chan
)
724 static inline int lttng_syscall_filter_enable_event(struct lttng_channel
*chan
,
725 struct lttng_kernel_event_recorder
*event
);
730 static inline int lttng_syscall_filter_disable_event(struct lttng_channel
*chan
,
731 struct lttng_kernel_event_recorder
*event
);
736 static inline long lttng_channel_syscall_mask(struct lttng_channel
*channel
,
737 struct lttng_kernel_syscall_mask __user
*usyscall_mask
)
742 static inline int lttng_syscalls_register_event_notifier(
743 struct lttng_event_notifier_group
*group
)
748 static inline int lttng_syscalls_unregister_event_notifier_group(
749 struct lttng_event_notifier_group
*group
)
754 static inline int lttng_syscall_filter_enable_event_notifier(
755 struct lttng_event_notifier_group
*group
,
761 static inline int lttng_syscall_filter_disable_event_notifier(
762 struct lttng_event_notifier_group
*group
,
770 #ifdef CONFIG_KPROBES
771 int lttng_kprobes_register_event(const char *name
,
772 const char *symbol_name
,
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
,
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
);
786 int lttng_kprobes_register_event(const char *name
,
787 const char *symbol_name
,
790 struct lttng_kernel_event_recorder
*event
)
796 void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder
*event
)
801 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder
*event
)
806 int lttng_kprobes_register_event_notifier(const char *symbol_name
,
809 struct lttng_kernel_event_notifier
*event_notifier
)
815 void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
)
820 void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier
*event_notifier
)
825 int lttng_event_add_callsite(struct lttng_kernel_event_common
*event
,
826 struct lttng_kernel_abi_event_callsite __user
*callsite
);
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
);
841 int lttng_uprobes_register_event(const char *name
,
842 int fd
, struct lttng_kernel_event_recorder
*event
)
848 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common
*event
,
849 struct lttng_kernel_abi_event_callsite __user
*callsite
)
855 void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder
*event
)
860 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder
*event
)
865 int lttng_uprobes_register_event_notifier(const char *name
,
866 int fd
, struct lttng_kernel_event_notifier
*event_notifier
)
872 void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
)
877 void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier
*event_notifier
)
882 #ifdef CONFIG_KRETPROBES
883 int lttng_kretprobes_register(const char *name
,
884 const char *symbol_name
,
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
,
895 int lttng_kretprobes_register(const char *name
,
896 const char *symbol_name
,
899 struct lttng_kernel_event_recorder
*event_entry
,
900 struct lttng_kernel_event_recorder
*event_exit
)
906 void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder
*event
)
911 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder
*event
)
916 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common
*event
,
923 void lttng_lock_sessions(void);
924 void lttng_unlock_sessions(void);
926 struct list_head
*lttng_get_probe_list_head(void);
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);
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
);
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
);
959 struct lttng_channel
*lttng_channel_create(struct lttng_session
*session
,
960 const char *transport_name
,
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
);
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
);
985 struct lttng_kernel_event_notifier
*lttng_event_notifier_create(
986 const struct lttng_kernel_event_desc
*event_notifier_desc
,
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
,
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
);
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
);
1005 void lttng_transport_register(struct lttng_transport
*transport
);
1006 void lttng_transport_unregister(struct lttng_transport
*transport
);
1008 void lttng_counter_transport_register(struct lttng_counter_transport
*transport
);
1009 void lttng_counter_transport_unregister(struct lttng_counter_transport
*transport
);
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);
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);
1022 int lttng_metadata_output_channel(struct lttng_metadata_stream
*stream
,
1023 struct channel
*chan
, bool *coherent
);
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
);
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
);
1036 int lttng_session_list_tracker_ids(struct lttng_session
*session
,
1037 enum tracker_type tracker_type
);
1039 void lttng_clock_ref(void);
1040 void lttng_clock_unref(void);
1042 void lttng_free_event_filter_runtime(struct lttng_kernel_event_common
*event
);
1044 int lttng_probes_init(void);
1046 int lttng_logger_init(void);
1047 void lttng_logger_exit(void);
1049 extern int lttng_statedump_start(struct lttng_session
*session
);
1051 int lttng_calibrate(struct lttng_kernel_abi_calibrate
*calibrate
);
1053 extern const struct file_operations lttng_tracepoint_list_fops
;
1054 extern const struct file_operations lttng_syscall_list_fops
;
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), \
1066 #endif /* _LTTNG_EVENTS_INTERNAL_H */