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 <wrapper/compiler_attributes.h>
13 #include <lttng/events.h>
15 struct lttng_syscall_filter
;
16 struct lttng_metadata_cache
;
18 struct perf_event_attr
;
19 struct lttng_kernel_ring_buffer_config
;
21 enum lttng_enabler_format_type
{
22 LTTNG_ENABLER_FORMAT_STAR_GLOB
,
23 LTTNG_ENABLER_FORMAT_NAME
,
32 * Objects in a linked-list of enablers, owned by an event.
34 struct lttng_enabler_ref
{
35 struct list_head node
; /* enabler ref list */
36 struct lttng_event_enabler_common
*ref
; /* backward ref */
39 struct lttng_krp
; /* Kretprobe handling */
41 struct lttng_uprobe_handler
{
42 struct lttng_kernel_event_common
*event
;
44 struct uprobe_consumer up_consumer
;
45 struct list_head node
;
55 struct list_head head
;
58 enum lttng_syscall_entryexit
{
63 enum lttng_syscall_abi
{
64 LTTNG_SYSCALL_ABI_NATIVE
,
65 LTTNG_SYSCALL_ABI_COMPAT
,
68 struct lttng_kernel_event_common_private
{
69 struct lttng_kernel_event_common
*pub
; /* Public event interface */
71 const struct lttng_kernel_event_desc
*desc
;
72 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
73 struct list_head enablers_ref_head
;
74 int registered
; /* has reg'd tracepoint probe */
77 int has_enablers_without_filter_bytecode
;
78 /* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */
79 struct list_head filter_bytecode_runtime_head
;
81 struct hlist_node hlist_node
; /* node in events hash table */
83 enum lttng_kernel_abi_instrumentation instrumentation
;
84 /* Selected by instrumentation */
86 struct lttng_kprobe kprobe
;
87 struct lttng_uprobe uprobe
;
89 struct lttng_krp
*lttng_krp
;
93 enum lttng_syscall_entryexit entryexit
;
94 enum lttng_syscall_abi abi
;
95 struct hlist_node node
; /* chain registered syscall event_notifier */
96 unsigned int syscall_id
;
101 struct lttng_kernel_event_recorder_private
{
102 struct lttng_kernel_event_common_private parent
;
104 struct lttng_kernel_event_recorder
*pub
; /* Public event interface */
105 struct list_head node
; /* Event recorder list */
106 struct lttng_kernel_ctx
*ctx
;
108 unsigned int metadata_dumped
:1;
111 struct lttng_kernel_event_notifier_private
{
112 struct lttng_kernel_event_common_private parent
;
114 struct lttng_kernel_event_notifier
*pub
; /* Public event notifier interface */
115 struct lttng_event_notifier_group
*group
; /* weak ref */
116 size_t num_captures
; /* Needed to allocate the msgpack array. */
117 uint64_t error_counter_index
;
118 struct list_head node
; /* Event notifier list */
119 struct list_head capture_bytecode_runtime_head
;
122 struct lttng_kernel_syscall_table
{
123 unsigned int sys_enter_registered
:1,
124 sys_exit_registered
:1;
126 struct hlist_head
*syscall_dispatch
; /* for syscall tracing */
127 struct hlist_head
*compat_syscall_dispatch
;
128 struct hlist_head
*syscall_exit_dispatch
; /* for syscall exit tracing */
129 struct hlist_head
*compat_syscall_exit_dispatch
;
132 * Combining all unknown syscall events works as long as they
133 * are only matched by "all" syscalls enablers, but will require
134 * a design change when we allow matching by syscall number, for
135 * instance by allocating sc_tables accomodating NR_syscalls
138 struct hlist_head unknown_syscall_dispatch
; /* for unknown syscalls */
139 struct hlist_head compat_unknown_syscall_dispatch
;
140 struct hlist_head unknown_syscall_exit_dispatch
;
141 struct hlist_head compat_unknown_syscall_exit_dispatch
;
143 struct lttng_syscall_filter
*sc_filter
;
144 int syscall_all_entry
;
145 int syscall_all_exit
;
148 struct lttng_kernel_channel_common_private
{
149 struct lttng_kernel_channel_common
*pub
;
151 struct file
*file
; /* File associated to channel */
152 unsigned int tstate
:1; /* Transient enable state */
154 struct lttng_kernel_syscall_table syscall_table
;
157 struct lttng_kernel_channel_buffer_private
{
158 struct lttng_kernel_channel_common_private parent
;
160 struct lttng_kernel_channel_buffer
*pub
;
162 unsigned int id
; /* Channel ID */
163 unsigned int free_event_id
; /* Next event ID to allocate */
164 int header_type
; /* 0: unset, 1: compact, 2: large */
166 enum channel_type channel_type
;
167 struct lttng_kernel_ctx
*ctx
;
168 struct lttng_kernel_ring_buffer_channel
*rb_chan
; /* Ring buffer channel */
169 unsigned int metadata_dumped
:1;
170 struct list_head node
; /* Channel list in session */
171 struct lttng_transport
*transport
;
174 enum lttng_kernel_bytecode_interpreter_ret
{
175 LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR
= -1,
176 LTTNG_KERNEL_BYTECODE_INTERPRETER_OK
= 0,
179 enum lttng_kernel_bytecode_filter_result
{
180 LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT
= 0,
181 LTTNG_KERNEL_BYTECODE_FILTER_REJECT
= 1,
184 struct lttng_kernel_bytecode_filter_ctx
{
185 enum lttng_kernel_bytecode_filter_result result
;
188 struct lttng_interpreter_output
;
190 enum lttng_kernel_bytecode_type
{
191 LTTNG_KERNEL_BYTECODE_TYPE_FILTER
,
192 LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE
,
195 enum lttng_kernel_event_enabler_type
{
196 LTTNG_EVENT_ENABLER_TYPE_RECORDER
,
197 LTTNG_EVENT_ENABLER_TYPE_NOTIFIER
,
200 struct lttng_kernel_bytecode_node
{
201 enum lttng_kernel_bytecode_type type
;
202 struct list_head node
;
203 struct lttng_event_enabler_common
*enabler
;
206 uint32_t reloc_offset
;
212 struct lttng_kernel_bytecode_runtime
{
213 /* Associated bytecode */
214 enum lttng_kernel_bytecode_type type
;
215 struct lttng_kernel_bytecode_node
*bc
;
216 int (*interpreter_func
)(struct lttng_kernel_bytecode_runtime
*kernel_bytecode
,
217 const char *interpreter_stack_data
,
218 struct lttng_kernel_probe_ctx
*lttng_probe_ctx
,
221 struct list_head node
; /* list of bytecode runtime in event */
222 struct lttng_kernel_ctx
*ctx
;
226 * Enabler field, within whatever object is enabling an event. Target of
227 * backward reference.
229 struct lttng_event_enabler_common
{
230 enum lttng_kernel_event_enabler_type enabler_type
;
231 enum lttng_enabler_format_type format_type
;
233 /* head list of struct lttng_kernel_bytecode_node */
234 struct list_head filter_bytecode_head
;
236 struct lttng_kernel_abi_event event_param
;
237 unsigned int enabled
:1;
239 uint64_t user_token
; /* User-provided token. */
242 struct lttng_event_recorder_enabler
{
243 struct lttng_event_enabler_common parent
;
244 struct list_head node
; /* per-session list of enablers */
245 bool published
; /* published in per-session list. */
246 struct lttng_kernel_channel_buffer
*chan
;
249 struct lttng_event_notifier_enabler
{
250 struct lttng_event_enabler_common parent
;
251 uint64_t error_counter_index
;
252 struct list_head node
; /* List of event_notifier enablers */
253 bool published
; /* published in group list. */
254 struct lttng_event_notifier_group
*group
;
256 /* head list of struct lttng_kernel_bytecode_node */
257 struct list_head capture_bytecode_head
;
258 uint64_t num_captures
;
261 struct lttng_ctx_value
{
270 * We need to keep this perf counter field separately from struct
271 * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses.
273 struct lttng_perf_counter_field
{
274 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
275 struct lttng_cpuhp_node cpuhp_prepare
;
276 struct lttng_cpuhp_node cpuhp_online
;
278 struct notifier_block nb
;
281 struct perf_event_attr
*attr
;
282 struct perf_event
**e
; /* per-cpu array */
284 struct lttng_kernel_event_field
*event_field
;
287 struct lttng_kernel_ctx_field
{
288 const struct lttng_kernel_event_field
*event_field
;
289 size_t (*get_size
)(void *priv
, struct lttng_kernel_probe_ctx
*probe_ctx
,
291 void (*record
)(void *priv
, struct lttng_kernel_probe_ctx
*probe_ctx
,
292 struct lttng_kernel_ring_buffer_ctx
*ctx
,
293 struct lttng_kernel_channel_buffer
*chan
);
294 void (*get_value
)(void *priv
, struct lttng_kernel_probe_ctx
*probe_ctx
,
295 struct lttng_ctx_value
*value
);
296 void (*destroy
)(void *priv
);
300 struct lttng_kernel_ctx
{
301 struct lttng_kernel_ctx_field
*fields
;
302 unsigned int nr_fields
;
303 unsigned int allocated_fields
;
304 size_t largest_align
; /* in bytes */
307 struct lttng_metadata_cache
{
308 char *data
; /* Metadata cache */
309 unsigned int cache_alloc
; /* Metadata allocated size (bytes) */
310 unsigned int metadata_written
; /* Number of bytes written in metadata cache */
311 atomic_t producing
; /* Metadata being produced (incomplete) */
312 struct kref refcount
; /* Metadata cache usage */
313 struct list_head metadata_stream
; /* Metadata stream list */
314 uuid_le uuid
; /* Trace session unique ID (copy) */
315 struct mutex lock
; /* Produce/consume lock */
316 uint64_t version
; /* Current version of the metadata */
319 struct lttng_metadata_stream
{
320 void *priv
; /* Ring buffer private data */
321 struct lttng_metadata_cache
*metadata_cache
;
322 unsigned int metadata_in
; /* Bytes read from the cache */
323 unsigned int metadata_out
; /* Bytes consumed from stream */
324 int finalized
; /* Has channel been finalized */
325 wait_queue_head_t read_wait
; /* Reader buffer-level wait queue */
326 struct list_head list
; /* Stream list */
327 struct lttng_transport
*transport
;
328 uint64_t version
; /* Current version of the metadata cache */
329 bool coherent
; /* Stream in a coherent state */
332 struct lttng_kernel_channel_buffer_ops_private
{
333 struct lttng_kernel_channel_buffer_ops
*pub
; /* Public channel buffer ops interface */
335 struct lttng_kernel_ring_buffer_channel
*(*channel_create
)(const char *name
,
338 size_t subbuf_size
, size_t num_subbuf
,
339 unsigned int switch_timer_interval
,
340 unsigned int read_timer_interval
);
341 void (*channel_destroy
)(struct lttng_kernel_ring_buffer_channel
*chan
);
342 struct lttng_kernel_ring_buffer
*(*buffer_read_open
)(struct lttng_kernel_ring_buffer_channel
*chan
);
343 int (*buffer_has_read_closed_stream
)(struct lttng_kernel_ring_buffer_channel
*chan
);
344 void (*buffer_read_close
)(struct lttng_kernel_ring_buffer
*buf
);
346 * packet_avail_size returns the available size in the current
347 * packet. Note that the size returned is only a hint, since it
348 * may change due to concurrent writes.
350 size_t (*packet_avail_size
)(struct lttng_kernel_ring_buffer_channel
*chan
);
351 wait_queue_head_t
*(*get_writer_buf_wait_queue
)(struct lttng_kernel_ring_buffer_channel
*chan
, int cpu
);
352 wait_queue_head_t
*(*get_hp_wait_queue
)(struct lttng_kernel_ring_buffer_channel
*chan
);
353 int (*is_finalized
)(struct lttng_kernel_ring_buffer_channel
*chan
);
354 int (*is_disabled
)(struct lttng_kernel_ring_buffer_channel
*chan
);
355 int (*timestamp_begin
) (const struct lttng_kernel_ring_buffer_config
*config
,
356 struct lttng_kernel_ring_buffer
*bufb
,
357 uint64_t *timestamp_begin
);
358 int (*timestamp_end
) (const struct lttng_kernel_ring_buffer_config
*config
,
359 struct lttng_kernel_ring_buffer
*bufb
,
360 uint64_t *timestamp_end
);
361 int (*events_discarded
) (const struct lttng_kernel_ring_buffer_config
*config
,
362 struct lttng_kernel_ring_buffer
*bufb
,
363 uint64_t *events_discarded
);
364 int (*content_size
) (const struct lttng_kernel_ring_buffer_config
*config
,
365 struct lttng_kernel_ring_buffer
*bufb
,
366 uint64_t *content_size
);
367 int (*packet_size
) (const struct lttng_kernel_ring_buffer_config
*config
,
368 struct lttng_kernel_ring_buffer
*bufb
,
369 uint64_t *packet_size
);
370 int (*stream_id
) (const struct lttng_kernel_ring_buffer_config
*config
,
371 struct lttng_kernel_ring_buffer
*bufb
,
372 uint64_t *stream_id
);
373 int (*current_timestamp
) (const struct lttng_kernel_ring_buffer_config
*config
,
374 struct lttng_kernel_ring_buffer
*bufb
,
376 int (*sequence_number
) (const struct lttng_kernel_ring_buffer_config
*config
,
377 struct lttng_kernel_ring_buffer
*bufb
,
379 int (*instance_id
) (const struct lttng_kernel_ring_buffer_config
*config
,
380 struct lttng_kernel_ring_buffer
*bufb
,
384 struct lttng_counter_ops
{
385 struct lib_counter
*(*counter_create
)(size_t nr_dimensions
,
386 const size_t *max_nr_elem
, /* for each dimension */
387 int64_t global_sum_step
);
388 void (*counter_destroy
)(struct lib_counter
*counter
);
389 int (*counter_add
)(struct lib_counter
*counter
, const size_t *dimension_indexes
,
392 * counter_read reads a specific cpu's counter if @cpu >= 0, or
393 * the global aggregation counter if @cpu == -1.
395 int (*counter_read
)(struct lib_counter
*counter
, const size_t *dimension_indexes
, int cpu
,
396 int64_t *value
, bool *overflow
, bool *underflow
);
398 * counter_aggregate returns the total sum of all per-cpu counters and
399 * the global aggregation counter.
401 int (*counter_aggregate
)(struct lib_counter
*counter
, const size_t *dimension_indexes
,
402 int64_t *value
, bool *overflow
, bool *underflow
);
403 int (*counter_clear
)(struct lib_counter
*counter
, const size_t *dimension_indexes
);
406 struct lttng_counter
{
407 struct file
*file
; /* File associated to counter. */
409 struct lttng_counter_transport
*transport
;
410 struct lib_counter
*counter
;
411 struct lttng_counter_ops
*ops
;
414 #define LTTNG_EVENT_HT_BITS 12
415 #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
417 struct lttng_event_ht
{
418 struct hlist_head table
[LTTNG_EVENT_HT_SIZE
];
421 struct lttng_event_notifier_group
{
422 struct file
*file
; /* File associated to event notifier group */
423 struct file
*notif_file
; /* File used to expose notifications to userspace. */
424 struct list_head node
; /* event notifier group list */
425 struct list_head enablers_head
; /* List of enablers */
426 struct list_head event_notifiers_head
; /* List of event notifier */
427 struct lttng_event_ht events_ht
; /* Hash table of event notifiers */
428 struct lttng_kernel_channel_buffer_ops
*ops
;
429 struct lttng_transport
*transport
;
430 struct lttng_kernel_ring_buffer_channel
*chan
; /* Ring buffer channel for event notifier group. */
431 struct lttng_kernel_ring_buffer
*buf
; /* Ring buffer for event notifier group. */
432 wait_queue_head_t read_wait
;
433 struct irq_work wakeup_pending
; /* Pending wakeup irq work. */
435 struct lttng_kernel_syscall_table syscall_table
;
437 struct lttng_counter
*error_counter
;
438 size_t error_counter_len
;
441 struct lttng_transport
{
443 struct module
*owner
;
444 struct list_head node
;
445 struct lttng_kernel_channel_buffer_ops ops
;
448 struct lttng_counter_transport
{
450 struct module
*owner
;
451 struct list_head node
;
452 struct lttng_counter_ops ops
;
455 struct lttng_kernel_session_private
{
456 struct lttng_kernel_session
*pub
; /* Public session interface */
458 int been_active
; /* Has trace session been active ? */
459 struct file
*file
; /* File associated to session */
460 struct list_head chan
; /* Channel list head */
461 struct list_head events
; /* Event list head */
462 struct list_head list
; /* Session list */
463 unsigned int free_chan_id
; /* Next chan ID to allocate */
464 uuid_le uuid
; /* Trace session unique ID */
465 struct lttng_metadata_cache
*metadata_cache
;
466 unsigned int metadata_dumped
:1,
467 tstate
:1; /* Transient enable state */
468 /* List of event enablers */
469 struct list_head enablers_head
;
470 /* Hash table of events */
471 struct lttng_event_ht events_ht
;
472 char name
[LTTNG_KERNEL_ABI_SESSION_NAME_LEN
];
473 char creation_time
[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN
];
476 struct lttng_id_hash_node
{
477 struct hlist_node hlist
;
492 struct lttng_kernel_id_tracker_private
{
493 struct lttng_kernel_id_tracker
*pub
; /* Public interface */
495 struct lttng_kernel_session
*session
;
496 enum tracker_type tracker_type
;
499 extern struct lttng_kernel_ctx
*lttng_static_ctx
;
502 const struct lttng_kernel_type_integer
*lttng_kernel_get_type_integer(const struct lttng_kernel_type_common
*type
)
504 if (type
->type
!= lttng_kernel_type_integer
)
506 return container_of(type
, const struct lttng_kernel_type_integer
, parent
);
510 const struct lttng_kernel_type_string
*lttng_kernel_get_type_string(const struct lttng_kernel_type_common
*type
)
512 if (type
->type
!= lttng_kernel_type_string
)
514 return container_of(type
, const struct lttng_kernel_type_string
, parent
);
518 const struct lttng_kernel_type_enum
*lttng_kernel_get_type_enum(const struct lttng_kernel_type_common
*type
)
520 if (type
->type
!= lttng_kernel_type_enum
)
522 return container_of(type
, const struct lttng_kernel_type_enum
, parent
);
526 const struct lttng_kernel_type_array
*lttng_kernel_get_type_array(const struct lttng_kernel_type_common
*type
)
528 if (type
->type
!= lttng_kernel_type_array
)
530 return container_of(type
, const struct lttng_kernel_type_array
, parent
);
534 const struct lttng_kernel_type_sequence
*lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common
*type
)
536 if (type
->type
!= lttng_kernel_type_sequence
)
538 return container_of(type
, const struct lttng_kernel_type_sequence
, parent
);
542 const struct lttng_kernel_type_struct
*lttng_kernel_get_type_struct(const struct lttng_kernel_type_common
*type
)
544 if (type
->type
!= lttng_kernel_type_struct
)
546 return container_of(type
, const struct lttng_kernel_type_struct
, parent
);
550 const struct lttng_kernel_type_variant
*lttng_kernel_get_type_variant(const struct lttng_kernel_type_common
*type
)
552 if (type
->type
!= lttng_kernel_type_variant
)
554 return container_of(type
, const struct lttng_kernel_type_variant
, parent
);
557 static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common
*type
)
559 const struct lttng_kernel_type_integer
*type_integer
= lttng_kernel_get_type_integer(type
);
563 switch (type_integer
->size
) {
578 int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common
*event
,
579 const char *interpreter_stack_data
,
580 struct lttng_kernel_probe_ctx
*probe_ctx
,
581 void *event_filter_ctx
);
584 struct lttng_event_enabler_common
*lttng_event_recorder_enabler_as_enabler(
585 struct lttng_event_recorder_enabler
*event_recorder_enabler
)
587 return &event_recorder_enabler
->parent
;
591 struct lttng_event_enabler_common
*lttng_event_notifier_enabler_as_enabler(
592 struct lttng_event_notifier_enabler
*event_notifier_enabler
)
594 return &event_notifier_enabler
->parent
;
597 int lttng_context_init(void);
598 void lttng_context_exit(void);
599 int lttng_kernel_context_append(struct lttng_kernel_ctx
**ctx_p
,
600 const struct lttng_kernel_ctx_field
*f
);
601 void lttng_kernel_context_remove_last(struct lttng_kernel_ctx
**ctx_p
);
602 struct lttng_kernel_ctx_field
*lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx
*ctx
,
604 int lttng_kernel_find_context(struct lttng_kernel_ctx
*ctx
, const char *name
);
605 int lttng_kernel_get_context_index(struct lttng_kernel_ctx
*ctx
, const char *name
);
606 void lttng_kernel_destroy_context(struct lttng_kernel_ctx
*ctx
);
607 int lttng_add_pid_to_ctx(struct lttng_kernel_ctx
**ctx
);
608 int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx
**ctx
);
609 int lttng_add_procname_to_ctx(struct lttng_kernel_ctx
**ctx
);
610 int lttng_add_prio_to_ctx(struct lttng_kernel_ctx
**ctx
);
611 int lttng_add_nice_to_ctx(struct lttng_kernel_ctx
**ctx
);
612 int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx
**ctx
);
613 int lttng_add_tid_to_ctx(struct lttng_kernel_ctx
**ctx
);
614 int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx
**ctx
);
615 int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx
**ctx
);
616 int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx
**ctx
);
617 int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx
**ctx
);
618 int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx
**ctx
);
619 int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx
**ctx
);
620 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
621 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx
**ctx
);
624 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx
**ctx
)
629 #ifdef CONFIG_PREEMPT_RT_FULL
630 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx
**ctx
);
633 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx
**ctx
)
639 int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx
**ctx
, int type
);
641 #if defined(CONFIG_CGROUPS) && \
642 ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
643 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
644 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
647 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
653 #if defined(CONFIG_IPC_NS) && \
654 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
655 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
658 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
664 #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
665 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
666 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
669 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
675 #if defined(CONFIG_NET_NS) && \
676 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
677 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
680 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
686 #if defined(CONFIG_PID_NS) && \
687 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
688 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
691 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
697 #if defined(CONFIG_USER_NS) && \
698 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
699 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
702 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
708 #if defined(CONFIG_UTS_NS) && \
709 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
710 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
713 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
719 #if defined(CONFIG_TIME_NS) && \
720 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0) || \
721 LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0))
722 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
725 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
731 int lttng_add_uid_to_ctx(struct lttng_kernel_ctx
**ctx
);
732 int lttng_add_euid_to_ctx(struct lttng_kernel_ctx
**ctx
);
733 int lttng_add_suid_to_ctx(struct lttng_kernel_ctx
**ctx
);
734 int lttng_add_gid_to_ctx(struct lttng_kernel_ctx
**ctx
);
735 int lttng_add_egid_to_ctx(struct lttng_kernel_ctx
**ctx
);
736 int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx
**ctx
);
737 int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx
**ctx
);
738 int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx
**ctx
);
739 int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx
**ctx
);
740 int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx
**ctx
);
741 int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx
**ctx
);
742 int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx
**ctx
);
744 #if defined(CONFIG_PERF_EVENTS)
745 int lttng_add_perf_counter_to_ctx(uint32_t type
,
748 struct lttng_kernel_ctx
**ctx
);
749 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
750 struct lttng_cpuhp_node
*node
);
751 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
752 struct lttng_cpuhp_node
*node
);
755 int lttng_add_perf_counter_to_ctx(uint32_t type
,
758 struct lttng_kernel_ctx
**ctx
)
763 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
764 struct lttng_cpuhp_node
*node
)
769 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
770 struct lttng_cpuhp_node
*node
)
776 struct lttng_event_recorder_enabler
*lttng_event_recorder_enabler_create(
777 enum lttng_enabler_format_type format_type
,
778 struct lttng_kernel_abi_event
*event_param
,
779 struct lttng_kernel_channel_buffer
*chan
);
780 void lttng_event_enabler_session_add(struct lttng_kernel_session
*session
,
781 struct lttng_event_recorder_enabler
*event_enabler
);
783 struct lttng_event_notifier_enabler
*lttng_event_notifier_enabler_create(
784 enum lttng_enabler_format_type format_type
,
785 struct lttng_kernel_abi_event_notifier
*event_notifier_param
,
786 struct lttng_event_notifier_group
*event_notifier_group
);
787 void lttng_event_notifier_enabler_group_add(struct lttng_event_notifier_group
*event_notifier_group
,
788 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
789 int lttng_event_notifier_enabler_attach_capture_bytecode(
790 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
791 struct lttng_kernel_abi_capture_bytecode __user
*bytecode
);
793 int lttng_event_enabler_enable(struct lttng_event_enabler_common
*event_enabler
);
794 int lttng_event_enabler_disable(struct lttng_event_enabler_common
*event_enabler
);
795 int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler_common
*event_enabler
,
796 struct lttng_kernel_abi_filter_bytecode __user
*bytecode
);
797 void lttng_event_enabler_destroy(struct lttng_event_enabler_common
*event_enabler
);
799 int lttng_desc_match_enabler(const struct lttng_kernel_event_desc
*desc
,
800 struct lttng_event_enabler_common
*enabler
);
802 void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc
*event_desc
,
803 struct lttng_kernel_ctx
*ctx
,
804 struct list_head
*instance_bytecode_runtime_head
,
805 struct list_head
*enabler_bytecode_runtime_head
);
807 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
808 int lttng_syscalls_register_event(struct lttng_event_enabler_common
*event_enabler
);
809 int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common
*event
);
810 int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common
*event
);
812 int lttng_syscalls_unregister_syscall_table(struct lttng_kernel_syscall_table
*syscall_table
);
813 int lttng_syscalls_destroy_syscall_table(struct lttng_kernel_syscall_table
*syscall_table
);
815 long lttng_syscall_table_get_active_mask(struct lttng_kernel_syscall_table
*syscall_table
,
816 struct lttng_kernel_abi_syscall_mask __user
*usyscall_mask
);
818 static inline int lttng_syscalls_register_event(struct lttng_event_enabler_common
*event_enabler
)
823 static inline int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common
*event
)
828 static inline int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common
*event
)
833 static inline int lttng_syscalls_unregister_syscall_table(struct lttng_kernel_syscall_table
*syscall_table
)
838 static inline int lttng_syscalls_destroy_syscall_table(struct lttng_kernel_syscall_table
*syscall_table
)
843 static inline long lttng_syscall_table_get_active_mask(struct lttng_kernel_syscall_table
*syscall_table
,
844 struct lttng_kernel_abi_syscall_mask __user
*usyscall_mask
)
849 static inline int lttng_syscalls_create_matching_event_notifiers(struct lttng_event_notifier_enabler
*event_notifier_enabler
)
856 #ifdef CONFIG_KPROBES
857 int lttng_kprobes_register_event(const char *name
,
858 const char *symbol_name
,
861 struct lttng_kernel_event_common
*event
);
862 void lttng_kprobes_unregister_event(struct lttng_kernel_event_common
*event
);
863 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common
*event
);
866 int lttng_kprobes_register_event(const char *name
,
867 const char *symbol_name
,
870 struct lttng_kernel_event_common
*event
)
876 void lttng_kprobes_unregister_event(struct lttng_kernel_event_common
*event
)
881 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common
*event
)
886 int lttng_event_add_callsite(struct lttng_kernel_event_common
*event
,
887 struct lttng_kernel_abi_event_callsite __user
*callsite
);
889 #ifdef CONFIG_UPROBES
890 int lttng_uprobes_register_event(const char *name
,
891 int fd
, struct lttng_kernel_event_common
*event
);
892 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common
*event
,
893 struct lttng_kernel_abi_event_callsite __user
*callsite
);
894 void lttng_uprobes_unregister_event(struct lttng_kernel_event_common
*event
);
895 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_common
*event
);
898 int lttng_uprobes_register_event(const char *name
,
899 int fd
, struct lttng_kernel_event_common
*event
)
905 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common
*event
,
906 struct lttng_kernel_abi_event_callsite __user
*callsite
)
912 void lttng_uprobes_unregister_event(struct lttng_kernel_event_common
*event
)
917 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_common
*event
)
922 #ifdef CONFIG_KRETPROBES
923 int lttng_kretprobes_register(const char *name
,
924 const char *symbol_name
,
927 struct lttng_kernel_event_common
*event_entry
,
928 struct lttng_kernel_event_common
*event_exit
);
929 void lttng_kretprobes_unregister(struct lttng_kernel_event_common
*event
);
930 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_common
*event
);
931 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common
*event
,
935 int lttng_kretprobes_register(const char *name
,
936 const char *symbol_name
,
939 struct lttng_kernel_event_common
*event_entry
,
940 struct lttng_kernel_event_common
*event_exit
)
946 void lttng_kretprobes_unregister(struct lttng_kernel_event_common
*event
)
951 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_common
*event
)
956 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common
*event
,
963 void lttng_lock_sessions(void);
964 void lttng_unlock_sessions(void);
966 struct list_head
*lttng_get_probe_list_head(void);
968 int lttng_fix_pending_events(void);
969 int lttng_fix_pending_event_notifiers(void);
970 int lttng_session_active(void);
971 bool lttng_event_notifier_active(void);
973 struct lttng_kernel_session
*lttng_session_create(void);
974 int lttng_session_enable(struct lttng_kernel_session
*session
);
975 int lttng_session_disable(struct lttng_kernel_session
*session
);
976 void lttng_session_destroy(struct lttng_kernel_session
*session
);
977 int lttng_session_metadata_regenerate(struct lttng_kernel_session
*session
);
978 int lttng_session_statedump(struct lttng_kernel_session
*session
);
979 void metadata_cache_destroy(struct kref
*kref
);
981 struct lttng_counter
*lttng_kernel_counter_create(
982 const char *counter_transport_name
, size_t number_dimensions
,
983 const size_t *dimensions_sizes
);
984 int lttng_kernel_counter_read(struct lttng_counter
*counter
,
985 const size_t *dimension_indexes
, int32_t cpu
,
986 int64_t *val
, bool *overflow
, bool *underflow
);
987 int lttng_kernel_counter_aggregate(struct lttng_counter
*counter
,
988 const size_t *dimension_indexes
, int64_t *val
,
989 bool *overflow
, bool *underflow
);
990 int lttng_kernel_counter_clear(struct lttng_counter
*counter
,
991 const size_t *dimension_indexes
);
992 struct lttng_event_notifier_group
*lttng_event_notifier_group_create(void);
993 int lttng_event_notifier_group_create_error_counter(
994 struct file
*event_notifier_group_file
,
995 const struct lttng_kernel_abi_counter_conf
*error_counter_conf
);
996 void lttng_event_notifier_group_destroy(
997 struct lttng_event_notifier_group
*event_notifier_group
);
999 struct lttng_kernel_channel_buffer
*lttng_channel_buffer_create(struct lttng_kernel_session
*session
,
1000 const char *transport_name
,
1002 size_t subbuf_size
, size_t num_subbuf
,
1003 unsigned int switch_timer_interval
,
1004 unsigned int read_timer_interval
,
1005 enum channel_type channel_type
);
1006 struct lttng_kernel_channel_buffer
*lttng_global_channel_create(struct lttng_kernel_session
*session
,
1007 int overwrite
, void *buf_addr
,
1008 size_t subbuf_size
, size_t num_subbuf
,
1009 unsigned int switch_timer_interval
,
1010 unsigned int read_timer_interval
);
1012 void lttng_metadata_channel_destroy(struct lttng_kernel_channel_buffer
*chan
);
1013 struct lttng_kernel_event_recorder
*lttng_kernel_event_recorder_create(struct lttng_event_recorder_enabler
*event_enabler
,
1014 const struct lttng_kernel_event_desc
*event_desc
);
1015 struct lttng_kernel_event_recorder
*_lttng_kernel_event_recorder_create(struct lttng_event_recorder_enabler
*event_enabler
,
1016 const struct lttng_kernel_event_desc
*event_desc
);
1017 struct lttng_kernel_event_recorder
*lttng_event_compat_old_create(struct lttng_kernel_channel_buffer
*chan
,
1018 struct lttng_kernel_abi_old_event
*old_event_param
,
1019 const struct lttng_kernel_event_desc
*internal_desc
);
1021 struct lttng_kernel_event_notifier
*lttng_event_notifier_create(struct lttng_event_notifier_enabler
*event_enabler
,
1022 const struct lttng_kernel_event_desc
*event_notifier_desc
);
1023 struct lttng_kernel_event_notifier
*_lttng_event_notifier_create(struct lttng_event_notifier_enabler
*event_enabler
,
1024 const struct lttng_kernel_event_desc
*event_notifier_desc
);
1026 int lttng_channel_enable(struct lttng_kernel_channel_common
*channel
);
1027 int lttng_channel_disable(struct lttng_kernel_channel_common
*channel
);
1028 int lttng_event_enable(struct lttng_kernel_event_common
*event
);
1029 int lttng_event_disable(struct lttng_kernel_event_common
*event
);
1031 void lttng_transport_register(struct lttng_transport
*transport
);
1032 void lttng_transport_unregister(struct lttng_transport
*transport
);
1034 void lttng_counter_transport_register(struct lttng_counter_transport
*transport
);
1035 void lttng_counter_transport_unregister(struct lttng_counter_transport
*transport
);
1037 void synchronize_trace(void);
1038 int lttng_abi_init(void);
1039 int lttng_abi_compat_old_init(void);
1040 void lttng_abi_exit(void);
1041 void lttng_abi_compat_old_exit(void);
1043 const struct lttng_kernel_event_desc
*lttng_event_desc_get(const char *name
);
1044 void lttng_event_desc_put(const struct lttng_kernel_event_desc
*desc
);
1045 int lttng_probes_init(void);
1046 void lttng_probes_exit(void);
1048 int lttng_metadata_output_channel(struct lttng_metadata_stream
*stream
,
1049 struct lttng_kernel_ring_buffer_channel
*chan
, bool *coherent
);
1051 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node
*node
);
1052 int lttng_id_tracker_empty_set(struct lttng_kernel_id_tracker
*lf
);
1053 int lttng_id_tracker_init(struct lttng_kernel_id_tracker
*lf
,
1054 struct lttng_kernel_session
*session
,
1055 enum tracker_type type
);
1056 void lttng_id_tracker_fini(struct lttng_kernel_id_tracker
*lf
);
1057 void lttng_id_tracker_destroy(struct lttng_kernel_id_tracker
*lf
, bool rcu
);
1058 int lttng_id_tracker_add(struct lttng_kernel_id_tracker
*lf
, int id
);
1059 int lttng_id_tracker_del(struct lttng_kernel_id_tracker
*lf
, int id
);
1061 int lttng_session_track_id(struct lttng_kernel_session
*session
,
1062 enum tracker_type tracker_type
, int id
);
1063 int lttng_session_untrack_id(struct lttng_kernel_session
*session
,
1064 enum tracker_type tracker_type
, int id
);
1066 int lttng_session_list_tracker_ids(struct lttng_kernel_session
*session
,
1067 enum tracker_type tracker_type
);
1069 void lttng_clock_ref(void);
1070 void lttng_clock_unref(void);
1072 void lttng_free_event_filter_runtime(struct lttng_kernel_event_common
*event
);
1074 int lttng_probes_init(void);
1076 int lttng_logger_init(void);
1077 void lttng_logger_exit(void);
1079 extern int lttng_statedump_start(struct lttng_kernel_session
*session
);
1081 int lttng_calibrate(struct lttng_kernel_abi_calibrate
*calibrate
);
1083 extern const struct file_operations lttng_tracepoint_list_fops
;
1084 extern const struct file_operations lttng_syscall_list_fops
;
1086 #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \
1087 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \
1088 .event_field = (_event_field), \
1089 .get_size = (_get_size), \
1090 .record = (_record), \
1091 .get_value = (_get_value), \
1092 .destroy = (_destroy), \
1096 #endif /* _LTTNG_EVENTS_INTERNAL_H */