Commit | Line | Data |
---|---|---|
92bc1e23 MD |
1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
2 | * | |
3 | * lttng/events-internal.h | |
4 | * | |
5 | * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
6 | */ | |
7 | ||
8 | #ifndef _LTTNG_EVENTS_INTERNAL_H | |
9 | #define _LTTNG_EVENTS_INTERNAL_H | |
10 | ||
c570be0d | 11 | #include <wrapper/compiler_attributes.h> |
b3756eaa | 12 | #include <wrapper/uuid.h> |
c570be0d | 13 | |
437d5aa5 MD |
14 | #include <lttng/events.h> |
15 | ||
71aef1c1 | 16 | struct lttng_syscall_filter; |
bdd23a70 MD |
17 | struct lttng_metadata_cache; |
18 | struct perf_event; | |
19 | struct perf_event_attr; | |
a2a1b5ab | 20 | struct lttng_kernel_ring_buffer_config; |
71aef1c1 | 21 | |
255a028a MD |
22 | enum lttng_enabler_format_type { |
23 | LTTNG_ENABLER_FORMAT_STAR_GLOB, | |
24 | LTTNG_ENABLER_FORMAT_NAME, | |
25 | }; | |
26 | ||
ac847066 MD |
27 | enum channel_type { |
28 | PER_CPU_CHANNEL, | |
29 | METADATA_CHANNEL, | |
30 | }; | |
31 | ||
255a028a MD |
32 | /* |
33 | * Objects in a linked-list of enablers, owned by an event. | |
34 | */ | |
35 | struct lttng_enabler_ref { | |
36 | struct list_head node; /* enabler ref list */ | |
37 | struct lttng_enabler *ref; /* backward ref */ | |
38 | }; | |
39 | ||
0dba22ad MD |
40 | struct lttng_krp; /* Kretprobe handling */ |
41 | ||
42 | struct lttng_uprobe_handler { | |
43 | struct lttng_kernel_event_common *event; | |
44 | loff_t offset; | |
45 | struct uprobe_consumer up_consumer; | |
46 | struct list_head node; | |
47 | }; | |
48 | ||
49 | struct lttng_kprobe { | |
50 | struct kprobe kp; | |
51 | char *symbol_name; | |
52 | }; | |
53 | ||
54 | struct lttng_uprobe { | |
55 | struct inode *inode; | |
56 | struct list_head head; | |
57 | }; | |
58 | ||
59 | enum lttng_syscall_entryexit { | |
60 | LTTNG_SYSCALL_ENTRY, | |
61 | LTTNG_SYSCALL_EXIT, | |
62 | }; | |
63 | ||
64 | enum lttng_syscall_abi { | |
65 | LTTNG_SYSCALL_ABI_NATIVE, | |
66 | LTTNG_SYSCALL_ABI_COMPAT, | |
67 | }; | |
68 | ||
a67ba386 MD |
69 | struct lttng_kernel_event_common_private { |
70 | struct lttng_kernel_event_common *pub; /* Public event interface */ | |
71 | ||
72 | const struct lttng_kernel_event_desc *desc; | |
73 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ | |
74 | struct list_head enablers_ref_head; | |
75 | int registered; /* has reg'd tracepoint probe */ | |
76 | uint64_t user_token; | |
77 | ||
78 | int has_enablers_without_filter_bytecode; | |
dc7350d6 | 79 | /* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */ |
a67ba386 MD |
80 | struct list_head filter_bytecode_runtime_head; |
81 | enum lttng_kernel_abi_instrumentation instrumentation; | |
82 | /* Selected by instrumentation */ | |
83 | union { | |
84 | struct lttng_kprobe kprobe; | |
85 | struct lttng_uprobe uprobe; | |
86 | struct { | |
87 | struct lttng_krp *lttng_krp; | |
88 | char *symbol_name; | |
89 | } kretprobe; | |
90 | struct { | |
91 | enum lttng_syscall_entryexit entryexit; | |
92 | enum lttng_syscall_abi abi; | |
93 | struct hlist_node node; /* chain registered syscall event_notifier */ | |
94 | unsigned int syscall_id; | |
95 | } syscall; | |
96 | } u; | |
97 | }; | |
98 | ||
99 | struct lttng_kernel_event_recorder_private { | |
100 | struct lttng_kernel_event_common_private parent; | |
101 | ||
102 | struct lttng_kernel_event_recorder *pub; /* Public event interface */ | |
103 | struct list_head node; /* Event recorder list */ | |
104 | struct hlist_node hlist; /* Hash table of event recorders */ | |
105 | struct lttng_kernel_ctx *ctx; | |
106 | unsigned int id; | |
107 | unsigned int metadata_dumped:1; | |
108 | }; | |
109 | ||
110 | struct lttng_kernel_event_notifier_private { | |
111 | struct lttng_kernel_event_common_private parent; | |
112 | ||
113 | struct lttng_kernel_event_notifier *pub; /* Public event notifier interface */ | |
114 | struct lttng_event_notifier_group *group; /* weak ref */ | |
115 | size_t num_captures; /* Needed to allocate the msgpack array. */ | |
116 | uint64_t error_counter_index; | |
117 | struct list_head node; /* Event notifier list */ | |
118 | struct hlist_node hlist; /* Hash table of event notifiers */ | |
119 | struct list_head capture_bytecode_runtime_head; | |
120 | ||
121 | }; | |
122 | ||
ac847066 MD |
123 | struct lttng_kernel_channel_common_private { |
124 | struct lttng_kernel_channel_common *pub; | |
125 | ||
126 | struct file *file; /* File associated to channel */ | |
127 | unsigned int sys_enter_registered:1, | |
128 | sys_exit_registered:1, | |
129 | tstate:1; /* Transient enable state */ | |
130 | ||
131 | struct hlist_head *sc_table; /* for syscall tracing */ | |
132 | struct hlist_head *compat_sc_table; | |
133 | struct hlist_head *sc_exit_table; /* for syscall exit tracing */ | |
134 | struct hlist_head *compat_sc_exit_table; | |
135 | struct hlist_head sc_unknown; /* for unknown syscalls */ | |
136 | struct hlist_head sc_compat_unknown; | |
137 | struct hlist_head sc_exit_unknown; | |
138 | struct hlist_head compat_sc_exit_unknown; | |
139 | struct lttng_syscall_filter *sc_filter; | |
140 | int syscall_all_entry; | |
141 | int syscall_all_exit; | |
142 | }; | |
143 | ||
144 | struct lttng_kernel_channel_buffer_private { | |
145 | struct lttng_kernel_channel_common_private parent; | |
146 | ||
147 | struct lttng_kernel_channel_buffer *pub; | |
148 | ||
149 | unsigned int id; /* Channel ID */ | |
150 | unsigned int free_event_id; /* Next event ID to allocate */ | |
151 | int header_type; /* 0: unset, 1: compact, 2: large */ | |
152 | ||
153 | enum channel_type channel_type; | |
154 | struct lttng_kernel_ctx *ctx; | |
4071a628 | 155 | struct lttng_kernel_ring_buffer_channel *rb_chan; /* Ring buffer channel */ |
ac847066 MD |
156 | unsigned int metadata_dumped:1; |
157 | struct list_head node; /* Channel list in session */ | |
158 | struct lttng_transport *transport; | |
159 | }; | |
160 | ||
8a445457 MD |
161 | enum lttng_kernel_bytecode_interpreter_ret { |
162 | LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR = -1, | |
163 | LTTNG_KERNEL_BYTECODE_INTERPRETER_OK = 0, | |
164 | }; | |
165 | ||
166 | enum lttng_kernel_bytecode_filter_result { | |
167 | LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT = 0, | |
168 | LTTNG_KERNEL_BYTECODE_FILTER_REJECT = 1, | |
169 | }; | |
170 | ||
171 | struct lttng_kernel_bytecode_filter_ctx { | |
172 | enum lttng_kernel_bytecode_filter_result result; | |
173 | }; | |
174 | ||
478a7793 MD |
175 | struct lttng_interpreter_output; |
176 | ||
177 | enum lttng_kernel_bytecode_type { | |
178 | LTTNG_KERNEL_BYTECODE_TYPE_FILTER, | |
179 | LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE, | |
180 | }; | |
181 | ||
182 | struct lttng_kernel_bytecode_node { | |
183 | enum lttng_kernel_bytecode_type type; | |
184 | struct list_head node; | |
185 | struct lttng_enabler *enabler; | |
186 | struct { | |
187 | uint32_t len; | |
188 | uint32_t reloc_offset; | |
189 | uint64_t seqnum; | |
190 | char data[]; | |
191 | } bc; | |
192 | }; | |
193 | ||
194 | struct lttng_kernel_bytecode_runtime { | |
195 | /* Associated bytecode */ | |
196 | enum lttng_kernel_bytecode_type type; | |
197 | struct lttng_kernel_bytecode_node *bc; | |
198 | int (*interpreter_func)(struct lttng_kernel_bytecode_runtime *kernel_bytecode, | |
199 | const char *interpreter_stack_data, | |
200 | struct lttng_kernel_probe_ctx *lttng_probe_ctx, | |
201 | void *caller_ctx); | |
202 | int link_failed; | |
203 | struct list_head node; /* list of bytecode runtime in event */ | |
204 | struct lttng_kernel_ctx *ctx; | |
205 | }; | |
206 | ||
b8b4704b MD |
207 | /* |
208 | * Enabler field, within whatever object is enabling an event. Target of | |
209 | * backward reference. | |
210 | */ | |
211 | struct lttng_enabler { | |
212 | enum lttng_enabler_format_type format_type; | |
213 | ||
9906b046 | 214 | /* head list of struct lttng_kernel_bytecode_node */ |
b8b4704b MD |
215 | struct list_head filter_bytecode_head; |
216 | ||
217 | struct lttng_kernel_abi_event event_param; | |
218 | unsigned int enabled:1; | |
219 | ||
220 | uint64_t user_token; /* User-provided token. */ | |
221 | }; | |
222 | ||
223 | struct lttng_event_enabler { | |
224 | struct lttng_enabler base; | |
225 | struct list_head node; /* per-session list of enablers */ | |
ac847066 | 226 | struct lttng_kernel_channel_buffer *chan; |
b8b4704b MD |
227 | }; |
228 | ||
229 | struct lttng_event_notifier_enabler { | |
230 | struct lttng_enabler base; | |
231 | uint64_t error_counter_index; | |
232 | struct list_head node; /* List of event_notifier enablers */ | |
233 | struct lttng_event_notifier_group *group; | |
234 | ||
9906b046 | 235 | /* head list of struct lttng_kernel_bytecode_node */ |
b8b4704b MD |
236 | struct list_head capture_bytecode_head; |
237 | uint64_t num_captures; | |
238 | }; | |
239 | ||
7207017d MD |
240 | struct lttng_ctx_value { |
241 | union { | |
242 | int64_t s64; | |
243 | const char *str; | |
244 | double d; | |
245 | } u; | |
246 | }; | |
247 | ||
248 | /* | |
249 | * We need to keep this perf counter field separately from struct | |
250 | * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses. | |
251 | */ | |
252 | struct lttng_perf_counter_field { | |
253 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) | |
254 | struct lttng_cpuhp_node cpuhp_prepare; | |
255 | struct lttng_cpuhp_node cpuhp_online; | |
256 | #else | |
257 | struct notifier_block nb; | |
258 | int hp_enable; | |
259 | #endif | |
260 | struct perf_event_attr *attr; | |
261 | struct perf_event **e; /* per-cpu array */ | |
262 | char *name; | |
263 | struct lttng_kernel_event_field *event_field; | |
264 | }; | |
265 | ||
266 | struct lttng_kernel_ctx_field { | |
267 | const struct lttng_kernel_event_field *event_field; | |
346cb5ee | 268 | size_t (*get_size)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
7207017d | 269 | size_t offset); |
346cb5ee | 270 | void (*record)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
e27e4381 | 271 | struct lttng_kernel_ring_buffer_ctx *ctx, |
ac847066 | 272 | struct lttng_kernel_channel_buffer *chan); |
346cb5ee | 273 | void (*get_value)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
7207017d MD |
274 | struct lttng_ctx_value *value); |
275 | void (*destroy)(void *priv); | |
276 | void *priv; | |
277 | }; | |
278 | ||
279 | struct lttng_kernel_ctx { | |
280 | struct lttng_kernel_ctx_field *fields; | |
281 | unsigned int nr_fields; | |
282 | unsigned int allocated_fields; | |
283 | size_t largest_align; /* in bytes */ | |
284 | }; | |
285 | ||
a8605b84 MD |
286 | struct lttng_metadata_cache { |
287 | char *data; /* Metadata cache */ | |
288 | unsigned int cache_alloc; /* Metadata allocated size (bytes) */ | |
289 | unsigned int metadata_written; /* Number of bytes written in metadata cache */ | |
290 | atomic_t producing; /* Metadata being produced (incomplete) */ | |
291 | struct kref refcount; /* Metadata cache usage */ | |
292 | struct list_head metadata_stream; /* Metadata stream list */ | |
b3756eaa | 293 | guid_t uuid; /* Trace session unique ID (copy) */ |
a8605b84 MD |
294 | struct mutex lock; /* Produce/consume lock */ |
295 | uint64_t version; /* Current version of the metadata */ | |
296 | }; | |
297 | ||
9a4deef1 MD |
298 | struct lttng_metadata_stream { |
299 | void *priv; /* Ring buffer private data */ | |
300 | struct lttng_metadata_cache *metadata_cache; | |
301 | unsigned int metadata_in; /* Bytes read from the cache */ | |
302 | unsigned int metadata_out; /* Bytes consumed from stream */ | |
303 | int finalized; /* Has channel been finalized */ | |
304 | wait_queue_head_t read_wait; /* Reader buffer-level wait queue */ | |
305 | struct list_head list; /* Stream list */ | |
306 | struct lttng_transport *transport; | |
307 | uint64_t version; /* Current version of the metadata cache */ | |
308 | bool coherent; /* Stream in a coherent state */ | |
309 | }; | |
310 | ||
da1fe18f MD |
311 | struct lttng_kernel_channel_buffer_ops_private { |
312 | struct lttng_kernel_channel_buffer_ops *pub; /* Public channel buffer ops interface */ | |
313 | ||
4071a628 | 314 | struct lttng_kernel_ring_buffer_channel *(*channel_create)(const char *name, |
da1fe18f MD |
315 | void *priv, |
316 | void *buf_addr, | |
317 | size_t subbuf_size, size_t num_subbuf, | |
318 | unsigned int switch_timer_interval, | |
319 | unsigned int read_timer_interval); | |
4071a628 | 320 | void (*channel_destroy)(struct lttng_kernel_ring_buffer_channel *chan); |
a2a1b5ab | 321 | struct lttng_kernel_ring_buffer *(*buffer_read_open)(struct lttng_kernel_ring_buffer_channel *chan); |
4071a628 | 322 | int (*buffer_has_read_closed_stream)(struct lttng_kernel_ring_buffer_channel *chan); |
a2a1b5ab | 323 | void (*buffer_read_close)(struct lttng_kernel_ring_buffer *buf); |
da1fe18f MD |
324 | /* |
325 | * packet_avail_size returns the available size in the current | |
326 | * packet. Note that the size returned is only a hint, since it | |
327 | * may change due to concurrent writes. | |
328 | */ | |
4071a628 MD |
329 | size_t (*packet_avail_size)(struct lttng_kernel_ring_buffer_channel *chan); |
330 | wait_queue_head_t *(*get_writer_buf_wait_queue)(struct lttng_kernel_ring_buffer_channel *chan, int cpu); | |
331 | wait_queue_head_t *(*get_hp_wait_queue)(struct lttng_kernel_ring_buffer_channel *chan); | |
332 | int (*is_finalized)(struct lttng_kernel_ring_buffer_channel *chan); | |
333 | int (*is_disabled)(struct lttng_kernel_ring_buffer_channel *chan); | |
a2a1b5ab MD |
334 | int (*timestamp_begin) (const struct lttng_kernel_ring_buffer_config *config, |
335 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f | 336 | uint64_t *timestamp_begin); |
a2a1b5ab MD |
337 | int (*timestamp_end) (const struct lttng_kernel_ring_buffer_config *config, |
338 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f | 339 | uint64_t *timestamp_end); |
a2a1b5ab MD |
340 | int (*events_discarded) (const struct lttng_kernel_ring_buffer_config *config, |
341 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f | 342 | uint64_t *events_discarded); |
a2a1b5ab MD |
343 | int (*content_size) (const struct lttng_kernel_ring_buffer_config *config, |
344 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f | 345 | uint64_t *content_size); |
a2a1b5ab MD |
346 | int (*packet_size) (const struct lttng_kernel_ring_buffer_config *config, |
347 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f | 348 | uint64_t *packet_size); |
a2a1b5ab MD |
349 | int (*stream_id) (const struct lttng_kernel_ring_buffer_config *config, |
350 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f | 351 | uint64_t *stream_id); |
a2a1b5ab MD |
352 | int (*current_timestamp) (const struct lttng_kernel_ring_buffer_config *config, |
353 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f | 354 | uint64_t *ts); |
a2a1b5ab MD |
355 | int (*sequence_number) (const struct lttng_kernel_ring_buffer_config *config, |
356 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f | 357 | uint64_t *seq); |
a2a1b5ab MD |
358 | int (*instance_id) (const struct lttng_kernel_ring_buffer_config *config, |
359 | struct lttng_kernel_ring_buffer *bufb, | |
da1fe18f MD |
360 | uint64_t *id); |
361 | }; | |
362 | ||
e71f3cec MD |
363 | struct lttng_counter_ops { |
364 | struct lib_counter *(*counter_create)(size_t nr_dimensions, | |
365 | const size_t *max_nr_elem, /* for each dimension */ | |
366 | int64_t global_sum_step); | |
367 | void (*counter_destroy)(struct lib_counter *counter); | |
368 | int (*counter_add)(struct lib_counter *counter, const size_t *dimension_indexes, | |
369 | int64_t v); | |
370 | /* | |
371 | * counter_read reads a specific cpu's counter if @cpu >= 0, or | |
372 | * the global aggregation counter if @cpu == -1. | |
373 | */ | |
374 | int (*counter_read)(struct lib_counter *counter, const size_t *dimension_indexes, int cpu, | |
375 | int64_t *value, bool *overflow, bool *underflow); | |
376 | /* | |
377 | * counter_aggregate returns the total sum of all per-cpu counters and | |
378 | * the global aggregation counter. | |
379 | */ | |
380 | int (*counter_aggregate)(struct lib_counter *counter, const size_t *dimension_indexes, | |
381 | int64_t *value, bool *overflow, bool *underflow); | |
382 | int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes); | |
383 | }; | |
384 | ||
385 | struct lttng_counter { | |
386 | struct file *file; /* File associated to counter. */ | |
387 | struct file *owner; | |
388 | struct lttng_counter_transport *transport; | |
389 | struct lib_counter *counter; | |
390 | struct lttng_counter_ops *ops; | |
391 | }; | |
392 | ||
fc2778a7 MD |
393 | #define LTTNG_EVENT_NOTIFIER_HT_BITS 12 |
394 | #define LTTNG_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_EVENT_NOTIFIER_HT_BITS) | |
395 | ||
396 | struct lttng_event_notifier_ht { | |
397 | struct hlist_head table[LTTNG_EVENT_NOTIFIER_HT_SIZE]; | |
398 | }; | |
399 | ||
e71f3cec MD |
400 | struct lttng_event_notifier_group { |
401 | struct file *file; /* File associated to event notifier group */ | |
402 | struct file *notif_file; /* File used to expose notifications to userspace. */ | |
403 | struct list_head node; /* event notifier group list */ | |
404 | struct list_head enablers_head; /* List of enablers */ | |
405 | struct list_head event_notifiers_head; /* List of event notifier */ | |
406 | struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */ | |
407 | struct lttng_kernel_channel_buffer_ops *ops; | |
408 | struct lttng_transport *transport; | |
4071a628 | 409 | struct lttng_kernel_ring_buffer_channel *chan; /* Ring buffer channel for event notifier group. */ |
a2a1b5ab | 410 | struct lttng_kernel_ring_buffer *buf; /* Ring buffer for event notifier group. */ |
e71f3cec MD |
411 | wait_queue_head_t read_wait; |
412 | struct irq_work wakeup_pending; /* Pending wakeup irq work. */ | |
413 | struct lttng_kernel_event_notifier *sc_unknown; /* for unknown syscalls */ | |
414 | struct lttng_kernel_event_notifier *sc_compat_unknown; | |
415 | ||
416 | struct lttng_syscall_filter *sc_filter; | |
417 | ||
418 | struct hlist_head *event_notifier_syscall_dispatch; | |
419 | struct hlist_head *event_notifier_compat_syscall_dispatch; | |
420 | struct hlist_head *event_notifier_exit_syscall_dispatch; | |
421 | struct hlist_head *event_notifier_exit_compat_syscall_dispatch; | |
422 | ||
423 | struct hlist_head event_notifier_unknown_syscall_dispatch; | |
424 | struct hlist_head event_notifier_compat_unknown_syscall_dispatch; | |
425 | struct hlist_head event_notifier_exit_unknown_syscall_dispatch; | |
426 | struct hlist_head event_notifier_exit_compat_unknown_syscall_dispatch; | |
427 | ||
428 | int syscall_all_entry; | |
429 | int syscall_all_exit; | |
430 | ||
431 | unsigned int sys_enter_registered:1, sys_exit_registered:1; | |
432 | ||
433 | struct lttng_counter *error_counter; | |
434 | size_t error_counter_len; | |
435 | }; | |
436 | ||
437 | struct lttng_transport { | |
438 | char *name; | |
439 | struct module *owner; | |
440 | struct list_head node; | |
441 | struct lttng_kernel_channel_buffer_ops ops; | |
442 | }; | |
443 | ||
444 | struct lttng_counter_transport { | |
445 | char *name; | |
446 | struct module *owner; | |
447 | struct list_head node; | |
448 | struct lttng_counter_ops ops; | |
449 | }; | |
450 | ||
fc2778a7 MD |
451 | #define LTTNG_EVENT_HT_BITS 12 |
452 | #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) | |
453 | ||
454 | struct lttng_event_ht { | |
455 | struct hlist_head table[LTTNG_EVENT_HT_SIZE]; | |
456 | }; | |
457 | ||
a40e3229 MD |
458 | struct lttng_kernel_session_private { |
459 | struct lttng_kernel_session *pub; /* Public session interface */ | |
460 | ||
461 | int been_active; /* Has trace session been active ? */ | |
462 | struct file *file; /* File associated to session */ | |
463 | struct list_head chan; /* Channel list head */ | |
464 | struct list_head events; /* Event list head */ | |
465 | struct list_head list; /* Session list */ | |
466 | unsigned int free_chan_id; /* Next chan ID to allocate */ | |
b3756eaa | 467 | guid_t uuid; /* Trace session unique ID */ |
a40e3229 MD |
468 | struct lttng_metadata_cache *metadata_cache; |
469 | unsigned int metadata_dumped:1, | |
470 | tstate:1; /* Transient enable state */ | |
471 | /* List of event enablers */ | |
472 | struct list_head enablers_head; | |
473 | /* Hash table of events */ | |
474 | struct lttng_event_ht events_ht; | |
475 | char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN]; | |
476 | char creation_time[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN]; | |
477 | }; | |
478 | ||
6e662c28 MD |
479 | struct lttng_id_hash_node { |
480 | struct hlist_node hlist; | |
481 | int id; | |
482 | }; | |
483 | ||
a2fa977a MD |
484 | enum tracker_type { |
485 | TRACKER_PID, | |
486 | TRACKER_VPID, | |
487 | TRACKER_UID, | |
488 | TRACKER_VUID, | |
489 | TRACKER_GID, | |
490 | TRACKER_VGID, | |
491 | ||
492 | TRACKER_UNKNOWN, | |
493 | }; | |
494 | ||
495 | struct lttng_kernel_id_tracker_private { | |
496 | struct lttng_kernel_id_tracker *pub; /* Public interface */ | |
497 | ||
498 | struct lttng_kernel_session *session; | |
499 | enum tracker_type tracker_type; | |
500 | }; | |
501 | ||
7207017d MD |
502 | extern struct lttng_kernel_ctx *lttng_static_ctx; |
503 | ||
437d5aa5 MD |
504 | static inline |
505 | const struct lttng_kernel_type_integer *lttng_kernel_get_type_integer(const struct lttng_kernel_type_common *type) | |
506 | { | |
507 | if (type->type != lttng_kernel_type_integer) | |
508 | return NULL; | |
509 | return container_of(type, const struct lttng_kernel_type_integer, parent); | |
510 | } | |
511 | ||
512 | static inline | |
513 | const struct lttng_kernel_type_string *lttng_kernel_get_type_string(const struct lttng_kernel_type_common *type) | |
514 | { | |
515 | if (type->type != lttng_kernel_type_string) | |
516 | return NULL; | |
517 | return container_of(type, const struct lttng_kernel_type_string, parent); | |
518 | } | |
519 | ||
520 | static inline | |
521 | const struct lttng_kernel_type_enum *lttng_kernel_get_type_enum(const struct lttng_kernel_type_common *type) | |
522 | { | |
523 | if (type->type != lttng_kernel_type_enum) | |
524 | return NULL; | |
525 | return container_of(type, const struct lttng_kernel_type_enum, parent); | |
526 | } | |
527 | ||
528 | static inline | |
529 | const struct lttng_kernel_type_array *lttng_kernel_get_type_array(const struct lttng_kernel_type_common *type) | |
530 | { | |
531 | if (type->type != lttng_kernel_type_array) | |
532 | return NULL; | |
533 | return container_of(type, const struct lttng_kernel_type_array, parent); | |
534 | } | |
535 | ||
536 | static inline | |
537 | const struct lttng_kernel_type_sequence *lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common *type) | |
538 | { | |
539 | if (type->type != lttng_kernel_type_sequence) | |
540 | return NULL; | |
541 | return container_of(type, const struct lttng_kernel_type_sequence, parent); | |
542 | } | |
543 | ||
544 | static inline | |
545 | const struct lttng_kernel_type_struct *lttng_kernel_get_type_struct(const struct lttng_kernel_type_common *type) | |
546 | { | |
547 | if (type->type != lttng_kernel_type_struct) | |
548 | return NULL; | |
549 | return container_of(type, const struct lttng_kernel_type_struct, parent); | |
550 | } | |
551 | ||
552 | static inline | |
553 | const struct lttng_kernel_type_variant *lttng_kernel_get_type_variant(const struct lttng_kernel_type_common *type) | |
554 | { | |
555 | if (type->type != lttng_kernel_type_variant) | |
556 | return NULL; | |
557 | return container_of(type, const struct lttng_kernel_type_variant, parent); | |
558 | } | |
559 | ||
560 | static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common *type) | |
561 | { | |
562 | const struct lttng_kernel_type_integer *type_integer = lttng_kernel_get_type_integer(type); | |
563 | ||
564 | if (!type_integer) | |
565 | return false; | |
566 | switch (type_integer->size) { | |
c570be0d MJ |
567 | case 8: |
568 | lttng_fallthrough; | |
569 | case 16: | |
570 | lttng_fallthrough; | |
571 | case 32: | |
572 | lttng_fallthrough; | |
437d5aa5 MD |
573 | case 64: |
574 | break; | |
575 | default: | |
576 | return false; | |
577 | } | |
578 | return true; | |
579 | } | |
580 | ||
8a445457 MD |
581 | int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *event, |
582 | const char *interpreter_stack_data, | |
346cb5ee | 583 | struct lttng_kernel_probe_ctx *probe_ctx, |
8a445457 MD |
584 | void *event_filter_ctx); |
585 | ||
b8b4704b MD |
586 | static inline |
587 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
588 | struct lttng_event_enabler *event_enabler) | |
589 | { | |
590 | return &event_enabler->base; | |
591 | } | |
592 | ||
593 | static inline | |
594 | struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( | |
595 | struct lttng_event_notifier_enabler *event_notifier_enabler) | |
596 | { | |
597 | return &event_notifier_enabler->base; | |
598 | } | |
599 | ||
7207017d MD |
600 | int lttng_context_init(void); |
601 | void lttng_context_exit(void); | |
602 | int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p, | |
603 | const struct lttng_kernel_ctx_field *f); | |
604 | void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p); | |
605 | struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx, | |
606 | size_t index); | |
607 | int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name); | |
608 | int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name); | |
609 | void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx); | |
610 | int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx); | |
611 | int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx); | |
612 | int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx); | |
613 | int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx); | |
43b9f043 | 614 | int wrapper_task_prio_init(void); |
7207017d MD |
615 | int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx); |
616 | int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx); | |
617 | int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx); | |
618 | int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx); | |
619 | int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx); | |
620 | int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx); | |
621 | int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx); | |
622 | int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx); | |
623 | int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx); | |
624 | #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT) | |
625 | int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx); | |
626 | #else | |
627 | static inline | |
628 | int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx) | |
629 | { | |
630 | return -ENOSYS; | |
631 | } | |
632 | #endif | |
633 | #ifdef CONFIG_PREEMPT_RT_FULL | |
634 | int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx); | |
635 | #else | |
636 | static inline | |
637 | int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx) | |
638 | { | |
639 | return -ENOSYS; | |
640 | } | |
641 | #endif | |
642 | ||
643 | int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type); | |
644 | ||
645 | #if defined(CONFIG_CGROUPS) && \ | |
646 | ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \ | |
647 | LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0)) | |
648 | int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
649 | #else | |
650 | static inline | |
651 | int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
652 | { | |
653 | return -ENOSYS; | |
654 | } | |
655 | #endif | |
656 | ||
657 | #if defined(CONFIG_IPC_NS) && \ | |
658 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
659 | int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
660 | #else | |
661 | static inline | |
662 | int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
663 | { | |
664 | return -ENOSYS; | |
665 | } | |
666 | #endif | |
667 | ||
668 | #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \ | |
669 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
670 | int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
671 | #else | |
672 | static inline | |
673 | int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
674 | { | |
675 | return -ENOSYS; | |
676 | } | |
677 | #endif | |
678 | ||
679 | #if defined(CONFIG_NET_NS) && \ | |
680 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
681 | int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
682 | #else | |
683 | static inline | |
684 | int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
685 | { | |
686 | return -ENOSYS; | |
687 | } | |
688 | #endif | |
689 | ||
690 | #if defined(CONFIG_PID_NS) && \ | |
691 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
692 | int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
693 | #else | |
694 | static inline | |
695 | int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
696 | { | |
697 | return -ENOSYS; | |
698 | } | |
699 | #endif | |
700 | ||
701 | #if defined(CONFIG_USER_NS) && \ | |
702 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
703 | int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
704 | #else | |
705 | static inline | |
706 | int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
707 | { | |
708 | return -ENOSYS; | |
709 | } | |
710 | #endif | |
711 | ||
712 | #if defined(CONFIG_UTS_NS) && \ | |
713 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
714 | int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
715 | #else | |
716 | static inline | |
717 | int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
718 | { | |
719 | return -ENOSYS; | |
720 | } | |
721 | #endif | |
722 | ||
723 | #if defined(CONFIG_TIME_NS) && \ | |
f3a2b1ec MJ |
724 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0) || \ |
725 | LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0)) | |
7207017d MD |
726 | int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
727 | #else | |
728 | static inline | |
729 | int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
730 | { | |
731 | return -ENOSYS; | |
732 | } | |
733 | #endif | |
734 | ||
735 | int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx); | |
736 | int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx); | |
737 | int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx); | |
738 | int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx); | |
739 | int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx); | |
740 | int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
741 | int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
742 | int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
743 | int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
744 | int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
745 | int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx); | |
746 | int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
747 | ||
748 | #if defined(CONFIG_PERF_EVENTS) | |
749 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
750 | uint64_t config, | |
751 | const char *name, | |
752 | struct lttng_kernel_ctx **ctx); | |
753 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, | |
754 | struct lttng_cpuhp_node *node); | |
755 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
756 | struct lttng_cpuhp_node *node); | |
757 | #else | |
758 | static inline | |
759 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
760 | uint64_t config, | |
761 | const char *name, | |
762 | struct lttng_kernel_ctx **ctx) | |
763 | { | |
764 | return -ENOSYS; | |
765 | } | |
766 | static inline | |
767 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, | |
768 | struct lttng_cpuhp_node *node) | |
769 | { | |
770 | return 0; | |
771 | } | |
772 | static inline | |
773 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
774 | struct lttng_cpuhp_node *node) | |
775 | { | |
776 | return 0; | |
777 | } | |
778 | #endif | |
779 | ||
255a028a MD |
780 | struct lttng_event_enabler *lttng_event_enabler_create( |
781 | enum lttng_enabler_format_type format_type, | |
782 | struct lttng_kernel_abi_event *event_param, | |
ac847066 | 783 | struct lttng_kernel_channel_buffer *chan); |
255a028a MD |
784 | |
785 | int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler); | |
786 | int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler); | |
787 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( | |
788 | struct lttng_event_notifier_group *event_notifier_group, | |
789 | enum lttng_enabler_format_type format_type, | |
790 | struct lttng_kernel_abi_event_notifier *event_notifier_param); | |
791 | ||
792 | int lttng_event_notifier_enabler_enable( | |
793 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
794 | int lttng_event_notifier_enabler_disable( | |
795 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
796 | ||
797 | int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler, | |
798 | struct lttng_kernel_abi_filter_bytecode __user *bytecode); | |
799 | int lttng_event_notifier_enabler_attach_filter_bytecode( | |
800 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
801 | struct lttng_kernel_abi_filter_bytecode __user *bytecode); | |
802 | int lttng_event_notifier_enabler_attach_capture_bytecode( | |
803 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
804 | struct lttng_kernel_abi_capture_bytecode __user *bytecode); | |
805 | ||
806 | int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc, | |
807 | struct lttng_enabler *enabler); | |
808 | ||
809 | void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc, | |
810 | struct lttng_kernel_ctx *ctx, | |
811 | struct list_head *instance_bytecode_runtime_head, | |
812 | struct list_head *enabler_bytecode_runtime_head); | |
813 | ||
814 | #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) | |
815 | int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler); | |
ac847066 MD |
816 | int lttng_syscalls_unregister_channel(struct lttng_kernel_channel_buffer *chan); |
817 | int lttng_syscalls_destroy_event(struct lttng_kernel_channel_buffer *chan); | |
255a028a | 818 | int lttng_syscall_filter_enable_event( |
ac847066 | 819 | struct lttng_kernel_channel_buffer *chan, |
255a028a MD |
820 | struct lttng_kernel_event_recorder *event); |
821 | int lttng_syscall_filter_disable_event( | |
ac847066 | 822 | struct lttng_kernel_channel_buffer *chan, |
255a028a MD |
823 | struct lttng_kernel_event_recorder *event); |
824 | ||
ac847066 | 825 | long lttng_channel_syscall_mask(struct lttng_kernel_channel_buffer *channel, |
255a028a MD |
826 | struct lttng_kernel_abi_syscall_mask __user *usyscall_mask); |
827 | ||
828 | int lttng_syscalls_register_event_notifier( | |
829 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
830 | int lttng_syscalls_create_matching_event_notifiers( | |
831 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
832 | int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group *group); | |
833 | int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
834 | int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
835 | #else | |
836 | static inline int lttng_syscalls_register_event( | |
837 | struct lttng_event_enabler *event_enabler) | |
838 | { | |
839 | return -ENOSYS; | |
840 | } | |
841 | ||
ac847066 | 842 | static inline int lttng_syscalls_unregister_channel(struct lttng_kernel_channel_buffer *chan) |
255a028a MD |
843 | { |
844 | return 0; | |
845 | } | |
846 | ||
ac847066 | 847 | static inline int lttng_syscalls_destroy(struct lttng_kernel_channel_buffer *chan) |
255a028a MD |
848 | { |
849 | return 0; | |
850 | } | |
851 | ||
ac847066 | 852 | static inline int lttng_syscall_filter_enable_event(struct lttng_kernel_channel_buffer *chan, |
3214222f | 853 | struct lttng_kernel_event_recorder *event) |
255a028a MD |
854 | { |
855 | return -ENOSYS; | |
856 | } | |
857 | ||
ac847066 | 858 | static inline int lttng_syscall_filter_disable_event(struct lttng_kernel_channel_buffer *chan, |
3214222f MD |
859 | struct lttng_kernel_event_recorder *event) |
860 | { | |
861 | return -ENOSYS; | |
862 | } | |
863 | ||
864 | static inline int lttng_syscalls_destroy_event(struct lttng_kernel_channel_buffer *chan) | |
865 | { | |
866 | return 0; | |
867 | } | |
868 | ||
869 | static inline int lttng_syscalls_create_matching_event_notifiers(struct lttng_event_notifier_enabler *event_notifier_enabler) | |
255a028a MD |
870 | { |
871 | return -ENOSYS; | |
872 | } | |
873 | ||
ac847066 | 874 | static inline long lttng_channel_syscall_mask(struct lttng_kernel_channel_buffer *channel, |
3214222f | 875 | struct lttng_kernel_abi_syscall_mask __user *usyscall_mask) |
255a028a MD |
876 | { |
877 | return -ENOSYS; | |
878 | } | |
879 | ||
3214222f | 880 | static inline int lttng_syscalls_register_event_notifier(struct lttng_event_notifier_enabler *event_notifier_enabler) |
255a028a MD |
881 | { |
882 | return -ENOSYS; | |
883 | } | |
884 | ||
885 | static inline int lttng_syscalls_unregister_event_notifier_group( | |
886 | struct lttng_event_notifier_group *group) | |
887 | { | |
888 | return 0; | |
889 | } | |
890 | ||
3214222f | 891 | static inline int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier) |
255a028a MD |
892 | { |
893 | return -ENOSYS; | |
894 | } | |
895 | ||
3214222f | 896 | static inline int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier) |
255a028a MD |
897 | { |
898 | return -ENOSYS; | |
899 | } | |
7207017d | 900 | |
255a028a | 901 | #endif |
7207017d | 902 | |
cb9a4b67 MD |
903 | #ifdef CONFIG_KPROBES |
904 | int lttng_kprobes_register_event(const char *name, | |
905 | const char *symbol_name, | |
906 | uint64_t offset, | |
907 | uint64_t addr, | |
908 | struct lttng_kernel_event_recorder *event); | |
909 | void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event); | |
910 | void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event); | |
911 | int lttng_kprobes_register_event_notifier(const char *symbol_name, | |
912 | uint64_t offset, | |
913 | uint64_t addr, | |
914 | struct lttng_kernel_event_notifier *event_notifier); | |
915 | void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
916 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier); | |
917 | #else | |
918 | static inline | |
919 | int lttng_kprobes_register_event(const char *name, | |
920 | const char *symbol_name, | |
921 | uint64_t offset, | |
922 | uint64_t addr, | |
923 | struct lttng_kernel_event_recorder *event) | |
924 | { | |
925 | return -ENOSYS; | |
926 | } | |
927 | ||
928 | static inline | |
929 | void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event) | |
930 | { | |
931 | } | |
932 | ||
933 | static inline | |
934 | void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event) | |
935 | { | |
936 | } | |
937 | ||
938 | static inline | |
939 | int lttng_kprobes_register_event_notifier(const char *symbol_name, | |
940 | uint64_t offset, | |
941 | uint64_t addr, | |
942 | struct lttng_kernel_event_notifier *event_notifier) | |
943 | { | |
944 | return -ENOSYS; | |
945 | } | |
946 | ||
947 | static inline | |
948 | void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier) | |
949 | { | |
950 | } | |
951 | ||
952 | static inline | |
953 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) | |
954 | { | |
955 | } | |
956 | #endif | |
957 | ||
958 | int lttng_event_add_callsite(struct lttng_kernel_event_common *event, | |
959 | struct lttng_kernel_abi_event_callsite __user *callsite); | |
960 | ||
961 | #ifdef CONFIG_UPROBES | |
962 | int lttng_uprobes_register_event(const char *name, | |
963 | int fd, struct lttng_kernel_event_recorder *event); | |
964 | int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event, | |
965 | struct lttng_kernel_abi_event_callsite __user *callsite); | |
966 | void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event); | |
967 | void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event); | |
968 | int lttng_uprobes_register_event_notifier(const char *name, | |
969 | int fd, struct lttng_kernel_event_notifier *event_notifier); | |
970 | void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
971 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier); | |
972 | #else | |
973 | static inline | |
974 | int lttng_uprobes_register_event(const char *name, | |
975 | int fd, struct lttng_kernel_event_recorder *event) | |
976 | { | |
977 | return -ENOSYS; | |
978 | } | |
979 | ||
980 | static inline | |
981 | int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event, | |
982 | struct lttng_kernel_abi_event_callsite __user *callsite) | |
983 | { | |
984 | return -ENOSYS; | |
985 | } | |
986 | ||
987 | static inline | |
988 | void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event) | |
989 | { | |
990 | } | |
991 | ||
992 | static inline | |
993 | void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event) | |
994 | { | |
995 | } | |
996 | ||
997 | static inline | |
998 | int lttng_uprobes_register_event_notifier(const char *name, | |
999 | int fd, struct lttng_kernel_event_notifier *event_notifier) | |
1000 | { | |
1001 | return -ENOSYS; | |
1002 | } | |
1003 | ||
1004 | static inline | |
1005 | void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier) | |
1006 | { | |
1007 | } | |
1008 | ||
1009 | static inline | |
1010 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) | |
1011 | { | |
1012 | } | |
1013 | #endif | |
1014 | ||
1015 | #ifdef CONFIG_KRETPROBES | |
1016 | int lttng_kretprobes_register(const char *name, | |
1017 | const char *symbol_name, | |
1018 | uint64_t offset, | |
1019 | uint64_t addr, | |
1020 | struct lttng_kernel_event_recorder *event_entry, | |
1021 | struct lttng_kernel_event_recorder *event_exit); | |
1022 | void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event); | |
1023 | void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event); | |
1024 | int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event, | |
1025 | int enable); | |
1026 | #else | |
1027 | static inline | |
1028 | int lttng_kretprobes_register(const char *name, | |
1029 | const char *symbol_name, | |
1030 | uint64_t offset, | |
1031 | uint64_t addr, | |
1032 | struct lttng_kernel_event_recorder *event_entry, | |
1033 | struct lttng_kernel_event_recorder *event_exit) | |
1034 | { | |
1035 | return -ENOSYS; | |
1036 | } | |
1037 | ||
1038 | static inline | |
1039 | void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event) | |
1040 | { | |
1041 | } | |
1042 | ||
1043 | static inline | |
1044 | void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event) | |
1045 | { | |
1046 | } | |
1047 | ||
1048 | static inline | |
1049 | int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event, | |
1050 | int enable) | |
1051 | { | |
1052 | return -ENOSYS; | |
1053 | } | |
1054 | #endif | |
1055 | ||
17f90b04 MD |
1056 | void lttng_lock_sessions(void); |
1057 | void lttng_unlock_sessions(void); | |
1058 | ||
1059 | struct list_head *lttng_get_probe_list_head(void); | |
1060 | ||
1061 | int lttng_fix_pending_events(void); | |
1062 | int lttng_fix_pending_event_notifiers(void); | |
1063 | int lttng_session_active(void); | |
1064 | bool lttng_event_notifier_active(void); | |
1065 | ||
a40e3229 MD |
1066 | struct lttng_kernel_session *lttng_session_create(void); |
1067 | int lttng_session_enable(struct lttng_kernel_session *session); | |
1068 | int lttng_session_disable(struct lttng_kernel_session *session); | |
1069 | void lttng_session_destroy(struct lttng_kernel_session *session); | |
1070 | int lttng_session_metadata_regenerate(struct lttng_kernel_session *session); | |
1071 | int lttng_session_statedump(struct lttng_kernel_session *session); | |
17f90b04 MD |
1072 | void metadata_cache_destroy(struct kref *kref); |
1073 | ||
1074 | struct lttng_counter *lttng_kernel_counter_create( | |
1075 | const char *counter_transport_name, size_t number_dimensions, | |
1076 | const size_t *dimensions_sizes); | |
1077 | int lttng_kernel_counter_read(struct lttng_counter *counter, | |
1078 | const size_t *dimension_indexes, int32_t cpu, | |
1079 | int64_t *val, bool *overflow, bool *underflow); | |
1080 | int lttng_kernel_counter_aggregate(struct lttng_counter *counter, | |
1081 | const size_t *dimension_indexes, int64_t *val, | |
1082 | bool *overflow, bool *underflow); | |
1083 | int lttng_kernel_counter_clear(struct lttng_counter *counter, | |
1084 | const size_t *dimension_indexes); | |
1085 | struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); | |
1086 | int lttng_event_notifier_group_create_error_counter( | |
1087 | struct file *event_notifier_group_file, | |
1088 | const struct lttng_kernel_abi_counter_conf *error_counter_conf); | |
1089 | void lttng_event_notifier_group_destroy( | |
1090 | struct lttng_event_notifier_group *event_notifier_group); | |
1091 | ||
ac847066 | 1092 | struct lttng_kernel_channel_buffer *lttng_channel_create(struct lttng_kernel_session *session, |
17f90b04 MD |
1093 | const char *transport_name, |
1094 | void *buf_addr, | |
1095 | size_t subbuf_size, size_t num_subbuf, | |
1096 | unsigned int switch_timer_interval, | |
1097 | unsigned int read_timer_interval, | |
1098 | enum channel_type channel_type); | |
ac847066 | 1099 | struct lttng_kernel_channel_buffer *lttng_global_channel_create(struct lttng_kernel_session *session, |
17f90b04 MD |
1100 | int overwrite, void *buf_addr, |
1101 | size_t subbuf_size, size_t num_subbuf, | |
1102 | unsigned int switch_timer_interval, | |
1103 | unsigned int read_timer_interval); | |
1104 | ||
ac847066 MD |
1105 | void lttng_metadata_channel_destroy(struct lttng_kernel_channel_buffer *chan); |
1106 | struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_kernel_channel_buffer *chan, | |
17f90b04 MD |
1107 | struct lttng_kernel_abi_event *event_param, |
1108 | const struct lttng_kernel_event_desc *event_desc, | |
1109 | enum lttng_kernel_abi_instrumentation itype); | |
ac847066 | 1110 | struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_kernel_channel_buffer *chan, |
17f90b04 MD |
1111 | struct lttng_kernel_abi_event *event_param, |
1112 | const struct lttng_kernel_event_desc *event_desc, | |
1113 | enum lttng_kernel_abi_instrumentation itype); | |
ac847066 | 1114 | struct lttng_kernel_event_recorder *lttng_event_compat_old_create(struct lttng_kernel_channel_buffer *chan, |
17f90b04 MD |
1115 | struct lttng_kernel_abi_old_event *old_event_param, |
1116 | const struct lttng_kernel_event_desc *internal_desc); | |
1117 | ||
1118 | struct lttng_kernel_event_notifier *lttng_event_notifier_create( | |
1119 | const struct lttng_kernel_event_desc *event_notifier_desc, | |
1120 | uint64_t id, | |
1121 | uint64_t error_counter_idx, | |
1122 | struct lttng_event_notifier_group *event_notifier_group, | |
1123 | struct lttng_kernel_abi_event_notifier *event_notifier_param, | |
1124 | enum lttng_kernel_abi_instrumentation itype); | |
1125 | struct lttng_kernel_event_notifier *_lttng_event_notifier_create( | |
1126 | const struct lttng_kernel_event_desc *event_notifier_desc, | |
1127 | uint64_t id, | |
1128 | uint64_t error_counter_idx, | |
1129 | struct lttng_event_notifier_group *event_notifier_group, | |
1130 | struct lttng_kernel_abi_event_notifier *event_notifier_param, | |
1131 | enum lttng_kernel_abi_instrumentation itype); | |
1132 | ||
ac847066 MD |
1133 | int lttng_channel_enable(struct lttng_kernel_channel_buffer *channel); |
1134 | int lttng_channel_disable(struct lttng_kernel_channel_buffer *channel); | |
17f90b04 MD |
1135 | int lttng_event_enable(struct lttng_kernel_event_common *event); |
1136 | int lttng_event_disable(struct lttng_kernel_event_common *event); | |
1137 | ||
1138 | void lttng_transport_register(struct lttng_transport *transport); | |
1139 | void lttng_transport_unregister(struct lttng_transport *transport); | |
1140 | ||
1141 | void lttng_counter_transport_register(struct lttng_counter_transport *transport); | |
1142 | void lttng_counter_transport_unregister(struct lttng_counter_transport *transport); | |
1143 | ||
1144 | void synchronize_trace(void); | |
1145 | int lttng_abi_init(void); | |
1146 | int lttng_abi_compat_old_init(void); | |
1147 | void lttng_abi_exit(void); | |
1148 | void lttng_abi_compat_old_exit(void); | |
1149 | ||
1150 | const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name); | |
1151 | void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc); | |
1152 | int lttng_probes_init(void); | |
1153 | void lttng_probes_exit(void); | |
1154 | ||
1155 | int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, | |
4071a628 | 1156 | struct lttng_kernel_ring_buffer_channel *chan, bool *coherent); |
17f90b04 MD |
1157 | |
1158 | int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node); | |
a2fa977a MD |
1159 | int lttng_id_tracker_empty_set(struct lttng_kernel_id_tracker *lf); |
1160 | int lttng_id_tracker_init(struct lttng_kernel_id_tracker *lf, | |
1161 | struct lttng_kernel_session *session, | |
1162 | enum tracker_type type); | |
1163 | void lttng_id_tracker_fini(struct lttng_kernel_id_tracker *lf); | |
1164 | void lttng_id_tracker_destroy(struct lttng_kernel_id_tracker *lf, bool rcu); | |
1165 | int lttng_id_tracker_add(struct lttng_kernel_id_tracker *lf, int id); | |
1166 | int lttng_id_tracker_del(struct lttng_kernel_id_tracker *lf, int id); | |
17f90b04 | 1167 | |
a40e3229 | 1168 | int lttng_session_track_id(struct lttng_kernel_session *session, |
17f90b04 | 1169 | enum tracker_type tracker_type, int id); |
a40e3229 | 1170 | int lttng_session_untrack_id(struct lttng_kernel_session *session, |
17f90b04 MD |
1171 | enum tracker_type tracker_type, int id); |
1172 | ||
a40e3229 | 1173 | int lttng_session_list_tracker_ids(struct lttng_kernel_session *session, |
17f90b04 MD |
1174 | enum tracker_type tracker_type); |
1175 | ||
1176 | void lttng_clock_ref(void); | |
1177 | void lttng_clock_unref(void); | |
1178 | ||
1179 | void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event); | |
1180 | ||
1181 | int lttng_probes_init(void); | |
1182 | ||
1183 | int lttng_logger_init(void); | |
1184 | void lttng_logger_exit(void); | |
1185 | ||
a40e3229 | 1186 | extern int lttng_statedump_start(struct lttng_kernel_session *session); |
17f90b04 MD |
1187 | |
1188 | int lttng_calibrate(struct lttng_kernel_abi_calibrate *calibrate); | |
1189 | ||
1190 | extern const struct file_operations lttng_tracepoint_list_fops; | |
1191 | extern const struct file_operations lttng_syscall_list_fops; | |
1192 | ||
7207017d MD |
1193 | #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \ |
1194 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \ | |
1195 | .event_field = (_event_field), \ | |
1196 | .get_size = (_get_size), \ | |
1197 | .record = (_record), \ | |
1198 | .get_value = (_get_value), \ | |
1199 | .destroy = (_destroy), \ | |
1200 | .priv = (_priv), \ | |
1201 | }) | |
1202 | ||
92bc1e23 | 1203 | #endif /* _LTTNG_EVENTS_INTERNAL_H */ |