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 struct lttng_syscall_filter
;
14 struct lttng_metadata_cache
;
16 struct perf_event_attr
;
17 struct lttng_kernel_ring_buffer_config
;
19 enum lttng_enabler_format_type
{
20 LTTNG_ENABLER_FORMAT_STAR_GLOB
,
21 LTTNG_ENABLER_FORMAT_NAME
,
30 * Objects in a linked-list of enablers, owned by an event.
32 struct lttng_enabler_ref
{
33 struct list_head node
; /* enabler ref list */
34 struct lttng_enabler
*ref
; /* backward ref */
37 struct lttng_krp
; /* Kretprobe handling */
39 struct lttng_uprobe_handler
{
40 struct lttng_kernel_event_common
*event
;
42 struct uprobe_consumer up_consumer
;
43 struct list_head node
;
53 struct list_head head
;
56 enum lttng_syscall_entryexit
{
61 enum lttng_syscall_abi
{
62 LTTNG_SYSCALL_ABI_NATIVE
,
63 LTTNG_SYSCALL_ABI_COMPAT
,
66 struct lttng_kernel_event_common_private
{
67 struct lttng_kernel_event_common
*pub
; /* Public event interface */
69 const struct lttng_kernel_event_desc
*desc
;
70 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
71 struct list_head enablers_ref_head
;
72 int registered
; /* has reg'd tracepoint probe */
75 int has_enablers_without_filter_bytecode
;
76 /* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */
77 struct list_head filter_bytecode_runtime_head
;
78 enum lttng_kernel_abi_instrumentation instrumentation
;
79 /* Selected by instrumentation */
81 struct lttng_kprobe kprobe
;
82 struct lttng_uprobe uprobe
;
84 struct lttng_krp
*lttng_krp
;
88 enum lttng_syscall_entryexit entryexit
;
89 enum lttng_syscall_abi abi
;
90 struct hlist_node node
; /* chain registered syscall event_notifier */
91 unsigned int syscall_id
;
96 struct lttng_kernel_event_recorder_private
{
97 struct lttng_kernel_event_common_private parent
;
99 struct lttng_kernel_event_recorder
*pub
; /* Public event interface */
100 struct list_head node
; /* Event recorder list */
101 struct hlist_node hlist
; /* Hash table of event recorders */
102 struct lttng_kernel_ctx
*ctx
;
104 unsigned int metadata_dumped
:1;
107 struct lttng_kernel_event_notifier_private
{
108 struct lttng_kernel_event_common_private parent
;
110 struct lttng_kernel_event_notifier
*pub
; /* Public event notifier interface */
111 struct lttng_event_notifier_group
*group
; /* weak ref */
112 size_t num_captures
; /* Needed to allocate the msgpack array. */
113 uint64_t error_counter_index
;
114 struct list_head node
; /* Event notifier list */
115 struct hlist_node hlist
; /* Hash table of event notifiers */
116 struct list_head capture_bytecode_runtime_head
;
120 struct lttng_kernel_channel_common_private
{
121 struct lttng_kernel_channel_common
*pub
;
123 struct file
*file
; /* File associated to channel */
124 unsigned int sys_enter_registered
:1,
125 sys_exit_registered
:1,
126 tstate
:1; /* Transient enable state */
128 struct hlist_head
*sc_table
; /* for syscall tracing */
129 struct hlist_head
*compat_sc_table
;
130 struct hlist_head
*sc_exit_table
; /* for syscall exit tracing */
131 struct hlist_head
*compat_sc_exit_table
;
132 struct hlist_head sc_unknown
; /* for unknown syscalls */
133 struct hlist_head sc_compat_unknown
;
134 struct hlist_head sc_exit_unknown
;
135 struct hlist_head compat_sc_exit_unknown
;
136 struct lttng_syscall_filter
*sc_filter
;
137 int syscall_all_entry
;
138 int syscall_all_exit
;
141 struct lttng_kernel_channel_buffer_private
{
142 struct lttng_kernel_channel_common_private parent
;
144 struct lttng_kernel_channel_buffer
*pub
;
146 unsigned int id
; /* Channel ID */
147 unsigned int free_event_id
; /* Next event ID to allocate */
148 int header_type
; /* 0: unset, 1: compact, 2: large */
150 enum channel_type channel_type
;
151 struct lttng_kernel_ctx
*ctx
;
152 struct lttng_kernel_ring_buffer_channel
*rb_chan
; /* Ring buffer channel */
153 unsigned int metadata_dumped
:1;
154 struct list_head node
; /* Channel list in session */
155 struct lttng_transport
*transport
;
158 enum lttng_kernel_bytecode_interpreter_ret
{
159 LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR
= -1,
160 LTTNG_KERNEL_BYTECODE_INTERPRETER_OK
= 0,
163 enum lttng_kernel_bytecode_filter_result
{
164 LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT
= 0,
165 LTTNG_KERNEL_BYTECODE_FILTER_REJECT
= 1,
168 struct lttng_kernel_bytecode_filter_ctx
{
169 enum lttng_kernel_bytecode_filter_result result
;
172 struct lttng_interpreter_output
;
174 enum lttng_kernel_bytecode_type
{
175 LTTNG_KERNEL_BYTECODE_TYPE_FILTER
,
176 LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE
,
179 struct lttng_kernel_bytecode_node
{
180 enum lttng_kernel_bytecode_type type
;
181 struct list_head node
;
182 struct lttng_enabler
*enabler
;
185 uint32_t reloc_offset
;
191 struct lttng_kernel_bytecode_runtime
{
192 /* Associated bytecode */
193 enum lttng_kernel_bytecode_type type
;
194 struct lttng_kernel_bytecode_node
*bc
;
195 int (*interpreter_func
)(struct lttng_kernel_bytecode_runtime
*kernel_bytecode
,
196 const char *interpreter_stack_data
,
197 struct lttng_kernel_probe_ctx
*lttng_probe_ctx
,
200 struct list_head node
; /* list of bytecode runtime in event */
201 struct lttng_kernel_ctx
*ctx
;
205 * Enabler field, within whatever object is enabling an event. Target of
206 * backward reference.
208 struct lttng_enabler
{
209 enum lttng_enabler_format_type format_type
;
211 /* head list of struct lttng_kernel_bytecode_node */
212 struct list_head filter_bytecode_head
;
214 struct lttng_kernel_abi_event event_param
;
215 unsigned int enabled
:1;
217 uint64_t user_token
; /* User-provided token. */
220 struct lttng_event_enabler
{
221 struct lttng_enabler base
;
222 struct list_head node
; /* per-session list of enablers */
223 struct lttng_kernel_channel_buffer
*chan
;
226 struct lttng_event_notifier_enabler
{
227 struct lttng_enabler base
;
228 uint64_t error_counter_index
;
229 struct list_head node
; /* List of event_notifier enablers */
230 struct lttng_event_notifier_group
*group
;
232 /* head list of struct lttng_kernel_bytecode_node */
233 struct list_head capture_bytecode_head
;
234 uint64_t num_captures
;
237 struct lttng_ctx_value
{
246 * We need to keep this perf counter field separately from struct
247 * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses.
249 struct lttng_perf_counter_field
{
250 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
251 struct lttng_cpuhp_node cpuhp_prepare
;
252 struct lttng_cpuhp_node cpuhp_online
;
254 struct notifier_block nb
;
257 struct perf_event_attr
*attr
;
258 struct perf_event
**e
; /* per-cpu array */
260 struct lttng_kernel_event_field
*event_field
;
263 struct lttng_kernel_ctx_field
{
264 const struct lttng_kernel_event_field
*event_field
;
265 size_t (*get_size
)(void *priv
, struct lttng_kernel_probe_ctx
*probe_ctx
,
267 void (*record
)(void *priv
, struct lttng_kernel_probe_ctx
*probe_ctx
,
268 struct lttng_kernel_ring_buffer_ctx
*ctx
,
269 struct lttng_kernel_channel_buffer
*chan
);
270 void (*get_value
)(void *priv
, struct lttng_kernel_probe_ctx
*probe_ctx
,
271 struct lttng_ctx_value
*value
);
272 void (*destroy
)(void *priv
);
276 struct lttng_kernel_ctx
{
277 struct lttng_kernel_ctx_field
*fields
;
278 unsigned int nr_fields
;
279 unsigned int allocated_fields
;
280 size_t largest_align
; /* in bytes */
283 struct lttng_metadata_cache
{
284 char *data
; /* Metadata cache */
285 unsigned int cache_alloc
; /* Metadata allocated size (bytes) */
286 unsigned int metadata_written
; /* Number of bytes written in metadata cache */
287 atomic_t producing
; /* Metadata being produced (incomplete) */
288 struct kref refcount
; /* Metadata cache usage */
289 struct list_head metadata_stream
; /* Metadata stream list */
290 uuid_le uuid
; /* Trace session unique ID (copy) */
291 struct mutex lock
; /* Produce/consume lock */
292 uint64_t version
; /* Current version of the metadata */
295 struct lttng_metadata_stream
{
296 void *priv
; /* Ring buffer private data */
297 struct lttng_metadata_cache
*metadata_cache
;
298 unsigned int metadata_in
; /* Bytes read from the cache */
299 unsigned int metadata_out
; /* Bytes consumed from stream */
300 int finalized
; /* Has channel been finalized */
301 wait_queue_head_t read_wait
; /* Reader buffer-level wait queue */
302 struct list_head list
; /* Stream list */
303 struct lttng_transport
*transport
;
304 uint64_t version
; /* Current version of the metadata cache */
305 bool coherent
; /* Stream in a coherent state */
308 struct lttng_kernel_channel_buffer_ops_private
{
309 struct lttng_kernel_channel_buffer_ops
*pub
; /* Public channel buffer ops interface */
311 struct lttng_kernel_ring_buffer_channel
*(*channel_create
)(const char *name
,
314 size_t subbuf_size
, size_t num_subbuf
,
315 unsigned int switch_timer_interval
,
316 unsigned int read_timer_interval
);
317 void (*channel_destroy
)(struct lttng_kernel_ring_buffer_channel
*chan
);
318 struct lttng_kernel_ring_buffer
*(*buffer_read_open
)(struct lttng_kernel_ring_buffer_channel
*chan
);
319 int (*buffer_has_read_closed_stream
)(struct lttng_kernel_ring_buffer_channel
*chan
);
320 void (*buffer_read_close
)(struct lttng_kernel_ring_buffer
*buf
);
322 * packet_avail_size returns the available size in the current
323 * packet. Note that the size returned is only a hint, since it
324 * may change due to concurrent writes.
326 size_t (*packet_avail_size
)(struct lttng_kernel_ring_buffer_channel
*chan
);
327 wait_queue_head_t
*(*get_writer_buf_wait_queue
)(struct lttng_kernel_ring_buffer_channel
*chan
, int cpu
);
328 wait_queue_head_t
*(*get_hp_wait_queue
)(struct lttng_kernel_ring_buffer_channel
*chan
);
329 int (*is_finalized
)(struct lttng_kernel_ring_buffer_channel
*chan
);
330 int (*is_disabled
)(struct lttng_kernel_ring_buffer_channel
*chan
);
331 int (*timestamp_begin
) (const struct lttng_kernel_ring_buffer_config
*config
,
332 struct lttng_kernel_ring_buffer
*bufb
,
333 uint64_t *timestamp_begin
);
334 int (*timestamp_end
) (const struct lttng_kernel_ring_buffer_config
*config
,
335 struct lttng_kernel_ring_buffer
*bufb
,
336 uint64_t *timestamp_end
);
337 int (*events_discarded
) (const struct lttng_kernel_ring_buffer_config
*config
,
338 struct lttng_kernel_ring_buffer
*bufb
,
339 uint64_t *events_discarded
);
340 int (*content_size
) (const struct lttng_kernel_ring_buffer_config
*config
,
341 struct lttng_kernel_ring_buffer
*bufb
,
342 uint64_t *content_size
);
343 int (*packet_size
) (const struct lttng_kernel_ring_buffer_config
*config
,
344 struct lttng_kernel_ring_buffer
*bufb
,
345 uint64_t *packet_size
);
346 int (*stream_id
) (const struct lttng_kernel_ring_buffer_config
*config
,
347 struct lttng_kernel_ring_buffer
*bufb
,
348 uint64_t *stream_id
);
349 int (*current_timestamp
) (const struct lttng_kernel_ring_buffer_config
*config
,
350 struct lttng_kernel_ring_buffer
*bufb
,
352 int (*sequence_number
) (const struct lttng_kernel_ring_buffer_config
*config
,
353 struct lttng_kernel_ring_buffer
*bufb
,
355 int (*instance_id
) (const struct lttng_kernel_ring_buffer_config
*config
,
356 struct lttng_kernel_ring_buffer
*bufb
,
360 struct lttng_counter_ops
{
361 struct lib_counter
*(*counter_create
)(size_t nr_dimensions
,
362 const size_t *max_nr_elem
, /* for each dimension */
363 int64_t global_sum_step
);
364 void (*counter_destroy
)(struct lib_counter
*counter
);
365 int (*counter_add
)(struct lib_counter
*counter
, const size_t *dimension_indexes
,
368 * counter_read reads a specific cpu's counter if @cpu >= 0, or
369 * the global aggregation counter if @cpu == -1.
371 int (*counter_read
)(struct lib_counter
*counter
, const size_t *dimension_indexes
, int cpu
,
372 int64_t *value
, bool *overflow
, bool *underflow
);
374 * counter_aggregate returns the total sum of all per-cpu counters and
375 * the global aggregation counter.
377 int (*counter_aggregate
)(struct lib_counter
*counter
, const size_t *dimension_indexes
,
378 int64_t *value
, bool *overflow
, bool *underflow
);
379 int (*counter_clear
)(struct lib_counter
*counter
, const size_t *dimension_indexes
);
382 struct lttng_counter
{
383 struct file
*file
; /* File associated to counter. */
385 struct lttng_counter_transport
*transport
;
386 struct lib_counter
*counter
;
387 struct lttng_counter_ops
*ops
;
390 #define LTTNG_EVENT_NOTIFIER_HT_BITS 12
391 #define LTTNG_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_EVENT_NOTIFIER_HT_BITS)
393 struct lttng_event_notifier_ht
{
394 struct hlist_head table
[LTTNG_EVENT_NOTIFIER_HT_SIZE
];
397 struct lttng_event_notifier_group
{
398 struct file
*file
; /* File associated to event notifier group */
399 struct file
*notif_file
; /* File used to expose notifications to userspace. */
400 struct list_head node
; /* event notifier group list */
401 struct list_head enablers_head
; /* List of enablers */
402 struct list_head event_notifiers_head
; /* List of event notifier */
403 struct lttng_event_notifier_ht event_notifiers_ht
; /* Hash table of event notifiers */
404 struct lttng_kernel_channel_buffer_ops
*ops
;
405 struct lttng_transport
*transport
;
406 struct lttng_kernel_ring_buffer_channel
*chan
; /* Ring buffer channel for event notifier group. */
407 struct lttng_kernel_ring_buffer
*buf
; /* Ring buffer for event notifier group. */
408 wait_queue_head_t read_wait
;
409 struct irq_work wakeup_pending
; /* Pending wakeup irq work. */
410 struct lttng_kernel_event_notifier
*sc_unknown
; /* for unknown syscalls */
411 struct lttng_kernel_event_notifier
*sc_compat_unknown
;
413 struct lttng_syscall_filter
*sc_filter
;
415 struct hlist_head
*event_notifier_syscall_dispatch
;
416 struct hlist_head
*event_notifier_compat_syscall_dispatch
;
417 struct hlist_head
*event_notifier_exit_syscall_dispatch
;
418 struct hlist_head
*event_notifier_exit_compat_syscall_dispatch
;
420 struct hlist_head event_notifier_unknown_syscall_dispatch
;
421 struct hlist_head event_notifier_compat_unknown_syscall_dispatch
;
422 struct hlist_head event_notifier_exit_unknown_syscall_dispatch
;
423 struct hlist_head event_notifier_exit_compat_unknown_syscall_dispatch
;
425 int syscall_all_entry
;
426 int syscall_all_exit
;
428 unsigned int sys_enter_registered
:1, sys_exit_registered
:1;
430 struct lttng_counter
*error_counter
;
431 size_t error_counter_len
;
434 struct lttng_transport
{
436 struct module
*owner
;
437 struct list_head node
;
438 struct lttng_kernel_channel_buffer_ops ops
;
441 struct lttng_counter_transport
{
443 struct module
*owner
;
444 struct list_head node
;
445 struct lttng_counter_ops ops
;
448 #define LTTNG_EVENT_HT_BITS 12
449 #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
451 struct lttng_event_ht
{
452 struct hlist_head table
[LTTNG_EVENT_HT_SIZE
];
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
) {
564 case 8: /* Fall-through. */
565 case 16: /* Fall-through. */
566 case 32: /* Fall-through. */
575 int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common
*event
,
576 const char *interpreter_stack_data
,
577 struct lttng_kernel_probe_ctx
*probe_ctx
,
578 void *event_filter_ctx
);
581 struct lttng_enabler
*lttng_event_enabler_as_enabler(
582 struct lttng_event_enabler
*event_enabler
)
584 return &event_enabler
->base
;
588 struct lttng_enabler
*lttng_event_notifier_enabler_as_enabler(
589 struct lttng_event_notifier_enabler
*event_notifier_enabler
)
591 return &event_notifier_enabler
->base
;
594 int lttng_context_init(void);
595 void lttng_context_exit(void);
596 int lttng_kernel_context_append(struct lttng_kernel_ctx
**ctx_p
,
597 const struct lttng_kernel_ctx_field
*f
);
598 void lttng_kernel_context_remove_last(struct lttng_kernel_ctx
**ctx_p
);
599 struct lttng_kernel_ctx_field
*lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx
*ctx
,
601 int lttng_kernel_find_context(struct lttng_kernel_ctx
*ctx
, const char *name
);
602 int lttng_kernel_get_context_index(struct lttng_kernel_ctx
*ctx
, const char *name
);
603 void lttng_kernel_destroy_context(struct lttng_kernel_ctx
*ctx
);
604 int lttng_add_pid_to_ctx(struct lttng_kernel_ctx
**ctx
);
605 int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx
**ctx
);
606 int lttng_add_procname_to_ctx(struct lttng_kernel_ctx
**ctx
);
607 int lttng_add_prio_to_ctx(struct lttng_kernel_ctx
**ctx
);
608 int lttng_add_nice_to_ctx(struct lttng_kernel_ctx
**ctx
);
609 int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx
**ctx
);
610 int lttng_add_tid_to_ctx(struct lttng_kernel_ctx
**ctx
);
611 int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx
**ctx
);
612 int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx
**ctx
);
613 int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx
**ctx
);
614 int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx
**ctx
);
615 int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx
**ctx
);
616 int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx
**ctx
);
617 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
618 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx
**ctx
);
621 int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx
**ctx
)
626 #ifdef CONFIG_PREEMPT_RT_FULL
627 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx
**ctx
);
630 int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx
**ctx
)
636 int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx
**ctx
, int type
);
638 #if defined(CONFIG_CGROUPS) && \
639 ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
640 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
641 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
644 int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
650 #if defined(CONFIG_IPC_NS) && \
651 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
652 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
655 int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
661 #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
662 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
663 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
666 int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
672 #if defined(CONFIG_NET_NS) && \
673 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
674 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
677 int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
683 #if defined(CONFIG_PID_NS) && \
684 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
685 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
688 int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
694 #if defined(CONFIG_USER_NS) && \
695 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
696 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
699 int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
705 #if defined(CONFIG_UTS_NS) && \
706 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
707 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
710 int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
716 #if defined(CONFIG_TIME_NS) && \
717 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0) || \
718 LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0))
719 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx
**ctx
);
722 int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx
**ctx
)
728 int lttng_add_uid_to_ctx(struct lttng_kernel_ctx
**ctx
);
729 int lttng_add_euid_to_ctx(struct lttng_kernel_ctx
**ctx
);
730 int lttng_add_suid_to_ctx(struct lttng_kernel_ctx
**ctx
);
731 int lttng_add_gid_to_ctx(struct lttng_kernel_ctx
**ctx
);
732 int lttng_add_egid_to_ctx(struct lttng_kernel_ctx
**ctx
);
733 int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx
**ctx
);
734 int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx
**ctx
);
735 int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx
**ctx
);
736 int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx
**ctx
);
737 int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx
**ctx
);
738 int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx
**ctx
);
739 int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx
**ctx
);
741 #if defined(CONFIG_PERF_EVENTS)
742 int lttng_add_perf_counter_to_ctx(uint32_t type
,
745 struct lttng_kernel_ctx
**ctx
);
746 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
747 struct lttng_cpuhp_node
*node
);
748 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
749 struct lttng_cpuhp_node
*node
);
752 int lttng_add_perf_counter_to_ctx(uint32_t type
,
755 struct lttng_kernel_ctx
**ctx
)
760 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
761 struct lttng_cpuhp_node
*node
)
766 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
767 struct lttng_cpuhp_node
*node
)
773 struct lttng_event_enabler
*lttng_event_enabler_create(
774 enum lttng_enabler_format_type format_type
,
775 struct lttng_kernel_abi_event
*event_param
,
776 struct lttng_kernel_channel_buffer
*chan
);
778 int lttng_event_enabler_enable(struct lttng_event_enabler
*event_enabler
);
779 int lttng_event_enabler_disable(struct lttng_event_enabler
*event_enabler
);
780 struct lttng_event_notifier_enabler
*lttng_event_notifier_enabler_create(
781 struct lttng_event_notifier_group
*event_notifier_group
,
782 enum lttng_enabler_format_type format_type
,
783 struct lttng_kernel_abi_event_notifier
*event_notifier_param
);
785 int lttng_event_notifier_enabler_enable(
786 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
787 int lttng_event_notifier_enabler_disable(
788 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
790 int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler
*event_enabler
,
791 struct lttng_kernel_abi_filter_bytecode __user
*bytecode
);
792 int lttng_event_notifier_enabler_attach_filter_bytecode(
793 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
794 struct lttng_kernel_abi_filter_bytecode __user
*bytecode
);
795 int lttng_event_notifier_enabler_attach_capture_bytecode(
796 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
797 struct lttng_kernel_abi_capture_bytecode __user
*bytecode
);
799 int lttng_desc_match_enabler(const struct lttng_kernel_event_desc
*desc
,
800 struct lttng_enabler
*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
*event_enabler
);
809 int lttng_syscalls_unregister_channel(struct lttng_kernel_channel_buffer
*chan
);
810 int lttng_syscalls_destroy_event(struct lttng_kernel_channel_buffer
*chan
);
811 int lttng_syscall_filter_enable_event(
812 struct lttng_kernel_channel_buffer
*chan
,
813 struct lttng_kernel_event_recorder
*event
);
814 int lttng_syscall_filter_disable_event(
815 struct lttng_kernel_channel_buffer
*chan
,
816 struct lttng_kernel_event_recorder
*event
);
818 long lttng_channel_syscall_mask(struct lttng_kernel_channel_buffer
*channel
,
819 struct lttng_kernel_abi_syscall_mask __user
*usyscall_mask
);
821 int lttng_syscalls_register_event_notifier(
822 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
823 int lttng_syscalls_create_matching_event_notifiers(
824 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
825 int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group
*group
);
826 int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
);
827 int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
);
829 static inline int lttng_syscalls_register_event(
830 struct lttng_event_enabler
*event_enabler
)
835 static inline int lttng_syscalls_unregister_channel(struct lttng_kernel_channel_buffer
*chan
)
840 static inline int lttng_syscalls_destroy(struct lttng_kernel_channel_buffer
*chan
)
845 static inline int lttng_syscall_filter_enable_event(struct lttng_kernel_channel_buffer
*chan
,
846 struct lttng_kernel_event_recorder
*event
);
851 static inline int lttng_syscall_filter_disable_event(struct lttng_kernel_channel_buffer
*chan
,
852 struct lttng_kernel_event_recorder
*event
);
857 static inline long lttng_channel_syscall_mask(struct lttng_kernel_channel_buffer
*channel
,
858 struct lttng_kernel_syscall_mask __user
*usyscall_mask
)
863 static inline int lttng_syscalls_register_event_notifier(
864 struct lttng_event_notifier_group
*group
)
869 static inline int lttng_syscalls_unregister_event_notifier_group(
870 struct lttng_event_notifier_group
*group
)
875 static inline int lttng_syscall_filter_enable_event_notifier(
876 struct lttng_event_notifier_group
*group
,
882 static inline int lttng_syscall_filter_disable_event_notifier(
883 struct lttng_event_notifier_group
*group
,
891 #ifdef CONFIG_KPROBES
892 int lttng_kprobes_register_event(const char *name
,
893 const char *symbol_name
,
896 struct lttng_kernel_event_recorder
*event
);
897 void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder
*event
);
898 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder
*event
);
899 int lttng_kprobes_register_event_notifier(const char *symbol_name
,
902 struct lttng_kernel_event_notifier
*event_notifier
);
903 void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
);
904 void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier
*event_notifier
);
907 int lttng_kprobes_register_event(const char *name
,
908 const char *symbol_name
,
911 struct lttng_kernel_event_recorder
*event
)
917 void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder
*event
)
922 void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder
*event
)
927 int lttng_kprobes_register_event_notifier(const char *symbol_name
,
930 struct lttng_kernel_event_notifier
*event_notifier
)
936 void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
)
941 void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier
*event_notifier
)
946 int lttng_event_add_callsite(struct lttng_kernel_event_common
*event
,
947 struct lttng_kernel_abi_event_callsite __user
*callsite
);
949 #ifdef CONFIG_UPROBES
950 int lttng_uprobes_register_event(const char *name
,
951 int fd
, struct lttng_kernel_event_recorder
*event
);
952 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common
*event
,
953 struct lttng_kernel_abi_event_callsite __user
*callsite
);
954 void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder
*event
);
955 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder
*event
);
956 int lttng_uprobes_register_event_notifier(const char *name
,
957 int fd
, struct lttng_kernel_event_notifier
*event_notifier
);
958 void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
);
959 void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier
*event_notifier
);
962 int lttng_uprobes_register_event(const char *name
,
963 int fd
, struct lttng_kernel_event_recorder
*event
)
969 int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common
*event
,
970 struct lttng_kernel_abi_event_callsite __user
*callsite
)
976 void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder
*event
)
981 void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder
*event
)
986 int lttng_uprobes_register_event_notifier(const char *name
,
987 int fd
, struct lttng_kernel_event_notifier
*event_notifier
)
993 void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier
*event_notifier
)
998 void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier
*event_notifier
)
1003 #ifdef CONFIG_KRETPROBES
1004 int lttng_kretprobes_register(const char *name
,
1005 const char *symbol_name
,
1008 struct lttng_kernel_event_recorder
*event_entry
,
1009 struct lttng_kernel_event_recorder
*event_exit
);
1010 void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder
*event
);
1011 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder
*event
);
1012 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common
*event
,
1016 int lttng_kretprobes_register(const char *name
,
1017 const char *symbol_name
,
1020 struct lttng_kernel_event_recorder
*event_entry
,
1021 struct lttng_kernel_event_recorder
*event_exit
)
1027 void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder
*event
)
1032 void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder
*event
)
1037 int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common
*event
,
1044 void lttng_lock_sessions(void);
1045 void lttng_unlock_sessions(void);
1047 struct list_head
*lttng_get_probe_list_head(void);
1049 int lttng_fix_pending_events(void);
1050 int lttng_fix_pending_event_notifiers(void);
1051 int lttng_session_active(void);
1052 bool lttng_event_notifier_active(void);
1054 struct lttng_kernel_session
*lttng_session_create(void);
1055 int lttng_session_enable(struct lttng_kernel_session
*session
);
1056 int lttng_session_disable(struct lttng_kernel_session
*session
);
1057 void lttng_session_destroy(struct lttng_kernel_session
*session
);
1058 int lttng_session_metadata_regenerate(struct lttng_kernel_session
*session
);
1059 int lttng_session_statedump(struct lttng_kernel_session
*session
);
1060 void metadata_cache_destroy(struct kref
*kref
);
1062 struct lttng_counter
*lttng_kernel_counter_create(
1063 const char *counter_transport_name
, size_t number_dimensions
,
1064 const size_t *dimensions_sizes
);
1065 int lttng_kernel_counter_read(struct lttng_counter
*counter
,
1066 const size_t *dimension_indexes
, int32_t cpu
,
1067 int64_t *val
, bool *overflow
, bool *underflow
);
1068 int lttng_kernel_counter_aggregate(struct lttng_counter
*counter
,
1069 const size_t *dimension_indexes
, int64_t *val
,
1070 bool *overflow
, bool *underflow
);
1071 int lttng_kernel_counter_clear(struct lttng_counter
*counter
,
1072 const size_t *dimension_indexes
);
1073 struct lttng_event_notifier_group
*lttng_event_notifier_group_create(void);
1074 int lttng_event_notifier_group_create_error_counter(
1075 struct file
*event_notifier_group_file
,
1076 const struct lttng_kernel_abi_counter_conf
*error_counter_conf
);
1077 void lttng_event_notifier_group_destroy(
1078 struct lttng_event_notifier_group
*event_notifier_group
);
1080 struct lttng_kernel_channel_buffer
*lttng_channel_create(struct lttng_kernel_session
*session
,
1081 const char *transport_name
,
1083 size_t subbuf_size
, size_t num_subbuf
,
1084 unsigned int switch_timer_interval
,
1085 unsigned int read_timer_interval
,
1086 enum channel_type channel_type
);
1087 struct lttng_kernel_channel_buffer
*lttng_global_channel_create(struct lttng_kernel_session
*session
,
1088 int overwrite
, void *buf_addr
,
1089 size_t subbuf_size
, size_t num_subbuf
,
1090 unsigned int switch_timer_interval
,
1091 unsigned int read_timer_interval
);
1093 void lttng_metadata_channel_destroy(struct lttng_kernel_channel_buffer
*chan
);
1094 struct lttng_kernel_event_recorder
*lttng_kernel_event_recorder_create(struct lttng_kernel_channel_buffer
*chan
,
1095 struct lttng_kernel_abi_event
*event_param
,
1096 const struct lttng_kernel_event_desc
*event_desc
,
1097 enum lttng_kernel_abi_instrumentation itype
);
1098 struct lttng_kernel_event_recorder
*_lttng_kernel_event_recorder_create(struct lttng_kernel_channel_buffer
*chan
,
1099 struct lttng_kernel_abi_event
*event_param
,
1100 const struct lttng_kernel_event_desc
*event_desc
,
1101 enum lttng_kernel_abi_instrumentation itype
);
1102 struct lttng_kernel_event_recorder
*lttng_event_compat_old_create(struct lttng_kernel_channel_buffer
*chan
,
1103 struct lttng_kernel_abi_old_event
*old_event_param
,
1104 const struct lttng_kernel_event_desc
*internal_desc
);
1106 struct lttng_kernel_event_notifier
*lttng_event_notifier_create(
1107 const struct lttng_kernel_event_desc
*event_notifier_desc
,
1109 uint64_t error_counter_idx
,
1110 struct lttng_event_notifier_group
*event_notifier_group
,
1111 struct lttng_kernel_abi_event_notifier
*event_notifier_param
,
1112 enum lttng_kernel_abi_instrumentation itype
);
1113 struct lttng_kernel_event_notifier
*_lttng_event_notifier_create(
1114 const struct lttng_kernel_event_desc
*event_notifier_desc
,
1116 uint64_t error_counter_idx
,
1117 struct lttng_event_notifier_group
*event_notifier_group
,
1118 struct lttng_kernel_abi_event_notifier
*event_notifier_param
,
1119 enum lttng_kernel_abi_instrumentation itype
);
1121 int lttng_channel_enable(struct lttng_kernel_channel_buffer
*channel
);
1122 int lttng_channel_disable(struct lttng_kernel_channel_buffer
*channel
);
1123 int lttng_event_enable(struct lttng_kernel_event_common
*event
);
1124 int lttng_event_disable(struct lttng_kernel_event_common
*event
);
1126 void lttng_transport_register(struct lttng_transport
*transport
);
1127 void lttng_transport_unregister(struct lttng_transport
*transport
);
1129 void lttng_counter_transport_register(struct lttng_counter_transport
*transport
);
1130 void lttng_counter_transport_unregister(struct lttng_counter_transport
*transport
);
1132 void synchronize_trace(void);
1133 int lttng_abi_init(void);
1134 int lttng_abi_compat_old_init(void);
1135 void lttng_abi_exit(void);
1136 void lttng_abi_compat_old_exit(void);
1138 const struct lttng_kernel_event_desc
*lttng_event_desc_get(const char *name
);
1139 void lttng_event_desc_put(const struct lttng_kernel_event_desc
*desc
);
1140 int lttng_probes_init(void);
1141 void lttng_probes_exit(void);
1143 int lttng_metadata_output_channel(struct lttng_metadata_stream
*stream
,
1144 struct lttng_kernel_ring_buffer_channel
*chan
, bool *coherent
);
1146 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node
*node
);
1147 int lttng_id_tracker_empty_set(struct lttng_kernel_id_tracker
*lf
);
1148 int lttng_id_tracker_init(struct lttng_kernel_id_tracker
*lf
,
1149 struct lttng_kernel_session
*session
,
1150 enum tracker_type type
);
1151 void lttng_id_tracker_fini(struct lttng_kernel_id_tracker
*lf
);
1152 void lttng_id_tracker_destroy(struct lttng_kernel_id_tracker
*lf
, bool rcu
);
1153 int lttng_id_tracker_add(struct lttng_kernel_id_tracker
*lf
, int id
);
1154 int lttng_id_tracker_del(struct lttng_kernel_id_tracker
*lf
, int id
);
1156 int lttng_session_track_id(struct lttng_kernel_session
*session
,
1157 enum tracker_type tracker_type
, int id
);
1158 int lttng_session_untrack_id(struct lttng_kernel_session
*session
,
1159 enum tracker_type tracker_type
, int id
);
1161 int lttng_session_list_tracker_ids(struct lttng_kernel_session
*session
,
1162 enum tracker_type tracker_type
);
1164 void lttng_clock_ref(void);
1165 void lttng_clock_unref(void);
1167 void lttng_free_event_filter_runtime(struct lttng_kernel_event_common
*event
);
1169 int lttng_probes_init(void);
1171 int lttng_logger_init(void);
1172 void lttng_logger_exit(void);
1174 extern int lttng_statedump_start(struct lttng_kernel_session
*session
);
1176 int lttng_calibrate(struct lttng_kernel_abi_calibrate
*calibrate
);
1178 extern const struct file_operations lttng_tracepoint_list_fops
;
1179 extern const struct file_operations lttng_syscall_list_fops
;
1181 #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \
1182 __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \
1183 .event_field = (_event_field), \
1184 .get_size = (_get_size), \
1185 .record = (_record), \
1186 .get_value = (_get_value), \
1187 .destroy = (_destroy), \
1191 #endif /* _LTTNG_EVENTS_INTERNAL_H */