Move headers under include/
[lttng-modules.git] / include / lttng / lttng-events.h
1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
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/lttng-cpuhotplug.h>
18 #include <linux/uuid.h>
19 #include <linux/uprobes.h>
20 #include <lttng/lttng-tracer.h>
21 #include <lttng/lttng-abi.h>
22 #include <lttng/lttng-abi-old.h>
23 #include <lttng/lttng-endian.h>
24
25 #define lttng_is_signed_type(type) (((type)(-1)) < 0)
26
27 struct lttng_channel;
28 struct lttng_session;
29 struct lttng_metadata_cache;
30 struct lib_ring_buffer_ctx;
31 struct perf_event;
32 struct perf_event_attr;
33 struct lib_ring_buffer_config;
34
35 /* Type description */
36
37 enum abstract_types {
38 atype_integer,
39 atype_string,
40 atype_enum_nestable,
41 atype_array_nestable,
42 atype_sequence_nestable,
43 atype_struct_nestable,
44 atype_variant_nestable,
45 NR_ABSTRACT_TYPES,
46 };
47
48 enum lttng_string_encodings {
49 lttng_encode_none = 0,
50 lttng_encode_UTF8 = 1,
51 lttng_encode_ASCII = 2,
52 NR_STRING_ENCODINGS,
53 };
54
55 enum channel_type {
56 PER_CPU_CHANNEL,
57 METADATA_CHANNEL,
58 };
59
60 struct lttng_enum_value {
61 unsigned long long value;
62 unsigned int signedness:1;
63 };
64
65 struct lttng_enum_entry {
66 struct lttng_enum_value start, end; /* start and end are inclusive */
67 const char *string;
68 struct {
69 unsigned int is_auto:1;
70 } options;
71 };
72
73 #define __type_integer(_type, _size, _alignment, _signedness, \
74 _byte_order, _base, _encoding) \
75 { \
76 .atype = atype_integer, \
77 .u.integer = \
78 { \
79 .size = (_size) ? : sizeof(_type) * CHAR_BIT, \
80 .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \
81 .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \
82 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
83 .base = _base, \
84 .encoding = lttng_encode_##_encoding, \
85 }, \
86 } \
87
88 struct lttng_integer_type {
89 unsigned int size; /* in bits */
90 unsigned short alignment; /* in bits */
91 unsigned int signedness:1,
92 reverse_byte_order:1;
93 unsigned int base; /* 2, 8, 10, 16, for pretty print */
94 enum lttng_string_encodings encoding;
95 };
96
97 struct lttng_type {
98 enum abstract_types atype;
99 union {
100 struct lttng_integer_type integer;
101 struct {
102 enum lttng_string_encodings encoding;
103 } string;
104 struct {
105 const struct lttng_enum_desc *desc; /* Enumeration mapping */
106 const struct lttng_type *container_type;
107 } enum_nestable;
108 struct {
109 const struct lttng_type *elem_type;
110 unsigned int length; /* Num. elems. */
111 unsigned int alignment;
112 } array_nestable;
113 struct {
114 const char *length_name; /* Length field name. */
115 const struct lttng_type *elem_type;
116 unsigned int alignment; /* Alignment before elements. */
117 } sequence_nestable;
118 struct {
119 unsigned int nr_fields;
120 const struct lttng_event_field *fields; /* Array of fields. */
121 unsigned int alignment;
122 } struct_nestable;
123 struct {
124 const char *tag_name;
125 const struct lttng_event_field *choices; /* Array of fields. */
126 unsigned int nr_choices;
127 unsigned int alignment;
128 } variant_nestable;
129 } u;
130 };
131
132 struct lttng_enum_desc {
133 const char *name;
134 const struct lttng_enum_entry *entries;
135 unsigned int nr_entries;
136 };
137
138 /* Event field description */
139
140 struct lttng_event_field {
141 const char *name;
142 struct lttng_type type;
143 unsigned int nowrite:1, /* do not write into trace */
144 user:1, /* fetch from user-space */
145 nofilter:1; /* do not consider for filter */
146 };
147
148 union lttng_ctx_value {
149 int64_t s64;
150 const char *str;
151 double d;
152 };
153
154 /*
155 * We need to keep this perf counter field separately from struct
156 * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
157 */
158 struct lttng_perf_counter_field {
159 struct lttng_cpuhp_node cpuhp_prepare;
160 struct lttng_cpuhp_node cpuhp_online;
161 struct perf_event_attr *attr;
162 struct perf_event **e; /* per-cpu array */
163 };
164
165 struct lttng_probe_ctx {
166 struct lttng_event *event;
167 uint8_t interruptible;
168 };
169
170 struct lttng_ctx_field {
171 struct lttng_event_field event_field;
172 size_t (*get_size)(size_t offset);
173 size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field,
174 struct lib_ring_buffer_ctx *ctx,
175 struct lttng_channel *chan);
176 void (*record)(struct lttng_ctx_field *field,
177 struct lib_ring_buffer_ctx *ctx,
178 struct lttng_channel *chan);
179 void (*get_value)(struct lttng_ctx_field *field,
180 struct lttng_probe_ctx *lttng_probe_ctx,
181 union lttng_ctx_value *value);
182 union {
183 struct lttng_perf_counter_field *perf_counter;
184 } u;
185 void (*destroy)(struct lttng_ctx_field *field);
186 /*
187 * Private data to keep state between get_size and record.
188 * User must perform its own synchronization to protect against
189 * concurrent and reentrant contexts.
190 */
191 void *priv;
192 };
193
194 struct lttng_ctx {
195 struct lttng_ctx_field *fields;
196 unsigned int nr_fields;
197 unsigned int allocated_fields;
198 size_t largest_align; /* in bytes */
199 };
200
201 struct lttng_event_desc {
202 const char *name; /* lttng-modules name */
203 const char *kname; /* Linux kernel name (tracepoints) */
204 void *probe_callback;
205 const struct lttng_event_ctx *ctx; /* context */
206 const struct lttng_event_field *fields; /* event payload */
207 unsigned int nr_fields;
208 struct module *owner;
209 };
210
211 struct lttng_probe_desc {
212 const char *provider;
213 const struct lttng_event_desc **event_desc;
214 unsigned int nr_events;
215 struct list_head head; /* chain registered probes */
216 struct list_head lazy_init_head;
217 int lazy; /* lazy registration */
218 };
219
220 struct lttng_krp; /* Kretprobe handling */
221
222 enum lttng_event_type {
223 LTTNG_TYPE_EVENT = 0,
224 LTTNG_TYPE_ENABLER = 1,
225 };
226
227 struct lttng_filter_bytecode_node {
228 struct list_head node;
229 struct lttng_enabler *enabler;
230 /*
231 * struct lttng_kernel_filter_bytecode has var. sized array, must be
232 * last field.
233 */
234 struct lttng_kernel_filter_bytecode bc;
235 };
236
237 /*
238 * Filter return value masks.
239 */
240 enum lttng_filter_ret {
241 LTTNG_FILTER_DISCARD = 0,
242 LTTNG_FILTER_RECORD_FLAG = (1ULL << 0),
243 /* Other bits are kept for future use. */
244 };
245
246 struct lttng_bytecode_runtime {
247 /* Associated bytecode */
248 struct lttng_filter_bytecode_node *bc;
249 uint64_t (*filter)(void *filter_data, struct lttng_probe_ctx *lttng_probe_ctx,
250 const char *filter_stack_data);
251 int link_failed;
252 struct list_head node; /* list of bytecode runtime in event */
253 struct lttng_event *event;
254 };
255
256 /*
257 * Objects in a linked-list of enablers, owned by an event.
258 */
259 struct lttng_enabler_ref {
260 struct list_head node; /* enabler ref list */
261 struct lttng_enabler *ref; /* backward ref */
262 };
263
264 struct lttng_uprobe_handler {
265 struct lttng_event *event;
266 loff_t offset;
267 struct uprobe_consumer up_consumer;
268 struct list_head node;
269 };
270
271 /*
272 * lttng_event structure is referred to by the tracing fast path. It must be
273 * kept small.
274 */
275 struct lttng_event {
276 enum lttng_event_type evtype; /* First field. */
277 unsigned int id;
278 struct lttng_channel *chan;
279 int enabled;
280 const struct lttng_event_desc *desc;
281 void *filter;
282 struct lttng_ctx *ctx;
283 enum lttng_kernel_instrumentation instrumentation;
284 union {
285 struct {
286 struct kprobe kp;
287 char *symbol_name;
288 } kprobe;
289 struct {
290 struct lttng_krp *lttng_krp;
291 char *symbol_name;
292 } kretprobe;
293 struct {
294 struct inode *inode;
295 struct list_head head;
296 } uprobe;
297 } u;
298 struct list_head list; /* Event list in session */
299 unsigned int metadata_dumped:1;
300
301 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
302 struct list_head enablers_ref_head;
303 struct hlist_node hlist; /* session ht of events */
304 int registered; /* has reg'd tracepoint probe */
305 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
306 struct list_head bytecode_runtime_head;
307 int has_enablers_without_bytecode;
308 };
309
310 enum lttng_enabler_type {
311 LTTNG_ENABLER_STAR_GLOB,
312 LTTNG_ENABLER_NAME,
313 };
314
315 /*
316 * Enabler field, within whatever object is enabling an event. Target of
317 * backward reference.
318 */
319 struct lttng_enabler {
320 enum lttng_event_type evtype; /* First field. */
321
322 enum lttng_enabler_type type;
323
324 struct list_head node; /* per-session list of enablers */
325 /* head list of struct lttng_ust_filter_bytecode_node */
326 struct list_head filter_bytecode_head;
327
328 struct lttng_kernel_event event_param;
329 struct lttng_channel *chan;
330 struct lttng_ctx *ctx;
331 unsigned int enabled:1;
332 };
333
334 struct lttng_channel_ops {
335 struct channel *(*channel_create)(const char *name,
336 struct lttng_channel *lttng_chan,
337 void *buf_addr,
338 size_t subbuf_size, size_t num_subbuf,
339 unsigned int switch_timer_interval,
340 unsigned int read_timer_interval);
341 void (*channel_destroy)(struct channel *chan);
342 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
343 int (*buffer_has_read_closed_stream)(struct channel *chan);
344 void (*buffer_read_close)(struct lib_ring_buffer *buf);
345 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
346 uint32_t event_id);
347 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
348 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
349 size_t len);
350 void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx,
351 const void *src, size_t len);
352 void (*event_memset)(struct lib_ring_buffer_ctx *ctx,
353 int c, size_t len);
354 void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src,
355 size_t len);
356 void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx,
357 const char __user *src, size_t len);
358 /*
359 * packet_avail_size returns the available size in the current
360 * packet. Note that the size returned is only a hint, since it
361 * may change due to concurrent writes.
362 */
363 size_t (*packet_avail_size)(struct channel *chan);
364 wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
365 wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
366 int (*is_finalized)(struct channel *chan);
367 int (*is_disabled)(struct channel *chan);
368 int (*timestamp_begin) (const struct lib_ring_buffer_config *config,
369 struct lib_ring_buffer *bufb,
370 uint64_t *timestamp_begin);
371 int (*timestamp_end) (const struct lib_ring_buffer_config *config,
372 struct lib_ring_buffer *bufb,
373 uint64_t *timestamp_end);
374 int (*events_discarded) (const struct lib_ring_buffer_config *config,
375 struct lib_ring_buffer *bufb,
376 uint64_t *events_discarded);
377 int (*content_size) (const struct lib_ring_buffer_config *config,
378 struct lib_ring_buffer *bufb,
379 uint64_t *content_size);
380 int (*packet_size) (const struct lib_ring_buffer_config *config,
381 struct lib_ring_buffer *bufb,
382 uint64_t *packet_size);
383 int (*stream_id) (const struct lib_ring_buffer_config *config,
384 struct lib_ring_buffer *bufb,
385 uint64_t *stream_id);
386 int (*current_timestamp) (const struct lib_ring_buffer_config *config,
387 struct lib_ring_buffer *bufb,
388 uint64_t *ts);
389 int (*sequence_number) (const struct lib_ring_buffer_config *config,
390 struct lib_ring_buffer *bufb,
391 uint64_t *seq);
392 int (*instance_id) (const struct lib_ring_buffer_config *config,
393 struct lib_ring_buffer *bufb,
394 uint64_t *id);
395 };
396
397 struct lttng_transport {
398 char *name;
399 struct module *owner;
400 struct list_head node;
401 struct lttng_channel_ops ops;
402 };
403
404 struct lttng_syscall_filter;
405
406 #define LTTNG_EVENT_HT_BITS 12
407 #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
408
409 struct lttng_event_ht {
410 struct hlist_head table[LTTNG_EVENT_HT_SIZE];
411 };
412
413 struct lttng_channel {
414 unsigned int id;
415 struct channel *chan; /* Channel buffers */
416 int enabled;
417 struct lttng_ctx *ctx;
418 /* Event ID management */
419 struct lttng_session *session;
420 struct file *file; /* File associated to channel */
421 unsigned int free_event_id; /* Next event ID to allocate */
422 struct list_head list; /* Channel list */
423 struct lttng_channel_ops *ops;
424 struct lttng_transport *transport;
425 struct lttng_event **sc_table; /* for syscall tracing */
426 struct lttng_event **compat_sc_table;
427 struct lttng_event **sc_exit_table; /* for syscall exit tracing */
428 struct lttng_event **compat_sc_exit_table;
429 struct lttng_event *sc_unknown; /* for unknown syscalls */
430 struct lttng_event *sc_compat_unknown;
431 struct lttng_event *sc_exit_unknown;
432 struct lttng_event *compat_sc_exit_unknown;
433 struct lttng_syscall_filter *sc_filter;
434 int header_type; /* 0: unset, 1: compact, 2: large */
435 enum channel_type channel_type;
436 unsigned int metadata_dumped:1,
437 sys_enter_registered:1,
438 sys_exit_registered:1,
439 syscall_all:1,
440 tstate:1; /* Transient enable state */
441 };
442
443 struct lttng_metadata_stream {
444 void *priv; /* Ring buffer private data */
445 struct lttng_metadata_cache *metadata_cache;
446 unsigned int metadata_in; /* Bytes read from the cache */
447 unsigned int metadata_out; /* Bytes consumed from stream */
448 int finalized; /* Has channel been finalized */
449 wait_queue_head_t read_wait; /* Reader buffer-level wait queue */
450 struct list_head list; /* Stream list */
451 struct lttng_transport *transport;
452 uint64_t version; /* Current version of the metadata cache */
453 };
454
455 #define LTTNG_DYNAMIC_LEN_STACK_SIZE 128
456
457 struct lttng_dynamic_len_stack {
458 size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE];
459 size_t offset;
460 };
461
462 DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack);
463
464 /*
465 * struct lttng_id_tracker declared in header due to deferencing of *v
466 * in RCU_INITIALIZER(v).
467 */
468 #define LTTNG_ID_HASH_BITS 6
469 #define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS)
470
471 enum tracker_type {
472 TRACKER_PID,
473 TRACKER_VPID,
474 TRACKER_UID,
475 TRACKER_VUID,
476 TRACKER_GID,
477 TRACKER_VGID,
478
479 TRACKER_UNKNOWN,
480 };
481
482 struct lttng_id_tracker_rcu {
483 struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE];
484 };
485
486 struct lttng_id_tracker {
487 struct lttng_session *session;
488 enum tracker_type tracker_type;
489 struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */
490 };
491
492 struct lttng_id_hash_node {
493 struct hlist_node hlist;
494 int id;
495 };
496
497 struct lttng_session {
498 int active; /* Is trace session active ? */
499 int been_active; /* Has trace session been active ? */
500 struct file *file; /* File associated to session */
501 struct list_head chan; /* Channel list head */
502 struct list_head events; /* Event list head */
503 struct list_head list; /* Session list */
504 unsigned int free_chan_id; /* Next chan ID to allocate */
505 uuid_le uuid; /* Trace session unique ID */
506 struct lttng_metadata_cache *metadata_cache;
507 struct lttng_id_tracker pid_tracker;
508 struct lttng_id_tracker vpid_tracker;
509 struct lttng_id_tracker uid_tracker;
510 struct lttng_id_tracker vuid_tracker;
511 struct lttng_id_tracker gid_tracker;
512 struct lttng_id_tracker vgid_tracker;
513 unsigned int metadata_dumped:1,
514 tstate:1; /* Transient enable state */
515 /* List of enablers */
516 struct list_head enablers_head;
517 /* Hash table of events */
518 struct lttng_event_ht events_ht;
519 char name[LTTNG_KERNEL_SESSION_NAME_LEN];
520 char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
521 };
522
523 struct lttng_metadata_cache {
524 char *data; /* Metadata cache */
525 unsigned int cache_alloc; /* Metadata allocated size (bytes) */
526 unsigned int metadata_written; /* Number of bytes written in metadata cache */
527 struct kref refcount; /* Metadata cache usage */
528 struct list_head metadata_stream; /* Metadata stream list */
529 uuid_le uuid; /* Trace session unique ID (copy) */
530 struct mutex lock; /* Produce/consume lock */
531 uint64_t version; /* Current version of the metadata */
532 };
533
534 void lttng_lock_sessions(void);
535 void lttng_unlock_sessions(void);
536
537 struct list_head *lttng_get_probe_list_head(void);
538
539 struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type,
540 struct lttng_kernel_event *event_param,
541 struct lttng_channel *chan);
542
543 int lttng_enabler_enable(struct lttng_enabler *enabler);
544 int lttng_enabler_disable(struct lttng_enabler *enabler);
545 int lttng_fix_pending_events(void);
546 int lttng_session_active(void);
547
548 struct lttng_session *lttng_session_create(void);
549 int lttng_session_enable(struct lttng_session *session);
550 int lttng_session_disable(struct lttng_session *session);
551 void lttng_session_destroy(struct lttng_session *session);
552 int lttng_session_metadata_regenerate(struct lttng_session *session);
553 int lttng_session_statedump(struct lttng_session *session);
554 void metadata_cache_destroy(struct kref *kref);
555
556 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
557 const char *transport_name,
558 void *buf_addr,
559 size_t subbuf_size, size_t num_subbuf,
560 unsigned int switch_timer_interval,
561 unsigned int read_timer_interval,
562 enum channel_type channel_type);
563 struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
564 int overwrite, void *buf_addr,
565 size_t subbuf_size, size_t num_subbuf,
566 unsigned int switch_timer_interval,
567 unsigned int read_timer_interval);
568
569 void lttng_metadata_channel_destroy(struct lttng_channel *chan);
570 struct lttng_event *lttng_event_create(struct lttng_channel *chan,
571 struct lttng_kernel_event *event_param,
572 void *filter,
573 const struct lttng_event_desc *event_desc,
574 enum lttng_kernel_instrumentation itype);
575 struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
576 struct lttng_kernel_event *event_param,
577 void *filter,
578 const struct lttng_event_desc *event_desc,
579 enum lttng_kernel_instrumentation itype);
580 struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
581 struct lttng_kernel_old_event *old_event_param,
582 void *filter,
583 const struct lttng_event_desc *internal_desc);
584
585 int lttng_channel_enable(struct lttng_channel *channel);
586 int lttng_channel_disable(struct lttng_channel *channel);
587 int lttng_event_enable(struct lttng_event *event);
588 int lttng_event_disable(struct lttng_event *event);
589
590 void lttng_transport_register(struct lttng_transport *transport);
591 void lttng_transport_unregister(struct lttng_transport *transport);
592
593 void synchronize_trace(void);
594 int lttng_abi_init(void);
595 int lttng_abi_compat_old_init(void);
596 void lttng_abi_exit(void);
597 void lttng_abi_compat_old_exit(void);
598
599 int lttng_probe_register(struct lttng_probe_desc *desc);
600 void lttng_probe_unregister(struct lttng_probe_desc *desc);
601 const struct lttng_event_desc *lttng_event_get(const char *name);
602 void lttng_event_put(const struct lttng_event_desc *desc);
603 int lttng_probes_init(void);
604 void lttng_probes_exit(void);
605
606 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
607 struct channel *chan);
608
609 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
610 int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf);
611 void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu);
612 bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id);
613 int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id);
614 int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id);
615
616 int lttng_session_track_id(struct lttng_session *session,
617 enum tracker_type tracker_type, int id);
618 int lttng_session_untrack_id(struct lttng_session *session,
619 enum tracker_type tracker_type, int id);
620
621 int lttng_session_list_tracker_ids(struct lttng_session *session,
622 enum tracker_type tracker_type);
623
624 void lttng_clock_ref(void);
625 void lttng_clock_unref(void);
626
627 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
628 int lttng_syscalls_register(struct lttng_channel *chan, void *filter);
629 int lttng_syscalls_unregister(struct lttng_channel *chan);
630 int lttng_syscall_filter_enable(struct lttng_channel *chan,
631 const char *name);
632 int lttng_syscall_filter_disable(struct lttng_channel *chan,
633 const char *name);
634 long lttng_channel_syscall_mask(struct lttng_channel *channel,
635 struct lttng_kernel_syscall_mask __user *usyscall_mask);
636 #else
637 static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
638 {
639 return -ENOSYS;
640 }
641
642 static inline int lttng_syscalls_unregister(struct lttng_channel *chan)
643 {
644 return 0;
645 }
646
647 static inline int lttng_syscall_filter_enable(struct lttng_channel *chan,
648 const char *name)
649 {
650 return -ENOSYS;
651 }
652
653 static inline int lttng_syscall_filter_disable(struct lttng_channel *chan,
654 const char *name)
655 {
656 return -ENOSYS;
657 }
658
659 static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
660 struct lttng_kernel_syscall_mask __user *usyscall_mask)
661 {
662 return -ENOSYS;
663 }
664 #endif
665
666 void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
667 int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
668 struct lttng_kernel_filter_bytecode __user *bytecode);
669 void lttng_enabler_event_link_bytecode(struct lttng_event *event,
670 struct lttng_enabler *enabler);
671
672 int lttng_probes_init(void);
673
674 extern struct lttng_ctx *lttng_static_ctx;
675
676 int lttng_context_init(void);
677 void lttng_context_exit(void);
678 struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
679 void lttng_context_update(struct lttng_ctx *ctx);
680 int lttng_find_context(struct lttng_ctx *ctx, const char *name);
681 int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
682 void lttng_remove_context_field(struct lttng_ctx **ctx,
683 struct lttng_ctx_field *field);
684 void lttng_destroy_context(struct lttng_ctx *ctx);
685 int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
686 int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
687 int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
688 int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
689 int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
690 int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
691 int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
692 int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
693 int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
694 int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
695 int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
696 int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx);
697 int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx);
698 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
699 int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx);
700 #else
701 static inline
702 int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
703 {
704 return -ENOSYS;
705 }
706 #endif
707 #ifdef CONFIG_PREEMPT_RT_FULL
708 int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx);
709 #else
710 static inline
711 int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
712 {
713 return -ENOSYS;
714 }
715 #endif
716
717 int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type);
718
719 #if defined(CONFIG_CGROUPS)
720 int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx);
721 #else
722 static inline
723 int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx)
724 {
725 return -ENOSYS;
726 }
727 #endif
728
729 #if defined(CONFIG_IPC_NS)
730 int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx);
731 #else
732 static inline
733 int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx)
734 {
735 return -ENOSYS;
736 }
737 #endif
738
739 #if !defined(LTTNG_MNT_NS_MISSING_HEADER)
740 int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx);
741 #else
742 static inline
743 int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx)
744 {
745 return -ENOSYS;
746 }
747 #endif
748
749 #if defined(CONFIG_NET_NS)
750 int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx);
751 #else
752 static inline
753 int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx)
754 {
755 return -ENOSYS;
756 }
757 #endif
758
759 #if defined(CONFIG_PID_NS)
760 int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx);
761 #else
762 static inline
763 int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx)
764 {
765 return -ENOSYS;
766 }
767 #endif
768
769 #if defined(CONFIG_USER_NS)
770 int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx);
771 #else
772 static inline
773 int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx)
774 {
775 return -ENOSYS;
776 }
777 #endif
778
779 #if defined(CONFIG_UTS_NS)
780 int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx);
781 #else
782 static inline
783 int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
784 {
785 return -ENOSYS;
786 }
787 #endif
788
789 int lttng_add_uid_to_ctx(struct lttng_ctx **ctx);
790 int lttng_add_euid_to_ctx(struct lttng_ctx **ctx);
791 int lttng_add_suid_to_ctx(struct lttng_ctx **ctx);
792 int lttng_add_gid_to_ctx(struct lttng_ctx **ctx);
793 int lttng_add_egid_to_ctx(struct lttng_ctx **ctx);
794 int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx);
795 int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx);
796 int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx);
797 int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx);
798 int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx);
799 int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx);
800 int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx);
801
802 #if defined(CONFIG_PERF_EVENTS)
803 int lttng_add_perf_counter_to_ctx(uint32_t type,
804 uint64_t config,
805 const char *name,
806 struct lttng_ctx **ctx);
807 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
808 struct lttng_cpuhp_node *node);
809 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
810 struct lttng_cpuhp_node *node);
811 #else
812 static inline
813 int lttng_add_perf_counter_to_ctx(uint32_t type,
814 uint64_t config,
815 const char *name,
816 struct lttng_ctx **ctx)
817 {
818 return -ENOSYS;
819 }
820 static inline
821 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
822 struct lttng_cpuhp_node *node)
823 {
824 return 0;
825 }
826 static inline
827 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
828 struct lttng_cpuhp_node *node)
829 {
830 return 0;
831 }
832 #endif
833
834 int lttng_logger_init(void);
835 void lttng_logger_exit(void);
836
837 extern int lttng_statedump_start(struct lttng_session *session);
838
839 #ifdef CONFIG_KPROBES
840 int lttng_kprobes_register(const char *name,
841 const char *symbol_name,
842 uint64_t offset,
843 uint64_t addr,
844 struct lttng_event *event);
845 void lttng_kprobes_unregister(struct lttng_event *event);
846 void lttng_kprobes_destroy_private(struct lttng_event *event);
847 #else
848 static inline
849 int lttng_kprobes_register(const char *name,
850 const char *symbol_name,
851 uint64_t offset,
852 uint64_t addr,
853 struct lttng_event *event)
854 {
855 return -ENOSYS;
856 }
857
858 static inline
859 void lttng_kprobes_unregister(struct lttng_event *event)
860 {
861 }
862
863 static inline
864 void lttng_kprobes_destroy_private(struct lttng_event *event)
865 {
866 }
867 #endif
868
869 int lttng_event_add_callsite(struct lttng_event *event,
870 struct lttng_kernel_event_callsite *callsite);
871
872 #ifdef CONFIG_UPROBES
873 int lttng_uprobes_register(const char *name,
874 int fd, struct lttng_event *event);
875 int lttng_uprobes_add_callsite(struct lttng_event *event,
876 struct lttng_kernel_event_callsite *callsite);
877 void lttng_uprobes_unregister(struct lttng_event *event);
878 void lttng_uprobes_destroy_private(struct lttng_event *event);
879 #else
880 static inline
881 int lttng_uprobes_register(const char *name,
882 int fd, struct lttng_event *event)
883 {
884 return -ENOSYS;
885 }
886
887 static inline
888 int lttng_uprobes_add_callsite(struct lttng_event *event,
889 struct lttng_kernel_event_callsite *callsite)
890 {
891 return -ENOSYS;
892 }
893
894 static inline
895 void lttng_uprobes_unregister(struct lttng_event *event)
896 {
897 }
898
899 static inline
900 void lttng_uprobes_destroy_private(struct lttng_event *event)
901 {
902 }
903 #endif
904
905 #ifdef CONFIG_KRETPROBES
906 int lttng_kretprobes_register(const char *name,
907 const char *symbol_name,
908 uint64_t offset,
909 uint64_t addr,
910 struct lttng_event *event_entry,
911 struct lttng_event *event_exit);
912 void lttng_kretprobes_unregister(struct lttng_event *event);
913 void lttng_kretprobes_destroy_private(struct lttng_event *event);
914 int lttng_kretprobes_event_enable_state(struct lttng_event *event,
915 int enable);
916 #else
917 static inline
918 int lttng_kretprobes_register(const char *name,
919 const char *symbol_name,
920 uint64_t offset,
921 uint64_t addr,
922 struct lttng_event *event_entry,
923 struct lttng_event *event_exit)
924 {
925 return -ENOSYS;
926 }
927
928 static inline
929 void lttng_kretprobes_unregister(struct lttng_event *event)
930 {
931 }
932
933 static inline
934 void lttng_kretprobes_destroy_private(struct lttng_event *event)
935 {
936 }
937
938 static inline
939 int lttng_kretprobes_event_enable_state(struct lttng_event *event,
940 int enable)
941 {
942 return -ENOSYS;
943 }
944 #endif
945
946 int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
947
948 extern const struct file_operations lttng_tracepoint_list_fops;
949 extern const struct file_operations lttng_syscall_list_fops;
950
951 #define TRACEPOINT_HAS_DATA_ARG
952
953 static inline bool lttng_is_bytewise_integer(const struct lttng_type *type)
954 {
955 if (type->atype != atype_integer)
956 return false;
957 switch (type->u.integer.size) {
958 case 8: /* Fall-through. */
959 case 16: /* Fall-through. */
960 case 32: /* Fall-through. */
961 case 64:
962 break;
963 default:
964 return false;
965 }
966 return true;
967 }
968
969 #endif /* _LTTNG_EVENTS_H */
This page took 0.078494 seconds and 4 git commands to generate.