SoW-2019-0002: Dynamic Snapshot
[deliverable/lttng-modules.git] / lttng-events.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3 * lttng-events.h
4 *
5 * Holds LTTng per-session event registry.
6 *
7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10#ifndef _LTTNG_EVENTS_H
11#define _LTTNG_EVENTS_H
12
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>
24
25#define lttng_is_signed_type(type) (((type)(-1)) < 0)
26
27struct lttng_channel;
28struct lttng_session;
29struct lttng_metadata_cache;
30struct lib_ring_buffer_ctx;
31struct perf_event;
32struct perf_event_attr;
33struct lib_ring_buffer_config;
34
35/* Type description */
36
37enum abstract_types {
38 atype_integer,
39 atype_enum,
40 atype_array,
41 atype_sequence,
42 atype_string,
43 atype_struct,
44 atype_array_compound, /* Array of compound types. */
45 atype_sequence_compound, /* Sequence of compound types. */
46 atype_variant,
47 atype_array_bitfield,
48 atype_sequence_bitfield,
49 NR_ABSTRACT_TYPES,
50};
51
52enum lttng_string_encodings {
53 lttng_encode_none = 0,
54 lttng_encode_UTF8 = 1,
55 lttng_encode_ASCII = 2,
56 NR_STRING_ENCODINGS,
57};
58
59enum channel_type {
60 PER_CPU_CHANNEL,
61 METADATA_CHANNEL,
62};
63
64struct lttng_enum_value {
65 unsigned long long value;
66 unsigned int signedness:1;
67};
68
69struct lttng_enum_entry {
70 struct lttng_enum_value start, end; /* start and end are inclusive */
71 const char *string;
72 struct {
73 unsigned int is_auto:1;
74 } options;
75};
76
77#define __type_integer(_type, _size, _alignment, _signedness, \
78 _byte_order, _base, _encoding) \
79 { \
80 .atype = atype_integer, \
81 .u.basic.integer = \
82 { \
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, \
87 .base = _base, \
88 .encoding = lttng_encode_##_encoding, \
89 }, \
90 } \
91
92struct lttng_integer_type {
93 unsigned int size; /* in bits */
94 unsigned short alignment; /* in bits */
95 unsigned int signedness:1,
96 reverse_byte_order:1;
97 unsigned int base; /* 2, 8, 10, 16, for pretty print */
98 enum lttng_string_encodings encoding;
99};
100
101union _lttng_basic_type {
102 struct lttng_integer_type integer;
103 struct {
104 const struct lttng_enum_desc *desc; /* Enumeration mapping */
105 struct lttng_integer_type container_type;
106 } enumeration;
107 struct {
108 enum lttng_string_encodings encoding;
109 } string;
110};
111
112struct lttng_basic_type {
113 enum abstract_types atype;
114 union {
115 union _lttng_basic_type basic;
116 } u;
117};
118
119struct lttng_type {
120 enum abstract_types atype;
121 union {
122 union _lttng_basic_type basic;
123 struct {
124 struct lttng_basic_type elem_type;
125 unsigned int length; /* num. elems. */
126 unsigned int elem_alignment; /* alignment override */
127 } array;
128 struct {
129 struct lttng_basic_type length_type;
130 struct lttng_basic_type elem_type;
131 unsigned int elem_alignment; /* alignment override */
132 } sequence;
133 struct {
134 uint32_t nr_fields;
135 struct lttng_event_field *fields; /* Array of fields. */
136 } _struct;
137 struct {
138 struct lttng_type *elem_type;
139 unsigned int length; /* num. elems. */
140 } array_compound;
141 struct {
142 struct lttng_type *elem_type;
143 const char *length_name;
144 } sequence_compound;
145 struct {
146 const char *tag_name;
147 struct lttng_event_field *choices; /* Array of fields. */
148 uint32_t nr_choices;
149 } variant;
150 } u;
151};
152
153struct lttng_enum_desc {
154 const char *name;
155 const struct lttng_enum_entry *entries;
156 unsigned int nr_entries;
157};
158
159/* Event field description */
160
161struct lttng_event_field {
162 const char *name;
163 struct lttng_type type;
164 unsigned int nowrite:1, /* do not write into trace */
165 user:1; /* fetch from user-space */
166};
167
168union lttng_ctx_value {
169 int64_t s64;
170 const char *str;
171 double d;
172};
173
174/*
175 * We need to keep this perf counter field separately from struct
176 * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
177 */
178struct 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;
182#else
183 struct notifier_block nb;
184 int hp_enable;
185#endif
186 struct perf_event_attr *attr;
187 struct perf_event **e; /* per-cpu array */
188};
189
190struct 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;
194};
195
196struct 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);
208 union {
209 struct lttng_perf_counter_field *perf_counter;
210 } u;
211 void (*destroy)(struct lttng_ctx_field *field);
212 /*
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.
216 */
217 void *priv;
218};
219
220struct lttng_ctx {
221 struct lttng_ctx_field *fields;
222 unsigned int nr_fields;
223 unsigned int allocated_fields;
224 size_t largest_align; /* in bytes */
225};
226
227struct 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;
236};
237
238struct 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 */
245};
246
247struct lttng_krp; /* Kretprobe handling */
248
249enum lttng_event_type {
250 LTTNG_TYPE_EVENT = 0,
251 LTTNG_TYPE_ENABLER = 1,
252};
253
254struct lttng_filter_bytecode_node {
255 struct list_head node;
256 struct lttng_enabler *enabler;
257 /*
258 * struct lttng_kernel_filter_bytecode has var. sized array, must be
259 * last field.
260 */
261 struct lttng_kernel_filter_bytecode bc;
262};
263
264/*
265 * Filter return value masks.
266 */
267enum lttng_filter_ret {
268 LTTNG_FILTER_DISCARD = 0,
269 LTTNG_FILTER_RECORD_FLAG = (1ULL << 0),
270 /* Other bits are kept for future use. */
271};
272
273struct 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);
278 int link_failed;
279 struct list_head node; /* list of bytecode runtime in event */
280 struct lttng_ctx *ctx;
281};
282
283/*
284 * Objects in a linked-list of enablers, owned by an event.
285 */
286struct lttng_enabler_ref {
287 struct list_head node; /* enabler ref list */
288 struct lttng_enabler *ref; /* backward ref */
289};
290
291struct lttng_uprobe_handler {
292 union {
293 struct lttng_event *event;
294 struct lttng_trigger *trigger;
295 } u;
296 loff_t offset;
297 struct uprobe_consumer up_consumer;
298 struct list_head node;
299};
300
301struct lttng_kprobe {
302 struct kprobe kp;
303 char *symbol_name;
304};
305
306struct lttng_uprobe {
307 struct inode *inode;
308 struct list_head head;
309};
310
311struct lttng_syscall {
312 struct list_head node; /* chain registered syscall trigger */
313 unsigned int syscall_id;
314 bool is_compat;
315};
316
317/*
318 * lttng_event structure is referred to by the tracing fast path. It must be
319 * kept small.
320 */
321struct lttng_event {
322 enum lttng_event_type evtype; /* First field. */
323 unsigned int id;
324 struct lttng_channel *chan;
325 int enabled;
326 const struct lttng_event_desc *desc;
327 void *filter;
328 struct lttng_ctx *ctx;
329 enum lttng_kernel_instrumentation instrumentation;
330 union {
331 struct lttng_kprobe kprobe;
332 struct {
333 struct lttng_krp *lttng_krp;
334 char *symbol_name;
335 } kretprobe;
336 struct {
337 char *symbol_name;
338 } ftrace;
339 struct lttng_uprobe uprobe;
340 } u;
341 struct list_head list; /* Event list in session */
342 unsigned int metadata_dumped:1;
343
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;
351};
352
353// FIXME: Really similar to lttng_event above. Could those be merged ?
354struct lttng_trigger {
355 enum lttng_event_type evtype; /* First field. */
356 uint64_t id;
357 int enabled;
358 int registered; /* has reg'd tracepoint probe */
359 const struct lttng_event_desc *desc;
360 void *filter;
361 struct list_head list; /* Trigger list in trigger group */
362
363 enum lttng_kernel_instrumentation instrumentation;
364 union {
365 struct lttng_kprobe kprobe;
366 struct lttng_uprobe uprobe;
367 struct lttng_syscall syscall;
368 } u;
369
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;
376
377 void (*send_notification)(struct lttng_trigger *trigger);
378 struct lttng_trigger_group *group; /* Weak ref */
379};
380
381enum lttng_enabler_format_type {
382 LTTNG_ENABLER_FORMAT_STAR_GLOB,
383 LTTNG_ENABLER_FORMAT_NAME,
384};
385
386/*
387 * Enabler field, within whatever object is enabling an event. Target of
388 * backward reference.
389 */
390struct lttng_enabler {
391 enum lttng_event_type evtype; /* First field. */
392
393 enum lttng_enabler_format_type format_type;
394
395 /* head list of struct lttng_ust_filter_bytecode_node */
396 struct list_head filter_bytecode_head;
397
398 struct lttng_kernel_event event_param;
399 unsigned int enabled:1;
400};
401
402struct lttng_event_enabler {
403 struct lttng_enabler base;
404 struct list_head node; /* per-session list of enablers */
405 struct lttng_channel *chan;
406 /*
407 * Unused, but kept around to make it explicit that the tracer can do
408 * it.
409 */
410 struct lttng_ctx *ctx;
411};
412
413struct lttng_trigger_enabler {
414 struct lttng_enabler base;
415 uint64_t id;
416 struct list_head node; /* List of trigger enablers */
417 struct lttng_trigger_group *group;
418};
419
420static inline
421struct lttng_enabler *lttng_event_enabler_as_enabler(
422 struct lttng_event_enabler *event_enabler)
423{
424 return &event_enabler->base;
425}
426
427static inline
428struct lttng_enabler *lttng_trigger_enabler_as_enabler(
429 struct lttng_trigger_enabler *trigger_enabler)
430{
431 return &trigger_enabler->base;
432}
433
434struct lttng_channel_ops {
435 struct channel *(*channel_create)(const char *name,
436 void *priv,
437 void *buf_addr,
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,
446 uint32_t event_id);
447 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
448 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
449 size_t len);
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,
453 int c, size_t len);
454 void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src,
455 size_t len);
456 void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx,
457 const char __user *src, size_t len);
458 /*
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.
462 */
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,
488 uint64_t *ts);
489 int (*sequence_number) (const struct lib_ring_buffer_config *config,
490 struct lib_ring_buffer *bufb,
491 uint64_t *seq);
492 int (*instance_id) (const struct lib_ring_buffer_config *config,
493 struct lib_ring_buffer *bufb,
494 uint64_t *id);
495};
496
497struct lttng_transport {
498 char *name;
499 struct module *owner;
500 struct list_head node;
501 struct lttng_channel_ops ops;
502};
503
504struct lttng_syscall_filter;
505
506#define LTTNG_EVENT_HT_BITS 12
507#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
508
509struct lttng_event_ht {
510 struct hlist_head table[LTTNG_EVENT_HT_SIZE];
511};
512
513#define LTTNG_TRIGGER_HT_BITS 12
514#define LTTNG_TRIGGER_HT_SIZE (1U << LTTNG_TRIGGER_HT_BITS)
515
516struct lttng_trigger_ht {
517 struct hlist_head table[LTTNG_TRIGGER_HT_SIZE];
518};
519
520struct lttng_channel {
521 unsigned int id;
522 struct channel *chan; /* Channel buffers */
523 int enabled;
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,
546 syscall_all:1,
547 tstate:1; /* Transient enable state */
548};
549
550struct 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 */
560};
561
562#define LTTNG_DYNAMIC_LEN_STACK_SIZE 128
563
564struct lttng_dynamic_len_stack {
565 size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE];
566 size_t offset;
567};
568
569DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack);
570
571/*
572 * struct lttng_id_tracker declared in header due to deferencing of *v
573 * in RCU_INITIALIZER(v).
574 */
575#define LTTNG_ID_HASH_BITS 6
576#define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS)
577
578enum tracker_type {
579 TRACKER_PID,
580 TRACKER_VPID,
581 TRACKER_UID,
582 TRACKER_VUID,
583 TRACKER_GID,
584 TRACKER_VGID,
585
586 TRACKER_UNKNOWN,
587};
588
589struct lttng_id_tracker_rcu {
590 struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE];
591};
592
593struct lttng_id_tracker {
594 struct lttng_session *session;
595 enum tracker_type tracker_type;
596 struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */
597};
598
599struct lttng_id_hash_node {
600 struct hlist_node hlist;
601 int id;
602};
603
604struct 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];
628};
629
630struct 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. */
644
645 struct list_head *trigger_syscall_dispatch;
646 struct list_head *trigger_compat_syscall_dispatch;
647
648 unsigned int syscall_all:1,
649 sys_enter_registered:1;
650};
651
652struct 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 */
661};
662
663void lttng_lock_sessions(void);
664void lttng_unlock_sessions(void);
665
666struct list_head *lttng_get_probe_list_head(void);
667
668struct 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);
672
673int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler);
674int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler);
675struct 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);
679
680int lttng_trigger_enabler_enable(struct lttng_trigger_enabler *trigger_enabler);
681int lttng_trigger_enabler_disable(struct lttng_trigger_enabler *trigger_enabler);
682int lttng_fix_pending_events(void);
683int lttng_fix_pending_triggers(void);
684int lttng_session_active(void);
685bool lttng_trigger_active(void);
686
687struct lttng_session *lttng_session_create(void);
688int lttng_session_enable(struct lttng_session *session);
689int lttng_session_disable(struct lttng_session *session);
690void lttng_session_destroy(struct lttng_session *session);
691int lttng_session_metadata_regenerate(struct lttng_session *session);
692int lttng_session_statedump(struct lttng_session *session);
693void metadata_cache_destroy(struct kref *kref);
694
695struct lttng_trigger_group *lttng_trigger_group_create(void);
696void lttng_trigger_group_destroy(struct lttng_trigger_group *trigger_group);
697
698struct lttng_channel *lttng_channel_create(struct lttng_session *session,
699 const char *transport_name,
700 void *buf_addr,
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);
705struct 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);
710
711void lttng_metadata_channel_destroy(struct lttng_channel *chan);
712struct lttng_event *lttng_event_create(struct lttng_channel *chan,
713 struct lttng_kernel_event *event_param,
714 void *filter,
715 const struct lttng_event_desc *event_desc,
716 enum lttng_kernel_instrumentation itype);
717struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
718 struct lttng_kernel_event *event_param,
719 void *filter,
720 const struct lttng_event_desc *event_desc,
721 enum lttng_kernel_instrumentation itype);
722struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
723 struct lttng_kernel_old_event *old_event_param,
724 void *filter,
725 const struct lttng_event_desc *internal_desc);
726
727struct lttng_trigger *lttng_trigger_create(
728 const struct lttng_event_desc *trigger_desc,
729 uint64_t id,
730 struct lttng_trigger_group *trigger_group,
731 struct lttng_kernel_trigger *trigger_param,
732 void *filter,
733 enum lttng_kernel_instrumentation itype);
734struct lttng_trigger *_lttng_trigger_create(
735 const struct lttng_event_desc *trigger_desc,
736 uint64_t id,
737 struct lttng_trigger_group *trigger_group,
738 struct lttng_kernel_trigger *trigger_param,
739 void *filter,
740 enum lttng_kernel_instrumentation itype);
741
742int lttng_channel_enable(struct lttng_channel *channel);
743int lttng_channel_disable(struct lttng_channel *channel);
744int lttng_event_enable(struct lttng_event *event);
745int lttng_event_disable(struct lttng_event *event);
746
747int lttng_trigger_enable(struct lttng_trigger *trigger);
748int lttng_trigger_disable(struct lttng_trigger *trigger);
749
750void lttng_transport_register(struct lttng_transport *transport);
751void lttng_transport_unregister(struct lttng_transport *transport);
752
753void synchronize_trace(void);
754int lttng_abi_init(void);
755int lttng_abi_compat_old_init(void);
756void lttng_abi_exit(void);
757void lttng_abi_compat_old_exit(void);
758
759int lttng_probe_register(struct lttng_probe_desc *desc);
760void lttng_probe_unregister(struct lttng_probe_desc *desc);
761const struct lttng_event_desc *lttng_event_desc_get(const char *name);
762void lttng_event_desc_put(const struct lttng_event_desc *desc);
763int lttng_probes_init(void);
764void lttng_probes_exit(void);
765
766int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
767 struct channel *chan);
768
769int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
770int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf);
771void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu);
772bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id);
773int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id);
774int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id);
775
776int lttng_session_track_id(struct lttng_session *session,
777 enum tracker_type tracker_type, int id);
778int lttng_session_untrack_id(struct lttng_session *session,
779 enum tracker_type tracker_type, int id);
780
781int lttng_session_list_tracker_ids(struct lttng_session *session,
782 enum tracker_type tracker_type);
783
784void lttng_clock_ref(void);
785void lttng_clock_unref(void);
786
787int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
788 struct lttng_enabler *enabler);
789
790#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
791int lttng_syscalls_register_event(struct lttng_channel *chan, void *filter);
792int lttng_syscalls_unregister_event(struct lttng_channel *chan);
793int lttng_syscall_filter_enable_event(struct lttng_channel *chan,
794 const char *name);
795int lttng_syscall_filter_disable_event(struct lttng_channel *chan,
796 const char *name);
797long lttng_channel_syscall_mask(struct lttng_channel *channel,
798 struct lttng_kernel_syscall_mask __user *usyscall_mask);
799
800int lttng_syscalls_register_trigger(struct lttng_trigger_enabler *trigger_enabler, void *filter);
801int lttng_syscals_create_matching_triggers(struct lttng_trigger_enabler *trigger_enabler, void *filter);
802int lttng_syscalls_unregister_trigger(struct lttng_trigger_group *group);
803int lttng_syscall_filter_enable_trigger(struct lttng_trigger *trigger);
804int lttng_syscall_filter_disable_trigger(struct lttng_trigger *trigger);
805#else
806static inline int lttng_syscalls_register_event(
807 struct lttng_channel *chan, void *filter)
808{
809 return -ENOSYS;
810}
811
812static inline int lttng_syscalls_unregister_event(struct lttng_channel *chan)
813{
814 return 0;
815}
816
817static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan,
818 const char *name)
819{
820 return -ENOSYS;
821}
822
823static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan,
824 const char *name)
825{
826 return -ENOSYS;
827}
828
829static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
830 struct lttng_kernel_syscall_mask __user *usyscall_mask)
831{
832 return -ENOSYS;
833}
834
835static inline int lttng_syscalls_register_trigger(
836 struct lttng_trigger_group *group, void *filter)
837{
838 return -ENOSYS;
839}
840
841static inline int lttng_syscalls_unregister_trigger(struct lttng_trigger_group *group)
842{
843 return 0;
844}
845
846static inline int lttng_syscall_filter_enable_trigger(struct lttng_trigger_group *group,
847 const char *name)
848{
849 return -ENOSYS;
850}
851
852static inline int lttng_syscall_filter_disable_trigger(struct lttng_trigger_group *group,
853 const char *name)
854{
855 return -ENOSYS;
856}
857
858#endif
859
860void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
861int lttng_event_enabler_attach_bytecode(struct lttng_event_enabler *event_enabler,
862 struct lttng_kernel_filter_bytecode __user *bytecode);
863int lttng_trigger_enabler_attach_bytecode(struct lttng_trigger_enabler *trigger_enabler,
864 struct lttng_kernel_filter_bytecode __user *bytecode);
865
866void 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);
870
871int lttng_probes_init(void);
872
873extern struct lttng_ctx *lttng_static_ctx;
874
875int lttng_context_init(void);
876void lttng_context_exit(void);
877struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
878void lttng_context_update(struct lttng_ctx *ctx);
879int lttng_find_context(struct lttng_ctx *ctx, const char *name);
880int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
881void lttng_remove_context_field(struct lttng_ctx **ctx,
882 struct lttng_ctx_field *field);
883void lttng_destroy_context(struct lttng_ctx *ctx);
884int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
885int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
886int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
887int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
888int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
889int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
890int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
891int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
892int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
893int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
894int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
895int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx);
896int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx);
897#if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
898int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx);
899#else
900static inline
901int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
902{
903 return -ENOSYS;
904}
905#endif
906#ifdef CONFIG_PREEMPT_RT_FULL
907int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx);
908#else
909static inline
910int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
911{
912 return -ENOSYS;
913}
914#endif
915
916int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type);
917
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))
921int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx);
922#else
923static inline
924int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx)
925{
926 return -ENOSYS;
927}
928#endif
929
930#if defined(CONFIG_IPC_NS) && \
931 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
932int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx);
933#else
934static inline
935int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx)
936{
937 return -ENOSYS;
938}
939#endif
940
941#if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
942 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
943int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx);
944#else
945static inline
946int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx)
947{
948 return -ENOSYS;
949}
950#endif
951
952#if defined(CONFIG_NET_NS) && \
953 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
954int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx);
955#else
956static inline
957int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx)
958{
959 return -ENOSYS;
960}
961#endif
962
963#if defined(CONFIG_PID_NS) && \
964 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
965int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx);
966#else
967static inline
968int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx)
969{
970 return -ENOSYS;
971}
972#endif
973
974#if defined(CONFIG_USER_NS) && \
975 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
976int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx);
977#else
978static inline
979int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx)
980{
981 return -ENOSYS;
982}
983#endif
984
985#if defined(CONFIG_UTS_NS) && \
986 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
987int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx);
988#else
989static inline
990int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
991{
992 return -ENOSYS;
993}
994#endif
995
996int lttng_add_uid_to_ctx(struct lttng_ctx **ctx);
997int lttng_add_euid_to_ctx(struct lttng_ctx **ctx);
998int lttng_add_suid_to_ctx(struct lttng_ctx **ctx);
999int lttng_add_gid_to_ctx(struct lttng_ctx **ctx);
1000int lttng_add_egid_to_ctx(struct lttng_ctx **ctx);
1001int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx);
1002int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx);
1003int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx);
1004int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx);
1005int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx);
1006int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx);
1007int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx);
1008
1009#if defined(CONFIG_PERF_EVENTS)
1010int lttng_add_perf_counter_to_ctx(uint32_t type,
1011 uint64_t config,
1012 const char *name,
1013 struct lttng_ctx **ctx);
1014int lttng_cpuhp_perf_counter_online(unsigned int cpu,
1015 struct lttng_cpuhp_node *node);
1016int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
1017 struct lttng_cpuhp_node *node);
1018#else
1019static inline
1020int lttng_add_perf_counter_to_ctx(uint32_t type,
1021 uint64_t config,
1022 const char *name,
1023 struct lttng_ctx **ctx)
1024{
1025 return -ENOSYS;
1026}
1027static inline
1028int lttng_cpuhp_perf_counter_online(unsigned int cpu,
1029 struct lttng_cpuhp_node *node)
1030{
1031 return 0;
1032}
1033static inline
1034int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
1035 struct lttng_cpuhp_node *node)
1036{
1037 return 0;
1038}
1039#endif
1040
1041int lttng_logger_init(void);
1042void lttng_logger_exit(void);
1043
1044extern int lttng_statedump_start(struct lttng_session *session);
1045
1046#ifdef CONFIG_KPROBES
1047int lttng_kprobes_register_event(const char *name,
1048 const char *symbol_name,
1049 uint64_t offset,
1050 uint64_t addr,
1051 struct lttng_event *event);
1052void lttng_kprobes_unregister_event(struct lttng_event *event);
1053void lttng_kprobes_destroy_event_private(struct lttng_event *event);
1054int lttng_kprobes_register_trigger(const char *symbol_name,
1055 uint64_t offset,
1056 uint64_t addr,
1057 struct lttng_trigger *trigger);
1058void lttng_kprobes_unregister_trigger(struct lttng_trigger *trigger);
1059void lttng_kprobes_destroy_trigger_private(struct lttng_trigger *trigger);
1060#else
1061static inline
1062int lttng_kprobes_register_event(const char *name,
1063 const char *symbol_name,
1064 uint64_t offset,
1065 uint64_t addr,
1066 struct lttng_event *event)
1067{
1068 return -ENOSYS;
1069}
1070
1071static inline
1072void lttng_kprobes_unregister_event(struct lttng_event *event)
1073{
1074}
1075
1076static inline
1077void lttng_kprobes_destroy_event_private(struct lttng_event *event)
1078{
1079}
1080
1081static inline
1082int lttng_kprobes_register_trigger(const char *symbol_name,
1083 uint64_t offset,
1084 uint64_t addr,
1085 struct lttng_trigger *trigger)
1086{
1087 return -ENOSYS;
1088}
1089
1090static inline
1091void lttng_kprobes_unregister_trigger(struct lttng_trigger *trigger)
1092{
1093}
1094
1095static inline
1096void lttng_kprobes_destroy_trigger_private(struct lttng_trigger *trigger)
1097{
1098}
1099#endif
1100
1101int lttng_event_add_callsite(struct lttng_event *event,
1102 struct lttng_kernel_event_callsite *callsite);
1103
1104int lttng_trigger_add_callsite(struct lttng_trigger *trigger,
1105 struct lttng_kernel_event_callsite *callsite);
1106
1107#ifdef CONFIG_UPROBES
1108int lttng_uprobes_register_event(const char *name,
1109 int fd, struct lttng_event *event);
1110int lttng_uprobes_event_add_callsite(struct lttng_event *event,
1111 struct lttng_kernel_event_callsite *callsite);
1112void lttng_uprobes_unregister_event(struct lttng_event *event);
1113void lttng_uprobes_destroy_event_private(struct lttng_event *event);
1114int lttng_uprobes_register_trigger(const char *name,
1115 int fd, struct lttng_trigger *trigger);
1116int lttng_uprobes_trigger_add_callsite(struct lttng_trigger *trigger,
1117 struct lttng_kernel_event_callsite *callsite);
1118void lttng_uprobes_unregister_trigger(struct lttng_trigger *trigger);
1119void lttng_uprobes_destroy_trigger_private(struct lttng_trigger *trigger);
1120#else
1121static inline
1122int lttng_uprobes_register_event(const char *name,
1123 int fd, struct lttng_event *event)
1124{
1125 return -ENOSYS;
1126}
1127
1128static inline
1129int lttng_uprobes_event_add_callsite(struct lttng_event *event,
1130 struct lttng_kernel_event_callsite *callsite)
1131{
1132 return -ENOSYS;
1133}
1134
1135static inline
1136void lttng_uprobes_unregister_event(struct lttng_event *event)
1137{
1138}
1139
1140static inline
1141void lttng_uprobes_destroy_event_private(struct lttng_event *event)
1142{
1143}
1144
1145static inline
1146int lttng_uprobes_register_trigger(const char *name,
1147 int fd, struct lttng_trigger *trigger)
1148{
1149 return -ENOSYS;
1150}
1151
1152static inline
1153int lttng_uprobes_trigger_add_callsite(struct lttng_trigger *trigger,
1154 struct lttng_kernel_event_callsite *callsite)
1155{
1156 return -ENOSYS;
1157}
1158
1159static inline
1160void lttng_uprobes_unregister_trigger(struct lttng_trigger *trigger)
1161{
1162}
1163
1164static inline
1165void lttng_uprobes_destroy_trigger_private(struct lttng_trigger *trigger)
1166{
1167}
1168#endif
1169
1170#ifdef CONFIG_KRETPROBES
1171int lttng_kretprobes_register(const char *name,
1172 const char *symbol_name,
1173 uint64_t offset,
1174 uint64_t addr,
1175 struct lttng_event *event_entry,
1176 struct lttng_event *event_exit);
1177void lttng_kretprobes_unregister(struct lttng_event *event);
1178void lttng_kretprobes_destroy_private(struct lttng_event *event);
1179int lttng_kretprobes_event_enable_state(struct lttng_event *event,
1180 int enable);
1181#else
1182static inline
1183int lttng_kretprobes_register(const char *name,
1184 const char *symbol_name,
1185 uint64_t offset,
1186 uint64_t addr,
1187 struct lttng_event *event_entry,
1188 struct lttng_event *event_exit)
1189{
1190 return -ENOSYS;
1191}
1192
1193static inline
1194void lttng_kretprobes_unregister(struct lttng_event *event)
1195{
1196}
1197
1198static inline
1199void lttng_kretprobes_destroy_private(struct lttng_event *event)
1200{
1201}
1202
1203static inline
1204int lttng_kretprobes_event_enable_state(struct lttng_event *event,
1205 int enable)
1206{
1207 return -ENOSYS;
1208}
1209#endif
1210
1211#if defined(CONFIG_DYNAMIC_FTRACE) && !defined(LTTNG_FTRACE_MISSING_HEADER)
1212int lttng_ftrace_register(const char *name,
1213 const char *symbol_name,
1214 struct lttng_event *event);
1215void lttng_ftrace_unregister(struct lttng_event *event);
1216void lttng_ftrace_destroy_private(struct lttng_event *event);
1217#else
1218static inline
1219int lttng_ftrace_register(const char *name,
1220 const char *symbol_name,
1221 struct lttng_event *event)
1222{
1223 return -ENOSYS;
1224}
1225
1226static inline
1227void lttng_ftrace_unregister(struct lttng_event *event)
1228{
1229}
1230
1231static inline
1232void lttng_ftrace_destroy_private(struct lttng_event *event)
1233{
1234}
1235#endif
1236
1237int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
1238
1239extern const struct file_operations lttng_tracepoint_list_fops;
1240extern const struct file_operations lttng_syscall_list_fops;
1241
1242#define TRACEPOINT_HAS_DATA_ARG
1243
1244#endif /* _LTTNG_EVENTS_H */
This page took 0.027287 seconds and 5 git commands to generate.