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