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