uprobe: Support multiple call sites for the same uprobe event
[lttng-modules.git] / lttng-abi.c
CommitLineData
9f36eaed
MJ
1/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
e8951e63 3 * lttng-abi.c
baf20995 4 *
e8951e63 5 * LTTng ABI
baf20995 6 *
886d51a3
MD
7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
baf20995
MD
9 * Mimic system calls for:
10 * - session creation, returns a file descriptor or failure.
ad1c05e1
MD
11 * - channel creation, returns a file descriptor or failure.
12 * - Operates on a session file descriptor
13 * - Takes all channel options as parameters.
14 * - stream get, returns a file descriptor or failure.
15 * - Operates on a channel file descriptor.
16 * - stream notifier get, returns a file descriptor or failure.
17 * - Operates on a channel file descriptor.
18 * - event creation, returns a file descriptor or failure.
19 * - Operates on a channel file descriptor
20 * - Takes an event name as parameter
21 * - Takes an instrumentation source as parameter
22 * - e.g. tracepoints, dynamic_probes...
23 * - Takes instrumentation source specific arguments.
baf20995
MD
24 */
25
11b5a3c2 26#include <linux/module.h>
e6a17f26 27#include <linux/proc_fs.h>
11b5a3c2
MD
28#include <linux/anon_inodes.h>
29#include <linux/file.h>
30#include <linux/uaccess.h>
31#include <linux/slab.h>
abc0446a 32#include <linux/err.h>
241ae9a8
MD
33#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
34#include <wrapper/ringbuffer/vfs.h>
35#include <wrapper/ringbuffer/backend.h>
36#include <wrapper/ringbuffer/frontend.h>
37#include <wrapper/poll.h>
38#include <wrapper/file.h>
39#include <wrapper/kref.h>
4993071a 40#include <lttng-string-utils.h>
241ae9a8
MD
41#include <lttng-abi.h>
42#include <lttng-abi-old.h>
43#include <lttng-events.h>
44#include <lttng-tracer.h>
f771eda6 45#include <lttng-tp-mempool.h>
241ae9a8 46#include <lib/ringbuffer/frontend_types.h>
baf20995
MD
47
48/*
49 * This is LTTng's own personal way to create a system call as an external
80996790 50 * module. We use ioctl() on /proc/lttng.
baf20995
MD
51 */
52
e6a17f26 53static struct proc_dir_entry *lttng_proc_dentry;
ad1c05e1
MD
54static const struct file_operations lttng_fops;
55static const struct file_operations lttng_session_fops;
56static const struct file_operations lttng_channel_fops;
5dbbdb43 57static const struct file_operations lttng_metadata_fops;
305d3e42 58static const struct file_operations lttng_event_fops;
ed8d02d6 59static struct file_operations lttng_stream_ring_buffer_file_operations;
baf20995 60
9616f0bf
JD
61static int put_u64(uint64_t val, unsigned long arg);
62
a33c9927
MD
63/*
64 * Teardown management: opened file descriptors keep a refcount on the module,
65 * so it can only exit when all file descriptors are closed.
66 */
67
ad1c05e1 68static
baf20995
MD
69int lttng_abi_create_session(void)
70{
a90917c3 71 struct lttng_session *session;
c0e31d2e 72 struct file *session_file;
11b5a3c2 73 int session_fd, ret;
baf20995 74
a90917c3 75 session = lttng_session_create();
baf20995
MD
76 if (!session)
77 return -ENOMEM;
4ac10b76 78 session_fd = lttng_get_unused_fd();
baf20995
MD
79 if (session_fd < 0) {
80 ret = session_fd;
81 goto fd_error;
82 }
c0e31d2e 83 session_file = anon_inode_getfile("[lttng_session]",
ad1c05e1 84 &lttng_session_fops,
baf20995 85 session, O_RDWR);
c0e31d2e
MD
86 if (IS_ERR(session_file)) {
87 ret = PTR_ERR(session_file);
baf20995
MD
88 goto file_error;
89 }
c0e31d2e
MD
90 session->file = session_file;
91 fd_install(session_fd, session_file);
baf20995
MD
92 return session_fd;
93
94file_error:
95 put_unused_fd(session_fd);
96fd_error:
a90917c3 97 lttng_session_destroy(session);
baf20995
MD
98 return ret;
99}
100
271b6681
MD
101static
102int lttng_abi_tracepoint_list(void)
103{
104 struct file *tracepoint_list_file;
105 int file_fd, ret;
106
4ac10b76 107 file_fd = lttng_get_unused_fd();
271b6681
MD
108 if (file_fd < 0) {
109 ret = file_fd;
110 goto fd_error;
111 }
30f18bf0 112
8ee099b6 113 tracepoint_list_file = anon_inode_getfile("[lttng_tracepoint_list]",
271b6681
MD
114 &lttng_tracepoint_list_fops,
115 NULL, O_RDWR);
116 if (IS_ERR(tracepoint_list_file)) {
117 ret = PTR_ERR(tracepoint_list_file);
118 goto file_error;
119 }
30f18bf0
MD
120 ret = lttng_tracepoint_list_fops.open(NULL, tracepoint_list_file);
121 if (ret < 0)
122 goto open_error;
271b6681
MD
123 fd_install(file_fd, tracepoint_list_file);
124 return file_fd;
125
30f18bf0
MD
126open_error:
127 fput(tracepoint_list_file);
271b6681
MD
128file_error:
129 put_unused_fd(file_fd);
130fd_error:
131 return ret;
132}
133
f127e61e
MD
134#ifndef CONFIG_HAVE_SYSCALL_TRACEPOINTS
135static inline
136int lttng_abi_syscall_list(void)
137{
138 return -ENOSYS;
139}
140#else
141static
142int lttng_abi_syscall_list(void)
143{
144 struct file *syscall_list_file;
145 int file_fd, ret;
146
147 file_fd = lttng_get_unused_fd();
148 if (file_fd < 0) {
149 ret = file_fd;
150 goto fd_error;
151 }
152
153 syscall_list_file = anon_inode_getfile("[lttng_syscall_list]",
154 &lttng_syscall_list_fops,
155 NULL, O_RDWR);
156 if (IS_ERR(syscall_list_file)) {
157 ret = PTR_ERR(syscall_list_file);
158 goto file_error;
159 }
160 ret = lttng_syscall_list_fops.open(NULL, syscall_list_file);
161 if (ret < 0)
162 goto open_error;
163 fd_install(file_fd, syscall_list_file);
f127e61e
MD
164 return file_fd;
165
166open_error:
167 fput(syscall_list_file);
168file_error:
169 put_unused_fd(file_fd);
170fd_error:
171 return ret;
172}
173#endif
174
80c16bcf 175static
6dccd6c1 176void lttng_abi_tracer_version(struct lttng_kernel_tracer_version *v)
80c16bcf 177{
6dccd6c1
JD
178 v->major = LTTNG_MODULES_MAJOR_VERSION;
179 v->minor = LTTNG_MODULES_MINOR_VERSION;
180 v->patchlevel = LTTNG_MODULES_PATCHLEVEL_VERSION;
80c16bcf
MD
181}
182
42cabb80
MD
183static
184void lttng_abi_tracer_abi_version(struct lttng_kernel_tracer_abi_version *v)
185{
186 v->major = LTTNG_MODULES_ABI_MAJOR_VERSION;
187 v->minor = LTTNG_MODULES_ABI_MINOR_VERSION;
188}
189
8070f5c0
MD
190static
191long lttng_abi_add_context(struct file *file,
6dccd6c1 192 struct lttng_kernel_context *context_param,
a90917c3 193 struct lttng_ctx **ctx, struct lttng_session *session)
8070f5c0 194{
8070f5c0
MD
195
196 if (session->been_active)
197 return -EPERM;
198
6dccd6c1 199 switch (context_param->ctx) {
12a313a5 200 case LTTNG_KERNEL_CONTEXT_PID:
8070f5c0 201 return lttng_add_pid_to_ctx(ctx);
a8ad3613
MD
202 case LTTNG_KERNEL_CONTEXT_PRIO:
203 return lttng_add_prio_to_ctx(ctx);
53f1f0ca
MD
204 case LTTNG_KERNEL_CONTEXT_NICE:
205 return lttng_add_nice_to_ctx(ctx);
b64bc438
MD
206 case LTTNG_KERNEL_CONTEXT_VPID:
207 return lttng_add_vpid_to_ctx(ctx);
208 case LTTNG_KERNEL_CONTEXT_TID:
209 return lttng_add_tid_to_ctx(ctx);
210 case LTTNG_KERNEL_CONTEXT_VTID:
211 return lttng_add_vtid_to_ctx(ctx);
212 case LTTNG_KERNEL_CONTEXT_PPID:
213 return lttng_add_ppid_to_ctx(ctx);
214 case LTTNG_KERNEL_CONTEXT_VPPID:
215 return lttng_add_vppid_to_ctx(ctx);
12a313a5 216 case LTTNG_KERNEL_CONTEXT_PERF_COUNTER:
6dccd6c1
JD
217 context_param->u.perf_counter.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
218 return lttng_add_perf_counter_to_ctx(context_param->u.perf_counter.type,
219 context_param->u.perf_counter.config,
220 context_param->u.perf_counter.name,
c24a0d71 221 ctx);
a2563e83
MD
222 case LTTNG_KERNEL_CONTEXT_PROCNAME:
223 return lttng_add_procname_to_ctx(ctx);
975da2c0
JD
224 case LTTNG_KERNEL_CONTEXT_HOSTNAME:
225 return lttng_add_hostname_to_ctx(ctx);
b3699d90
MD
226 case LTTNG_KERNEL_CONTEXT_CPU_ID:
227 return lttng_add_cpu_id_to_ctx(ctx);
79150a49
JD
228 case LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE:
229 return lttng_add_interruptible_to_ctx(ctx);
230 case LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE:
231 return lttng_add_need_reschedule_to_ctx(ctx);
232 case LTTNG_KERNEL_CONTEXT_PREEMPTIBLE:
233 return lttng_add_preemptible_to_ctx(ctx);
234 case LTTNG_KERNEL_CONTEXT_MIGRATABLE:
235 return lttng_add_migratable_to_ctx(ctx);
2fa2d39a
FG
236 case LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL:
237 case LTTNG_KERNEL_CONTEXT_CALLSTACK_USER:
238 return lttng_add_callstack_to_ctx(ctx, context_param->ctx);
8070f5c0
MD
239 default:
240 return -EINVAL;
241 }
242}
243
ad1c05e1
MD
244/**
245 * lttng_ioctl - lttng syscall through ioctl
246 *
c0e31d2e 247 * @file: the file
ad1c05e1
MD
248 * @cmd: the command
249 * @arg: command arg
250 *
251 * This ioctl implements lttng commands:
38d024ae 252 * LTTNG_KERNEL_SESSION
ad1c05e1 253 * Returns a LTTng trace session file descriptor
271b6681
MD
254 * LTTNG_KERNEL_TRACER_VERSION
255 * Returns the LTTng kernel tracer version
256 * LTTNG_KERNEL_TRACEPOINT_LIST
257 * Returns a file descriptor listing available tracepoints
360f38ea
MD
258 * LTTNG_KERNEL_WAIT_QUIESCENT
259 * Returns after all previously running probes have completed
42cabb80
MD
260 * LTTNG_KERNEL_TRACER_ABI_VERSION
261 * Returns the LTTng kernel tracer ABI version
ad1c05e1
MD
262 *
263 * The returned session will be deleted when its file descriptor is closed.
264 */
265static
c0e31d2e 266long lttng_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
ad1c05e1
MD
267{
268 switch (cmd) {
6dccd6c1 269 case LTTNG_KERNEL_OLD_SESSION:
38d024ae 270 case LTTNG_KERNEL_SESSION:
ad1c05e1 271 return lttng_abi_create_session();
6dccd6c1
JD
272 case LTTNG_KERNEL_OLD_TRACER_VERSION:
273 {
274 struct lttng_kernel_tracer_version v;
275 struct lttng_kernel_old_tracer_version oldv;
276 struct lttng_kernel_old_tracer_version *uversion =
277 (struct lttng_kernel_old_tracer_version __user *) arg;
278
279 lttng_abi_tracer_version(&v);
280 oldv.major = v.major;
281 oldv.minor = v.minor;
282 oldv.patchlevel = v.patchlevel;
283
284 if (copy_to_user(uversion, &oldv, sizeof(oldv)))
285 return -EFAULT;
286 return 0;
287 }
80c16bcf 288 case LTTNG_KERNEL_TRACER_VERSION:
6dccd6c1
JD
289 {
290 struct lttng_kernel_tracer_version version;
291 struct lttng_kernel_tracer_version *uversion =
292 (struct lttng_kernel_tracer_version __user *) arg;
293
294 lttng_abi_tracer_version(&version);
42cabb80
MD
295
296 if (copy_to_user(uversion, &version, sizeof(version)))
297 return -EFAULT;
298 return 0;
299 }
300 case LTTNG_KERNEL_TRACER_ABI_VERSION:
301 {
302 struct lttng_kernel_tracer_abi_version version;
303 struct lttng_kernel_tracer_abi_version *uversion =
304 (struct lttng_kernel_tracer_abi_version __user *) arg;
305
306 lttng_abi_tracer_abi_version(&version);
307
6dccd6c1
JD
308 if (copy_to_user(uversion, &version, sizeof(version)))
309 return -EFAULT;
310 return 0;
311 }
312 case LTTNG_KERNEL_OLD_TRACEPOINT_LIST:
271b6681
MD
313 case LTTNG_KERNEL_TRACEPOINT_LIST:
314 return lttng_abi_tracepoint_list();
2d2464bd
MD
315 case LTTNG_KERNEL_SYSCALL_LIST:
316 return lttng_abi_syscall_list();
6dccd6c1 317 case LTTNG_KERNEL_OLD_WAIT_QUIESCENT:
5f7f9078
MD
318 case LTTNG_KERNEL_WAIT_QUIESCENT:
319 synchronize_trace();
320 return 0;
6dccd6c1
JD
321 case LTTNG_KERNEL_OLD_CALIBRATE:
322 {
323 struct lttng_kernel_old_calibrate __user *ucalibrate =
324 (struct lttng_kernel_old_calibrate __user *) arg;
325 struct lttng_kernel_old_calibrate old_calibrate;
326 struct lttng_kernel_calibrate calibrate;
327 int ret;
328
329 if (copy_from_user(&old_calibrate, ucalibrate, sizeof(old_calibrate)))
330 return -EFAULT;
331 calibrate.type = old_calibrate.type;
332 ret = lttng_calibrate(&calibrate);
333 if (copy_to_user(ucalibrate, &old_calibrate, sizeof(old_calibrate)))
334 return -EFAULT;
335 return ret;
336 }
57105fc2
MD
337 case LTTNG_KERNEL_CALIBRATE:
338 {
3db41b2c
MD
339 struct lttng_kernel_calibrate __user *ucalibrate =
340 (struct lttng_kernel_calibrate __user *) arg;
341 struct lttng_kernel_calibrate calibrate;
57105fc2
MD
342 int ret;
343
344 if (copy_from_user(&calibrate, ucalibrate, sizeof(calibrate)))
345 return -EFAULT;
346 ret = lttng_calibrate(&calibrate);
347 if (copy_to_user(ucalibrate, &calibrate, sizeof(calibrate)))
348 return -EFAULT;
349 return ret;
350 }
ad1c05e1
MD
351 default:
352 return -ENOIOCTLCMD;
353 }
354}
355
ad1c05e1 356static const struct file_operations lttng_fops = {
a33c9927 357 .owner = THIS_MODULE,
ad1c05e1
MD
358 .unlocked_ioctl = lttng_ioctl,
359#ifdef CONFIG_COMPAT
03037b98 360 .compat_ioctl = lttng_ioctl,
ad1c05e1 361#endif
11b5a3c2 362};
ad1c05e1 363
5dbbdb43 364static
c0e31d2e 365int lttng_abi_create_channel(struct file *session_file,
6dccd6c1 366 struct lttng_kernel_channel *chan_param,
5dbbdb43 367 enum channel_type channel_type)
baf20995 368{
a90917c3 369 struct lttng_session *session = session_file->private_data;
88dfd899 370 const struct file_operations *fops = NULL;
5dbbdb43 371 const char *transport_name;
a90917c3 372 struct lttng_channel *chan;
c0e31d2e 373 struct file *chan_file;
baf20995 374 int chan_fd;
ad1c05e1 375 int ret = 0;
baf20995 376
4ac10b76 377 chan_fd = lttng_get_unused_fd();
baf20995
MD
378 if (chan_fd < 0) {
379 ret = chan_fd;
380 goto fd_error;
381 }
88dfd899
MD
382 switch (channel_type) {
383 case PER_CPU_CHANNEL:
384 fops = &lttng_channel_fops;
385 break;
386 case METADATA_CHANNEL:
387 fops = &lttng_metadata_fops;
388 break;
389 }
2470a237 390
c0e31d2e 391 chan_file = anon_inode_getfile("[lttng_channel]",
88dfd899 392 fops,
03037b98 393 NULL, O_RDWR);
c0e31d2e
MD
394 if (IS_ERR(chan_file)) {
395 ret = PTR_ERR(chan_file);
baf20995
MD
396 goto file_error;
397 }
5dbbdb43
MD
398 switch (channel_type) {
399 case PER_CPU_CHANNEL:
6dccd6c1
JD
400 if (chan_param->output == LTTNG_KERNEL_SPLICE) {
401 transport_name = chan_param->overwrite ?
96ba7208 402 "relay-overwrite" : "relay-discard";
6dccd6c1
JD
403 } else if (chan_param->output == LTTNG_KERNEL_MMAP) {
404 transport_name = chan_param->overwrite ?
96ba7208
JD
405 "relay-overwrite-mmap" : "relay-discard-mmap";
406 } else {
407 return -EINVAL;
408 }
5dbbdb43 409 break;
5dbbdb43 410 case METADATA_CHANNEL:
6dccd6c1 411 if (chan_param->output == LTTNG_KERNEL_SPLICE)
96ba7208 412 transport_name = "relay-metadata";
6dccd6c1 413 else if (chan_param->output == LTTNG_KERNEL_MMAP)
96ba7208
JD
414 transport_name = "relay-metadata-mmap";
415 else
416 return -EINVAL;
5dbbdb43
MD
417 break;
418 default:
419 transport_name = "<unknown>";
420 break;
421 }
9c1f4643
MD
422 if (atomic_long_add_unless(&session_file->f_count,
423 1, INT_MAX) == INT_MAX) {
424 goto refcount_error;
425 }
03037b98
MD
426 /*
427 * We tolerate no failure path after channel creation. It will stay
428 * invariant for the rest of the session.
429 */
a90917c3 430 chan = lttng_channel_create(session, transport_name, NULL,
6dccd6c1
JD
431 chan_param->subbuf_size,
432 chan_param->num_subbuf,
433 chan_param->switch_timer_interval,
d83004aa
JD
434 chan_param->read_timer_interval,
435 channel_type);
03037b98 436 if (!chan) {
f3d01b96 437 ret = -EINVAL;
03037b98
MD
438 goto chan_error;
439 }
11b5a3c2 440 chan->file = chan_file;
c0e31d2e
MD
441 chan_file->private_data = chan;
442 fd_install(chan_fd, chan_file);
ad1c05e1 443
baf20995
MD
444 return chan_fd;
445
03037b98 446chan_error:
9c1f4643
MD
447 atomic_long_dec(&session_file->f_count);
448refcount_error:
c0e31d2e 449 fput(chan_file);
baf20995
MD
450file_error:
451 put_unused_fd(chan_fd);
452fd_error:
baf20995
MD
453 return ret;
454}
455
456/**
ad1c05e1 457 * lttng_session_ioctl - lttng session fd ioctl
baf20995 458 *
c0e31d2e 459 * @file: the file
baf20995
MD
460 * @cmd: the command
461 * @arg: command arg
462 *
463 * This ioctl implements lttng commands:
38d024ae 464 * LTTNG_KERNEL_CHANNEL
baf20995 465 * Returns a LTTng channel file descriptor
e64957da
MD
466 * LTTNG_KERNEL_ENABLE
467 * Enables tracing for a session (weak enable)
468 * LTTNG_KERNEL_DISABLE
469 * Disables tracing for a session (strong disable)
8070f5c0
MD
470 * LTTNG_KERNEL_METADATA
471 * Returns a LTTng metadata file descriptor
e0130fab
MD
472 * LTTNG_KERNEL_SESSION_TRACK_PID
473 * Add PID to session tracker
474 * LTTNG_KERNEL_SESSION_UNTRACK_PID
475 * Remove PID from session tracker
ad1c05e1
MD
476 *
477 * The returned channel will be deleted when its file descriptor is closed.
478 */
479static
c0e31d2e 480long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
ad1c05e1 481{
a90917c3 482 struct lttng_session *session = file->private_data;
c0e31d2e 483
ad1c05e1 484 switch (cmd) {
6dccd6c1
JD
485 case LTTNG_KERNEL_OLD_CHANNEL:
486 {
487 struct lttng_kernel_channel chan_param;
488 struct lttng_kernel_old_channel old_chan_param;
489
490 if (copy_from_user(&old_chan_param,
491 (struct lttng_kernel_old_channel __user *) arg,
492 sizeof(struct lttng_kernel_old_channel)))
493 return -EFAULT;
494 chan_param.overwrite = old_chan_param.overwrite;
495 chan_param.subbuf_size = old_chan_param.subbuf_size;
496 chan_param.num_subbuf = old_chan_param.num_subbuf;
497 chan_param.switch_timer_interval = old_chan_param.switch_timer_interval;
498 chan_param.read_timer_interval = old_chan_param.read_timer_interval;
499 chan_param.output = old_chan_param.output;
500
501 return lttng_abi_create_channel(file, &chan_param,
502 PER_CPU_CHANNEL);
503 }
38d024ae 504 case LTTNG_KERNEL_CHANNEL:
6dccd6c1
JD
505 {
506 struct lttng_kernel_channel chan_param;
507
508 if (copy_from_user(&chan_param,
38d024ae 509 (struct lttng_kernel_channel __user *) arg,
6dccd6c1
JD
510 sizeof(struct lttng_kernel_channel)))
511 return -EFAULT;
512 return lttng_abi_create_channel(file, &chan_param,
5dbbdb43 513 PER_CPU_CHANNEL);
6dccd6c1
JD
514 }
515 case LTTNG_KERNEL_OLD_SESSION_START:
516 case LTTNG_KERNEL_OLD_ENABLE:
38d024ae 517 case LTTNG_KERNEL_SESSION_START:
e64957da 518 case LTTNG_KERNEL_ENABLE:
a90917c3 519 return lttng_session_enable(session);
6dccd6c1
JD
520 case LTTNG_KERNEL_OLD_SESSION_STOP:
521 case LTTNG_KERNEL_OLD_DISABLE:
38d024ae 522 case LTTNG_KERNEL_SESSION_STOP:
e64957da 523 case LTTNG_KERNEL_DISABLE:
a90917c3 524 return lttng_session_disable(session);
6dccd6c1
JD
525 case LTTNG_KERNEL_OLD_METADATA:
526 {
527 struct lttng_kernel_channel chan_param;
528 struct lttng_kernel_old_channel old_chan_param;
529
530 if (copy_from_user(&old_chan_param,
531 (struct lttng_kernel_old_channel __user *) arg,
532 sizeof(struct lttng_kernel_old_channel)))
533 return -EFAULT;
534 chan_param.overwrite = old_chan_param.overwrite;
535 chan_param.subbuf_size = old_chan_param.subbuf_size;
536 chan_param.num_subbuf = old_chan_param.num_subbuf;
537 chan_param.switch_timer_interval = old_chan_param.switch_timer_interval;
538 chan_param.read_timer_interval = old_chan_param.read_timer_interval;
539 chan_param.output = old_chan_param.output;
540
541 return lttng_abi_create_channel(file, &chan_param,
542 METADATA_CHANNEL);
543 }
38d024ae 544 case LTTNG_KERNEL_METADATA:
6dccd6c1
JD
545 {
546 struct lttng_kernel_channel chan_param;
547
548 if (copy_from_user(&chan_param,
549 (struct lttng_kernel_channel __user *) arg,
550 sizeof(struct lttng_kernel_channel)))
551 return -EFAULT;
552 return lttng_abi_create_channel(file, &chan_param,
5dbbdb43 553 METADATA_CHANNEL);
6dccd6c1 554 }
e0130fab
MD
555 case LTTNG_KERNEL_SESSION_TRACK_PID:
556 return lttng_session_track_pid(session, (int) arg);
557 case LTTNG_KERNEL_SESSION_UNTRACK_PID:
558 return lttng_session_untrack_pid(session, (int) arg);
7e6f9ef6
MD
559 case LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS:
560 return lttng_session_list_tracker_pids(session);
9616f0bf
JD
561 case LTTNG_KERNEL_SESSION_METADATA_REGEN:
562 return lttng_session_metadata_regenerate(session);
601252cf
MD
563 case LTTNG_KERNEL_SESSION_STATEDUMP:
564 return lttng_session_statedump(session);
ad1c05e1
MD
565 default:
566 return -ENOIOCTLCMD;
567 }
568}
569
03037b98
MD
570/*
571 * Called when the last file reference is dropped.
572 *
573 * Big fat note: channels and events are invariant for the whole session after
574 * their creation. So this session destruction also destroys all channel and
575 * event structures specific to this session (they are not destroyed when their
576 * individual file is released).
577 */
ad1c05e1 578static
03037b98 579int lttng_session_release(struct inode *inode, struct file *file)
ad1c05e1 580{
a90917c3 581 struct lttng_session *session = file->private_data;
c269fff4
MD
582
583 if (session)
a90917c3 584 lttng_session_destroy(session);
11b5a3c2 585 return 0;
ad1c05e1 586}
ad1c05e1
MD
587
588static const struct file_operations lttng_session_fops = {
a33c9927 589 .owner = THIS_MODULE,
03037b98 590 .release = lttng_session_release,
ad1c05e1
MD
591 .unlocked_ioctl = lttng_session_ioctl,
592#ifdef CONFIG_COMPAT
03037b98 593 .compat_ioctl = lttng_session_ioctl,
ad1c05e1 594#endif
11b5a3c2 595};
ad1c05e1 596
d83004aa
JD
597/**
598 * lttng_metadata_ring_buffer_poll - LTTng ring buffer poll file operation
599 * @filp: the file
600 * @wait: poll table
601 *
602 * Handles the poll operations for the metadata channels.
603 */
ad1c05e1 604static
d83004aa
JD
605unsigned int lttng_metadata_ring_buffer_poll(struct file *filp,
606 poll_table *wait)
607{
608 struct lttng_metadata_stream *stream = filp->private_data;
609 struct lib_ring_buffer *buf = stream->priv;
610 int finalized;
611 unsigned int mask = 0;
612
613 if (filp->f_mode & FMODE_READ) {
614 poll_wait_set_exclusive(wait);
615 poll_wait(filp, &stream->read_wait, wait);
616
617 finalized = stream->finalized;
618
619 /*
620 * lib_ring_buffer_is_finalized() contains a smp_rmb()
621 * ordering finalized load before offsets loads.
622 */
623 WARN_ON(atomic_long_read(&buf->active_readers) != 1);
624
625 if (finalized)
626 mask |= POLLHUP;
627
92d9f5e6 628 mutex_lock(&stream->metadata_cache->lock);
d83004aa 629 if (stream->metadata_cache->metadata_written >
f613e3e6 630 stream->metadata_out)
d83004aa 631 mask |= POLLIN;
92d9f5e6 632 mutex_unlock(&stream->metadata_cache->lock);
d83004aa
JD
633 }
634
635 return mask;
636}
637
f613e3e6
MD
638static
639void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file *filp,
640 unsigned int cmd, unsigned long arg)
641{
642 struct lttng_metadata_stream *stream = filp->private_data;
643
644 stream->metadata_out = stream->metadata_in;
645}
646
d1344afa
JD
647/*
648 * Reset the counter of how much metadata has been consumed to 0. That way,
649 * the consumer receives the content of the metadata cache unchanged. This is
650 * different from the metadata_regenerate where the offset from epoch is
651 * resampled, here we want the exact same content as the last time the metadata
652 * was generated. This command is only possible if all the metadata written
653 * in the cache has been output to the metadata stream to avoid corrupting the
654 * metadata file.
655 *
656 * Return 0 on success, a negative value on error.
657 */
658static
659int lttng_metadata_cache_dump(struct lttng_metadata_stream *stream)
660{
661 int ret;
662 struct lttng_metadata_cache *cache = stream->metadata_cache;
663
664 mutex_lock(&cache->lock);
665 if (stream->metadata_out != cache->metadata_written) {
666 ret = -EBUSY;
667 goto end;
668 }
669 stream->metadata_out = 0;
670 stream->metadata_in = 0;
671 wake_up_interruptible(&stream->read_wait);
672 ret = 0;
673
674end:
675 mutex_unlock(&cache->lock);
676 return ret;
677}
678
d83004aa
JD
679static
680long lttng_metadata_ring_buffer_ioctl(struct file *filp,
681 unsigned int cmd, unsigned long arg)
682{
683 int ret;
684 struct lttng_metadata_stream *stream = filp->private_data;
685 struct lib_ring_buffer *buf = stream->priv;
686
687 switch (cmd) {
d83004aa
JD
688 case RING_BUFFER_GET_NEXT_SUBBUF:
689 {
35097f36
JD
690 struct lttng_metadata_stream *stream = filp->private_data;
691 struct lib_ring_buffer *buf = stream->priv;
692 struct channel *chan = buf->backend.chan;
693
694 ret = lttng_metadata_output_channel(stream, chan);
695 if (ret > 0) {
696 lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
697 ret = 0;
698 } else if (ret < 0)
d83004aa
JD
699 goto err;
700 break;
701 }
f613e3e6
MD
702 case RING_BUFFER_GET_SUBBUF:
703 {
704 /*
705 * Random access is not allowed for metadata channel.
706 */
707 return -ENOSYS;
708 }
c6f05468 709 case RING_BUFFER_FLUSH_EMPTY: /* Fall-through. */
35097f36
JD
710 case RING_BUFFER_FLUSH:
711 {
712 struct lttng_metadata_stream *stream = filp->private_data;
713 struct lib_ring_buffer *buf = stream->priv;
714 struct channel *chan = buf->backend.chan;
715
716 /*
717 * Before doing the actual ring buffer flush, write up to one
718 * packet of metadata in the ring buffer.
719 */
720 ret = lttng_metadata_output_channel(stream, chan);
721 if (ret < 0)
722 goto err;
723 break;
724 }
9616f0bf
JD
725 case RING_BUFFER_GET_METADATA_VERSION:
726 {
727 struct lttng_metadata_stream *stream = filp->private_data;
728
729 return put_u64(stream->version, arg);
730 }
d1344afa
JD
731 case RING_BUFFER_METADATA_CACHE_DUMP:
732 {
733 struct lttng_metadata_stream *stream = filp->private_data;
734
735 return lttng_metadata_cache_dump(stream);
736 }
d83004aa
JD
737 default:
738 break;
739 }
f613e3e6
MD
740 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
741
d83004aa 742 /* Performing lib ring buffer ioctl after our own. */
f613e3e6
MD
743 ret = lib_ring_buffer_ioctl(filp, cmd, arg, buf);
744 if (ret < 0)
745 goto err;
d83004aa 746
f613e3e6
MD
747 switch (cmd) {
748 case RING_BUFFER_PUT_NEXT_SUBBUF:
749 {
750 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp,
751 cmd, arg);
752 break;
753 }
754 default:
755 break;
756 }
d83004aa
JD
757err:
758 return ret;
759}
760
aeb9064d 761#ifdef CONFIG_COMPAT
d83004aa
JD
762static
763long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
764 unsigned int cmd, unsigned long arg)
765{
766 int ret;
767 struct lttng_metadata_stream *stream = filp->private_data;
768 struct lib_ring_buffer *buf = stream->priv;
769
770 switch (cmd) {
d83004aa
JD
771 case RING_BUFFER_GET_NEXT_SUBBUF:
772 {
35097f36
JD
773 struct lttng_metadata_stream *stream = filp->private_data;
774 struct lib_ring_buffer *buf = stream->priv;
775 struct channel *chan = buf->backend.chan;
776
777 ret = lttng_metadata_output_channel(stream, chan);
778 if (ret > 0) {
779 lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
780 ret = 0;
781 } else if (ret < 0)
d83004aa
JD
782 goto err;
783 break;
784 }
f613e3e6
MD
785 case RING_BUFFER_GET_SUBBUF:
786 {
787 /*
788 * Random access is not allowed for metadata channel.
789 */
790 return -ENOSYS;
791 }
c6f05468 792 case RING_BUFFER_FLUSH_EMPTY: /* Fall-through. */
96c55c2f
MD
793 case RING_BUFFER_FLUSH:
794 {
795 struct lttng_metadata_stream *stream = filp->private_data;
796 struct lib_ring_buffer *buf = stream->priv;
797 struct channel *chan = buf->backend.chan;
798
799 /*
800 * Before doing the actual ring buffer flush, write up to one
801 * packet of metadata in the ring buffer.
802 */
803 ret = lttng_metadata_output_channel(stream, chan);
804 if (ret < 0)
805 goto err;
806 break;
807 }
808 case RING_BUFFER_GET_METADATA_VERSION:
809 {
810 struct lttng_metadata_stream *stream = filp->private_data;
811
812 return put_u64(stream->version, arg);
813 }
d1344afa
JD
814 case RING_BUFFER_METADATA_CACHE_DUMP:
815 {
816 struct lttng_metadata_stream *stream = filp->private_data;
817
818 return lttng_metadata_cache_dump(stream);
819 }
d83004aa
JD
820 default:
821 break;
822 }
f613e3e6
MD
823 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
824
d83004aa 825 /* Performing lib ring buffer ioctl after our own. */
f613e3e6
MD
826 ret = lib_ring_buffer_compat_ioctl(filp, cmd, arg, buf);
827 if (ret < 0)
828 goto err;
d83004aa 829
f613e3e6
MD
830 switch (cmd) {
831 case RING_BUFFER_PUT_NEXT_SUBBUF:
832 {
833 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp,
834 cmd, arg);
835 break;
836 }
837 default:
838 break;
839 }
d83004aa
JD
840err:
841 return ret;
842}
aeb9064d 843#endif
d83004aa 844
b3b8072b
MD
845/*
846 * This is not used by anonymous file descriptors. This code is left
847 * there if we ever want to implement an inode with open() operation.
848 */
d83004aa
JD
849static
850int lttng_metadata_ring_buffer_open(struct inode *inode, struct file *file)
851{
852 struct lttng_metadata_stream *stream = inode->i_private;
853 struct lib_ring_buffer *buf = stream->priv;
854
855 file->private_data = buf;
b3b8072b
MD
856 /*
857 * Since life-time of metadata cache differs from that of
858 * session, we need to keep our own reference on the transport.
859 */
860 if (!try_module_get(stream->transport->owner)) {
861 printk(KERN_WARNING "LTT : Can't lock transport module.\n");
862 return -EBUSY;
863 }
d83004aa
JD
864 return lib_ring_buffer_open(inode, file, buf);
865}
866
867static
868int lttng_metadata_ring_buffer_release(struct inode *inode, struct file *file)
869{
870 struct lttng_metadata_stream *stream = file->private_data;
871 struct lib_ring_buffer *buf = stream->priv;
872
873 kref_put(&stream->metadata_cache->refcount, metadata_cache_destroy);
b3b8072b 874 module_put(stream->transport->owner);
d83004aa
JD
875 return lib_ring_buffer_release(inode, file, buf);
876}
877
878static
879ssize_t lttng_metadata_ring_buffer_splice_read(struct file *in, loff_t *ppos,
880 struct pipe_inode_info *pipe, size_t len,
881 unsigned int flags)
882{
883 struct lttng_metadata_stream *stream = in->private_data;
884 struct lib_ring_buffer *buf = stream->priv;
885
886 return lib_ring_buffer_splice_read(in, ppos, pipe, len,
887 flags, buf);
888}
889
890static
891int lttng_metadata_ring_buffer_mmap(struct file *filp,
892 struct vm_area_struct *vma)
893{
894 struct lttng_metadata_stream *stream = filp->private_data;
895 struct lib_ring_buffer *buf = stream->priv;
896
897 return lib_ring_buffer_mmap(filp, vma, buf);
898}
899
900static
901const struct file_operations lttng_metadata_ring_buffer_file_operations = {
902 .owner = THIS_MODULE,
903 .open = lttng_metadata_ring_buffer_open,
904 .release = lttng_metadata_ring_buffer_release,
905 .poll = lttng_metadata_ring_buffer_poll,
906 .splice_read = lttng_metadata_ring_buffer_splice_read,
907 .mmap = lttng_metadata_ring_buffer_mmap,
908 .unlocked_ioctl = lttng_metadata_ring_buffer_ioctl,
909 .llseek = vfs_lib_ring_buffer_no_llseek,
910#ifdef CONFIG_COMPAT
911 .compat_ioctl = lttng_metadata_ring_buffer_compat_ioctl,
912#endif
913};
914
915static
916int lttng_abi_create_stream_fd(struct file *channel_file, void *stream_priv,
917 const struct file_operations *fops)
ad1c05e1 918{
ad1c05e1 919 int stream_fd, ret;
11b5a3c2 920 struct file *stream_file;
ad1c05e1 921
4ac10b76 922 stream_fd = lttng_get_unused_fd();
ad1c05e1
MD
923 if (stream_fd < 0) {
924 ret = stream_fd;
925 goto fd_error;
926 }
d83004aa
JD
927 stream_file = anon_inode_getfile("[lttng_stream]", fops,
928 stream_priv, O_RDWR);
c0e31d2e
MD
929 if (IS_ERR(stream_file)) {
930 ret = PTR_ERR(stream_file);
ad1c05e1
MD
931 goto file_error;
932 }
409453cb
MD
933 /*
934 * OPEN_FMODE, called within anon_inode_getfile/alloc_file, don't honor
935 * FMODE_LSEEK, FMODE_PREAD nor FMODE_PWRITE. We need to read from this
936 * file descriptor, so we set FMODE_PREAD here.
937 */
d7b6f197 938 stream_file->f_mode |= FMODE_PREAD;
c0e31d2e 939 fd_install(stream_fd, stream_file);
dda6a249
MD
940 /*
941 * The stream holds a reference to the channel within the generic ring
942 * buffer library, so no need to hold a refcount on the channel and
943 * session files here.
944 */
ad1c05e1
MD
945 return stream_fd;
946
947file_error:
948 put_unused_fd(stream_fd);
d83004aa
JD
949fd_error:
950 return ret;
951}
952
953static
954int lttng_abi_open_stream(struct file *channel_file)
955{
956 struct lttng_channel *channel = channel_file->private_data;
957 struct lib_ring_buffer *buf;
958 int ret;
959 void *stream_priv;
960
961 buf = channel->ops->buffer_read_open(channel->chan);
962 if (!buf)
963 return -ENOENT;
964
965 stream_priv = buf;
966 ret = lttng_abi_create_stream_fd(channel_file, stream_priv,
ed8d02d6 967 &lttng_stream_ring_buffer_file_operations);
d83004aa
JD
968 if (ret < 0)
969 goto fd_error;
970
971 return ret;
972
973fd_error:
974 channel->ops->buffer_read_close(buf);
975 return ret;
976}
977
978static
979int lttng_abi_open_metadata_stream(struct file *channel_file)
980{
981 struct lttng_channel *channel = channel_file->private_data;
982 struct lttng_session *session = channel->session;
983 struct lib_ring_buffer *buf;
984 int ret;
985 struct lttng_metadata_stream *metadata_stream;
986 void *stream_priv;
987
988 buf = channel->ops->buffer_read_open(channel->chan);
989 if (!buf)
990 return -ENOENT;
991
992 metadata_stream = kzalloc(sizeof(struct lttng_metadata_stream),
993 GFP_KERNEL);
b3b8072b
MD
994 if (!metadata_stream) {
995 ret = -ENOMEM;
996 goto nomem;
997 }
d83004aa
JD
998 metadata_stream->metadata_cache = session->metadata_cache;
999 init_waitqueue_head(&metadata_stream->read_wait);
1000 metadata_stream->priv = buf;
1001 stream_priv = metadata_stream;
b3b8072b
MD
1002 metadata_stream->transport = channel->transport;
1003
1004 /*
1005 * Since life-time of metadata cache differs from that of
1006 * session, we need to keep our own reference on the transport.
1007 */
1008 if (!try_module_get(metadata_stream->transport->owner)) {
1009 printk(KERN_WARNING "LTT : Can't lock transport module.\n");
1010 ret = -EINVAL;
1011 goto notransport;
1012 }
1013
901aaa5f
FD
1014 if (!lttng_kref_get(&session->metadata_cache->refcount)) {
1015 ret = -EOVERFLOW;
9c1f4643 1016 goto kref_error;
901aaa5f
FD
1017 }
1018
d83004aa
JD
1019 ret = lttng_abi_create_stream_fd(channel_file, stream_priv,
1020 &lttng_metadata_ring_buffer_file_operations);
1021 if (ret < 0)
1022 goto fd_error;
1023
d83004aa
JD
1024 list_add(&metadata_stream->list,
1025 &session->metadata_cache->metadata_stream);
1026 return ret;
1027
ad1c05e1 1028fd_error:
9c1f4643
MD
1029 kref_put(&session->metadata_cache->refcount, metadata_cache_destroy);
1030kref_error:
b3b8072b
MD
1031 module_put(metadata_stream->transport->owner);
1032notransport:
1033 kfree(metadata_stream);
1034nomem:
11b5a3c2 1035 channel->ops->buffer_read_close(buf);
ad1c05e1
MD
1036 return ret;
1037}
1038
653fe716 1039static
c0e31d2e 1040int lttng_abi_create_event(struct file *channel_file,
6dccd6c1 1041 struct lttng_kernel_event *event_param)
653fe716 1042{
a90917c3 1043 struct lttng_channel *channel = channel_file->private_data;
653fe716 1044 int event_fd, ret;
11b5a3c2 1045 struct file *event_file;
3c997079 1046 void *priv;
653fe716 1047
6dccd6c1
JD
1048 event_param->name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
1049 switch (event_param->instrumentation) {
7371f44c 1050 case LTTNG_KERNEL_KRETPROBE:
6dccd6c1 1051 event_param->u.kretprobe.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
7371f44c 1052 break;
ab2277d6 1053 case LTTNG_KERNEL_KPROBE:
6dccd6c1 1054 event_param->u.kprobe.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
e0a7a7c4 1055 break;
ab2277d6 1056 case LTTNG_KERNEL_FUNCTION:
6dccd6c1 1057 event_param->u.ftrace.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
e0a7a7c4
MD
1058 break;
1059 default:
1060 break;
1061 }
33a39a3c
MD
1062 event_fd = lttng_get_unused_fd();
1063 if (event_fd < 0) {
1064 ret = event_fd;
1065 goto fd_error;
1066 }
1067 event_file = anon_inode_getfile("[lttng_event]",
1068 &lttng_event_fops,
1069 NULL, O_RDWR);
1070 if (IS_ERR(event_file)) {
1071 ret = PTR_ERR(event_file);
1072 goto file_error;
1073 }
9c1f4643
MD
1074 /* The event holds a reference on the channel */
1075 if (atomic_long_add_unless(&channel_file->f_count,
1076 1, INT_MAX) == INT_MAX) {
0d2c717f 1077 ret = -EOVERFLOW;
9c1f4643
MD
1078 goto refcount_error;
1079 }
33a39a3c
MD
1080 if (event_param->instrumentation == LTTNG_KERNEL_TRACEPOINT
1081 || event_param->instrumentation == LTTNG_KERNEL_SYSCALL) {
1082 struct lttng_enabler *enabler;
1083
4993071a
PP
1084 if (strutils_is_star_glob_pattern(event_param->name)) {
1085 /*
1086 * If the event name is a star globbing pattern,
1087 * we create the special star globbing enabler.
1088 */
1089 enabler = lttng_enabler_create(LTTNG_ENABLER_STAR_GLOB,
33a39a3c 1090 event_param, channel);
3c997079 1091 } else {
33a39a3c
MD
1092 enabler = lttng_enabler_create(LTTNG_ENABLER_NAME,
1093 event_param, channel);
1ec65de1 1094 }
33a39a3c
MD
1095 priv = enabler;
1096 } else {
1097 struct lttng_event *event;
4ee2453d 1098
33a39a3c
MD
1099 /*
1100 * We tolerate no failure path after event creation. It
1101 * will stay invariant for the rest of the session.
1102 */
1103 event = lttng_event_create(channel, event_param,
1104 NULL, NULL,
1105 event_param->instrumentation);
1106 WARN_ON_ONCE(!event);
1107 if (IS_ERR(event)) {
1108 ret = PTR_ERR(event);
1109 goto event_error;
80f87dd2 1110 }
33a39a3c 1111 priv = event;
03037b98 1112 }
33a39a3c
MD
1113 event_file->private_data = priv;
1114 fd_install(event_fd, event_file);
653fe716
MD
1115 return event_fd;
1116
03037b98 1117event_error:
9c1f4643
MD
1118 atomic_long_dec(&channel_file->f_count);
1119refcount_error:
c0e31d2e 1120 fput(event_file);
653fe716
MD
1121file_error:
1122 put_unused_fd(event_fd);
1123fd_error:
653fe716
MD
1124 return ret;
1125}
ad1c05e1
MD
1126
1127/**
1128 * lttng_channel_ioctl - lttng syscall through ioctl
1129 *
c0e31d2e 1130 * @file: the file
ad1c05e1
MD
1131 * @cmd: the command
1132 * @arg: command arg
1133 *
1134 * This ioctl implements lttng commands:
38d024ae 1135 * LTTNG_KERNEL_STREAM
ad1c05e1
MD
1136 * Returns an event stream file descriptor or failure.
1137 * (typically, one event stream records events from one CPU)
38d024ae 1138 * LTTNG_KERNEL_EVENT
ad1c05e1 1139 * Returns an event file descriptor or failure.
8070f5c0
MD
1140 * LTTNG_KERNEL_CONTEXT
1141 * Prepend a context field to each event in the channel
e64957da
MD
1142 * LTTNG_KERNEL_ENABLE
1143 * Enable recording for events in this channel (weak enable)
1144 * LTTNG_KERNEL_DISABLE
1145 * Disable recording for events in this channel (strong disable)
baf20995 1146 *
baf20995
MD
1147 * Channel and event file descriptors also hold a reference on the session.
1148 */
ad1c05e1 1149static
c0e31d2e 1150long lttng_channel_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
baf20995 1151{
a90917c3 1152 struct lttng_channel *channel = file->private_data;
8070f5c0 1153
baf20995 1154 switch (cmd) {
6dccd6c1 1155 case LTTNG_KERNEL_OLD_STREAM:
38d024ae 1156 case LTTNG_KERNEL_STREAM:
c0e31d2e 1157 return lttng_abi_open_stream(file);
6dccd6c1
JD
1158 case LTTNG_KERNEL_OLD_EVENT:
1159 {
1160 struct lttng_kernel_event *uevent_param;
1161 struct lttng_kernel_old_event *old_uevent_param;
1162 int ret;
1163
1164 uevent_param = kmalloc(sizeof(struct lttng_kernel_event),
1165 GFP_KERNEL);
1166 if (!uevent_param) {
1167 ret = -ENOMEM;
1168 goto old_event_end;
1169 }
1170 old_uevent_param = kmalloc(
1171 sizeof(struct lttng_kernel_old_event),
1172 GFP_KERNEL);
1173 if (!old_uevent_param) {
1174 ret = -ENOMEM;
1175 goto old_event_error_free_param;
1176 }
1177 if (copy_from_user(old_uevent_param,
1178 (struct lttng_kernel_old_event __user *) arg,
1179 sizeof(struct lttng_kernel_old_event))) {
1180 ret = -EFAULT;
1181 goto old_event_error_free_old_param;
1182 }
1183
1184 memcpy(uevent_param->name, old_uevent_param->name,
1185 sizeof(uevent_param->name));
1186 uevent_param->instrumentation =
1187 old_uevent_param->instrumentation;
1188
1189 switch (old_uevent_param->instrumentation) {
1190 case LTTNG_KERNEL_KPROBE:
1191 uevent_param->u.kprobe.addr =
1192 old_uevent_param->u.kprobe.addr;
1193 uevent_param->u.kprobe.offset =
1194 old_uevent_param->u.kprobe.offset;
1195 memcpy(uevent_param->u.kprobe.symbol_name,
1196 old_uevent_param->u.kprobe.symbol_name,
1197 sizeof(uevent_param->u.kprobe.symbol_name));
1198 break;
1199 case LTTNG_KERNEL_KRETPROBE:
1200 uevent_param->u.kretprobe.addr =
1201 old_uevent_param->u.kretprobe.addr;
1202 uevent_param->u.kretprobe.offset =
1203 old_uevent_param->u.kretprobe.offset;
1204 memcpy(uevent_param->u.kretprobe.symbol_name,
1205 old_uevent_param->u.kretprobe.symbol_name,
1206 sizeof(uevent_param->u.kretprobe.symbol_name));
1207 break;
1208 case LTTNG_KERNEL_FUNCTION:
1209 memcpy(uevent_param->u.ftrace.symbol_name,
1210 old_uevent_param->u.ftrace.symbol_name,
1211 sizeof(uevent_param->u.ftrace.symbol_name));
1212 break;
1213 default:
1214 break;
1215 }
1216 ret = lttng_abi_create_event(file, uevent_param);
1217
1218old_event_error_free_old_param:
1219 kfree(old_uevent_param);
1220old_event_error_free_param:
1221 kfree(uevent_param);
1222old_event_end:
1223 return ret;
1224 }
38d024ae 1225 case LTTNG_KERNEL_EVENT:
6dccd6c1
JD
1226 {
1227 struct lttng_kernel_event uevent_param;
1228
1229 if (copy_from_user(&uevent_param,
1230 (struct lttng_kernel_event __user *) arg,
1231 sizeof(uevent_param)))
1232 return -EFAULT;
1233 return lttng_abi_create_event(file, &uevent_param);
1234 }
1235 case LTTNG_KERNEL_OLD_CONTEXT:
1236 {
1237 struct lttng_kernel_context *ucontext_param;
1238 struct lttng_kernel_old_context *old_ucontext_param;
1239 int ret;
1240
1241 ucontext_param = kmalloc(sizeof(struct lttng_kernel_context),
1242 GFP_KERNEL);
1243 if (!ucontext_param) {
1244 ret = -ENOMEM;
1245 goto old_ctx_end;
1246 }
1247 old_ucontext_param = kmalloc(sizeof(struct lttng_kernel_old_context),
1248 GFP_KERNEL);
1249 if (!old_ucontext_param) {
1250 ret = -ENOMEM;
1251 goto old_ctx_error_free_param;
1252 }
1253
1254 if (copy_from_user(old_ucontext_param,
1255 (struct lttng_kernel_old_context __user *) arg,
1256 sizeof(struct lttng_kernel_old_context))) {
1257 ret = -EFAULT;
1258 goto old_ctx_error_free_old_param;
1259 }
1260 ucontext_param->ctx = old_ucontext_param->ctx;
1261 memcpy(ucontext_param->padding, old_ucontext_param->padding,
1262 sizeof(ucontext_param->padding));
1263 /* only type that uses the union */
1264 if (old_ucontext_param->ctx == LTTNG_KERNEL_CONTEXT_PERF_COUNTER) {
1265 ucontext_param->u.perf_counter.type =
1266 old_ucontext_param->u.perf_counter.type;
1267 ucontext_param->u.perf_counter.config =
1268 old_ucontext_param->u.perf_counter.config;
1269 memcpy(ucontext_param->u.perf_counter.name,
1270 old_ucontext_param->u.perf_counter.name,
1271 sizeof(ucontext_param->u.perf_counter.name));
1272 }
1273
1274 ret = lttng_abi_add_context(file,
1275 ucontext_param,
1276 &channel->ctx, channel->session);
1277
1278old_ctx_error_free_old_param:
1279 kfree(old_ucontext_param);
1280old_ctx_error_free_param:
1281 kfree(ucontext_param);
1282old_ctx_end:
1283 return ret;
1284 }
8070f5c0 1285 case LTTNG_KERNEL_CONTEXT:
6dccd6c1
JD
1286 {
1287 struct lttng_kernel_context ucontext_param;
1288
1289 if (copy_from_user(&ucontext_param,
8070f5c0 1290 (struct lttng_kernel_context __user *) arg,
6dccd6c1
JD
1291 sizeof(ucontext_param)))
1292 return -EFAULT;
1293 return lttng_abi_add_context(file,
1294 &ucontext_param,
8070f5c0 1295 &channel->ctx, channel->session);
6dccd6c1
JD
1296 }
1297 case LTTNG_KERNEL_OLD_ENABLE:
e64957da 1298 case LTTNG_KERNEL_ENABLE:
a90917c3 1299 return lttng_channel_enable(channel);
6dccd6c1 1300 case LTTNG_KERNEL_OLD_DISABLE:
e64957da 1301 case LTTNG_KERNEL_DISABLE:
a90917c3 1302 return lttng_channel_disable(channel);
12e579db
MD
1303 case LTTNG_KERNEL_SYSCALL_MASK:
1304 return lttng_channel_syscall_mask(channel,
1305 (struct lttng_kernel_syscall_mask __user *) arg);
baf20995
MD
1306 default:
1307 return -ENOIOCTLCMD;
1308 }
1309}
1310
5dbbdb43
MD
1311/**
1312 * lttng_metadata_ioctl - lttng syscall through ioctl
1313 *
1314 * @file: the file
1315 * @cmd: the command
1316 * @arg: command arg
1317 *
1318 * This ioctl implements lttng commands:
38d024ae 1319 * LTTNG_KERNEL_STREAM
5dbbdb43
MD
1320 * Returns an event stream file descriptor or failure.
1321 *
1322 * Channel and event file descriptors also hold a reference on the session.
1323 */
1324static
1325long lttng_metadata_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1326{
1327 switch (cmd) {
6dccd6c1 1328 case LTTNG_KERNEL_OLD_STREAM:
38d024ae 1329 case LTTNG_KERNEL_STREAM:
d83004aa 1330 return lttng_abi_open_metadata_stream(file);
5dbbdb43
MD
1331 default:
1332 return -ENOIOCTLCMD;
1333 }
1334}
1335
653fe716
MD
1336/**
1337 * lttng_channel_poll - lttng stream addition/removal monitoring
1338 *
c0e31d2e 1339 * @file: the file
653fe716
MD
1340 * @wait: poll table
1341 */
c0e31d2e 1342unsigned int lttng_channel_poll(struct file *file, poll_table *wait)
653fe716 1343{
a90917c3 1344 struct lttng_channel *channel = file->private_data;
653fe716
MD
1345 unsigned int mask = 0;
1346
c0e31d2e 1347 if (file->f_mode & FMODE_READ) {
a33e44a6 1348 poll_wait_set_exclusive(wait);
24cedcfe
MD
1349 poll_wait(file, channel->ops->get_hp_wait_queue(channel->chan),
1350 wait);
653fe716 1351
254ec7bc
MD
1352 if (channel->ops->is_disabled(channel->chan))
1353 return POLLERR;
24cedcfe 1354 if (channel->ops->is_finalized(channel->chan))
653fe716 1355 return POLLHUP;
f71ecafa 1356 if (channel->ops->buffer_has_read_closed_stream(channel->chan))
653fe716 1357 return POLLIN | POLLRDNORM;
f71ecafa 1358 return 0;
653fe716
MD
1359 }
1360 return mask;
1361
1362}
1363
0a84a57f
MD
1364static
1365int lttng_channel_release(struct inode *inode, struct file *file)
1366{
a90917c3 1367 struct lttng_channel *channel = file->private_data;
c269fff4
MD
1368
1369 if (channel)
1370 fput(channel->session->file);
0a84a57f
MD
1371 return 0;
1372}
1373
d83004aa
JD
1374static
1375int lttng_metadata_channel_release(struct inode *inode, struct file *file)
1376{
1377 struct lttng_channel *channel = file->private_data;
1378
1379 if (channel) {
d83004aa 1380 fput(channel->session->file);
a3381417 1381 lttng_metadata_channel_destroy(channel);
d83004aa
JD
1382 }
1383
1384 return 0;
1385}
1386
ad1c05e1 1387static const struct file_operations lttng_channel_fops = {
a33c9927 1388 .owner = THIS_MODULE,
03037b98 1389 .release = lttng_channel_release,
653fe716 1390 .poll = lttng_channel_poll,
ad1c05e1 1391 .unlocked_ioctl = lttng_channel_ioctl,
baf20995 1392#ifdef CONFIG_COMPAT
03037b98 1393 .compat_ioctl = lttng_channel_ioctl,
baf20995 1394#endif
11b5a3c2 1395};
baf20995 1396
5dbbdb43 1397static const struct file_operations lttng_metadata_fops = {
a33c9927 1398 .owner = THIS_MODULE,
d83004aa 1399 .release = lttng_metadata_channel_release,
5dbbdb43
MD
1400 .unlocked_ioctl = lttng_metadata_ioctl,
1401#ifdef CONFIG_COMPAT
1402 .compat_ioctl = lttng_metadata_ioctl,
1403#endif
1404};
1405
8070f5c0
MD
1406/**
1407 * lttng_event_ioctl - lttng syscall through ioctl
1408 *
1409 * @file: the file
1410 * @cmd: the command
1411 * @arg: command arg
1412 *
1413 * This ioctl implements lttng commands:
8070f5c0
MD
1414 * LTTNG_KERNEL_CONTEXT
1415 * Prepend a context field to each record of this event
e64957da
MD
1416 * LTTNG_KERNEL_ENABLE
1417 * Enable recording for this event (weak enable)
1418 * LTTNG_KERNEL_DISABLE
1419 * Disable recording for this event (strong disable)
8070f5c0
MD
1420 */
1421static
1422long lttng_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1423{
3c997079
MD
1424 struct lttng_event *event;
1425 struct lttng_enabler *enabler;
1426 enum lttng_event_type *evtype = file->private_data;
8070f5c0
MD
1427
1428 switch (cmd) {
6dccd6c1
JD
1429 case LTTNG_KERNEL_OLD_CONTEXT:
1430 {
3c997079
MD
1431 /* Not implemented */
1432 return -ENOSYS;
6dccd6c1 1433 }
8070f5c0 1434 case LTTNG_KERNEL_CONTEXT:
6dccd6c1 1435 {
3c997079
MD
1436 /* Not implemented */
1437 return -ENOSYS;
6dccd6c1
JD
1438 }
1439 case LTTNG_KERNEL_OLD_ENABLE:
e64957da 1440 case LTTNG_KERNEL_ENABLE:
3c997079
MD
1441 switch (*evtype) {
1442 case LTTNG_TYPE_EVENT:
1443 event = file->private_data;
1444 return lttng_event_enable(event);
1445 case LTTNG_TYPE_ENABLER:
1446 enabler = file->private_data;
1447 return lttng_enabler_enable(enabler);
1448 default:
1449 WARN_ON_ONCE(1);
1450 return -ENOSYS;
1451 }
6dccd6c1 1452 case LTTNG_KERNEL_OLD_DISABLE:
e64957da 1453 case LTTNG_KERNEL_DISABLE:
3c997079
MD
1454 switch (*evtype) {
1455 case LTTNG_TYPE_EVENT:
1456 event = file->private_data;
1457 return lttng_event_disable(event);
1458 case LTTNG_TYPE_ENABLER:
1459 enabler = file->private_data;
1460 return lttng_enabler_disable(enabler);
1461 default:
1462 WARN_ON_ONCE(1);
1463 return -ENOSYS;
1464 }
07dfc1d0
MD
1465 case LTTNG_KERNEL_FILTER:
1466 switch (*evtype) {
1467 case LTTNG_TYPE_EVENT:
1468 return -EINVAL;
1469 case LTTNG_TYPE_ENABLER:
1470 {
1471 enabler = file->private_data;
1472 return lttng_enabler_attach_bytecode(enabler,
1473 (struct lttng_kernel_filter_bytecode __user *) arg);
1474 }
1475
1476 }
3aed4dca
FD
1477 case LTTNG_KERNEL_ADD_CALLSITE:
1478 switch (*evtype) {
1479 case LTTNG_TYPE_EVENT:
1480 event = file->private_data;
1481 return lttng_event_add_callsite(event,
1482 (struct lttng_kernel_event_callsite __user *) arg);
1483 case LTTNG_TYPE_ENABLER:
1484 return -EINVAL;
1485 }
8070f5c0
MD
1486 default:
1487 return -ENOIOCTLCMD;
1488 }
1489}
1490
0a84a57f
MD
1491static
1492int lttng_event_release(struct inode *inode, struct file *file)
1493{
3c997079
MD
1494 struct lttng_event *event;
1495 struct lttng_enabler *enabler;
1496 enum lttng_event_type *evtype = file->private_data;
1497
1498 if (!evtype)
1499 return 0;
1500
1501 switch (*evtype) {
1502 case LTTNG_TYPE_EVENT:
1503 event = file->private_data;
1504 if (event)
1505 fput(event->chan->file);
1506 break;
1507 case LTTNG_TYPE_ENABLER:
1508 enabler = file->private_data;
1509 if (enabler)
1510 fput(enabler->chan->file);
1511 break;
1512 default:
1513 WARN_ON_ONCE(1);
1514 break;
1515 }
c269fff4 1516
0a84a57f
MD
1517 return 0;
1518}
1519
3b923e5b 1520/* TODO: filter control ioctl */
0a84a57f 1521static const struct file_operations lttng_event_fops = {
a33c9927 1522 .owner = THIS_MODULE,
0a84a57f 1523 .release = lttng_event_release,
8070f5c0
MD
1524 .unlocked_ioctl = lttng_event_ioctl,
1525#ifdef CONFIG_COMPAT
1526 .compat_ioctl = lttng_event_ioctl,
1527#endif
11b5a3c2 1528};
0a84a57f 1529
3b731ab1
JD
1530static int put_u64(uint64_t val, unsigned long arg)
1531{
1532 return put_user(val, (uint64_t __user *) arg);
1533}
1534
ed8d02d6
JD
1535static long lttng_stream_ring_buffer_ioctl(struct file *filp,
1536 unsigned int cmd, unsigned long arg)
1537{
3b731ab1
JD
1538 struct lib_ring_buffer *buf = filp->private_data;
1539 struct channel *chan = buf->backend.chan;
1540 const struct lib_ring_buffer_config *config = &chan->backend.config;
dd5a0db3 1541 const struct lttng_channel_ops *ops = chan->backend.priv_ops;
3b731ab1
JD
1542 int ret;
1543
1544 if (atomic_read(&chan->record_disabled))
1545 return -EIO;
1546
ed8d02d6 1547 switch (cmd) {
3b731ab1
JD
1548 case LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN:
1549 {
1550 uint64_t ts;
1551
dd5a0db3 1552 ret = ops->timestamp_begin(config, buf, &ts);
3b731ab1
JD
1553 if (ret < 0)
1554 goto error;
1555 return put_u64(ts, arg);
1556 }
1557 case LTTNG_RING_BUFFER_GET_TIMESTAMP_END:
1558 {
1559 uint64_t ts;
1560
dd5a0db3 1561 ret = ops->timestamp_end(config, buf, &ts);
3b731ab1
JD
1562 if (ret < 0)
1563 goto error;
1564 return put_u64(ts, arg);
1565 }
1566 case LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED:
1567 {
1568 uint64_t ed;
1569
dd5a0db3 1570 ret = ops->events_discarded(config, buf, &ed);
3b731ab1
JD
1571 if (ret < 0)
1572 goto error;
1573 return put_u64(ed, arg);
1574 }
1575 case LTTNG_RING_BUFFER_GET_CONTENT_SIZE:
1576 {
1577 uint64_t cs;
1578
dd5a0db3 1579 ret = ops->content_size(config, buf, &cs);
3b731ab1
JD
1580 if (ret < 0)
1581 goto error;
1582 return put_u64(cs, arg);
1583 }
1584 case LTTNG_RING_BUFFER_GET_PACKET_SIZE:
1585 {
1586 uint64_t ps;
1587
dd5a0db3 1588 ret = ops->packet_size(config, buf, &ps);
3b731ab1
JD
1589 if (ret < 0)
1590 goto error;
1591 return put_u64(ps, arg);
1592 }
1593 case LTTNG_RING_BUFFER_GET_STREAM_ID:
1594 {
1595 uint64_t si;
1596
dd5a0db3 1597 ret = ops->stream_id(config, buf, &si);
3b731ab1
JD
1598 if (ret < 0)
1599 goto error;
1600 return put_u64(si, arg);
1601 }
2348ca17
JD
1602 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP:
1603 {
1604 uint64_t ts;
1605
dd5a0db3 1606 ret = ops->current_timestamp(config, buf, &ts);
2348ca17
JD
1607 if (ret < 0)
1608 goto error;
1609 return put_u64(ts, arg);
1610 }
5b3cf4f9
JD
1611 case LTTNG_RING_BUFFER_GET_SEQ_NUM:
1612 {
1613 uint64_t seq;
1614
1615 ret = ops->sequence_number(config, buf, &seq);
1616 if (ret < 0)
1617 goto error;
1618 return put_u64(seq, arg);
1619 }
5594698f
JD
1620 case LTTNG_RING_BUFFER_INSTANCE_ID:
1621 {
1622 uint64_t id;
1623
1624 ret = ops->instance_id(config, buf, &id);
1625 if (ret < 0)
1626 goto error;
1627 return put_u64(id, arg);
1628 }
3b731ab1
JD
1629 default:
1630 return lib_ring_buffer_file_operations.unlocked_ioctl(filp,
1631 cmd, arg);
ed8d02d6 1632 }
3b731ab1
JD
1633
1634error:
1635 return -ENOSYS;
ed8d02d6
JD
1636}
1637
1638#ifdef CONFIG_COMPAT
1639static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
1640 unsigned int cmd, unsigned long arg)
1641{
3b731ab1
JD
1642 struct lib_ring_buffer *buf = filp->private_data;
1643 struct channel *chan = buf->backend.chan;
1644 const struct lib_ring_buffer_config *config = &chan->backend.config;
dd5a0db3 1645 const struct lttng_channel_ops *ops = chan->backend.priv_ops;
3b731ab1
JD
1646 int ret;
1647
1648 if (atomic_read(&chan->record_disabled))
1649 return -EIO;
1650
ed8d02d6 1651 switch (cmd) {
3b731ab1
JD
1652 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN:
1653 {
1654 uint64_t ts;
1655
dd5a0db3 1656 ret = ops->timestamp_begin(config, buf, &ts);
3b731ab1
JD
1657 if (ret < 0)
1658 goto error;
1659 return put_u64(ts, arg);
1660 }
1661 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END:
1662 {
1663 uint64_t ts;
1664
dd5a0db3 1665 ret = ops->timestamp_end(config, buf, &ts);
3b731ab1
JD
1666 if (ret < 0)
1667 goto error;
1668 return put_u64(ts, arg);
1669 }
1670 case LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED:
1671 {
1672 uint64_t ed;
1673
dd5a0db3 1674 ret = ops->events_discarded(config, buf, &ed);
3b731ab1
JD
1675 if (ret < 0)
1676 goto error;
1677 return put_u64(ed, arg);
ed8d02d6 1678 }
3b731ab1
JD
1679 case LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE:
1680 {
1681 uint64_t cs;
1682
dd5a0db3 1683 ret = ops->content_size(config, buf, &cs);
3b731ab1
JD
1684 if (ret < 0)
1685 goto error;
1686 return put_u64(cs, arg);
1687 }
1688 case LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE:
1689 {
1690 uint64_t ps;
1691
dd5a0db3 1692 ret = ops->packet_size(config, buf, &ps);
3b731ab1
JD
1693 if (ret < 0)
1694 goto error;
1695 return put_u64(ps, arg);
1696 }
1697 case LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID:
1698 {
1699 uint64_t si;
1700
dd5a0db3 1701 ret = ops->stream_id(config, buf, &si);
3b731ab1
JD
1702 if (ret < 0)
1703 goto error;
1704 return put_u64(si, arg);
1705 }
2348ca17
JD
1706 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP:
1707 {
1708 uint64_t ts;
1709
dd5a0db3 1710 ret = ops->current_timestamp(config, buf, &ts);
2348ca17
JD
1711 if (ret < 0)
1712 goto error;
1713 return put_u64(ts, arg);
1714 }
5b3cf4f9
JD
1715 case LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM:
1716 {
1717 uint64_t seq;
1718
1719 ret = ops->sequence_number(config, buf, &seq);
1720 if (ret < 0)
1721 goto error;
1722 return put_u64(seq, arg);
1723 }
5594698f
JD
1724 case LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID:
1725 {
1726 uint64_t id;
1727
1728 ret = ops->instance_id(config, buf, &id);
1729 if (ret < 0)
1730 goto error;
1731 return put_u64(id, arg);
1732 }
3b731ab1
JD
1733 default:
1734 return lib_ring_buffer_file_operations.compat_ioctl(filp,
1735 cmd, arg);
1736 }
1737
1738error:
1739 return -ENOSYS;
ed8d02d6
JD
1740}
1741#endif /* CONFIG_COMPAT */
1742
1743static void lttng_stream_override_ring_buffer_fops(void)
1744{
1745 lttng_stream_ring_buffer_file_operations.owner = THIS_MODULE;
1746 lttng_stream_ring_buffer_file_operations.open =
1747 lib_ring_buffer_file_operations.open;
1748 lttng_stream_ring_buffer_file_operations.release =
1749 lib_ring_buffer_file_operations.release;
1750 lttng_stream_ring_buffer_file_operations.poll =
1751 lib_ring_buffer_file_operations.poll;
1752 lttng_stream_ring_buffer_file_operations.splice_read =
1753 lib_ring_buffer_file_operations.splice_read;
1754 lttng_stream_ring_buffer_file_operations.mmap =
1755 lib_ring_buffer_file_operations.mmap;
1756 lttng_stream_ring_buffer_file_operations.unlocked_ioctl =
1757 lttng_stream_ring_buffer_ioctl;
1758 lttng_stream_ring_buffer_file_operations.llseek =
1759 lib_ring_buffer_file_operations.llseek;
1760#ifdef CONFIG_COMPAT
1761 lttng_stream_ring_buffer_file_operations.compat_ioctl =
1762 lttng_stream_ring_buffer_compat_ioctl;
1763#endif
1764}
1765
80996790 1766int __init lttng_abi_init(void)
baf20995
MD
1767{
1768 int ret = 0;
1769
6d2a620c 1770 wrapper_vmalloc_sync_all();
2754583e 1771 lttng_clock_ref();
f771eda6
JD
1772
1773 ret = lttng_tp_mempool_init();
1774 if (ret) {
1775 goto error;
1776 }
1777
d29348f7 1778 lttng_proc_dentry = proc_create_data("lttng", S_IRUSR | S_IWUSR, NULL,
e6a17f26 1779 &lttng_fops, NULL);
2470a237 1780
255e52a4 1781 if (!lttng_proc_dentry) {
baf20995
MD
1782 printk(KERN_ERR "Error creating LTTng control file\n");
1783 ret = -ENOMEM;
1784 goto error;
1785 }
ed8d02d6 1786 lttng_stream_override_ring_buffer_fops();
2754583e 1787 return 0;
ed8d02d6 1788
baf20995 1789error:
f771eda6 1790 lttng_tp_mempool_destroy();
2754583e 1791 lttng_clock_unref();
baf20995
MD
1792 return ret;
1793}
1794
e6e65fcd
MD
1795/* No __exit annotation because used by init error path too. */
1796void lttng_abi_exit(void)
baf20995 1797{
f771eda6 1798 lttng_tp_mempool_destroy();
2754583e 1799 lttng_clock_unref();
e6a17f26
MD
1800 if (lttng_proc_dentry)
1801 remove_proc_entry("lttng", NULL);
baf20995 1802}
This page took 0.126803 seconds and 4 git commands to generate.