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 <linux/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 <wrapper/uprobes.h>
20 #include <lttng-tracer.h>
21 #include <lttng-abi.h>
22 #include <lttng-abi-old.h>
23 #include <linux/irq_work.h>
25 #define lttng_is_signed_type(type) (((type)(-1)) < 0)
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, _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, \
88 .encoding = lttng_encode_##_encoding, \
92 struct lttng_integer_type {
93 unsigned int size
; /* in bits */
94 unsigned short alignment
; /* in bits */
95 unsigned int signedness
:1,
97 unsigned int base
; /* 2, 8, 10, 16, for pretty print */
98 enum lttng_string_encodings encoding
;
101 union _lttng_basic_type
{
102 struct lttng_integer_type integer
;
104 const struct lttng_enum_desc
*desc
; /* Enumeration mapping */
105 struct lttng_integer_type container_type
;
108 enum lttng_string_encodings encoding
;
112 struct lttng_basic_type
{
113 enum abstract_types atype
;
115 union _lttng_basic_type basic
;
120 enum abstract_types atype
;
122 union _lttng_basic_type basic
;
124 struct lttng_basic_type elem_type
;
125 unsigned int length
; /* num. elems. */
126 unsigned int elem_alignment
; /* alignment override */
129 struct lttng_basic_type length_type
;
130 struct lttng_basic_type elem_type
;
131 unsigned int elem_alignment
; /* alignment override */
135 struct lttng_event_field
*fields
; /* Array of fields. */
138 struct lttng_type
*elem_type
;
139 unsigned int length
; /* num. elems. */
142 struct lttng_type
*elem_type
;
143 const char *length_name
;
146 const char *tag_name
;
147 struct lttng_event_field
*choices
; /* Array of fields. */
153 struct lttng_enum_desc
{
155 const struct lttng_enum_entry
*entries
;
156 unsigned int nr_entries
;
159 /* Event field description */
161 struct lttng_event_field
{
163 struct lttng_type type
;
164 unsigned int nowrite
:1, /* do not write into trace */
165 user
:1; /* fetch from user-space */
168 union lttng_ctx_value
{
175 * We need to keep this perf counter field separately from struct
176 * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
178 struct lttng_perf_counter_field
{
179 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
180 struct lttng_cpuhp_node cpuhp_prepare
;
181 struct lttng_cpuhp_node cpuhp_online
;
183 struct notifier_block nb
;
186 struct perf_event_attr
*attr
;
187 struct perf_event
**e
; /* per-cpu array */
190 struct lttng_probe_ctx
{
191 struct lttng_event
*event
;
192 struct lttng_trigger
*trigger
; // Not sure if we will ever need it.
193 uint8_t interruptible
;
196 struct lttng_ctx_field
{
197 struct lttng_event_field event_field
;
198 size_t (*get_size
)(size_t offset
);
199 size_t (*get_size_arg
)(size_t offset
, struct lttng_ctx_field
*field
,
200 struct lib_ring_buffer_ctx
*ctx
,
201 struct lttng_channel
*chan
);
202 void (*record
)(struct lttng_ctx_field
*field
,
203 struct lib_ring_buffer_ctx
*ctx
,
204 struct lttng_channel
*chan
);
205 void (*get_value
)(struct lttng_ctx_field
*field
,
206 struct lttng_probe_ctx
*lttng_probe_ctx
,
207 union lttng_ctx_value
*value
);
209 struct lttng_perf_counter_field
*perf_counter
;
211 void (*destroy
)(struct lttng_ctx_field
*field
);
213 * Private data to keep state between get_size and record.
214 * User must perform its own synchronization to protect against
215 * concurrent and reentrant contexts.
221 struct lttng_ctx_field
*fields
;
222 unsigned int nr_fields
;
223 unsigned int allocated_fields
;
224 size_t largest_align
; /* in bytes */
227 struct lttng_event_desc
{
228 const char *name
; /* lttng-modules name */
229 const char *kname
; /* Linux kernel name (tracepoints) */
230 void *probe_callback
;
231 const struct lttng_event_ctx
*ctx
; /* context */
232 const struct lttng_event_field
*fields
; /* event payload */
233 unsigned int nr_fields
;
234 struct module
*owner
;
235 void *trigger_callback
;
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_ctx
*ctx
;
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
{
293 struct lttng_event
*event
;
294 struct lttng_trigger
*trigger
;
297 struct uprobe_consumer up_consumer
;
298 struct list_head node
;
301 struct lttng_kprobe
{
306 struct lttng_uprobe
{
308 struct list_head head
;
311 struct lttng_syscall
{
312 struct list_head node
; /* chain registered syscall trigger */
313 unsigned int syscall_id
;
318 * lttng_event structure is referred to by the tracing fast path. It must be
322 enum lttng_event_type evtype
; /* First field. */
324 struct lttng_channel
*chan
;
326 const struct lttng_event_desc
*desc
;
328 struct lttng_ctx
*ctx
;
329 enum lttng_kernel_instrumentation instrumentation
;
331 struct lttng_kprobe kprobe
;
333 struct lttng_krp
*lttng_krp
;
339 struct lttng_uprobe uprobe
;
341 struct list_head list
; /* Event list in session */
342 unsigned int metadata_dumped
:1;
344 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
345 struct list_head enablers_ref_head
;
346 struct hlist_node hlist
; /* session ht of events */
347 int registered
; /* has reg'd tracepoint probe */
348 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
349 struct list_head bytecode_runtime_head
;
350 int has_enablers_without_bytecode
;
353 // FIXME: Really similar to lttng_event above. Could those be merged ?
354 struct lttng_trigger
{
355 enum lttng_event_type evtype
; /* First field. */
358 int registered
; /* has reg'd tracepoint probe */
359 const struct lttng_event_desc
*desc
;
361 struct list_head list
; /* Trigger list in trigger group */
363 enum lttng_kernel_instrumentation instrumentation
;
365 struct lttng_kprobe kprobe
;
366 struct lttng_uprobe uprobe
;
367 struct lttng_syscall syscall
;
370 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
371 struct list_head enablers_ref_head
;
372 struct hlist_node hlist
; /* session ht of triggers */
373 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
374 struct list_head bytecode_runtime_head
;
375 int has_enablers_without_bytecode
;
377 void (*send_notification
)(struct lttng_trigger
*trigger
);
378 struct lttng_trigger_group
*group
; /* Weak ref */
381 enum lttng_enabler_format_type
{
382 LTTNG_ENABLER_FORMAT_STAR_GLOB
,
383 LTTNG_ENABLER_FORMAT_NAME
,
387 * Enabler field, within whatever object is enabling an event. Target of
388 * backward reference.
390 struct lttng_enabler
{
391 enum lttng_event_type evtype
; /* First field. */
393 enum lttng_enabler_format_type format_type
;
395 /* head list of struct lttng_ust_filter_bytecode_node */
396 struct list_head filter_bytecode_head
;
398 struct lttng_kernel_event event_param
;
399 unsigned int enabled
:1;
402 struct lttng_event_enabler
{
403 struct lttng_enabler base
;
404 struct list_head node
; /* per-session list of enablers */
405 struct lttng_channel
*chan
;
407 * Unused, but kept around to make it explicit that the tracer can do
410 struct lttng_ctx
*ctx
;
413 struct lttng_trigger_enabler
{
414 struct lttng_enabler base
;
416 struct list_head node
; /* List of trigger enablers */
417 struct lttng_trigger_group
*group
;
421 struct lttng_enabler
*lttng_event_enabler_as_enabler(
422 struct lttng_event_enabler
*event_enabler
)
424 return &event_enabler
->base
;
428 struct lttng_enabler
*lttng_trigger_enabler_as_enabler(
429 struct lttng_trigger_enabler
*trigger_enabler
)
431 return &trigger_enabler
->base
;
434 struct lttng_channel_ops
{
435 struct channel
*(*channel_create
)(const char *name
,
438 size_t subbuf_size
, size_t num_subbuf
,
439 unsigned int switch_timer_interval
,
440 unsigned int read_timer_interval
);
441 void (*channel_destroy
)(struct channel
*chan
);
442 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
443 int (*buffer_has_read_closed_stream
)(struct channel
*chan
);
444 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
445 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
,
447 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
448 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
450 void (*event_write_from_user
)(struct lib_ring_buffer_ctx
*ctx
,
451 const void *src
, size_t len
);
452 void (*event_memset
)(struct lib_ring_buffer_ctx
*ctx
,
454 void (*event_strcpy
)(struct lib_ring_buffer_ctx
*ctx
, const char *src
,
456 void (*event_strcpy_from_user
)(struct lib_ring_buffer_ctx
*ctx
,
457 const char __user
*src
, size_t len
);
459 * packet_avail_size returns the available size in the current
460 * packet. Note that the size returned is only a hint, since it
461 * may change due to concurrent writes.
463 size_t (*packet_avail_size
)(struct channel
*chan
);
464 wait_queue_head_t
*(*get_writer_buf_wait_queue
)(struct channel
*chan
, int cpu
);
465 wait_queue_head_t
*(*get_hp_wait_queue
)(struct channel
*chan
);
466 int (*is_finalized
)(struct channel
*chan
);
467 int (*is_disabled
)(struct channel
*chan
);
468 int (*timestamp_begin
) (const struct lib_ring_buffer_config
*config
,
469 struct lib_ring_buffer
*bufb
,
470 uint64_t *timestamp_begin
);
471 int (*timestamp_end
) (const struct lib_ring_buffer_config
*config
,
472 struct lib_ring_buffer
*bufb
,
473 uint64_t *timestamp_end
);
474 int (*events_discarded
) (const struct lib_ring_buffer_config
*config
,
475 struct lib_ring_buffer
*bufb
,
476 uint64_t *events_discarded
);
477 int (*content_size
) (const struct lib_ring_buffer_config
*config
,
478 struct lib_ring_buffer
*bufb
,
479 uint64_t *content_size
);
480 int (*packet_size
) (const struct lib_ring_buffer_config
*config
,
481 struct lib_ring_buffer
*bufb
,
482 uint64_t *packet_size
);
483 int (*stream_id
) (const struct lib_ring_buffer_config
*config
,
484 struct lib_ring_buffer
*bufb
,
485 uint64_t *stream_id
);
486 int (*current_timestamp
) (const struct lib_ring_buffer_config
*config
,
487 struct lib_ring_buffer
*bufb
,
489 int (*sequence_number
) (const struct lib_ring_buffer_config
*config
,
490 struct lib_ring_buffer
*bufb
,
492 int (*instance_id
) (const struct lib_ring_buffer_config
*config
,
493 struct lib_ring_buffer
*bufb
,
497 struct lttng_transport
{
499 struct module
*owner
;
500 struct list_head node
;
501 struct lttng_channel_ops ops
;
504 struct lttng_syscall_filter
;
506 #define LTTNG_EVENT_HT_BITS 12
507 #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
509 struct lttng_event_ht
{
510 struct hlist_head table
[LTTNG_EVENT_HT_SIZE
];
513 #define LTTNG_TRIGGER_HT_BITS 12
514 #define LTTNG_TRIGGER_HT_SIZE (1U << LTTNG_TRIGGER_HT_BITS)
516 struct lttng_trigger_ht
{
517 struct hlist_head table
[LTTNG_TRIGGER_HT_SIZE
];
520 struct lttng_channel
{
522 struct channel
*chan
; /* Channel buffers */
524 struct lttng_ctx
*ctx
;
525 /* Event ID management */
526 struct lttng_session
*session
;
527 struct file
*file
; /* File associated to channel */
528 unsigned int free_event_id
; /* Next event ID to allocate */
529 struct list_head list
; /* Channel list */
530 struct lttng_channel_ops
*ops
;
531 struct lttng_transport
*transport
;
532 struct lttng_event
**sc_table
; /* for syscall tracing */
533 struct lttng_event
**compat_sc_table
;
534 struct lttng_event
**sc_exit_table
; /* for syscall exit tracing */
535 struct lttng_event
**compat_sc_exit_table
;
536 struct lttng_event
*sc_unknown
; /* for unknown syscalls */
537 struct lttng_event
*sc_compat_unknown
;
538 struct lttng_event
*sc_exit_unknown
;
539 struct lttng_event
*compat_sc_exit_unknown
;
540 struct lttng_syscall_filter
*sc_filter
;
541 int header_type
; /* 0: unset, 1: compact, 2: large */
542 enum channel_type channel_type
;
543 unsigned int metadata_dumped
:1,
544 sys_enter_registered
:1,
545 sys_exit_registered
:1,
547 tstate
:1; /* Transient enable state */
550 struct lttng_metadata_stream
{
551 void *priv
; /* Ring buffer private data */
552 struct lttng_metadata_cache
*metadata_cache
;
553 unsigned int metadata_in
; /* Bytes read from the cache */
554 unsigned int metadata_out
; /* Bytes consumed from stream */
555 int finalized
; /* Has channel been finalized */
556 wait_queue_head_t read_wait
; /* Reader buffer-level wait queue */
557 struct list_head list
; /* Stream list */
558 struct lttng_transport
*transport
;
559 uint64_t version
; /* Current version of the metadata cache */
562 #define LTTNG_DYNAMIC_LEN_STACK_SIZE 128
564 struct lttng_dynamic_len_stack
{
565 size_t stack
[LTTNG_DYNAMIC_LEN_STACK_SIZE
];
569 DECLARE_PER_CPU(struct lttng_dynamic_len_stack
, lttng_dynamic_len_stack
);
572 * struct lttng_id_tracker declared in header due to deferencing of *v
573 * in RCU_INITIALIZER(v).
575 #define LTTNG_ID_HASH_BITS 6
576 #define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS)
589 struct lttng_id_tracker_rcu
{
590 struct hlist_head id_hash
[LTTNG_ID_TABLE_SIZE
];
593 struct lttng_id_tracker
{
594 struct lttng_session
*session
;
595 enum tracker_type tracker_type
;
596 struct lttng_id_tracker_rcu
*p
; /* RCU dereferenced. */
599 struct lttng_id_hash_node
{
600 struct hlist_node hlist
;
604 struct lttng_session
{
605 int active
; /* Is trace session active ? */
606 int been_active
; /* Has trace session been active ? */
607 struct file
*file
; /* File associated to session */
608 struct list_head chan
; /* Channel list head */
609 struct list_head events
; /* Event list head */
610 struct list_head list
; /* Session list */
611 unsigned int free_chan_id
; /* Next chan ID to allocate */
612 uuid_le uuid
; /* Trace session unique ID */
613 struct lttng_metadata_cache
*metadata_cache
;
614 struct lttng_id_tracker pid_tracker
;
615 struct lttng_id_tracker vpid_tracker
;
616 struct lttng_id_tracker uid_tracker
;
617 struct lttng_id_tracker vuid_tracker
;
618 struct lttng_id_tracker gid_tracker
;
619 struct lttng_id_tracker vgid_tracker
;
620 unsigned int metadata_dumped
:1,
621 tstate
:1; /* Transient enable state */
622 /* List of event enablers */
623 struct list_head enablers_head
;
624 /* Hash table of events */
625 struct lttng_event_ht events_ht
;
626 char name
[LTTNG_KERNEL_SESSION_NAME_LEN
];
627 char creation_time
[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
];
630 struct lttng_trigger_group
{
631 struct file
*file
; /* File associated to trigger group */
632 struct file
*notif_file
; /* File used to expose notifications to userspace. */
633 struct list_head node
; /* Trigger group list */
634 struct list_head enablers_head
; /* List of enablers */
635 struct list_head triggers_head
; /* List of triggers */
636 struct lttng_trigger_ht triggers_ht
; /* Hash table of triggers */
637 struct lttng_ctx
*ctx
; /* Contexts for filters. */
638 struct lttng_channel_ops
*ops
;
639 struct lttng_transport
*transport
;
640 struct channel
*chan
; /* Ring buffer channel for trigger group. */
641 struct lib_ring_buffer
*buf
; /* Ring buffer for trigger group. */
642 wait_queue_head_t read_wait
;
643 struct irq_work wakeup_pending
; /* Pending wakeup irq work. */
645 struct list_head
*trigger_syscall_dispatch
;
646 struct list_head
*trigger_compat_syscall_dispatch
;
648 unsigned int syscall_all
:1,
649 sys_enter_registered
:1;
652 struct lttng_metadata_cache
{
653 char *data
; /* Metadata cache */
654 unsigned int cache_alloc
; /* Metadata allocated size (bytes) */
655 unsigned int metadata_written
; /* Number of bytes written in metadata cache */
656 struct kref refcount
; /* Metadata cache usage */
657 struct list_head metadata_stream
; /* Metadata stream list */
658 uuid_le uuid
; /* Trace session unique ID (copy) */
659 struct mutex lock
; /* Produce/consume lock */
660 uint64_t version
; /* Current version of the metadata */
663 void lttng_lock_sessions(void);
664 void lttng_unlock_sessions(void);
666 struct list_head
*lttng_get_probe_list_head(void);
668 struct lttng_event_enabler
*lttng_event_enabler_create(
669 enum lttng_enabler_format_type format_type
,
670 struct lttng_kernel_event
*event_param
,
671 struct lttng_channel
*chan
);
673 int lttng_event_enabler_enable(struct lttng_event_enabler
*event_enabler
);
674 int lttng_event_enabler_disable(struct lttng_event_enabler
*event_enabler
);
675 struct lttng_trigger_enabler
*lttng_trigger_enabler_create(
676 struct lttng_trigger_group
*trigger_group
,
677 enum lttng_enabler_format_type format_type
,
678 struct lttng_kernel_trigger
*trigger_param
);
680 int lttng_trigger_enabler_enable(struct lttng_trigger_enabler
*trigger_enabler
);
681 int lttng_trigger_enabler_disable(struct lttng_trigger_enabler
*trigger_enabler
);
682 int lttng_fix_pending_events(void);
683 int lttng_fix_pending_triggers(void);
684 int lttng_session_active(void);
685 bool lttng_trigger_active(void);
687 struct lttng_session
*lttng_session_create(void);
688 int lttng_session_enable(struct lttng_session
*session
);
689 int lttng_session_disable(struct lttng_session
*session
);
690 void lttng_session_destroy(struct lttng_session
*session
);
691 int lttng_session_metadata_regenerate(struct lttng_session
*session
);
692 int lttng_session_statedump(struct lttng_session
*session
);
693 void metadata_cache_destroy(struct kref
*kref
);
695 struct lttng_trigger_group
*lttng_trigger_group_create(void);
696 void lttng_trigger_group_destroy(struct lttng_trigger_group
*trigger_group
);
698 struct lttng_channel
*lttng_channel_create(struct lttng_session
*session
,
699 const char *transport_name
,
701 size_t subbuf_size
, size_t num_subbuf
,
702 unsigned int switch_timer_interval
,
703 unsigned int read_timer_interval
,
704 enum channel_type channel_type
);
705 struct lttng_channel
*lttng_global_channel_create(struct lttng_session
*session
,
706 int overwrite
, void *buf_addr
,
707 size_t subbuf_size
, size_t num_subbuf
,
708 unsigned int switch_timer_interval
,
709 unsigned int read_timer_interval
);
711 void lttng_metadata_channel_destroy(struct lttng_channel
*chan
);
712 struct lttng_event
*lttng_event_create(struct lttng_channel
*chan
,
713 struct lttng_kernel_event
*event_param
,
715 const struct lttng_event_desc
*event_desc
,
716 enum lttng_kernel_instrumentation itype
);
717 struct lttng_event
*_lttng_event_create(struct lttng_channel
*chan
,
718 struct lttng_kernel_event
*event_param
,
720 const struct lttng_event_desc
*event_desc
,
721 enum lttng_kernel_instrumentation itype
);
722 struct lttng_event
*lttng_event_compat_old_create(struct lttng_channel
*chan
,
723 struct lttng_kernel_old_event
*old_event_param
,
725 const struct lttng_event_desc
*internal_desc
);
727 struct lttng_trigger
*lttng_trigger_create(
728 const struct lttng_event_desc
*trigger_desc
,
730 struct lttng_trigger_group
*trigger_group
,
731 struct lttng_kernel_trigger
*trigger_param
,
733 enum lttng_kernel_instrumentation itype
);
734 struct lttng_trigger
*_lttng_trigger_create(
735 const struct lttng_event_desc
*trigger_desc
,
737 struct lttng_trigger_group
*trigger_group
,
738 struct lttng_kernel_trigger
*trigger_param
,
740 enum lttng_kernel_instrumentation itype
);
742 int lttng_channel_enable(struct lttng_channel
*channel
);
743 int lttng_channel_disable(struct lttng_channel
*channel
);
744 int lttng_event_enable(struct lttng_event
*event
);
745 int lttng_event_disable(struct lttng_event
*event
);
747 int lttng_trigger_enable(struct lttng_trigger
*trigger
);
748 int lttng_trigger_disable(struct lttng_trigger
*trigger
);
750 void lttng_transport_register(struct lttng_transport
*transport
);
751 void lttng_transport_unregister(struct lttng_transport
*transport
);
753 void synchronize_trace(void);
754 int lttng_abi_init(void);
755 int lttng_abi_compat_old_init(void);
756 void lttng_abi_exit(void);
757 void lttng_abi_compat_old_exit(void);
759 int lttng_probe_register(struct lttng_probe_desc
*desc
);
760 void lttng_probe_unregister(struct lttng_probe_desc
*desc
);
761 const struct lttng_event_desc
*lttng_event_desc_get(const char *name
);
762 void lttng_event_desc_put(const struct lttng_event_desc
*desc
);
763 int lttng_probes_init(void);
764 void lttng_probes_exit(void);
766 int lttng_metadata_output_channel(struct lttng_metadata_stream
*stream
,
767 struct channel
*chan
);
769 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node
*node
);
770 int lttng_id_tracker_empty_set(struct lttng_id_tracker
*lf
);
771 void lttng_id_tracker_destroy(struct lttng_id_tracker
*lf
, bool rcu
);
772 bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu
*p
, int id
);
773 int lttng_id_tracker_add(struct lttng_id_tracker
*lf
, int id
);
774 int lttng_id_tracker_del(struct lttng_id_tracker
*lf
, int id
);
776 int lttng_session_track_id(struct lttng_session
*session
,
777 enum tracker_type tracker_type
, int id
);
778 int lttng_session_untrack_id(struct lttng_session
*session
,
779 enum tracker_type tracker_type
, int id
);
781 int lttng_session_list_tracker_ids(struct lttng_session
*session
,
782 enum tracker_type tracker_type
);
784 void lttng_clock_ref(void);
785 void lttng_clock_unref(void);
787 int lttng_desc_match_enabler(const struct lttng_event_desc
*desc
,
788 struct lttng_enabler
*enabler
);
790 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
791 int lttng_syscalls_register_event(struct lttng_channel
*chan
, void *filter
);
792 int lttng_syscalls_unregister_event(struct lttng_channel
*chan
);
793 int lttng_syscall_filter_enable_event(struct lttng_channel
*chan
,
795 int lttng_syscall_filter_disable_event(struct lttng_channel
*chan
,
797 long lttng_channel_syscall_mask(struct lttng_channel
*channel
,
798 struct lttng_kernel_syscall_mask __user
*usyscall_mask
);
800 int lttng_syscalls_register_trigger(struct lttng_trigger_enabler
*trigger_enabler
, void *filter
);
801 int lttng_syscals_create_matching_triggers(struct lttng_trigger_enabler
*trigger_enabler
, void *filter
);
802 int lttng_syscalls_unregister_trigger(struct lttng_trigger_group
*group
);
803 int lttng_syscall_filter_enable_trigger(struct lttng_trigger
*trigger
);
804 int lttng_syscall_filter_disable_trigger(struct lttng_trigger
*trigger
);
806 static inline int lttng_syscalls_register_event(
807 struct lttng_channel
*chan
, void *filter
)
812 static inline int lttng_syscalls_unregister_event(struct lttng_channel
*chan
)
817 static inline int lttng_syscall_filter_enable_event(struct lttng_channel
*chan
,
823 static inline int lttng_syscall_filter_disable_event(struct lttng_channel
*chan
,
829 static inline long lttng_channel_syscall_mask(struct lttng_channel
*channel
,
830 struct lttng_kernel_syscall_mask __user
*usyscall_mask
)
835 static inline int lttng_syscalls_register_trigger(
836 struct lttng_trigger_group
*group
, void *filter
)
841 static inline int lttng_syscalls_unregister_trigger(struct lttng_trigger_group
*group
)
846 static inline int lttng_syscall_filter_enable_trigger(struct lttng_trigger_group
*group
,
852 static inline int lttng_syscall_filter_disable_trigger(struct lttng_trigger_group
*group
,
860 void lttng_filter_sync_state(struct lttng_bytecode_runtime
*runtime
);
861 int lttng_event_enabler_attach_bytecode(struct lttng_event_enabler
*event_enabler
,
862 struct lttng_kernel_filter_bytecode __user
*bytecode
);
863 int lttng_trigger_enabler_attach_bytecode(struct lttng_trigger_enabler
*trigger_enabler
,
864 struct lttng_kernel_filter_bytecode __user
*bytecode
);
866 void lttng_enabler_link_bytecode(const struct lttng_event_desc
*event_desc
,
867 struct lttng_ctx
*ctx
,
868 struct list_head
*bytecode_runtime_head
,
869 struct lttng_enabler
*enabler
);
871 int lttng_probes_init(void);
873 extern struct lttng_ctx
*lttng_static_ctx
;
875 int lttng_context_init(void);
876 void lttng_context_exit(void);
877 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx
);
878 void lttng_context_update(struct lttng_ctx
*ctx
);
879 int lttng_find_context(struct lttng_ctx
*ctx
, const char *name
);
880 int lttng_get_context_index(struct lttng_ctx
*ctx
, const char *name
);
881 void lttng_remove_context_field(struct lttng_ctx
**ctx
,
882 struct lttng_ctx_field
*field
);
883 void lttng_destroy_context(struct lttng_ctx
*ctx
);
884 int lttng_add_pid_to_ctx(struct lttng_ctx
**ctx
);
885 int lttng_add_cpu_id_to_ctx(struct lttng_ctx
**ctx
);
886 int lttng_add_procname_to_ctx(struct lttng_ctx
**ctx
);
887 int lttng_add_prio_to_ctx(struct lttng_ctx
**ctx
);
888 int lttng_add_nice_to_ctx(struct lttng_ctx
**ctx
);
889 int lttng_add_vpid_to_ctx(struct lttng_ctx
**ctx
);
890 int lttng_add_tid_to_ctx(struct lttng_ctx
**ctx
);
891 int lttng_add_vtid_to_ctx(struct lttng_ctx
**ctx
);
892 int lttng_add_ppid_to_ctx(struct lttng_ctx
**ctx
);
893 int lttng_add_vppid_to_ctx(struct lttng_ctx
**ctx
);
894 int lttng_add_hostname_to_ctx(struct lttng_ctx
**ctx
);
895 int lttng_add_interruptible_to_ctx(struct lttng_ctx
**ctx
);
896 int lttng_add_need_reschedule_to_ctx(struct lttng_ctx
**ctx
);
897 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
898 int lttng_add_preemptible_to_ctx(struct lttng_ctx
**ctx
);
901 int lttng_add_preemptible_to_ctx(struct lttng_ctx
**ctx
)
906 #ifdef CONFIG_PREEMPT_RT_FULL
907 int lttng_add_migratable_to_ctx(struct lttng_ctx
**ctx
);
910 int lttng_add_migratable_to_ctx(struct lttng_ctx
**ctx
)
916 int lttng_add_callstack_to_ctx(struct lttng_ctx
**ctx
, int type
);
918 #if defined(CONFIG_CGROUPS) && \
919 ((LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) || \
920 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
921 int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx
**ctx
);
924 int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx
**ctx
)
930 #if defined(CONFIG_IPC_NS) && \
931 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
932 int lttng_add_ipc_ns_to_ctx(struct lttng_ctx
**ctx
);
935 int lttng_add_ipc_ns_to_ctx(struct lttng_ctx
**ctx
)
941 #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
942 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
943 int lttng_add_mnt_ns_to_ctx(struct lttng_ctx
**ctx
);
946 int lttng_add_mnt_ns_to_ctx(struct lttng_ctx
**ctx
)
952 #if defined(CONFIG_NET_NS) && \
953 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
954 int lttng_add_net_ns_to_ctx(struct lttng_ctx
**ctx
);
957 int lttng_add_net_ns_to_ctx(struct lttng_ctx
**ctx
)
963 #if defined(CONFIG_PID_NS) && \
964 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
965 int lttng_add_pid_ns_to_ctx(struct lttng_ctx
**ctx
);
968 int lttng_add_pid_ns_to_ctx(struct lttng_ctx
**ctx
)
974 #if defined(CONFIG_USER_NS) && \
975 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
976 int lttng_add_user_ns_to_ctx(struct lttng_ctx
**ctx
);
979 int lttng_add_user_ns_to_ctx(struct lttng_ctx
**ctx
)
985 #if defined(CONFIG_UTS_NS) && \
986 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
987 int lttng_add_uts_ns_to_ctx(struct lttng_ctx
**ctx
);
990 int lttng_add_uts_ns_to_ctx(struct lttng_ctx
**ctx
)
996 int lttng_add_uid_to_ctx(struct lttng_ctx
**ctx
);
997 int lttng_add_euid_to_ctx(struct lttng_ctx
**ctx
);
998 int lttng_add_suid_to_ctx(struct lttng_ctx
**ctx
);
999 int lttng_add_gid_to_ctx(struct lttng_ctx
**ctx
);
1000 int lttng_add_egid_to_ctx(struct lttng_ctx
**ctx
);
1001 int lttng_add_sgid_to_ctx(struct lttng_ctx
**ctx
);
1002 int lttng_add_vuid_to_ctx(struct lttng_ctx
**ctx
);
1003 int lttng_add_veuid_to_ctx(struct lttng_ctx
**ctx
);
1004 int lttng_add_vsuid_to_ctx(struct lttng_ctx
**ctx
);
1005 int lttng_add_vgid_to_ctx(struct lttng_ctx
**ctx
);
1006 int lttng_add_vegid_to_ctx(struct lttng_ctx
**ctx
);
1007 int lttng_add_vsgid_to_ctx(struct lttng_ctx
**ctx
);
1009 #if defined(CONFIG_PERF_EVENTS)
1010 int lttng_add_perf_counter_to_ctx(uint32_t type
,
1013 struct lttng_ctx
**ctx
);
1014 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
1015 struct lttng_cpuhp_node
*node
);
1016 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
1017 struct lttng_cpuhp_node
*node
);
1020 int lttng_add_perf_counter_to_ctx(uint32_t type
,
1023 struct lttng_ctx
**ctx
)
1028 int lttng_cpuhp_perf_counter_online(unsigned int cpu
,
1029 struct lttng_cpuhp_node
*node
)
1034 int lttng_cpuhp_perf_counter_dead(unsigned int cpu
,
1035 struct lttng_cpuhp_node
*node
)
1041 int lttng_logger_init(void);
1042 void lttng_logger_exit(void);
1044 extern int lttng_statedump_start(struct lttng_session
*session
);
1046 #ifdef CONFIG_KPROBES
1047 int lttng_kprobes_register_event(const char *name
,
1048 const char *symbol_name
,
1051 struct lttng_event
*event
);
1052 void lttng_kprobes_unregister_event(struct lttng_event
*event
);
1053 void lttng_kprobes_destroy_event_private(struct lttng_event
*event
);
1054 int lttng_kprobes_register_trigger(const char *symbol_name
,
1057 struct lttng_trigger
*trigger
);
1058 void lttng_kprobes_unregister_trigger(struct lttng_trigger
*trigger
);
1059 void lttng_kprobes_destroy_trigger_private(struct lttng_trigger
*trigger
);
1062 int lttng_kprobes_register_event(const char *name
,
1063 const char *symbol_name
,
1066 struct lttng_event
*event
)
1072 void lttng_kprobes_unregister_event(struct lttng_event
*event
)
1077 void lttng_kprobes_destroy_event_private(struct lttng_event
*event
)
1082 int lttng_kprobes_register_trigger(const char *symbol_name
,
1085 struct lttng_trigger
*trigger
)
1091 void lttng_kprobes_unregister_trigger(struct lttng_trigger
*trigger
)
1096 void lttng_kprobes_destroy_trigger_private(struct lttng_trigger
*trigger
)
1101 int lttng_event_add_callsite(struct lttng_event
*event
,
1102 struct lttng_kernel_event_callsite
*callsite
);
1104 int lttng_trigger_add_callsite(struct lttng_trigger
*trigger
,
1105 struct lttng_kernel_event_callsite
*callsite
);
1107 #ifdef CONFIG_UPROBES
1108 int lttng_uprobes_register_event(const char *name
,
1109 int fd
, struct lttng_event
*event
);
1110 int lttng_uprobes_event_add_callsite(struct lttng_event
*event
,
1111 struct lttng_kernel_event_callsite
*callsite
);
1112 void lttng_uprobes_unregister_event(struct lttng_event
*event
);
1113 void lttng_uprobes_destroy_event_private(struct lttng_event
*event
);
1114 int lttng_uprobes_register_trigger(const char *name
,
1115 int fd
, struct lttng_trigger
*trigger
);
1116 int lttng_uprobes_trigger_add_callsite(struct lttng_trigger
*trigger
,
1117 struct lttng_kernel_event_callsite
*callsite
);
1118 void lttng_uprobes_unregister_trigger(struct lttng_trigger
*trigger
);
1119 void lttng_uprobes_destroy_trigger_private(struct lttng_trigger
*trigger
);
1122 int lttng_uprobes_register_event(const char *name
,
1123 int fd
, struct lttng_event
*event
)
1129 int lttng_uprobes_event_add_callsite(struct lttng_event
*event
,
1130 struct lttng_kernel_event_callsite
*callsite
)
1136 void lttng_uprobes_unregister_event(struct lttng_event
*event
)
1141 void lttng_uprobes_destroy_event_private(struct lttng_event
*event
)
1146 int lttng_uprobes_register_trigger(const char *name
,
1147 int fd
, struct lttng_trigger
*trigger
)
1153 int lttng_uprobes_trigger_add_callsite(struct lttng_trigger
*trigger
,
1154 struct lttng_kernel_event_callsite
*callsite
)
1160 void lttng_uprobes_unregister_trigger(struct lttng_trigger
*trigger
)
1165 void lttng_uprobes_destroy_trigger_private(struct lttng_trigger
*trigger
)
1170 #ifdef CONFIG_KRETPROBES
1171 int lttng_kretprobes_register(const char *name
,
1172 const char *symbol_name
,
1175 struct lttng_event
*event_entry
,
1176 struct lttng_event
*event_exit
);
1177 void lttng_kretprobes_unregister(struct lttng_event
*event
);
1178 void lttng_kretprobes_destroy_private(struct lttng_event
*event
);
1179 int lttng_kretprobes_event_enable_state(struct lttng_event
*event
,
1183 int lttng_kretprobes_register(const char *name
,
1184 const char *symbol_name
,
1187 struct lttng_event
*event_entry
,
1188 struct lttng_event
*event_exit
)
1194 void lttng_kretprobes_unregister(struct lttng_event
*event
)
1199 void lttng_kretprobes_destroy_private(struct lttng_event
*event
)
1204 int lttng_kretprobes_event_enable_state(struct lttng_event
*event
,
1211 #if defined(CONFIG_DYNAMIC_FTRACE) && !defined(LTTNG_FTRACE_MISSING_HEADER)
1212 int lttng_ftrace_register(const char *name
,
1213 const char *symbol_name
,
1214 struct lttng_event
*event
);
1215 void lttng_ftrace_unregister(struct lttng_event
*event
);
1216 void lttng_ftrace_destroy_private(struct lttng_event
*event
);
1219 int lttng_ftrace_register(const char *name
,
1220 const char *symbol_name
,
1221 struct lttng_event
*event
)
1227 void lttng_ftrace_unregister(struct lttng_event
*event
)
1232 void lttng_ftrace_destroy_private(struct lttng_event
*event
)
1237 int lttng_calibrate(struct lttng_kernel_calibrate
*calibrate
);
1239 extern const struct file_operations lttng_tracepoint_list_fops
;
1240 extern const struct file_operations lttng_syscall_list_fops
;
1242 #define TRACEPOINT_HAS_DATA_ARG
1244 #endif /* _LTTNG_EVENTS_H */