page alloc wrapper: Fix get_pfnblock_flags_mask prototype
[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 <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
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, _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
93struct 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
103union _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
115struct lttng_basic_type {
116 enum abstract_types atype;
117 union {
118 union _lttng_basic_type basic;
119 } u;
120};
121
122struct 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
156struct 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
164struct lttng_event_field {
165 const char *name;
166 struct lttng_type type;
167 unsigned int nowrite:1; /* do not write into trace */
168};
169
170union 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 */
180struct 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
192struct lttng_probe_ctx {
193 struct lttng_event *event;
194 uint8_t interruptible;
195};
196
197struct 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
221struct 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
228struct 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
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_event *event;
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 struct lttng_event *event;
293 loff_t offset;
294 struct uprobe_consumer up_consumer;
295 struct list_head node;
296};
297
298enum lttng_syscall_entryexit {
299 LTTNG_SYSCALL_ENTRY,
300 LTTNG_SYSCALL_EXIT,
301};
302
303enum 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 */
312struct 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
352enum 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 */
361struct 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
376struct 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
439struct lttng_transport {
440 char *name;
441 struct module *owner;
442 struct list_head node;
443 struct lttng_channel_ops ops;
444};
445
446struct lttng_syscall_filter;
447
448#define LTTNG_EVENT_HT_BITS 12
449#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
450
451struct lttng_event_ht {
452 struct hlist_head table[LTTNG_EVENT_HT_SIZE];
453};
454
455struct 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
485struct 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
500struct lttng_dynamic_len_stack {
501 size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE];
502 size_t offset;
503};
504
505DECLARE_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
514enum 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
525struct lttng_id_tracker_rcu {
526 struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE];
527};
528
529struct 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
535struct lttng_id_hash_node {
536 struct hlist_node hlist;
537 int id;
538};
539
540struct 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
566struct 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
578void lttng_lock_sessions(void);
579void lttng_unlock_sessions(void);
580
581struct list_head *lttng_get_probe_list_head(void);
582
583struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type,
584 struct lttng_kernel_event *event_param,
585 struct lttng_channel *chan);
586
587int lttng_enabler_enable(struct lttng_enabler *enabler);
588int lttng_enabler_disable(struct lttng_enabler *enabler);
589int lttng_fix_pending_events(void);
590int lttng_session_active(void);
591
592struct lttng_session *lttng_session_create(void);
593int lttng_session_enable(struct lttng_session *session);
594int lttng_session_disable(struct lttng_session *session);
595void lttng_session_destroy(struct lttng_session *session);
596int lttng_session_metadata_regenerate(struct lttng_session *session);
597int lttng_session_statedump(struct lttng_session *session);
598void metadata_cache_destroy(struct kref *kref);
599
600struct 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);
607struct 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
613void lttng_metadata_channel_destroy(struct lttng_channel *chan);
614struct 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);
619struct 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);
624struct 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
629int lttng_channel_enable(struct lttng_channel *channel);
630int lttng_channel_disable(struct lttng_channel *channel);
631int lttng_event_enable(struct lttng_event *event);
632int lttng_event_disable(struct lttng_event *event);
633
634void lttng_transport_register(struct lttng_transport *transport);
635void lttng_transport_unregister(struct lttng_transport *transport);
636
637void synchronize_trace(void);
638int lttng_abi_init(void);
639int lttng_abi_compat_old_init(void);
640void lttng_abi_exit(void);
641void lttng_abi_compat_old_exit(void);
642
643int lttng_probe_register(struct lttng_probe_desc *desc);
644void lttng_probe_unregister(struct lttng_probe_desc *desc);
645const struct lttng_event_desc *lttng_event_get(const char *name);
646void lttng_event_put(const struct lttng_event_desc *desc);
647int lttng_probes_init(void);
648void lttng_probes_exit(void);
649
650int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
651 struct channel *chan, bool *coherent);
652
653int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
654int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf);
655void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu);
656bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id);
657int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id);
658int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id);
659
660int lttng_session_track_id(struct lttng_session *session,
661 enum tracker_type tracker_type, int id);
662int lttng_session_untrack_id(struct lttng_session *session,
663 enum tracker_type tracker_type, int id);
664
665int lttng_session_list_tracker_ids(struct lttng_session *session,
666 enum tracker_type tracker_type);
667
668void lttng_clock_ref(void);
669void lttng_clock_unref(void);
670
671#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
672int lttng_syscalls_register(struct lttng_channel *chan, void *filter);
673int lttng_syscalls_unregister(struct lttng_channel *chan);
674int lttng_syscalls_destroy(struct lttng_channel *chan);
675int lttng_syscall_filter_enable(struct lttng_channel *chan,
676 struct lttng_event *event);
677int lttng_syscall_filter_disable(struct lttng_channel *chan,
678 struct lttng_event *event);
679long lttng_channel_syscall_mask(struct lttng_channel *channel,
680 struct lttng_kernel_syscall_mask __user *usyscall_mask);
681#else
682static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
683{
684 return -ENOSYS;
685}
686
687static inline int lttng_syscalls_unregister(struct lttng_channel *chan)
688{
689 return 0;
690}
691
692static inline int lttng_syscalls_destroy(struct lttng_channel *chan)
693{
694 return 0;
695}
696
697static inline int lttng_syscall_filter_enable(struct lttng_channel *chan,
698 struct lttng_event *event)
699{
700 return -ENOSYS;
701}
702
703static inline int lttng_syscall_filter_disable(struct lttng_channel *chan,
704 struct lttng_event *event)
705{
706 return -ENOSYS;
707}
708
709static 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
716void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
717int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
718 struct lttng_kernel_filter_bytecode __user *bytecode);
719void lttng_enabler_event_link_bytecode(struct lttng_event *event,
720 struct lttng_enabler *enabler);
721void lttng_free_event_filter_runtime(struct lttng_event *event);
722
723int lttng_probes_init(void);
724
725extern struct lttng_ctx *lttng_static_ctx;
726
727int lttng_context_init(void);
728void lttng_context_exit(void);
729struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
730void lttng_context_update(struct lttng_ctx *ctx);
731int lttng_find_context(struct lttng_ctx *ctx, const char *name);
732int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
733void lttng_remove_context_field(struct lttng_ctx **ctx,
734 struct lttng_ctx_field *field);
735void lttng_destroy_context(struct lttng_ctx *ctx);
736int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
737int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
738int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
739int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
740int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
741int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
742int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
743int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
744int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
745int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
746int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
747int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx);
748int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx);
749#if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
750int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx);
751#else
752static inline
753int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
754{
755 return -ENOSYS;
756}
757#endif
758#ifdef CONFIG_PREEMPT_RT_FULL
759int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx);
760#else
761static inline
762int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
763{
764 return -ENOSYS;
765}
766#endif
767
768int 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))
773int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx);
774#else
775static inline
776int 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))
784int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx);
785#else
786static inline
787int 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))
795int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx);
796#else
797static inline
798int 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))
806int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx);
807#else
808static inline
809int 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))
817int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx);
818#else
819static inline
820int 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))
828int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx);
829#else
830static inline
831int 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))
839int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx);
840#else
841static inline
842int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
843{
844 return -ENOSYS;
845}
846#endif
847
848int lttng_add_uid_to_ctx(struct lttng_ctx **ctx);
849int lttng_add_euid_to_ctx(struct lttng_ctx **ctx);
850int lttng_add_suid_to_ctx(struct lttng_ctx **ctx);
851int lttng_add_gid_to_ctx(struct lttng_ctx **ctx);
852int lttng_add_egid_to_ctx(struct lttng_ctx **ctx);
853int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx);
854int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx);
855int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx);
856int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx);
857int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx);
858int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx);
859int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx);
860
861#if defined(CONFIG_PERF_EVENTS)
862int lttng_add_perf_counter_to_ctx(uint32_t type,
863 uint64_t config,
864 const char *name,
865 struct lttng_ctx **ctx);
866int lttng_cpuhp_perf_counter_online(unsigned int cpu,
867 struct lttng_cpuhp_node *node);
868int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
869 struct lttng_cpuhp_node *node);
870#else
871static inline
872int 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}
879static inline
880int lttng_cpuhp_perf_counter_online(unsigned int cpu,
881 struct lttng_cpuhp_node *node)
882{
883 return 0;
884}
885static inline
886int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
887 struct lttng_cpuhp_node *node)
888{
889 return 0;
890}
891#endif
892
893int lttng_logger_init(void);
894void lttng_logger_exit(void);
895
896extern int lttng_statedump_start(struct lttng_session *session);
897
898#ifdef CONFIG_KPROBES
899int lttng_kprobes_register(const char *name,
900 const char *symbol_name,
901 uint64_t offset,
902 uint64_t addr,
903 struct lttng_event *event);
904void lttng_kprobes_unregister(struct lttng_event *event);
905void lttng_kprobes_destroy_private(struct lttng_event *event);
906#else
907static inline
908int 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
917static inline
918void lttng_kprobes_unregister(struct lttng_event *event)
919{
920}
921
922static inline
923void lttng_kprobes_destroy_private(struct lttng_event *event)
924{
925}
926#endif
927
928int lttng_event_add_callsite(struct lttng_event *event,
929 struct lttng_kernel_event_callsite *callsite);
930
931#ifdef CONFIG_UPROBES
932int lttng_uprobes_register(const char *name,
933 int fd, struct lttng_event *event);
934int lttng_uprobes_add_callsite(struct lttng_event *event,
935 struct lttng_kernel_event_callsite *callsite);
936void lttng_uprobes_unregister(struct lttng_event *event);
937void lttng_uprobes_destroy_private(struct lttng_event *event);
938#else
939static inline
940int lttng_uprobes_register(const char *name,
941 int fd, struct lttng_event *event)
942{
943 return -ENOSYS;
944}
945
946static inline
947int lttng_uprobes_add_callsite(struct lttng_event *event,
948 struct lttng_kernel_event_callsite *callsite)
949{
950 return -ENOSYS;
951}
952
953static inline
954void lttng_uprobes_unregister(struct lttng_event *event)
955{
956}
957
958static inline
959void lttng_uprobes_destroy_private(struct lttng_event *event)
960{
961}
962#endif
963
964#ifdef CONFIG_KRETPROBES
965int 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);
971void lttng_kretprobes_unregister(struct lttng_event *event);
972void lttng_kretprobes_destroy_private(struct lttng_event *event);
973int lttng_kretprobes_event_enable_state(struct lttng_event *event,
974 int enable);
975#else
976static inline
977int 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
987static inline
988void lttng_kretprobes_unregister(struct lttng_event *event)
989{
990}
991
992static inline
993void lttng_kretprobes_destroy_private(struct lttng_event *event)
994{
995}
996
997static inline
998int lttng_kretprobes_event_enable_state(struct lttng_event *event,
999 int enable)
1000{
1001 return -ENOSYS;
1002}
1003#endif
1004
1005int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
1006
1007extern const struct file_operations lttng_tracepoint_list_fops;
1008extern 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.026726 seconds and 4 git commands to generate.