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