Version 2.8.7
[lttng-modules.git] / lttng-events.h
1 #ifndef _LTTNG_EVENTS_H
2 #define _LTTNG_EVENTS_H
3
4 /*
5 * lttng-events.h
6 *
7 * Holds LTTng per-session event registry.
8 *
9 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; only
14 * version 2.1 of the License.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #include <linux/version.h>
27 #include <linux/list.h>
28 #include <linux/kprobes.h>
29 #include <linux/kref.h>
30 #include <lttng-cpuhotplug.h>
31 #include <wrapper/uuid.h>
32 #include <lttng-abi.h>
33 #include <lttng-abi-old.h>
34
35 #define lttng_is_signed_type(type) (((type)(-1)) < 0)
36
37 struct lttng_channel;
38 struct lttng_session;
39 struct lttng_metadata_cache;
40 struct lib_ring_buffer_ctx;
41 struct perf_event;
42 struct perf_event_attr;
43 struct lib_ring_buffer_config;
44
45 /* Type description */
46
47 enum abstract_types {
48 atype_integer,
49 atype_enum,
50 atype_array,
51 atype_sequence,
52 atype_string,
53 NR_ABSTRACT_TYPES,
54 };
55
56 enum lttng_string_encodings {
57 lttng_encode_none = 0,
58 lttng_encode_UTF8 = 1,
59 lttng_encode_ASCII = 2,
60 NR_STRING_ENCODINGS,
61 };
62
63 enum channel_type {
64 PER_CPU_CHANNEL,
65 METADATA_CHANNEL,
66 };
67
68 struct lttng_enum_entry {
69 unsigned long long start, end; /* start and end are inclusive */
70 const char *string;
71 };
72
73 #define __type_integer(_type, _size, _alignment, _signedness, \
74 _byte_order, _base, _encoding) \
75 { \
76 .atype = atype_integer, \
77 .u.basic.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 union _lttng_basic_type {
98 struct lttng_integer_type integer;
99 struct {
100 const char *name;
101 } enumeration;
102 struct {
103 enum lttng_string_encodings encoding;
104 } string;
105 };
106
107 struct lttng_basic_type {
108 enum abstract_types atype;
109 union {
110 union _lttng_basic_type basic;
111 } u;
112 };
113
114 struct lttng_type {
115 enum abstract_types atype;
116 union {
117 union _lttng_basic_type basic;
118 struct {
119 struct lttng_basic_type elem_type;
120 unsigned int length; /* num. elems. */
121 unsigned int elem_alignment; /* alignment override */
122 } array;
123 struct {
124 struct lttng_basic_type length_type;
125 struct lttng_basic_type elem_type;
126 unsigned int elem_alignment; /* alignment override */
127 } sequence;
128 } u;
129 };
130
131 struct lttng_enum {
132 const char *name;
133 struct lttng_type container_type;
134 const struct lttng_enum_entry *entries;
135 unsigned int len;
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 };
146
147 union lttng_ctx_value {
148 int64_t s64;
149 const char *str;
150 double d;
151 };
152
153 /*
154 * We need to keep this perf counter field separately from struct
155 * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
156 */
157 struct lttng_perf_counter_field {
158 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
159 struct lttng_cpuhp_node cpuhp_prepare;
160 struct lttng_cpuhp_node cpuhp_online;
161 #else
162 struct notifier_block nb;
163 int hp_enable;
164 #endif
165 struct perf_event_attr *attr;
166 struct perf_event **e; /* per-cpu array */
167 };
168
169 struct lttng_probe_ctx {
170 struct lttng_event *event;
171 uint8_t interruptible;
172 };
173
174 struct lttng_ctx_field {
175 struct lttng_event_field event_field;
176 size_t (*get_size)(size_t offset);
177 void (*record)(struct lttng_ctx_field *field,
178 struct lib_ring_buffer_ctx *ctx,
179 struct lttng_channel *chan);
180 void (*get_value)(struct lttng_ctx_field *field,
181 struct lttng_probe_ctx *lttng_probe_ctx,
182 union lttng_ctx_value *value);
183 union {
184 struct lttng_perf_counter_field *perf_counter;
185 } u;
186 void (*destroy)(struct lttng_ctx_field *field);
187 };
188
189 struct lttng_ctx {
190 struct lttng_ctx_field *fields;
191 unsigned int nr_fields;
192 unsigned int allocated_fields;
193 size_t largest_align; /* in bytes */
194 };
195
196 struct lttng_event_desc {
197 const char *name; /* lttng-modules name */
198 const char *kname; /* Linux kernel name (tracepoints) */
199 void *probe_callback;
200 const struct lttng_event_ctx *ctx; /* context */
201 const struct lttng_event_field *fields; /* event payload */
202 unsigned int nr_fields;
203 struct module *owner;
204 };
205
206 struct lttng_probe_desc {
207 const char *provider;
208 const struct lttng_event_desc **event_desc;
209 unsigned int nr_events;
210 struct list_head head; /* chain registered probes */
211 struct list_head lazy_init_head;
212 int lazy; /* lazy registration */
213 };
214
215 struct lttng_krp; /* Kretprobe handling */
216
217 enum lttng_event_type {
218 LTTNG_TYPE_EVENT = 0,
219 LTTNG_TYPE_ENABLER = 1,
220 };
221
222 struct lttng_filter_bytecode_node {
223 struct list_head node;
224 struct lttng_enabler *enabler;
225 /*
226 * struct lttng_kernel_filter_bytecode has var. sized array, must be
227 * last field.
228 */
229 struct lttng_kernel_filter_bytecode bc;
230 };
231
232 /*
233 * Filter return value masks.
234 */
235 enum lttng_filter_ret {
236 LTTNG_FILTER_DISCARD = 0,
237 LTTNG_FILTER_RECORD_FLAG = (1ULL << 0),
238 /* Other bits are kept for future use. */
239 };
240
241 struct lttng_bytecode_runtime {
242 /* Associated bytecode */
243 struct lttng_filter_bytecode_node *bc;
244 uint64_t (*filter)(void *filter_data, struct lttng_probe_ctx *lttng_probe_ctx,
245 const char *filter_stack_data);
246 int link_failed;
247 struct list_head node; /* list of bytecode runtime in event */
248 };
249
250 /*
251 * Objects in a linked-list of enablers, owned by an event.
252 */
253 struct lttng_enabler_ref {
254 struct list_head node; /* enabler ref list */
255 struct lttng_enabler *ref; /* backward ref */
256 };
257
258 /*
259 * lttng_event structure is referred to by the tracing fast path. It must be
260 * kept small.
261 */
262 struct lttng_event {
263 enum lttng_event_type evtype; /* First field. */
264 unsigned int id;
265 struct lttng_channel *chan;
266 int enabled;
267 const struct lttng_event_desc *desc;
268 void *filter;
269 struct lttng_ctx *ctx;
270 enum lttng_kernel_instrumentation instrumentation;
271 union {
272 struct {
273 struct kprobe kp;
274 char *symbol_name;
275 } kprobe;
276 struct {
277 struct lttng_krp *lttng_krp;
278 char *symbol_name;
279 } kretprobe;
280 struct {
281 char *symbol_name;
282 } ftrace;
283 } u;
284 struct list_head list; /* Event list in session */
285 unsigned int metadata_dumped:1;
286
287 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
288 struct list_head enablers_ref_head;
289 struct hlist_node hlist; /* session ht of events */
290 int registered; /* has reg'd tracepoint probe */
291 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
292 struct list_head bytecode_runtime_head;
293 int has_enablers_without_bytecode;
294 };
295
296 enum lttng_enabler_type {
297 LTTNG_ENABLER_WILDCARD,
298 LTTNG_ENABLER_NAME,
299 };
300
301 /*
302 * Enabler field, within whatever object is enabling an event. Target of
303 * backward reference.
304 */
305 struct lttng_enabler {
306 enum lttng_event_type evtype; /* First field. */
307
308 enum lttng_enabler_type type;
309
310 struct list_head node; /* per-session list of enablers */
311 /* head list of struct lttng_ust_filter_bytecode_node */
312 struct list_head filter_bytecode_head;
313
314 struct lttng_kernel_event event_param;
315 struct lttng_channel *chan;
316 struct lttng_ctx *ctx;
317 unsigned int enabled:1;
318 };
319
320 struct lttng_channel_ops {
321 struct channel *(*channel_create)(const char *name,
322 struct lttng_channel *lttng_chan,
323 void *buf_addr,
324 size_t subbuf_size, size_t num_subbuf,
325 unsigned int switch_timer_interval,
326 unsigned int read_timer_interval);
327 void (*channel_destroy)(struct channel *chan);
328 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
329 int (*buffer_has_read_closed_stream)(struct channel *chan);
330 void (*buffer_read_close)(struct lib_ring_buffer *buf);
331 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
332 uint32_t event_id);
333 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
334 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
335 size_t len);
336 void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx,
337 const void *src, size_t len);
338 void (*event_memset)(struct lib_ring_buffer_ctx *ctx,
339 int c, size_t len);
340 void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src,
341 size_t len);
342 void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx,
343 const char __user *src, size_t len);
344 /*
345 * packet_avail_size returns the available size in the current
346 * packet. Note that the size returned is only a hint, since it
347 * may change due to concurrent writes.
348 */
349 size_t (*packet_avail_size)(struct channel *chan);
350 wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
351 wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
352 int (*is_finalized)(struct channel *chan);
353 int (*is_disabled)(struct channel *chan);
354 int (*timestamp_begin) (const struct lib_ring_buffer_config *config,
355 struct lib_ring_buffer *bufb,
356 uint64_t *timestamp_begin);
357 int (*timestamp_end) (const struct lib_ring_buffer_config *config,
358 struct lib_ring_buffer *bufb,
359 uint64_t *timestamp_end);
360 int (*events_discarded) (const struct lib_ring_buffer_config *config,
361 struct lib_ring_buffer *bufb,
362 uint64_t *events_discarded);
363 int (*content_size) (const struct lib_ring_buffer_config *config,
364 struct lib_ring_buffer *bufb,
365 uint64_t *content_size);
366 int (*packet_size) (const struct lib_ring_buffer_config *config,
367 struct lib_ring_buffer *bufb,
368 uint64_t *packet_size);
369 int (*stream_id) (const struct lib_ring_buffer_config *config,
370 struct lib_ring_buffer *bufb,
371 uint64_t *stream_id);
372 int (*current_timestamp) (const struct lib_ring_buffer_config *config,
373 struct lib_ring_buffer *bufb,
374 uint64_t *ts);
375 int (*sequence_number) (const struct lib_ring_buffer_config *config,
376 struct lib_ring_buffer *bufb,
377 uint64_t *seq);
378 int (*instance_id) (const struct lib_ring_buffer_config *config,
379 struct lib_ring_buffer *bufb,
380 uint64_t *id);
381 };
382
383 struct lttng_transport {
384 char *name;
385 struct module *owner;
386 struct list_head node;
387 struct lttng_channel_ops ops;
388 };
389
390 struct lttng_syscall_filter;
391
392 #define LTTNG_EVENT_HT_BITS 12
393 #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
394
395 struct lttng_event_ht {
396 struct hlist_head table[LTTNG_EVENT_HT_SIZE];
397 };
398
399 struct lttng_channel {
400 unsigned int id;
401 struct channel *chan; /* Channel buffers */
402 int enabled;
403 struct lttng_ctx *ctx;
404 /* Event ID management */
405 struct lttng_session *session;
406 struct file *file; /* File associated to channel */
407 unsigned int free_event_id; /* Next event ID to allocate */
408 struct list_head list; /* Channel list */
409 struct lttng_channel_ops *ops;
410 struct lttng_transport *transport;
411 struct lttng_event **sc_table; /* for syscall tracing */
412 struct lttng_event **compat_sc_table;
413 struct lttng_event **sc_exit_table; /* for syscall exit tracing */
414 struct lttng_event **compat_sc_exit_table;
415 struct lttng_event *sc_unknown; /* for unknown syscalls */
416 struct lttng_event *sc_compat_unknown;
417 struct lttng_event *sc_exit_unknown;
418 struct lttng_event *compat_sc_exit_unknown;
419 struct lttng_syscall_filter *sc_filter;
420 int header_type; /* 0: unset, 1: compact, 2: large */
421 enum channel_type channel_type;
422 unsigned int metadata_dumped:1,
423 sys_enter_registered:1,
424 sys_exit_registered:1,
425 syscall_all:1,
426 tstate:1; /* Transient enable state */
427 };
428
429 struct lttng_metadata_stream {
430 void *priv; /* Ring buffer private data */
431 struct lttng_metadata_cache *metadata_cache;
432 unsigned int metadata_in; /* Bytes read from the cache */
433 unsigned int metadata_out; /* Bytes consumed from stream */
434 int finalized; /* Has channel been finalized */
435 wait_queue_head_t read_wait; /* Reader buffer-level wait queue */
436 struct list_head list; /* Stream list */
437 struct lttng_transport *transport;
438 uint64_t version; /* Current version of the metadata cache */
439 };
440
441
442 /*
443 * struct lttng_pid_tracker declared in header due to deferencing of *v
444 * in RCU_INITIALIZER(v).
445 */
446 #define LTTNG_PID_HASH_BITS 6
447 #define LTTNG_PID_TABLE_SIZE (1 << LTTNG_PID_HASH_BITS)
448
449 struct lttng_pid_tracker {
450 struct hlist_head pid_hash[LTTNG_PID_TABLE_SIZE];
451 };
452
453 struct lttng_pid_hash_node {
454 struct hlist_node hlist;
455 int pid;
456 };
457
458 struct lttng_session {
459 int active; /* Is trace session active ? */
460 int been_active; /* Has trace session been active ? */
461 struct file *file; /* File associated to session */
462 struct list_head chan; /* Channel list head */
463 struct list_head events; /* Event list head */
464 struct list_head list; /* Session list */
465 unsigned int free_chan_id; /* Next chan ID to allocate */
466 uuid_le uuid; /* Trace session unique ID */
467 struct lttng_metadata_cache *metadata_cache;
468 struct lttng_pid_tracker *pid_tracker;
469 unsigned int metadata_dumped:1,
470 tstate:1; /* Transient enable state */
471 /* List of enablers */
472 struct list_head enablers_head;
473 /* Hash table of events */
474 struct lttng_event_ht events_ht;
475 };
476
477 struct lttng_metadata_cache {
478 char *data; /* Metadata cache */
479 unsigned int cache_alloc; /* Metadata allocated size (bytes) */
480 unsigned int metadata_written; /* Number of bytes written in metadata cache */
481 struct kref refcount; /* Metadata cache usage */
482 struct list_head metadata_stream; /* Metadata stream list */
483 uuid_le uuid; /* Trace session unique ID (copy) */
484 struct mutex lock; /* Produce/consume lock */
485 uint64_t version; /* Current version of the metadata */
486 };
487
488 void lttng_lock_sessions(void);
489 void lttng_unlock_sessions(void);
490
491 struct list_head *lttng_get_probe_list_head(void);
492
493 struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type,
494 struct lttng_kernel_event *event_param,
495 struct lttng_channel *chan);
496
497 int lttng_enabler_enable(struct lttng_enabler *enabler);
498 int lttng_enabler_disable(struct lttng_enabler *enabler);
499 int lttng_fix_pending_events(void);
500 int lttng_session_active(void);
501
502 struct lttng_session *lttng_session_create(void);
503 int lttng_session_enable(struct lttng_session *session);
504 int lttng_session_disable(struct lttng_session *session);
505 void lttng_session_destroy(struct lttng_session *session);
506 int lttng_session_metadata_regenerate(struct lttng_session *session);
507 void metadata_cache_destroy(struct kref *kref);
508
509 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
510 const char *transport_name,
511 void *buf_addr,
512 size_t subbuf_size, size_t num_subbuf,
513 unsigned int switch_timer_interval,
514 unsigned int read_timer_interval,
515 enum channel_type channel_type);
516 struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
517 int overwrite, void *buf_addr,
518 size_t subbuf_size, size_t num_subbuf,
519 unsigned int switch_timer_interval,
520 unsigned int read_timer_interval);
521
522 void lttng_metadata_channel_destroy(struct lttng_channel *chan);
523 struct lttng_event *lttng_event_create(struct lttng_channel *chan,
524 struct lttng_kernel_event *event_param,
525 void *filter,
526 const struct lttng_event_desc *event_desc,
527 enum lttng_kernel_instrumentation itype);
528 struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
529 struct lttng_kernel_event *event_param,
530 void *filter,
531 const struct lttng_event_desc *event_desc,
532 enum lttng_kernel_instrumentation itype);
533 struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
534 struct lttng_kernel_old_event *old_event_param,
535 void *filter,
536 const struct lttng_event_desc *internal_desc);
537
538 int lttng_channel_enable(struct lttng_channel *channel);
539 int lttng_channel_disable(struct lttng_channel *channel);
540 int lttng_event_enable(struct lttng_event *event);
541 int lttng_event_disable(struct lttng_event *event);
542
543 void lttng_transport_register(struct lttng_transport *transport);
544 void lttng_transport_unregister(struct lttng_transport *transport);
545
546 void synchronize_trace(void);
547 int lttng_abi_init(void);
548 int lttng_abi_compat_old_init(void);
549 void lttng_abi_exit(void);
550 void lttng_abi_compat_old_exit(void);
551
552 int lttng_probe_register(struct lttng_probe_desc *desc);
553 void lttng_probe_unregister(struct lttng_probe_desc *desc);
554 const struct lttng_event_desc *lttng_event_get(const char *name);
555 void lttng_event_put(const struct lttng_event_desc *desc);
556 int lttng_probes_init(void);
557 void lttng_probes_exit(void);
558
559 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
560 struct channel *chan);
561
562 int lttng_pid_tracker_get_node_pid(const struct lttng_pid_hash_node *node);
563 struct lttng_pid_tracker *lttng_pid_tracker_create(void);
564 void lttng_pid_tracker_destroy(struct lttng_pid_tracker *lpf);
565 bool lttng_pid_tracker_lookup(struct lttng_pid_tracker *lpf, int pid);
566 int lttng_pid_tracker_add(struct lttng_pid_tracker *lpf, int pid);
567 int lttng_pid_tracker_del(struct lttng_pid_tracker *lpf, int pid);
568
569 int lttng_session_track_pid(struct lttng_session *session, int pid);
570 int lttng_session_untrack_pid(struct lttng_session *session, int pid);
571
572 int lttng_session_list_tracker_pids(struct lttng_session *session);
573
574 void lttng_clock_ref(void);
575 void lttng_clock_unref(void);
576
577 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
578 int lttng_syscalls_register(struct lttng_channel *chan, void *filter);
579 int lttng_syscalls_unregister(struct lttng_channel *chan);
580 int lttng_syscall_filter_enable(struct lttng_channel *chan,
581 const char *name);
582 int lttng_syscall_filter_disable(struct lttng_channel *chan,
583 const char *name);
584 long lttng_channel_syscall_mask(struct lttng_channel *channel,
585 struct lttng_kernel_syscall_mask __user *usyscall_mask);
586 #else
587 static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
588 {
589 return -ENOSYS;
590 }
591
592 static inline int lttng_syscalls_unregister(struct lttng_channel *chan)
593 {
594 return 0;
595 }
596
597 static inline int lttng_syscall_filter_enable(struct lttng_channel *chan,
598 const char *name)
599 {
600 return -ENOSYS;
601 }
602
603 static inline int lttng_syscall_filter_disable(struct lttng_channel *chan,
604 const char *name)
605 {
606 return -ENOSYS;
607 }
608
609 static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
610 struct lttng_kernel_syscall_mask __user *usyscall_mask)
611 {
612 return -ENOSYS;
613 }
614 #endif
615
616 void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
617 int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
618 struct lttng_kernel_filter_bytecode __user *bytecode);
619 void lttng_enabler_event_link_bytecode(struct lttng_event *event,
620 struct lttng_enabler *enabler);
621
622 extern struct lttng_ctx *lttng_static_ctx;
623
624 int lttng_context_init(void);
625 void lttng_context_exit(void);
626 struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
627 void lttng_context_update(struct lttng_ctx *ctx);
628 int lttng_find_context(struct lttng_ctx *ctx, const char *name);
629 int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
630 void lttng_remove_context_field(struct lttng_ctx **ctx,
631 struct lttng_ctx_field *field);
632 void lttng_destroy_context(struct lttng_ctx *ctx);
633 int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
634 int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
635 int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
636 int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
637 int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
638 int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
639 int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
640 int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
641 int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
642 int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
643 int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
644 int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx);
645 int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx);
646 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
647 int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx);
648 #else
649 static inline
650 int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
651 {
652 return -ENOSYS;
653 }
654 #endif
655 #ifdef CONFIG_PREEMPT_RT_FULL
656 int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx);
657 #else
658 static inline
659 int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
660 {
661 return -ENOSYS;
662 }
663 #endif
664 #if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
665 int lttng_add_perf_counter_to_ctx(uint32_t type,
666 uint64_t config,
667 const char *name,
668 struct lttng_ctx **ctx);
669 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
670 struct lttng_cpuhp_node *node);
671 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
672 struct lttng_cpuhp_node *node);
673 #else
674 static inline
675 int lttng_add_perf_counter_to_ctx(uint32_t type,
676 uint64_t config,
677 const char *name,
678 struct lttng_ctx **ctx)
679 {
680 return -ENOSYS;
681 }
682 static inline
683 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
684 struct lttng_cpuhp_node *node)
685 {
686 return 0;
687 }
688 static inline
689 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
690 struct lttng_cpuhp_node *node)
691 {
692 return 0;
693 }
694 #endif
695
696 int lttng_logger_init(void);
697 void lttng_logger_exit(void);
698
699 extern int lttng_statedump_start(struct lttng_session *session);
700
701 #ifdef CONFIG_KPROBES
702 int lttng_kprobes_register(const char *name,
703 const char *symbol_name,
704 uint64_t offset,
705 uint64_t addr,
706 struct lttng_event *event);
707 void lttng_kprobes_unregister(struct lttng_event *event);
708 void lttng_kprobes_destroy_private(struct lttng_event *event);
709 #else
710 static inline
711 int lttng_kprobes_register(const char *name,
712 const char *symbol_name,
713 uint64_t offset,
714 uint64_t addr,
715 struct lttng_event *event)
716 {
717 return -ENOSYS;
718 }
719
720 static inline
721 void lttng_kprobes_unregister(struct lttng_event *event)
722 {
723 }
724
725 static inline
726 void lttng_kprobes_destroy_private(struct lttng_event *event)
727 {
728 }
729 #endif
730
731 #ifdef CONFIG_KRETPROBES
732 int lttng_kretprobes_register(const char *name,
733 const char *symbol_name,
734 uint64_t offset,
735 uint64_t addr,
736 struct lttng_event *event_entry,
737 struct lttng_event *event_exit);
738 void lttng_kretprobes_unregister(struct lttng_event *event);
739 void lttng_kretprobes_destroy_private(struct lttng_event *event);
740 int lttng_kretprobes_event_enable_state(struct lttng_event *event,
741 int enable);
742 #else
743 static inline
744 int lttng_kretprobes_register(const char *name,
745 const char *symbol_name,
746 uint64_t offset,
747 uint64_t addr,
748 struct lttng_event *event_entry,
749 struct lttng_event *event_exit)
750 {
751 return -ENOSYS;
752 }
753
754 static inline
755 void lttng_kretprobes_unregister(struct lttng_event *event)
756 {
757 }
758
759 static inline
760 void lttng_kretprobes_destroy_private(struct lttng_event *event)
761 {
762 }
763
764 static inline
765 int lttng_kretprobes_event_enable_state(struct lttng_event *event,
766 int enable)
767 {
768 return -ENOSYS;
769 }
770 #endif
771
772 #if defined(CONFIG_DYNAMIC_FTRACE) && !defined(LTTNG_FTRACE_MISSING_HEADER)
773 int lttng_ftrace_register(const char *name,
774 const char *symbol_name,
775 struct lttng_event *event);
776 void lttng_ftrace_unregister(struct lttng_event *event);
777 void lttng_ftrace_destroy_private(struct lttng_event *event);
778 #else
779 static inline
780 int lttng_ftrace_register(const char *name,
781 const char *symbol_name,
782 struct lttng_event *event)
783 {
784 return -ENOSYS;
785 }
786
787 static inline
788 void lttng_ftrace_unregister(struct lttng_event *event)
789 {
790 }
791
792 static inline
793 void lttng_ftrace_destroy_private(struct lttng_event *event)
794 {
795 }
796 #endif
797
798 int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
799
800 extern const struct file_operations lttng_tracepoint_list_fops;
801 extern const struct file_operations lttng_syscall_list_fops;
802
803 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
804 #define TRACEPOINT_HAS_DATA_ARG
805 #endif
806
807 #endif /* _LTTNG_EVENTS_H */
This page took 0.043566 seconds and 4 git commands to generate.