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