1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
5 * Holds LTTng per-session event registry.
7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #ifndef _LTTNG_EVENTS_H
11 #define _LTTNG_EVENTS_H
13 #include <lttng-kernel-version.h>
14 #include <linux/list.h>
15 #include <linux/kprobes.h>
16 #include <linux/kref.h>
17 #include <lttng-cpuhotplug.h>
18 #include <linux/uuid.h>
19 #include <linux/irq_work.h>
20 #include <wrapper/uprobes.h>
21 #include <lttng-tracer.h>
22 #include <lttng-abi.h>
23 #include <lttng-abi-old.h>
25 #define lttng_is_signed_type(type) (((type) -1) < (type) 1)
29 struct lttng_metadata_cache
;
30 struct lib_ring_buffer_ctx
;
32 struct perf_event_attr
;
33 struct lib_ring_buffer_config
;
35 /* Type description */
44 atype_array_compound
, /* Array of compound types. */
45 atype_sequence_compound
, /* Sequence of compound types. */
48 atype_sequence_bitfield
,
52 enum lttng_string_encodings
{
53 lttng_encode_none
= 0,
54 lttng_encode_UTF8
= 1,
55 lttng_encode_ASCII
= 2,
64 struct lttng_enum_value
{
65 unsigned long long value
;
66 unsigned int signedness
:1;
69 struct lttng_enum_entry
{
70 struct lttng_enum_value start
, end
; /* start and end are inclusive */
73 unsigned int is_auto
:1;
77 #define __type_integer(_type, _size, _alignment, _signedness, \
78 _byte_order, _user, _base, _encoding) \
80 .atype = atype_integer, \
83 .size = (_size) ? : sizeof(_type) * CHAR_BIT, \
84 .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \
85 .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \
86 .reverse_byte_order = (_byte_order) != __BYTE_ORDER, \
89 .encoding = lttng_encode_##_encoding, \
93 struct lttng_integer_type {
94 unsigned int size
; /* in bits */
95 unsigned short alignment
; /* in bits */
96 unsigned int signedness
:1,
98 user
:1; /* fetch from user-space */
99 unsigned int base
; /* 2, 8, 10, 16, for pretty print */
100 enum lttng_string_encodings encoding
;
103 union _lttng_basic_type
{
104 struct lttng_integer_type integer
;
106 const struct lttng_enum_desc
*desc
; /* Enumeration mapping */
107 struct lttng_integer_type container_type
;
110 enum lttng_string_encodings encoding
;
111 unsigned int user
:1; /* fetch from user-space */
115 struct lttng_basic_type
{
116 enum abstract_types atype
;
118 union _lttng_basic_type basic
;
123 enum abstract_types atype
;
125 union _lttng_basic_type basic
;
127 struct lttng_basic_type elem_type
;
128 unsigned int length
; /* num. elems. */
129 unsigned int elem_alignment
; /* alignment override */
132 struct lttng_basic_type length_type
;
133 struct lttng_basic_type elem_type
;
134 unsigned int elem_alignment
; /* alignment override */
138 struct lttng_event_field
*fields
; /* Array of fields. */
141 struct lttng_type
*elem_type
;
142 unsigned int length
; /* num. elems. */
145 struct lttng_type
*elem_type
;
146 const char *length_name
;
149 const char *tag_name
;
150 struct lttng_event_field
*choices
; /* Array of fields. */
156 struct lttng_enum_desc
{
158 const struct lttng_enum_entry
*entries
;
159 unsigned int nr_entries
;
162 /* Event field description */
164 struct lttng_event_field
{
166 struct lttng_type type
;
167 unsigned int nowrite
:1; /* do not write into trace */
170 union lttng_ctx_value
{
177 * We need to keep this perf counter field separately from struct
178 * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
180 struct lttng_perf_counter_field
{
181 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
182 struct lttng_cpuhp_node cpuhp_prepare
;
183 struct lttng_cpuhp_node cpuhp_online
;
185 struct notifier_block nb
;
188 struct perf_event_attr
*attr
;
189 struct perf_event
**e
; /* per-cpu array */
192 struct lttng_probe_ctx
{
193 struct lttng_event
*event
;
194 uint8_t interruptible
;
197 struct lttng_ctx_field
{
198 struct lttng_event_field event_field
;
199 size_t (*get_size
)(size_t offset
);
200 size_t (*get_size_arg
)(size_t offset
, struct lttng_ctx_field
*field
,
201 struct lib_ring_buffer_ctx
*ctx
,
202 struct lttng_channel
*chan
);
203 void (*record
)(struct lttng_ctx_field
*field
,
204 struct lib_ring_buffer_ctx
*ctx
,
205 struct lttng_channel
*chan
);
206 void (*get_value
)(struct lttng_ctx_field
*field
,
207 struct lttng_probe_ctx
*lttng_probe_ctx
,
208 union lttng_ctx_value
*value
);
210 struct lttng_perf_counter_field
*perf_counter
;
212 void (*destroy
)(struct lttng_ctx_field
*field
);
214 * Private data to keep state between get_size and record.
215 * User must perform its own synchronization to protect against
216 * concurrent and reentrant contexts.
222 struct lttng_ctx_field
*fields
;
223 unsigned int nr_fields
;
224 unsigned int allocated_fields
;
225 size_t largest_align
; /* in bytes */
228 struct lttng_event_desc
{
229 const char *name
; /* lttng-modules name */
230 const char *kname
; /* Linux kernel name (tracepoints) */
231 void *probe_callback
;
232 const struct lttng_event_ctx
*ctx
; /* context */
233 const struct lttng_event_field
*fields
; /* event payload */
234 unsigned int nr_fields
;
235 struct module
*owner
;
238 struct lttng_probe_desc
{
239 const char *provider
;
240 const struct lttng_event_desc
**event_desc
;
241 unsigned int nr_events
;
242 struct list_head head
; /* chain registered probes */
243 struct list_head lazy_init_head
;
244 int lazy
; /* lazy registration */
247 struct lttng_krp
; /* Kretprobe handling */
249 enum lttng_event_type
{
250 LTTNG_TYPE_EVENT
= 0,
251 LTTNG_TYPE_ENABLER
= 1,
254 struct lttng_filter_bytecode_node
{
255 struct list_head node
;
256 struct lttng_enabler
*enabler
;
258 * struct lttng_kernel_filter_bytecode has var. sized array, must be
261 struct lttng_kernel_filter_bytecode bc
;
265 * Filter return value masks.
267 enum lttng_filter_ret
{
268 LTTNG_FILTER_DISCARD
= 0,
269 LTTNG_FILTER_RECORD_FLAG
= (1ULL << 0),
270 /* Other bits are kept for future use. */
273 struct lttng_bytecode_runtime
{
274 /* Associated bytecode */
275 struct lttng_filter_bytecode_node
*bc
;
276 uint64_t (*filter
)(void *filter_data
, struct lttng_probe_ctx
*lttng_probe_ctx
,
277 const char *filter_stack_data
);
279 struct list_head node
; /* list of bytecode runtime in event */
280 struct lttng_event
*event
;
284 * Objects in a linked-list of enablers, owned by an event.
286 struct lttng_enabler_ref
{
287 struct list_head node
; /* enabler ref list */
288 struct lttng_enabler
*ref
; /* backward ref */
291 struct lttng_uprobe_handler
{
292 struct lttng_event
*event
;
294 struct uprobe_consumer up_consumer
;
295 struct list_head node
;
298 enum lttng_syscall_entryexit
{
303 enum lttng_syscall_abi
{
304 LTTNG_SYSCALL_ABI_NATIVE
,
305 LTTNG_SYSCALL_ABI_COMPAT
,
309 * lttng_event structure is referred to by the tracing fast path. It must be
313 enum lttng_event_type evtype
; /* First field. */
315 struct lttng_channel
*chan
;
317 const struct lttng_event_desc
*desc
;
319 struct lttng_ctx
*ctx
;
320 enum lttng_kernel_instrumentation instrumentation
;
327 struct lttng_krp
*lttng_krp
;
332 struct list_head head
;
336 enum lttng_syscall_entryexit entryexit
;
337 enum lttng_syscall_abi abi
;
340 struct list_head list
; /* Event list in session */
341 unsigned int metadata_dumped
:1;
343 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
344 struct list_head enablers_ref_head
;
345 struct hlist_node hlist
; /* session ht of events */
346 int registered
; /* has reg'd tracepoint probe */
347 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
348 struct list_head bytecode_runtime_head
;
349 int has_enablers_without_bytecode
;
352 enum lttng_enabler_type
{
353 LTTNG_ENABLER_STAR_GLOB
,
358 * Enabler field, within whatever object is enabling an event. Target of
359 * backward reference.
361 struct lttng_enabler
{
362 enum lttng_event_type evtype
; /* First field. */
364 enum lttng_enabler_type type
;
366 struct list_head node
; /* per-session list of enablers */
367 /* head list of struct lttng_ust_filter_bytecode_node */
368 struct list_head filter_bytecode_head
;
370 struct lttng_kernel_event event_param
;
371 struct lttng_channel
*chan
;
372 struct lttng_ctx
*ctx
;
373 unsigned int enabled
:1;
376 struct lttng_channel_ops
{
377 struct channel
*(*channel_create
)(const char *name
,
378 struct lttng_channel
*lttng_chan
,
380 size_t subbuf_size
, size_t num_subbuf
,
381 unsigned int switch_timer_interval
,
382 unsigned int read_timer_interval
);
383 void (*channel_destroy
)(struct channel
*chan
);
384 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
385 int (*buffer_has_read_closed_stream
)(struct channel
*chan
);
386 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
387 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
,
389 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
390 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
392 void (*event_write_from_user
)(struct lib_ring_buffer_ctx
*ctx
,
393 const void *src
, size_t len
);
394 void (*event_memset
)(struct lib_ring_buffer_ctx
*ctx
,
396 void (*event_strcpy
)(struct lib_ring_buffer_ctx
*ctx
, const char *src
,
398 void (*event_strcpy_from_user
)(struct lib_ring_buffer_ctx
*ctx
,
399 const char __user
*src
, size_t len
);
401 * packet_avail_size returns the available size in the current
402 * packet. Note that the size returned is only a hint, since it
403 * may change due to concurrent writes.
405 size_t (*packet_avail_size
)(struct channel
*chan
);
406 wait_queue_head_t
*(*get_writer_buf_wait_queue
)(struct channel
*chan
, int cpu
);
407 wait_queue_head_t
*(*get_hp_wait_queue
)(struct channel
*chan
);
408 int (*is_finalized
)(struct channel
*chan
);
409 int (*is_disabled
)(struct channel
*chan
);
410 int (*timestamp_begin
) (const struct lib_ring_buffer_config
*config
,
411 struct lib_ring_buffer
*bufb
,
412 uint64_t *timestamp_begin
);
413 int (*timestamp_end
) (const struct lib_ring_buffer_config
*config
,
414 struct lib_ring_buffer
*bufb
,
415 uint64_t *timestamp_end
);
416 int (*events_discarded
) (const struct lib_ring_buffer_config
*config
,
417 struct lib_ring_buffer
*bufb
,
418 uint64_t *events_discarded
);
419 int (*content_size
) (const struct lib_ring_buffer_config
*config
,
420 struct lib_ring_buffer
*bufb
,
421 uint64_t *content_size
);
422 int (*packet_size
) (const struct lib_ring_buffer_config
*config
,
423 struct lib_ring_buffer
*bufb
,
424 uint64_t *packet_size
);
425 int (*stream_id
) (const struct lib_ring_buffer_config
*config
,
426 struct lib_ring_buffer
*bufb
,
427 uint64_t *stream_id
);
428 int (*current_timestamp
) (const struct lib_ring_buffer_config
*config
,
429 struct lib_ring_buffer
*bufb
,
431 int (*sequence_number
) (const struct lib_ring_buffer_config
*config
,
432 struct lib_ring_buffer
*bufb
,
434 int (*instance_id
) (const struct lib_ring_buffer_config
*config
,
435 struct lib_ring_buffer
*bufb
,
439 struct lttng_transport
{
441 struct module
*owner
;
442 struct list_head node
;
443 struct lttng_channel_ops ops
;
446 struct lttng_syscall_filter
;
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_channel
{
457 struct channel
*chan
; /* Channel buffers */
459 struct lttng_ctx
*ctx
;
460 /* Event ID management */
461 struct lttng_session
*session
;
462 struct file
*file
; /* File associated to channel */
463 unsigned int free_event_id
; /* Next event ID to allocate */
464 struct list_head list
; /* Channel list */
465 struct lttng_channel_ops
*ops
;
466 struct lttng_transport
*transport
;
467 struct lttng_event
**sc_table
; /* for syscall tracing */
468 struct lttng_event
**compat_sc_table
;
469 struct lttng_event
**sc_exit_table
; /* for syscall exit tracing */
470 struct lttng_event
**compat_sc_exit_table
;
471 struct lttng_event
*sc_unknown
; /* for unknown syscalls */
472 struct lttng_event
*sc_compat_unknown
;
473 struct lttng_event
*sc_exit_unknown
;
474 struct lttng_event
*compat_sc_exit_unknown
;
475 struct lttng_syscall_filter
*sc_filter
;
476 int header_type
; /* 0: unset, 1: compact, 2: large */
477 enum channel_type channel_type
;
479 unsigned int metadata_dumped
:1,
480 sys_enter_registered
:1,
481 sys_exit_registered
:1,
482 tstate
:1; /* Transient enable state */
485 struct lttng_metadata_stream
{
486 void *priv
; /* Ring buffer private data */
487 struct lttng_metadata_cache
*metadata_cache
;
488 unsigned int metadata_in
; /* Bytes read from the cache */
489 unsigned int metadata_out
; /* Bytes consumed from stream */
490 int finalized
; /* Has channel been finalized */
491 wait_queue_head_t read_wait
; /* Reader buffer-level wait queue */
492 struct list_head list
; /* Stream list */
493 struct lttng_transport
*transport
;
494 uint64_t version
; /* Current version of the metadata cache */
495 bool coherent
; /* Stream in a coherent state */
498 #define LTTNG_DYNAMIC_LEN_STACK_SIZE 128
500 struct lttng_dynamic_len_stack
{
501 size_t stack
[LTTNG_DYNAMIC_LEN_STACK_SIZE
];
505 DECLARE_PER_CPU(struct lttng_dynamic_len_stack
, lttng_dynamic_len_stack
);
508 * struct lttng_id_tracker declared in header due to deferencing of *v
509 * in RCU_INITIALIZER(v).
511 #define LTTNG_ID_HASH_BITS 6
512 #define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS)
525 struct lttng_id_tracker_rcu
{
526 struct hlist_head id_hash
[LTTNG_ID_TABLE_SIZE
];
529 struct lttng_id_tracker
{
530 struct lttng_session
*session
;
531 enum tracker_type tracker_type
;
532 struct lttng_id_tracker_rcu
*p
; /* RCU dereferenced. */
535 struct lttng_id_hash_node
{
536 struct hlist_node hlist
;
540 struct lttng_session
{
541 int active
; /* Is trace session active ? */
542 int been_active
; /* Has trace session been active ? */
543 struct file
*file
; /* File associated to session */
544 struct list_head chan
; /* Channel list head */
545 struct list_head events
; /* Event list head */
546 struct list_head list
; /* Session list */
547 unsigned int free_chan_id
; /* Next chan ID to allocate */
548 uuid_le uuid
; /* Trace session unique ID */
549 struct lttng_metadata_cache
*metadata_cache
;
550 struct lttng_id_tracker pid_tracker
;
551 struct lttng_id_tracker vpid_tracker
;
552 struct lttng_id_tracker uid_tracker
;
553 struct lttng_id_tracker vuid_tracker
;
554 struct lttng_id_tracker gid_tracker
;
555 struct lttng_id_tracker vgid_tracker
;
556 unsigned int metadata_dumped
:1,
557 tstate
:1; /* Transient enable state */
558 /* List of enablers */
559 struct list_head enablers_head
;
560 /* Hash table of events */
561 struct lttng_event_ht events_ht
;
562 char name
[LTTNG_KERNEL_SESSION_NAME_LEN
];
563 char creation_time
[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
];
566 struct lttng_metadata_cache
{
567 char *data
; /* Metadata cache */
568 unsigned int cache_alloc
; /* Metadata allocated size (bytes) */
569 unsigned int metadata_written
; /* Number of bytes written in metadata cache */
570 atomic_t producing
; /* Metadata being produced (incomplete) */
571 struct kref refcount
; /* Metadata cache usage */
572 struct list_head metadata_stream
; /* Metadata stream list */
573 uuid_le uuid
; /* Trace session unique ID (copy) */
574 struct mutex lock
; /* Produce/consume lock */
575 uint64_t version
; /* Current version of the metadata */
578 void lttng_lock_sessions(void);
579 void lttng_unlock_sessions(void);
581 struct list_head
*lttng_get_probe_list_head(void);
583 struct lttng_enabler
*lttng_enabler_create(enum lttng_enabler_type type
,
584 struct lttng_kernel_event
*event_param
,
585 struct lttng_channel
*chan
);
587 int lttng_enabler_enable(struct lttng_enabler
*enabler
);
588 int lttng_enabler_disable(struct lttng_enabler
*enabler
);
589 int lttng_fix_pending_events(void);
590 int lttng_session_active(void);
592 struct lttng_session
*lttng_session_create(void);
593 int lttng_session_enable(struct lttng_session
*session
);
594 int lttng_session_disable(struct lttng_session
*session
);
595 void lttng_session_destroy(struct lttng_session
*session
);
596 int lttng_session_metadata_regenerate(struct lttng_session
*session
);
597 int lttng_session_statedump(struct lttng_session
*session
);
598 void metadata_cache_destroy(struct kref
*kref
);
600 struct lttng_channel
*lttng_channel_create(struct lttng_session
*session
,
601 const char *transport_name
,
603 size_t subbuf_size
, size_t num_subbuf
,
604 unsigned int switch_timer_interval
,
605 unsigned int read_timer_interval
,
606 enum channel_type channel_type
);
607 struct lttng_channel
*lttng_global_channel_create(struct lttng_session
*session
,
608 int overwrite
, void *buf_addr
,
609 size_t subbuf_size
, size_t num_subbuf
,
610 unsigned int switch_timer_interval
,
611 unsigned int read_timer_interval
);
613 void lttng_metadata_channel_destroy(struct lttng_channel
*chan
);
614 struct lttng_event
*lttng_event_create(struct lttng_channel
*chan
,
615 struct lttng_kernel_event
*event_param
,
617 const struct lttng_event_desc
*event_desc
,
618 enum lttng_kernel_instrumentation itype
);
619 struct lttng_event
*_lttng_event_create(struct lttng_channel
*chan
,
620 struct lttng_kernel_event
*event_param
,
622 const struct lttng_event_desc
*event_desc
,
623 enum lttng_kernel_instrumentation itype
);
624 struct lttng_event
*lttng_event_compat_old_create(struct lttng_channel
*chan
,
625 struct lttng_kernel_old_event
*old_event_param
,
627 const struct lttng_event_desc
*internal_desc
);
629 int lttng_channel_enable(struct lttng_channel
*channel
);
630 int lttng_channel_disable(struct lttng_channel
*channel
);
631 int lttng_event_enable(struct lttng_event
*event
);
632 int lttng_event_disable(struct lttng_event
*event
);
634 void lttng_transport_register(struct lttng_transport
*transport
);
635 void lttng_transport_unregister(struct lttng_transport
*transport
);
637 void synchronize_trace(void);
638 int lttng_abi_init(void);
639 int lttng_abi_compat_old_init(void);
640 void lttng_abi_exit(void);
641 void lttng_abi_compat_old_exit(void);
643 int lttng_probe_register(struct lttng_probe_desc
*desc
);
644 void lttng_probe_unregister(struct lttng_probe_desc
*desc
);
645 const struct lttng_event_desc
*lttng_event_get(const char *name
);
646 void lttng_event_put(const struct lttng_event_desc
*desc
);
647 int lttng_probes_init(void);
648 void lttng_probes_exit(void);
650 int lttng_metadata_output_channel(struct lttng_metadata_stream
*stream
,
651 struct channel
*chan
, bool *coherent
);
653 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node
*node
);
654 int lttng_id_tracker_empty_set(struct lttng_id_tracker
*lf
);
655 void lttng_id_tracker_destroy(struct lttng_id_tracker
*lf
, bool rcu
);
656 bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu
*p
, int id
);
657 int lttng_id_tracker_add(struct lttng_id_tracker
*lf
, int id
);
658 int lttng_id_tracker_del(struct lttng_id_tracker
*lf
, int id
);
660 int lttng_session_track_id(struct lttng_session
*session
,
661 enum tracker_type tracker_type
, int id
);
662 int lttng_session_untrack_id(struct lttng_session
*session
,
663 enum tracker_type tracker_type
, int id
);
665 int lttng_session_list_tracker_ids(struct lttng_session
*session
,
666 enum tracker_type tracker_type
);
668 void lttng_clock_ref(void);
669 void lttng_clock_unref(void);
671 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
672 int lttng_syscalls_register(struct lttng_channel
*chan
, void *filter
);
673 int lttng_syscalls_unregister(struct lttng_channel
*chan
);
674 int lttng_syscalls_destroy(struct lttng_channel
*chan
);
675 int lttng_syscall_filter_enable(struct lttng_channel
*chan
,
676 struct lttng_event
*event
);
677 int lttng_syscall_filter_disable(struct lttng_channel
*chan
,
678 struct lttng_event
*event
);
679 long lttng_channel_syscall_mask(struct lttng_channel
*channel
,
680 struct lttng_kernel_syscall_mask __user
*usyscall_mask
);
682 static inline int lttng_syscalls_register(struct lttng_channel
*chan
, void *filter
)
687 static inline int lttng_syscalls_unregister(struct lttng_channel
*chan
)
692 static inline int lttng_syscalls_destroy(struct lttng_channel
*chan
)
697 static inline int lttng_syscall_filter_enable(struct lttng_channel
*chan
,
698 struct lttng_event
*event
)
703 static inline int lttng_syscall_filter_disable(struct lttng_channel
*chan
,
704 struct lttng_event
*event
)
709 static inline long lttng_channel_syscall_mask(struct lttng_channel
*channel
,
710 struct lttng_kernel_syscall_mask __user
*usyscall_mask
)
716 void lttng_filter_sync_state(struct lttng_bytecode_runtime
*runtime
);
717 int lttng_enabler_attach_bytecode(struct lttng_enabler
*enabler
,
718 struct lttng_kernel_filter_bytecode __user
*bytecode
);
719 void lttng_enabler_event_link_bytecode(struct lttng_event
*event
,
720 struct lttng_enabler
*enabler
);
721 void lttng_free_event_filter_runtime(struct lttng_event
*event
);
723 int lttng_probes_init(void);
725 extern struct lttng_ctx
*lttng_static_ctx
;
727 int lttng_context_init(void);
728 void lttng_context_exit(void);
729 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx
);
730 void lttng_context_update(struct lttng_ctx
*ctx
);
731 int lttng_find_context(struct lttng_ctx
*ctx
, const char *name
);
732 int lttng_get_context_index(struct lttng_ctx
*ctx
, const char *name
);
733 void lttng_remove_context_field(struct lttng_ctx
**ctx
,
734 struct lttng_ctx_field
*field
);
735 void lttng_destroy_context(struct lttng_ctx
*ctx
);
736 int lttng_add_pid_to_ctx(struct lttng_ctx
**ctx
);
737 int lttng_add_cpu_id_to_ctx(struct lttng_ctx
**ctx
);
738 int lttng_add_procname_to_ctx(struct lttng_ctx
**ctx
);
739 int lttng_add_prio_to_ctx(struct lttng_ctx
**ctx
);
740 int lttng_add_nice_to_ctx(struct lttng_ctx
**ctx
);
741 int lttng_add_vpid_to_ctx(struct lttng_ctx
**ctx
);
742 int lttng_add_tid_to_ctx(struct lttng_ctx
**ctx
);
743 int lttng_add_vtid_to_ctx(struct lttng_ctx
**ctx
);
744 int lttng_add_ppid_to_ctx(struct lttng_ctx
**ctx
);
745 int lttng_add_vppid_to_ctx(struct lttng_ctx
**ctx
);
746 int lttng_add_hostname_to_ctx(struct lttng_ctx
**ctx
);
747 int lttng_add_interruptible_to_ctx(struct lttng_ctx
**ctx
);
748 int lttng_add_need_reschedule_to_ctx(struct lttng_ctx
**ctx
);
749 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
750 int lttng_add_preemptible_to_ctx(struct lttng_ctx
**ctx
);
753 int lttng_add_preemptible_to_ctx(struct lttng_ctx
**ctx
)
758 #ifdef CONFIG_PREEMPT_RT_FULL
759 int lttng_add_migratable_to_ctx(struct lttng_ctx
**ctx
);
762 int lttng_add_migratable_to_ctx(struct lttng_ctx
**ctx
)
768 int lttng_add_callstack_to_ctx(struct lttng_ctx
**ctx
, int type
);
770 #if defined(CONFIG_CGROUPS) && \
771 ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
772 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
773 int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx
**ctx
);
776 int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx
**ctx
)
782 #if defined(CONFIG_IPC_NS) && \
783 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
784 int lttng_add_ipc_ns_to_ctx(struct lttng_ctx
**ctx
);
787 int lttng_add_ipc_ns_to_ctx(struct lttng_ctx
**ctx
)
793 #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
794 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
795 int lttng_add_mnt_ns_to_ctx(struct lttng_ctx
**ctx
);
798 int lttng_add_mnt_ns_to_ctx(struct lttng_ctx
**ctx
)
804 #if defined(CONFIG_NET_NS) && \
805 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
806 int lttng_add_net_ns_to_ctx(struct lttng_ctx
**ctx
);
809 int lttng_add_net_ns_to_ctx(struct lttng_ctx
**ctx
)
815 #if defined(CONFIG_PID_NS) && \
816 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
817 int lttng_add_pid_ns_to_ctx(struct lttng_ctx
**ctx
);
820 int lttng_add_pid_ns_to_ctx(struct lttng_ctx
**ctx
)
826 #if defined(CONFIG_USER_NS) && \
827 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
828 int lttng_add_user_ns_to_ctx(struct lttng_ctx
**ctx
);
831 int lttng_add_user_ns_to_ctx(struct lttng_ctx
**ctx
)
837 #if defined(CONFIG_UTS_NS) && \
838 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
839 int lttng_add_uts_ns_to_ctx(struct lttng_ctx
**ctx
);
842 int lttng_add_uts_ns_to_ctx(struct lttng_ctx
**ctx
)
848 int lttng_add_uid_to_ctx(struct lttng_ctx
**ctx
);
849 int lttng_add_euid_to_ctx(struct lttng_ctx
**ctx
);
850 int lttng_add_suid_to_ctx(struct lttng_ctx
**ctx
);
851 int lttng_add_gid_to_ctx(struct lttng_ctx
**ctx
);
852 int lttng_add_egid_to_ctx(struct lttng_ctx
**ctx
);
853 int lttng_add_sgid_to_ctx(struct lttng_ctx
**ctx
);
854 int lttng_add_vuid_to_ctx(struct lttng_ctx
**ctx
);
855 int lttng_add_veuid_to_ctx(struct lttng_ctx
**ctx
);
856 int lttng_add_vsuid_to_ctx(struct lttng_ctx
**ctx
);
857 int lttng_add_vgid_to_ctx(struct lttng_ctx
**ctx
);
858 int lttng_add_vegid_to_ctx(struct lttng_ctx
**ctx
);
859 int lttng_add_vsgid_to_ctx(struct lttng_ctx
**ctx
);
861 #if defined(CONFIG_PERF_EVENTS)
862 int lttng_add_perf_counter_to_ctx(uint32_t type
,
865 struct lttng_ctx
**ctx
);
866 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
867 struct lttng_cpuhp_node
*node
);
868 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
869 struct lttng_cpuhp_node
*node
);
872 int lttng_add_perf_counter_to_ctx(uint32_t type
,
875 struct lttng_ctx
**ctx
)
880 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
881 struct lttng_cpuhp_node
*node
)
886 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
887 struct lttng_cpuhp_node
*node
)
893 int lttng_logger_init(void);
894 void lttng_logger_exit(void);
896 extern int lttng_statedump_start(struct lttng_session
*session
);
898 #ifdef CONFIG_KPROBES
899 int lttng_kprobes_register(const char *name
,
900 const char *symbol_name
,
903 struct lttng_event
*event
);
904 void lttng_kprobes_unregister(struct lttng_event
*event
);
905 void lttng_kprobes_destroy_private(struct lttng_event
*event
);
908 int lttng_kprobes_register(const char *name
,
909 const char *symbol_name
,
912 struct lttng_event
*event
)
918 void lttng_kprobes_unregister(struct lttng_event
*event
)
923 void lttng_kprobes_destroy_private(struct lttng_event
*event
)
928 int lttng_event_add_callsite(struct lttng_event
*event
,
929 struct lttng_kernel_event_callsite
*callsite
);
931 #ifdef CONFIG_UPROBES
932 int lttng_uprobes_register(const char *name
,
933 int fd
, struct lttng_event
*event
);
934 int lttng_uprobes_add_callsite(struct lttng_event
*event
,
935 struct lttng_kernel_event_callsite
*callsite
);
936 void lttng_uprobes_unregister(struct lttng_event
*event
);
937 void lttng_uprobes_destroy_private(struct lttng_event
*event
);
940 int lttng_uprobes_register(const char *name
,
941 int fd
, struct lttng_event
*event
)
947 int lttng_uprobes_add_callsite(struct lttng_event
*event
,
948 struct lttng_kernel_event_callsite
*callsite
)
954 void lttng_uprobes_unregister(struct lttng_event
*event
)
959 void lttng_uprobes_destroy_private(struct lttng_event
*event
)
964 #ifdef CONFIG_KRETPROBES
965 int lttng_kretprobes_register(const char *name
,
966 const char *symbol_name
,
969 struct lttng_event
*event_entry
,
970 struct lttng_event
*event_exit
);
971 void lttng_kretprobes_unregister(struct lttng_event
*event
);
972 void lttng_kretprobes_destroy_private(struct lttng_event
*event
);
973 int lttng_kretprobes_event_enable_state(struct lttng_event
*event
,
977 int lttng_kretprobes_register(const char *name
,
978 const char *symbol_name
,
981 struct lttng_event
*event_entry
,
982 struct lttng_event
*event_exit
)
988 void lttng_kretprobes_unregister(struct lttng_event
*event
)
993 void lttng_kretprobes_destroy_private(struct lttng_event
*event
)
998 int lttng_kretprobes_event_enable_state(struct lttng_event
*event
,
1005 int lttng_calibrate(struct lttng_kernel_calibrate
*calibrate
);
1007 extern const struct file_operations lttng_tracepoint_list_fops
;
1008 extern const struct file_operations lttng_syscall_list_fops
;
1010 #define TRACEPOINT_HAS_DATA_ARG
1012 #endif /* _LTTNG_EVENTS_H */