1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Mimic system calls for:
10 * - session creation, returns a file descriptor or failure.
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.
26 #include <linux/module.h>
27 #include <linux/proc_fs.h>
28 #include <linux/anon_inodes.h>
29 #include <linux/file.h>
30 #include <linux/uaccess.h>
31 #include <linux/slab.h>
32 #include <linux/err.h>
33 #include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
34 #include <ringbuffer/vfs.h>
35 #include <ringbuffer/backend.h>
36 #include <ringbuffer/frontend.h>
37 #include <wrapper/poll.h>
38 #include <wrapper/file.h>
39 #include <wrapper/kref.h>
40 #include <lttng/string-utils.h>
41 #include <lttng/abi.h>
42 #include <lttng/abi-old.h>
43 #include <lttng/events.h>
44 #include <lttng/tracer.h>
45 #include <lttng/tp-mempool.h>
46 #include <ringbuffer/frontend_types.h>
49 * This is LTTng's own personal way to create a system call as an external
50 * module. We use ioctl() on /proc/lttng.
53 static struct proc_dir_entry
*lttng_proc_dentry
;
55 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0))
56 static const struct proc_ops lttng_proc_ops
;
58 static const struct file_operations lttng_proc_ops
;
61 static const struct file_operations lttng_session_fops
;
62 static const struct file_operations lttng_event_notifier_group_fops
;
63 static const struct file_operations lttng_channel_fops
;
64 static const struct file_operations lttng_metadata_fops
;
65 static const struct file_operations lttng_event_fops
;
66 static struct file_operations lttng_stream_ring_buffer_file_operations
;
68 static int put_u64(uint64_t val
, unsigned long arg
);
69 static int put_u32(uint32_t val
, unsigned long arg
);
72 * Teardown management: opened file descriptors keep a refcount on the module,
73 * so it can only exit when all file descriptors are closed.
77 int lttng_abi_create_session(void)
79 struct lttng_session
*session
;
80 struct file
*session_file
;
83 session
= lttng_session_create();
86 session_fd
= lttng_get_unused_fd();
91 session_file
= anon_inode_getfile("[lttng_session]",
94 if (IS_ERR(session_file
)) {
95 ret
= PTR_ERR(session_file
);
98 session
->file
= session_file
;
99 fd_install(session_fd
, session_file
);
103 put_unused_fd(session_fd
);
105 lttng_session_destroy(session
);
109 void event_notifier_send_notification_work_wakeup(struct irq_work
*entry
)
111 struct lttng_event_notifier_group
*event_notifier_group
=
112 container_of(entry
, struct lttng_event_notifier_group
,
114 wake_up_interruptible(&event_notifier_group
->read_wait
);
118 int lttng_abi_create_event_notifier_group(void)
120 struct lttng_event_notifier_group
*event_notifier_group
;
121 struct file
*event_notifier_group_file
;
122 int event_notifier_group_fd
, ret
;
124 event_notifier_group
= lttng_event_notifier_group_create();
125 if (!event_notifier_group
)
128 event_notifier_group_fd
= lttng_get_unused_fd();
129 if (event_notifier_group_fd
< 0) {
130 ret
= event_notifier_group_fd
;
133 event_notifier_group_file
= anon_inode_getfile("[lttng_event_notifier_group]",
134 <tng_event_notifier_group_fops
,
135 event_notifier_group
, O_RDWR
);
136 if (IS_ERR(event_notifier_group_file
)) {
137 ret
= PTR_ERR(event_notifier_group_file
);
141 event_notifier_group
->file
= event_notifier_group_file
;
142 init_waitqueue_head(&event_notifier_group
->read_wait
);
143 init_irq_work(&event_notifier_group
->wakeup_pending
,
144 event_notifier_send_notification_work_wakeup
);
145 fd_install(event_notifier_group_fd
, event_notifier_group_file
);
146 return event_notifier_group_fd
;
149 put_unused_fd(event_notifier_group_fd
);
151 lttng_event_notifier_group_destroy(event_notifier_group
);
156 int lttng_abi_tracepoint_list(void)
158 struct file
*tracepoint_list_file
;
161 file_fd
= lttng_get_unused_fd();
167 tracepoint_list_file
= anon_inode_getfile("[lttng_tracepoint_list]",
168 <tng_tracepoint_list_fops
,
170 if (IS_ERR(tracepoint_list_file
)) {
171 ret
= PTR_ERR(tracepoint_list_file
);
174 ret
= lttng_tracepoint_list_fops
.open(NULL
, tracepoint_list_file
);
177 fd_install(file_fd
, tracepoint_list_file
);
181 fput(tracepoint_list_file
);
183 put_unused_fd(file_fd
);
188 #ifndef CONFIG_HAVE_SYSCALL_TRACEPOINTS
190 int lttng_abi_syscall_list(void)
196 int lttng_abi_syscall_list(void)
198 struct file
*syscall_list_file
;
201 file_fd
= lttng_get_unused_fd();
207 syscall_list_file
= anon_inode_getfile("[lttng_syscall_list]",
208 <tng_syscall_list_fops
,
210 if (IS_ERR(syscall_list_file
)) {
211 ret
= PTR_ERR(syscall_list_file
);
214 ret
= lttng_syscall_list_fops
.open(NULL
, syscall_list_file
);
217 fd_install(file_fd
, syscall_list_file
);
221 fput(syscall_list_file
);
223 put_unused_fd(file_fd
);
230 void lttng_abi_tracer_version(struct lttng_kernel_tracer_version
*v
)
232 v
->major
= LTTNG_MODULES_MAJOR_VERSION
;
233 v
->minor
= LTTNG_MODULES_MINOR_VERSION
;
234 v
->patchlevel
= LTTNG_MODULES_PATCHLEVEL_VERSION
;
238 void lttng_abi_tracer_abi_version(struct lttng_kernel_tracer_abi_version
*v
)
240 v
->major
= LTTNG_MODULES_ABI_MAJOR_VERSION
;
241 v
->minor
= LTTNG_MODULES_ABI_MINOR_VERSION
;
245 long lttng_abi_add_context(struct file
*file
,
246 struct lttng_kernel_context
*context_param
,
247 struct lttng_ctx
**ctx
, struct lttng_session
*session
)
250 if (session
->been_active
)
253 switch (context_param
->ctx
) {
254 case LTTNG_KERNEL_CONTEXT_PID
:
255 return lttng_add_pid_to_ctx(ctx
);
256 case LTTNG_KERNEL_CONTEXT_PRIO
:
257 return lttng_add_prio_to_ctx(ctx
);
258 case LTTNG_KERNEL_CONTEXT_NICE
:
259 return lttng_add_nice_to_ctx(ctx
);
260 case LTTNG_KERNEL_CONTEXT_VPID
:
261 return lttng_add_vpid_to_ctx(ctx
);
262 case LTTNG_KERNEL_CONTEXT_TID
:
263 return lttng_add_tid_to_ctx(ctx
);
264 case LTTNG_KERNEL_CONTEXT_VTID
:
265 return lttng_add_vtid_to_ctx(ctx
);
266 case LTTNG_KERNEL_CONTEXT_PPID
:
267 return lttng_add_ppid_to_ctx(ctx
);
268 case LTTNG_KERNEL_CONTEXT_VPPID
:
269 return lttng_add_vppid_to_ctx(ctx
);
270 case LTTNG_KERNEL_CONTEXT_PERF_COUNTER
:
271 context_param
->u
.perf_counter
.name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
272 return lttng_add_perf_counter_to_ctx(context_param
->u
.perf_counter
.type
,
273 context_param
->u
.perf_counter
.config
,
274 context_param
->u
.perf_counter
.name
,
276 case LTTNG_KERNEL_CONTEXT_PROCNAME
:
277 return lttng_add_procname_to_ctx(ctx
);
278 case LTTNG_KERNEL_CONTEXT_HOSTNAME
:
279 return lttng_add_hostname_to_ctx(ctx
);
280 case LTTNG_KERNEL_CONTEXT_CPU_ID
:
281 return lttng_add_cpu_id_to_ctx(ctx
);
282 case LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE
:
283 return lttng_add_interruptible_to_ctx(ctx
);
284 case LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE
:
285 return lttng_add_need_reschedule_to_ctx(ctx
);
286 case LTTNG_KERNEL_CONTEXT_PREEMPTIBLE
:
287 return lttng_add_preemptible_to_ctx(ctx
);
288 case LTTNG_KERNEL_CONTEXT_MIGRATABLE
:
289 return lttng_add_migratable_to_ctx(ctx
);
290 case LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL
:
291 case LTTNG_KERNEL_CONTEXT_CALLSTACK_USER
:
292 return lttng_add_callstack_to_ctx(ctx
, context_param
->ctx
);
293 case LTTNG_KERNEL_CONTEXT_CGROUP_NS
:
294 return lttng_add_cgroup_ns_to_ctx(ctx
);
295 case LTTNG_KERNEL_CONTEXT_IPC_NS
:
296 return lttng_add_ipc_ns_to_ctx(ctx
);
297 case LTTNG_KERNEL_CONTEXT_MNT_NS
:
298 return lttng_add_mnt_ns_to_ctx(ctx
);
299 case LTTNG_KERNEL_CONTEXT_NET_NS
:
300 return lttng_add_net_ns_to_ctx(ctx
);
301 case LTTNG_KERNEL_CONTEXT_PID_NS
:
302 return lttng_add_pid_ns_to_ctx(ctx
);
303 case LTTNG_KERNEL_CONTEXT_USER_NS
:
304 return lttng_add_user_ns_to_ctx(ctx
);
305 case LTTNG_KERNEL_CONTEXT_UTS_NS
:
306 return lttng_add_uts_ns_to_ctx(ctx
);
307 case LTTNG_KERNEL_CONTEXT_UID
:
308 return lttng_add_uid_to_ctx(ctx
);
309 case LTTNG_KERNEL_CONTEXT_EUID
:
310 return lttng_add_euid_to_ctx(ctx
);
311 case LTTNG_KERNEL_CONTEXT_SUID
:
312 return lttng_add_suid_to_ctx(ctx
);
313 case LTTNG_KERNEL_CONTEXT_GID
:
314 return lttng_add_gid_to_ctx(ctx
);
315 case LTTNG_KERNEL_CONTEXT_EGID
:
316 return lttng_add_egid_to_ctx(ctx
);
317 case LTTNG_KERNEL_CONTEXT_SGID
:
318 return lttng_add_sgid_to_ctx(ctx
);
319 case LTTNG_KERNEL_CONTEXT_VUID
:
320 return lttng_add_vuid_to_ctx(ctx
);
321 case LTTNG_KERNEL_CONTEXT_VEUID
:
322 return lttng_add_veuid_to_ctx(ctx
);
323 case LTTNG_KERNEL_CONTEXT_VSUID
:
324 return lttng_add_vsuid_to_ctx(ctx
);
325 case LTTNG_KERNEL_CONTEXT_VGID
:
326 return lttng_add_vgid_to_ctx(ctx
);
327 case LTTNG_KERNEL_CONTEXT_VEGID
:
328 return lttng_add_vegid_to_ctx(ctx
);
329 case LTTNG_KERNEL_CONTEXT_VSGID
:
330 return lttng_add_vsgid_to_ctx(ctx
);
331 case LTTNG_KERNEL_CONTEXT_TIME_NS
:
332 return lttng_add_time_ns_to_ctx(ctx
);
339 * lttng_ioctl - lttng syscall through ioctl
345 * This ioctl implements lttng commands:
346 * LTTNG_KERNEL_SESSION
347 * Returns a LTTng trace session file descriptor
348 * LTTNG_KERNEL_TRACER_VERSION
349 * Returns the LTTng kernel tracer version
350 * LTTNG_KERNEL_TRACEPOINT_LIST
351 * Returns a file descriptor listing available tracepoints
352 * LTTNG_KERNEL_WAIT_QUIESCENT
353 * Returns after all previously running probes have completed
354 * LTTNG_KERNEL_TRACER_ABI_VERSION
355 * Returns the LTTng kernel tracer ABI version
356 * LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_CREATE
357 * Returns a LTTng event notifier group file descriptor
359 * The returned session will be deleted when its file descriptor is closed.
362 long lttng_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
365 case LTTNG_KERNEL_OLD_SESSION
:
366 case LTTNG_KERNEL_SESSION
:
367 return lttng_abi_create_session();
368 case LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_CREATE
:
369 return lttng_abi_create_event_notifier_group();
370 case LTTNG_KERNEL_OLD_TRACER_VERSION
:
372 struct lttng_kernel_tracer_version v
;
373 struct lttng_kernel_old_tracer_version oldv
;
374 struct lttng_kernel_old_tracer_version
*uversion
=
375 (struct lttng_kernel_old_tracer_version __user
*) arg
;
377 lttng_abi_tracer_version(&v
);
378 oldv
.major
= v
.major
;
379 oldv
.minor
= v
.minor
;
380 oldv
.patchlevel
= v
.patchlevel
;
382 if (copy_to_user(uversion
, &oldv
, sizeof(oldv
)))
386 case LTTNG_KERNEL_TRACER_VERSION
:
388 struct lttng_kernel_tracer_version version
;
389 struct lttng_kernel_tracer_version
*uversion
=
390 (struct lttng_kernel_tracer_version __user
*) arg
;
392 lttng_abi_tracer_version(&version
);
394 if (copy_to_user(uversion
, &version
, sizeof(version
)))
398 case LTTNG_KERNEL_TRACER_ABI_VERSION
:
400 struct lttng_kernel_tracer_abi_version version
;
401 struct lttng_kernel_tracer_abi_version
*uversion
=
402 (struct lttng_kernel_tracer_abi_version __user
*) arg
;
404 lttng_abi_tracer_abi_version(&version
);
406 if (copy_to_user(uversion
, &version
, sizeof(version
)))
410 case LTTNG_KERNEL_OLD_TRACEPOINT_LIST
:
411 case LTTNG_KERNEL_TRACEPOINT_LIST
:
412 return lttng_abi_tracepoint_list();
413 case LTTNG_KERNEL_SYSCALL_LIST
:
414 return lttng_abi_syscall_list();
415 case LTTNG_KERNEL_OLD_WAIT_QUIESCENT
:
416 case LTTNG_KERNEL_WAIT_QUIESCENT
:
419 case LTTNG_KERNEL_OLD_CALIBRATE
:
421 struct lttng_kernel_old_calibrate __user
*ucalibrate
=
422 (struct lttng_kernel_old_calibrate __user
*) arg
;
423 struct lttng_kernel_old_calibrate old_calibrate
;
424 struct lttng_kernel_calibrate calibrate
;
427 if (copy_from_user(&old_calibrate
, ucalibrate
, sizeof(old_calibrate
)))
429 calibrate
.type
= old_calibrate
.type
;
430 ret
= lttng_calibrate(&calibrate
);
431 if (copy_to_user(ucalibrate
, &old_calibrate
, sizeof(old_calibrate
)))
435 case LTTNG_KERNEL_CALIBRATE
:
437 struct lttng_kernel_calibrate __user
*ucalibrate
=
438 (struct lttng_kernel_calibrate __user
*) arg
;
439 struct lttng_kernel_calibrate calibrate
;
442 if (copy_from_user(&calibrate
, ucalibrate
, sizeof(calibrate
)))
444 ret
= lttng_calibrate(&calibrate
);
445 if (copy_to_user(ucalibrate
, &calibrate
, sizeof(calibrate
)))
454 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0))
455 static const struct proc_ops lttng_proc_ops
= {
456 .proc_ioctl
= lttng_ioctl
,
458 .proc_compat_ioctl
= lttng_ioctl
,
459 #endif /* CONFIG_COMPAT */
462 static const struct file_operations lttng_proc_ops
= {
463 .owner
= THIS_MODULE
,
464 .unlocked_ioctl
= lttng_ioctl
,
466 .compat_ioctl
= lttng_ioctl
,
467 #endif /* CONFIG_COMPAT */
472 int lttng_abi_create_channel(struct file
*session_file
,
473 struct lttng_kernel_channel
*chan_param
,
474 enum channel_type channel_type
)
476 struct lttng_session
*session
= session_file
->private_data
;
477 const struct file_operations
*fops
= NULL
;
478 const char *transport_name
;
479 struct lttng_channel
*chan
;
480 struct file
*chan_file
;
484 chan_fd
= lttng_get_unused_fd();
489 switch (channel_type
) {
490 case PER_CPU_CHANNEL
:
491 fops
= <tng_channel_fops
;
493 case METADATA_CHANNEL
:
494 fops
= <tng_metadata_fops
;
498 chan_file
= anon_inode_getfile("[lttng_channel]",
501 if (IS_ERR(chan_file
)) {
502 ret
= PTR_ERR(chan_file
);
505 switch (channel_type
) {
506 case PER_CPU_CHANNEL
:
507 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
) {
508 transport_name
= chan_param
->overwrite
?
509 "relay-overwrite" : "relay-discard";
510 } else if (chan_param
->output
== LTTNG_KERNEL_MMAP
) {
511 transport_name
= chan_param
->overwrite
?
512 "relay-overwrite-mmap" : "relay-discard-mmap";
517 case METADATA_CHANNEL
:
518 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
)
519 transport_name
= "relay-metadata";
520 else if (chan_param
->output
== LTTNG_KERNEL_MMAP
)
521 transport_name
= "relay-metadata-mmap";
526 transport_name
= "<unknown>";
529 if (!atomic_long_add_unless(&session_file
->f_count
, 1, LONG_MAX
)) {
534 * We tolerate no failure path after channel creation. It will stay
535 * invariant for the rest of the session.
537 chan
= lttng_channel_create(session
, transport_name
, NULL
,
538 chan_param
->subbuf_size
,
539 chan_param
->num_subbuf
,
540 chan_param
->switch_timer_interval
,
541 chan_param
->read_timer_interval
,
547 chan
->file
= chan_file
;
548 chan_file
->private_data
= chan
;
549 fd_install(chan_fd
, chan_file
);
554 atomic_long_dec(&session_file
->f_count
);
558 put_unused_fd(chan_fd
);
564 int lttng_abi_session_set_name(struct lttng_session
*session
,
565 struct lttng_kernel_session_name
*name
)
569 len
= strnlen(name
->name
, LTTNG_KERNEL_SESSION_NAME_LEN
);
571 if (len
== LTTNG_KERNEL_SESSION_NAME_LEN
) {
572 /* Name is too long/malformed */
576 strcpy(session
->name
, name
->name
);
581 int lttng_abi_session_set_creation_time(struct lttng_session
*session
,
582 struct lttng_kernel_session_creation_time
*time
)
586 len
= strnlen(time
->iso8601
, LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
);
588 if (len
== LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
) {
589 /* Time is too long/malformed */
593 strcpy(session
->creation_time
, time
->iso8601
);
598 enum tracker_type
get_tracker_type(struct lttng_kernel_tracker_args
*tracker
)
600 switch (tracker
->type
) {
601 case LTTNG_KERNEL_TRACKER_PID
:
603 case LTTNG_KERNEL_TRACKER_VPID
:
605 case LTTNG_KERNEL_TRACKER_UID
:
607 case LTTNG_KERNEL_TRACKER_VUID
:
609 case LTTNG_KERNEL_TRACKER_GID
:
611 case LTTNG_KERNEL_TRACKER_VGID
:
614 return TRACKER_UNKNOWN
;
619 * lttng_session_ioctl - lttng session fd ioctl
625 * This ioctl implements lttng commands:
626 * LTTNG_KERNEL_CHANNEL
627 * Returns a LTTng channel file descriptor
628 * LTTNG_KERNEL_ENABLE
629 * Enables tracing for a session (weak enable)
630 * LTTNG_KERNEL_DISABLE
631 * Disables tracing for a session (strong disable)
632 * LTTNG_KERNEL_METADATA
633 * Returns a LTTng metadata file descriptor
634 * LTTNG_KERNEL_SESSION_TRACK_PID
635 * Add PID to session PID tracker
636 * LTTNG_KERNEL_SESSION_UNTRACK_PID
637 * Remove PID from session PID tracker
638 * LTTNG_KERNEL_SESSION_TRACK_ID
640 * LTTNG_KERNEL_SESSION_UNTRACK_ID
641 * Remove ID from tracker
643 * The returned channel will be deleted when its file descriptor is closed.
646 long lttng_session_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
648 struct lttng_session
*session
= file
->private_data
;
649 struct lttng_kernel_channel chan_param
;
650 struct lttng_kernel_old_channel old_chan_param
;
653 case LTTNG_KERNEL_OLD_CHANNEL
:
655 if (copy_from_user(&old_chan_param
,
656 (struct lttng_kernel_old_channel __user
*) arg
,
657 sizeof(struct lttng_kernel_old_channel
)))
659 chan_param
.overwrite
= old_chan_param
.overwrite
;
660 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
661 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
662 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
663 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
664 chan_param
.output
= old_chan_param
.output
;
666 return lttng_abi_create_channel(file
, &chan_param
,
669 case LTTNG_KERNEL_CHANNEL
:
671 if (copy_from_user(&chan_param
,
672 (struct lttng_kernel_channel __user
*) arg
,
673 sizeof(struct lttng_kernel_channel
)))
675 return lttng_abi_create_channel(file
, &chan_param
,
678 case LTTNG_KERNEL_OLD_SESSION_START
:
679 case LTTNG_KERNEL_OLD_ENABLE
:
680 case LTTNG_KERNEL_SESSION_START
:
681 case LTTNG_KERNEL_ENABLE
:
682 return lttng_session_enable(session
);
683 case LTTNG_KERNEL_OLD_SESSION_STOP
:
684 case LTTNG_KERNEL_OLD_DISABLE
:
685 case LTTNG_KERNEL_SESSION_STOP
:
686 case LTTNG_KERNEL_DISABLE
:
687 return lttng_session_disable(session
);
688 case LTTNG_KERNEL_OLD_METADATA
:
690 if (copy_from_user(&old_chan_param
,
691 (struct lttng_kernel_old_channel __user
*) arg
,
692 sizeof(struct lttng_kernel_old_channel
)))
694 chan_param
.overwrite
= old_chan_param
.overwrite
;
695 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
696 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
697 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
698 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
699 chan_param
.output
= old_chan_param
.output
;
701 return lttng_abi_create_channel(file
, &chan_param
,
704 case LTTNG_KERNEL_METADATA
:
706 if (copy_from_user(&chan_param
,
707 (struct lttng_kernel_channel __user
*) arg
,
708 sizeof(struct lttng_kernel_channel
)))
710 return lttng_abi_create_channel(file
, &chan_param
,
713 case LTTNG_KERNEL_SESSION_TRACK_PID
:
714 return lttng_session_track_id(session
, TRACKER_PID
, (int) arg
);
715 case LTTNG_KERNEL_SESSION_UNTRACK_PID
:
716 return lttng_session_untrack_id(session
, TRACKER_PID
, (int) arg
);
717 case LTTNG_KERNEL_SESSION_TRACK_ID
:
719 struct lttng_kernel_tracker_args tracker
;
720 enum tracker_type tracker_type
;
722 if (copy_from_user(&tracker
,
723 (struct lttng_kernel_tracker_args __user
*) arg
,
724 sizeof(struct lttng_kernel_tracker_args
)))
726 tracker_type
= get_tracker_type(&tracker
);
727 if (tracker_type
== TRACKER_UNKNOWN
)
729 return lttng_session_track_id(session
, tracker_type
, tracker
.id
);
731 case LTTNG_KERNEL_SESSION_UNTRACK_ID
:
733 struct lttng_kernel_tracker_args tracker
;
734 enum tracker_type tracker_type
;
736 if (copy_from_user(&tracker
,
737 (struct lttng_kernel_tracker_args __user
*) arg
,
738 sizeof(struct lttng_kernel_tracker_args
)))
740 tracker_type
= get_tracker_type(&tracker
);
741 if (tracker_type
== TRACKER_UNKNOWN
)
743 return lttng_session_untrack_id(session
, tracker_type
,
746 case LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS
:
747 return lttng_session_list_tracker_ids(session
, TRACKER_PID
);
748 case LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS
:
750 struct lttng_kernel_tracker_args tracker
;
751 enum tracker_type tracker_type
;
753 if (copy_from_user(&tracker
,
754 (struct lttng_kernel_tracker_args __user
*) arg
,
755 sizeof(struct lttng_kernel_tracker_args
)))
757 tracker_type
= get_tracker_type(&tracker
);
758 if (tracker_type
== TRACKER_UNKNOWN
)
760 return lttng_session_list_tracker_ids(session
, tracker_type
);
762 case LTTNG_KERNEL_SESSION_METADATA_REGEN
:
763 return lttng_session_metadata_regenerate(session
);
764 case LTTNG_KERNEL_SESSION_STATEDUMP
:
765 return lttng_session_statedump(session
);
766 case LTTNG_KERNEL_SESSION_SET_NAME
:
768 struct lttng_kernel_session_name name
;
770 if (copy_from_user(&name
,
771 (struct lttng_kernel_session_name __user
*) arg
,
772 sizeof(struct lttng_kernel_session_name
)))
774 return lttng_abi_session_set_name(session
, &name
);
776 case LTTNG_KERNEL_SESSION_SET_CREATION_TIME
:
778 struct lttng_kernel_session_creation_time time
;
780 if (copy_from_user(&time
,
781 (struct lttng_kernel_session_creation_time __user
*) arg
,
782 sizeof(struct lttng_kernel_session_creation_time
)))
784 return lttng_abi_session_set_creation_time(session
, &time
);
792 * Called when the last file reference is dropped.
794 * Big fat note: channels and events are invariant for the whole session after
795 * their creation. So this session destruction also destroys all channel and
796 * event structures specific to this session (they are not destroyed when their
797 * individual file is released).
800 int lttng_session_release(struct inode
*inode
, struct file
*file
)
802 struct lttng_session
*session
= file
->private_data
;
805 lttng_session_destroy(session
);
809 static const struct file_operations lttng_session_fops
= {
810 .owner
= THIS_MODULE
,
811 .release
= lttng_session_release
,
812 .unlocked_ioctl
= lttng_session_ioctl
,
814 .compat_ioctl
= lttng_session_ioctl
,
818 static const struct file_operations lttng_event_notifier_group_notif_fops
= {
819 .owner
= THIS_MODULE
,
823 * lttng_metadata_ring_buffer_poll - LTTng ring buffer poll file operation
827 * Handles the poll operations for the metadata channels.
830 unsigned int lttng_metadata_ring_buffer_poll(struct file
*filp
,
833 struct lttng_metadata_stream
*stream
= filp
->private_data
;
834 struct lib_ring_buffer
*buf
= stream
->priv
;
836 unsigned int mask
= 0;
838 if (filp
->f_mode
& FMODE_READ
) {
839 poll_wait_set_exclusive(wait
);
840 poll_wait(filp
, &stream
->read_wait
, wait
);
842 finalized
= stream
->finalized
;
845 * lib_ring_buffer_is_finalized() contains a smp_rmb()
846 * ordering finalized load before offsets loads.
848 WARN_ON(atomic_long_read(&buf
->active_readers
) != 1);
853 mutex_lock(&stream
->metadata_cache
->lock
);
854 if (stream
->metadata_cache
->metadata_written
>
855 stream
->metadata_out
)
857 mutex_unlock(&stream
->metadata_cache
->lock
);
864 void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file
*filp
,
865 unsigned int cmd
, unsigned long arg
)
867 struct lttng_metadata_stream
*stream
= filp
->private_data
;
869 stream
->metadata_out
= stream
->metadata_in
;
873 * Reset the counter of how much metadata has been consumed to 0. That way,
874 * the consumer receives the content of the metadata cache unchanged. This is
875 * different from the metadata_regenerate where the offset from epoch is
876 * resampled, here we want the exact same content as the last time the metadata
877 * was generated. This command is only possible if all the metadata written
878 * in the cache has been output to the metadata stream to avoid corrupting the
881 * Return 0 on success, a negative value on error.
884 int lttng_metadata_cache_dump(struct lttng_metadata_stream
*stream
)
887 struct lttng_metadata_cache
*cache
= stream
->metadata_cache
;
889 mutex_lock(&cache
->lock
);
890 if (stream
->metadata_out
!= cache
->metadata_written
) {
894 stream
->metadata_out
= 0;
895 stream
->metadata_in
= 0;
896 wake_up_interruptible(&stream
->read_wait
);
900 mutex_unlock(&cache
->lock
);
905 long lttng_metadata_ring_buffer_ioctl(struct file
*filp
,
906 unsigned int cmd
, unsigned long arg
)
909 struct lttng_metadata_stream
*stream
= filp
->private_data
;
910 struct lib_ring_buffer
*buf
= stream
->priv
;
914 if (cmd
== RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
)
915 rb_cmd
= RING_BUFFER_GET_NEXT_SUBBUF
;
920 case RING_BUFFER_GET_NEXT_SUBBUF
:
922 struct lttng_metadata_stream
*stream
= filp
->private_data
;
923 struct lib_ring_buffer
*buf
= stream
->priv
;
924 struct channel
*chan
= buf
->backend
.chan
;
926 ret
= lttng_metadata_output_channel(stream
, chan
, NULL
);
928 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
934 case RING_BUFFER_GET_SUBBUF
:
937 * Random access is not allowed for metadata channel.
941 case RING_BUFFER_FLUSH_EMPTY
: /* Fall-through. */
942 case RING_BUFFER_FLUSH
:
944 struct lttng_metadata_stream
*stream
= filp
->private_data
;
945 struct lib_ring_buffer
*buf
= stream
->priv
;
946 struct channel
*chan
= buf
->backend
.chan
;
949 * Before doing the actual ring buffer flush, write up to one
950 * packet of metadata in the ring buffer.
952 ret
= lttng_metadata_output_channel(stream
, chan
, NULL
);
957 case RING_BUFFER_GET_METADATA_VERSION
:
959 struct lttng_metadata_stream
*stream
= filp
->private_data
;
961 return put_u64(stream
->version
, arg
);
963 case RING_BUFFER_METADATA_CACHE_DUMP
:
965 struct lttng_metadata_stream
*stream
= filp
->private_data
;
967 return lttng_metadata_cache_dump(stream
);
969 case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
:
971 struct lttng_metadata_stream
*stream
= filp
->private_data
;
972 struct lib_ring_buffer
*buf
= stream
->priv
;
973 struct channel
*chan
= buf
->backend
.chan
;
975 ret
= lttng_metadata_output_channel(stream
, chan
, &coherent
);
977 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
979 } else if (ret
< 0) {
987 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
989 /* Performing lib ring buffer ioctl after our own. */
990 ret
= lib_ring_buffer_ioctl(filp
, rb_cmd
, arg
, buf
);
995 case RING_BUFFER_PUT_NEXT_SUBBUF
:
997 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
1001 case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
:
1003 return put_u32(coherent
, arg
);
1012 #ifdef CONFIG_COMPAT
1014 long lttng_metadata_ring_buffer_compat_ioctl(struct file
*filp
,
1015 unsigned int cmd
, unsigned long arg
)
1018 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1019 struct lib_ring_buffer
*buf
= stream
->priv
;
1020 unsigned int rb_cmd
;
1023 if (cmd
== RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
)
1024 rb_cmd
= RING_BUFFER_GET_NEXT_SUBBUF
;
1029 case RING_BUFFER_GET_NEXT_SUBBUF
:
1031 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1032 struct lib_ring_buffer
*buf
= stream
->priv
;
1033 struct channel
*chan
= buf
->backend
.chan
;
1035 ret
= lttng_metadata_output_channel(stream
, chan
, NULL
);
1037 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
1043 case RING_BUFFER_GET_SUBBUF
:
1046 * Random access is not allowed for metadata channel.
1050 case RING_BUFFER_FLUSH_EMPTY
: /* Fall-through. */
1051 case RING_BUFFER_FLUSH
:
1053 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1054 struct lib_ring_buffer
*buf
= stream
->priv
;
1055 struct channel
*chan
= buf
->backend
.chan
;
1058 * Before doing the actual ring buffer flush, write up to one
1059 * packet of metadata in the ring buffer.
1061 ret
= lttng_metadata_output_channel(stream
, chan
, NULL
);
1066 case RING_BUFFER_GET_METADATA_VERSION
:
1068 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1070 return put_u64(stream
->version
, arg
);
1072 case RING_BUFFER_METADATA_CACHE_DUMP
:
1074 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1076 return lttng_metadata_cache_dump(stream
);
1078 case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
:
1080 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1081 struct lib_ring_buffer
*buf
= stream
->priv
;
1082 struct channel
*chan
= buf
->backend
.chan
;
1084 ret
= lttng_metadata_output_channel(stream
, chan
, &coherent
);
1086 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
1088 } else if (ret
< 0) {
1096 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
1098 /* Performing lib ring buffer ioctl after our own. */
1099 ret
= lib_ring_buffer_compat_ioctl(filp
, rb_cmd
, arg
, buf
);
1104 case RING_BUFFER_PUT_NEXT_SUBBUF
:
1106 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
1110 case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
:
1112 return put_u32(coherent
, arg
);
1123 * This is not used by anonymous file descriptors. This code is left
1124 * there if we ever want to implement an inode with open() operation.
1127 int lttng_metadata_ring_buffer_open(struct inode
*inode
, struct file
*file
)
1129 struct lttng_metadata_stream
*stream
= inode
->i_private
;
1130 struct lib_ring_buffer
*buf
= stream
->priv
;
1132 file
->private_data
= buf
;
1134 * Since life-time of metadata cache differs from that of
1135 * session, we need to keep our own reference on the transport.
1137 if (!try_module_get(stream
->transport
->owner
)) {
1138 printk(KERN_WARNING
"LTTng: Can't lock transport module.\n");
1141 return lib_ring_buffer_open(inode
, file
, buf
);
1145 int lttng_metadata_ring_buffer_release(struct inode
*inode
, struct file
*file
)
1147 struct lttng_metadata_stream
*stream
= file
->private_data
;
1148 struct lib_ring_buffer
*buf
= stream
->priv
;
1150 mutex_lock(&stream
->metadata_cache
->lock
);
1151 list_del(&stream
->list
);
1152 mutex_unlock(&stream
->metadata_cache
->lock
);
1153 kref_put(&stream
->metadata_cache
->refcount
, metadata_cache_destroy
);
1154 module_put(stream
->transport
->owner
);
1156 return lib_ring_buffer_release(inode
, file
, buf
);
1160 ssize_t
lttng_metadata_ring_buffer_splice_read(struct file
*in
, loff_t
*ppos
,
1161 struct pipe_inode_info
*pipe
, size_t len
,
1164 struct lttng_metadata_stream
*stream
= in
->private_data
;
1165 struct lib_ring_buffer
*buf
= stream
->priv
;
1167 return lib_ring_buffer_splice_read(in
, ppos
, pipe
, len
,
1172 int lttng_metadata_ring_buffer_mmap(struct file
*filp
,
1173 struct vm_area_struct
*vma
)
1175 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1176 struct lib_ring_buffer
*buf
= stream
->priv
;
1178 return lib_ring_buffer_mmap(filp
, vma
, buf
);
1182 const struct file_operations lttng_metadata_ring_buffer_file_operations
= {
1183 .owner
= THIS_MODULE
,
1184 .open
= lttng_metadata_ring_buffer_open
,
1185 .release
= lttng_metadata_ring_buffer_release
,
1186 .poll
= lttng_metadata_ring_buffer_poll
,
1187 .splice_read
= lttng_metadata_ring_buffer_splice_read
,
1188 .mmap
= lttng_metadata_ring_buffer_mmap
,
1189 .unlocked_ioctl
= lttng_metadata_ring_buffer_ioctl
,
1190 .llseek
= vfs_lib_ring_buffer_no_llseek
,
1191 #ifdef CONFIG_COMPAT
1192 .compat_ioctl
= lttng_metadata_ring_buffer_compat_ioctl
,
1197 int lttng_abi_create_stream_fd(struct file
*channel_file
, void *stream_priv
,
1198 const struct file_operations
*fops
, const char *name
)
1201 struct file
*stream_file
;
1203 stream_fd
= lttng_get_unused_fd();
1204 if (stream_fd
< 0) {
1208 stream_file
= anon_inode_getfile(name
, fops
, stream_priv
, O_RDWR
);
1209 if (IS_ERR(stream_file
)) {
1210 ret
= PTR_ERR(stream_file
);
1214 * OPEN_FMODE, called within anon_inode_getfile/alloc_file, don't honor
1215 * FMODE_LSEEK, FMODE_PREAD nor FMODE_PWRITE. We need to read from this
1216 * file descriptor, so we set FMODE_PREAD here.
1218 stream_file
->f_mode
|= FMODE_PREAD
;
1219 fd_install(stream_fd
, stream_file
);
1221 * The stream holds a reference to the channel within the generic ring
1222 * buffer library, so no need to hold a refcount on the channel and
1223 * session files here.
1228 put_unused_fd(stream_fd
);
1234 int lttng_abi_open_stream(struct file
*channel_file
)
1236 struct lttng_channel
*channel
= channel_file
->private_data
;
1237 struct lib_ring_buffer
*buf
;
1241 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
1246 ret
= lttng_abi_create_stream_fd(channel_file
, stream_priv
,
1247 <tng_stream_ring_buffer_file_operations
,
1255 channel
->ops
->buffer_read_close(buf
);
1260 int lttng_abi_open_metadata_stream(struct file
*channel_file
)
1262 struct lttng_channel
*channel
= channel_file
->private_data
;
1263 struct lttng_session
*session
= channel
->session
;
1264 struct lib_ring_buffer
*buf
;
1266 struct lttng_metadata_stream
*metadata_stream
;
1269 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
1273 metadata_stream
= kzalloc(sizeof(struct lttng_metadata_stream
),
1275 if (!metadata_stream
) {
1279 metadata_stream
->metadata_cache
= session
->metadata_cache
;
1280 init_waitqueue_head(&metadata_stream
->read_wait
);
1281 metadata_stream
->priv
= buf
;
1282 stream_priv
= metadata_stream
;
1283 metadata_stream
->transport
= channel
->transport
;
1284 /* Initial state is an empty metadata, considered as incoherent. */
1285 metadata_stream
->coherent
= false;
1288 * Since life-time of metadata cache differs from that of
1289 * session, we need to keep our own reference on the transport.
1291 if (!try_module_get(metadata_stream
->transport
->owner
)) {
1292 printk(KERN_WARNING
"LTTng: Can't lock transport module.\n");
1297 if (!lttng_kref_get(&session
->metadata_cache
->refcount
)) {
1302 ret
= lttng_abi_create_stream_fd(channel_file
, stream_priv
,
1303 <tng_metadata_ring_buffer_file_operations
,
1304 "[lttng_metadata_stream]");
1308 mutex_lock(&session
->metadata_cache
->lock
);
1309 list_add(&metadata_stream
->list
,
1310 &session
->metadata_cache
->metadata_stream
);
1311 mutex_unlock(&session
->metadata_cache
->lock
);
1315 kref_put(&session
->metadata_cache
->refcount
, metadata_cache_destroy
);
1317 module_put(metadata_stream
->transport
->owner
);
1319 kfree(metadata_stream
);
1321 channel
->ops
->buffer_read_close(buf
);
1326 int lttng_abi_open_event_notifier_group_stream(struct file
*notif_file
)
1328 struct lttng_event_notifier_group
*event_notifier_group
= notif_file
->private_data
;
1329 struct channel
*chan
= event_notifier_group
->chan
;
1330 struct lib_ring_buffer
*buf
;
1334 buf
= event_notifier_group
->ops
->buffer_read_open(chan
);
1338 /* The event_notifier notification fd holds a reference on the event_notifier group */
1339 if (!atomic_long_add_unless(¬if_file
->f_count
, 1, LONG_MAX
)) {
1341 goto refcount_error
;
1343 event_notifier_group
->buf
= buf
;
1344 stream_priv
= event_notifier_group
;
1345 ret
= lttng_abi_create_stream_fd(notif_file
, stream_priv
,
1346 <tng_event_notifier_group_notif_fops
,
1347 "[lttng_event_notifier_stream]");
1354 atomic_long_dec(¬if_file
->f_count
);
1356 event_notifier_group
->ops
->buffer_read_close(buf
);
1361 int lttng_abi_validate_event_param(struct lttng_kernel_event
*event_param
)
1363 /* Limit ABI to implemented features. */
1364 switch (event_param
->instrumentation
) {
1365 case LTTNG_KERNEL_SYSCALL
:
1366 switch (event_param
->u
.syscall
.entryexit
) {
1367 case LTTNG_KERNEL_SYSCALL_ENTRYEXIT
:
1372 switch (event_param
->u
.syscall
.abi
) {
1373 case LTTNG_KERNEL_SYSCALL_ABI_ALL
:
1378 switch (event_param
->u
.syscall
.match
) {
1379 case LTTNG_SYSCALL_MATCH_NAME
:
1386 case LTTNG_KERNEL_TRACEPOINT
: /* Fallthrough */
1387 case LTTNG_KERNEL_KPROBE
: /* Fallthrough */
1388 case LTTNG_KERNEL_KRETPROBE
: /* Fallthrough */
1389 case LTTNG_KERNEL_NOOP
: /* Fallthrough */
1390 case LTTNG_KERNEL_UPROBE
:
1393 case LTTNG_KERNEL_FUNCTION
: /* Fallthrough */
1401 int lttng_abi_create_event(struct file
*channel_file
,
1402 struct lttng_kernel_event
*event_param
)
1404 struct lttng_channel
*channel
= channel_file
->private_data
;
1406 struct file
*event_file
;
1409 event_param
->name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
1410 switch (event_param
->instrumentation
) {
1411 case LTTNG_KERNEL_KRETPROBE
:
1412 event_param
->u
.kretprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
1414 case LTTNG_KERNEL_KPROBE
:
1415 event_param
->u
.kprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
1417 case LTTNG_KERNEL_FUNCTION
:
1419 /* Not implemented. */
1424 event_fd
= lttng_get_unused_fd();
1429 event_file
= anon_inode_getfile("[lttng_event]",
1432 if (IS_ERR(event_file
)) {
1433 ret
= PTR_ERR(event_file
);
1436 /* The event holds a reference on the channel */
1437 if (!atomic_long_add_unless(&channel_file
->f_count
, 1, LONG_MAX
)) {
1439 goto refcount_error
;
1441 ret
= lttng_abi_validate_event_param(event_param
);
1444 if (event_param
->instrumentation
== LTTNG_KERNEL_TRACEPOINT
1445 || event_param
->instrumentation
== LTTNG_KERNEL_SYSCALL
) {
1446 struct lttng_event_enabler
*event_enabler
;
1448 if (strutils_is_star_glob_pattern(event_param
->name
)) {
1450 * If the event name is a star globbing pattern,
1451 * we create the special star globbing enabler.
1453 event_enabler
= lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_STAR_GLOB
,
1454 event_param
, channel
);
1456 event_enabler
= lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_NAME
,
1457 event_param
, channel
);
1459 priv
= event_enabler
;
1461 struct lttng_event
*event
;
1464 * We tolerate no failure path after event creation. It
1465 * will stay invariant for the rest of the session.
1467 event
= lttng_event_create(channel
, event_param
,
1469 event_param
->instrumentation
);
1470 WARN_ON_ONCE(!event
);
1471 if (IS_ERR(event
)) {
1472 ret
= PTR_ERR(event
);
1477 event_file
->private_data
= priv
;
1478 fd_install(event_fd
, event_file
);
1482 atomic_long_dec(&channel_file
->f_count
);
1486 put_unused_fd(event_fd
);
1492 long lttng_event_notifier_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1494 struct lttng_event_notifier_enabler
*event_notifier_enabler
;
1495 enum lttng_event_type
*evtype
= file
->private_data
;
1498 case LTTNG_KERNEL_ENABLE
:
1500 case LTTNG_TYPE_EVENT
:
1502 case LTTNG_TYPE_ENABLER
:
1503 event_notifier_enabler
= file
->private_data
;
1504 return lttng_event_notifier_enabler_enable(event_notifier_enabler
);
1509 case LTTNG_KERNEL_DISABLE
:
1511 case LTTNG_TYPE_EVENT
:
1513 case LTTNG_TYPE_ENABLER
:
1514 event_notifier_enabler
= file
->private_data
;
1515 return lttng_event_notifier_enabler_disable(event_notifier_enabler
);
1520 case LTTNG_KERNEL_FILTER
:
1522 case LTTNG_TYPE_EVENT
:
1524 case LTTNG_TYPE_ENABLER
:
1525 event_notifier_enabler
= file
->private_data
;
1526 return lttng_event_notifier_enabler_attach_bytecode(event_notifier_enabler
,
1527 (struct lttng_kernel_filter_bytecode __user
*) arg
);
1533 return -ENOIOCTLCMD
;
1538 int lttng_event_notifier_release(struct inode
*inode
, struct file
*file
)
1540 struct lttng_event_notifier
*event_notifier
;
1541 struct lttng_event_notifier_enabler
*event_notifier_enabler
;
1542 enum lttng_event_type
*evtype
= file
->private_data
;
1548 case LTTNG_TYPE_EVENT
:
1549 event_notifier
= file
->private_data
;
1551 fput(event_notifier
->group
->file
);
1553 case LTTNG_TYPE_ENABLER
:
1554 event_notifier_enabler
= file
->private_data
;
1555 if (event_notifier_enabler
)
1556 fput(event_notifier_enabler
->group
->file
);
1566 static const struct file_operations lttng_event_notifier_fops
= {
1567 .owner
= THIS_MODULE
,
1568 .release
= lttng_event_notifier_release
,
1569 .unlocked_ioctl
= lttng_event_notifier_ioctl
,
1570 #ifdef CONFIG_COMPAT
1571 .compat_ioctl
= lttng_event_notifier_ioctl
,
1576 int lttng_abi_create_event_notifier(struct file
*event_notifier_group_file
,
1577 struct lttng_kernel_event_notifier
*event_notifier_param
)
1579 struct lttng_event_notifier_group
*event_notifier_group
=
1580 event_notifier_group_file
->private_data
;
1581 int event_notifier_fd
, ret
;
1582 struct file
*event_notifier_file
;
1585 switch (event_notifier_param
->event
.instrumentation
) {
1586 case LTTNG_KERNEL_TRACEPOINT
:
1587 case LTTNG_KERNEL_KPROBE
:
1588 case LTTNG_KERNEL_UPROBE
:
1589 case LTTNG_KERNEL_KRETPROBE
:
1590 case LTTNG_KERNEL_FUNCTION
:
1591 case LTTNG_KERNEL_NOOP
:
1592 case LTTNG_KERNEL_SYSCALL
:
1598 event_notifier_param
->event
.name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
1600 event_notifier_fd
= lttng_get_unused_fd();
1601 if (event_notifier_fd
< 0) {
1602 ret
= event_notifier_fd
;
1606 event_notifier_file
= anon_inode_getfile("[lttng_event_notifier]",
1607 <tng_event_notifier_fops
,
1609 if (IS_ERR(event_notifier_file
)) {
1610 ret
= PTR_ERR(event_notifier_file
);
1614 /* The event notifier holds a reference on the event notifier group. */
1615 if (!atomic_long_add_unless(&event_notifier_group_file
->f_count
, 1, LONG_MAX
)) {
1617 goto refcount_error
;
1620 if (event_notifier_param
->event
.instrumentation
== LTTNG_KERNEL_TRACEPOINT
1621 || event_notifier_param
->event
.instrumentation
== LTTNG_KERNEL_SYSCALL
) {
1622 struct lttng_event_notifier_enabler
*enabler
;
1624 if (strutils_is_star_glob_pattern(event_notifier_param
->event
.name
)) {
1626 * If the event name is a star globbing pattern,
1627 * we create the special star globbing enabler.
1629 enabler
= lttng_event_notifier_enabler_create(
1630 event_notifier_group
,
1631 LTTNG_ENABLER_FORMAT_STAR_GLOB
,
1632 event_notifier_param
);
1634 enabler
= lttng_event_notifier_enabler_create(
1635 event_notifier_group
,
1636 LTTNG_ENABLER_FORMAT_NAME
,
1637 event_notifier_param
);
1641 struct lttng_event_notifier
*event_notifier
;
1644 * We tolerate no failure path after event notifier creation.
1645 * It will stay invariant for the rest of the session.
1647 event_notifier
= lttng_event_notifier_create(NULL
,
1648 event_notifier_param
->event
.token
, event_notifier_group
,
1649 event_notifier_param
, NULL
,
1650 event_notifier_param
->event
.instrumentation
);
1651 WARN_ON_ONCE(!event_notifier
);
1652 if (IS_ERR(event_notifier
)) {
1653 ret
= PTR_ERR(event_notifier
);
1654 goto event_notifier_error
;
1656 priv
= event_notifier
;
1658 event_notifier_file
->private_data
= priv
;
1659 fd_install(event_notifier_fd
, event_notifier_file
);
1660 return event_notifier_fd
;
1662 event_notifier_error
:
1663 atomic_long_dec(&event_notifier_group_file
->f_count
);
1665 fput(event_notifier_file
);
1667 put_unused_fd(event_notifier_fd
);
1674 long lttng_event_notifier_group_ioctl(struct file
*file
, unsigned int cmd
,
1678 case LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD
:
1680 return lttng_abi_open_event_notifier_group_stream(file
);
1682 case LTTNG_KERNEL_EVENT_NOTIFIER_CREATE
:
1684 struct lttng_kernel_event_notifier uevent_notifier_param
;
1686 if (copy_from_user(&uevent_notifier_param
,
1687 (struct lttng_kernel_event_notifier __user
*) arg
,
1688 sizeof(uevent_notifier_param
)))
1690 return lttng_abi_create_event_notifier(file
, &uevent_notifier_param
);
1693 return -ENOIOCTLCMD
;
1699 int lttng_event_notifier_group_release(struct inode
*inode
, struct file
*file
)
1701 struct lttng_event_notifier_group
*event_notifier_group
=
1704 if (event_notifier_group
)
1705 lttng_event_notifier_group_destroy(event_notifier_group
);
1709 static const struct file_operations lttng_event_notifier_group_fops
= {
1710 .owner
= THIS_MODULE
,
1711 .release
= lttng_event_notifier_group_release
,
1712 .unlocked_ioctl
= lttng_event_notifier_group_ioctl
,
1713 #ifdef CONFIG_COMPAT
1714 .compat_ioctl
= lttng_event_notifier_group_ioctl
,
1719 * lttng_channel_ioctl - lttng syscall through ioctl
1725 * This ioctl implements lttng commands:
1726 * LTTNG_KERNEL_STREAM
1727 * Returns an event stream file descriptor or failure.
1728 * (typically, one event stream records events from one CPU)
1729 * LTTNG_KERNEL_EVENT
1730 * Returns an event file descriptor or failure.
1731 * LTTNG_KERNEL_CONTEXT
1732 * Prepend a context field to each event in the channel
1733 * LTTNG_KERNEL_ENABLE
1734 * Enable recording for events in this channel (weak enable)
1735 * LTTNG_KERNEL_DISABLE
1736 * Disable recording for events in this channel (strong disable)
1738 * Channel and event file descriptors also hold a reference on the session.
1741 long lttng_channel_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1743 struct lttng_channel
*channel
= file
->private_data
;
1746 case LTTNG_KERNEL_OLD_STREAM
:
1747 case LTTNG_KERNEL_STREAM
:
1748 return lttng_abi_open_stream(file
);
1749 case LTTNG_KERNEL_OLD_EVENT
:
1751 struct lttng_kernel_event
*uevent_param
;
1752 struct lttng_kernel_old_event
*old_uevent_param
;
1755 uevent_param
= kmalloc(sizeof(struct lttng_kernel_event
),
1757 if (!uevent_param
) {
1761 old_uevent_param
= kmalloc(
1762 sizeof(struct lttng_kernel_old_event
),
1764 if (!old_uevent_param
) {
1766 goto old_event_error_free_param
;
1768 if (copy_from_user(old_uevent_param
,
1769 (struct lttng_kernel_old_event __user
*) arg
,
1770 sizeof(struct lttng_kernel_old_event
))) {
1772 goto old_event_error_free_old_param
;
1775 memcpy(uevent_param
->name
, old_uevent_param
->name
,
1776 sizeof(uevent_param
->name
));
1777 uevent_param
->instrumentation
=
1778 old_uevent_param
->instrumentation
;
1780 switch (old_uevent_param
->instrumentation
) {
1781 case LTTNG_KERNEL_KPROBE
:
1782 uevent_param
->u
.kprobe
.addr
=
1783 old_uevent_param
->u
.kprobe
.addr
;
1784 uevent_param
->u
.kprobe
.offset
=
1785 old_uevent_param
->u
.kprobe
.offset
;
1786 memcpy(uevent_param
->u
.kprobe
.symbol_name
,
1787 old_uevent_param
->u
.kprobe
.symbol_name
,
1788 sizeof(uevent_param
->u
.kprobe
.symbol_name
));
1790 case LTTNG_KERNEL_KRETPROBE
:
1791 uevent_param
->u
.kretprobe
.addr
=
1792 old_uevent_param
->u
.kretprobe
.addr
;
1793 uevent_param
->u
.kretprobe
.offset
=
1794 old_uevent_param
->u
.kretprobe
.offset
;
1795 memcpy(uevent_param
->u
.kretprobe
.symbol_name
,
1796 old_uevent_param
->u
.kretprobe
.symbol_name
,
1797 sizeof(uevent_param
->u
.kretprobe
.symbol_name
));
1799 case LTTNG_KERNEL_FUNCTION
:
1801 /* Not implemented. */
1806 ret
= lttng_abi_create_event(file
, uevent_param
);
1808 old_event_error_free_old_param
:
1809 kfree(old_uevent_param
);
1810 old_event_error_free_param
:
1811 kfree(uevent_param
);
1815 case LTTNG_KERNEL_EVENT
:
1817 struct lttng_kernel_event uevent_param
;
1819 if (copy_from_user(&uevent_param
,
1820 (struct lttng_kernel_event __user
*) arg
,
1821 sizeof(uevent_param
)))
1823 return lttng_abi_create_event(file
, &uevent_param
);
1825 case LTTNG_KERNEL_OLD_CONTEXT
:
1827 struct lttng_kernel_context
*ucontext_param
;
1828 struct lttng_kernel_old_context
*old_ucontext_param
;
1831 ucontext_param
= kmalloc(sizeof(struct lttng_kernel_context
),
1833 if (!ucontext_param
) {
1837 old_ucontext_param
= kmalloc(sizeof(struct lttng_kernel_old_context
),
1839 if (!old_ucontext_param
) {
1841 goto old_ctx_error_free_param
;
1844 if (copy_from_user(old_ucontext_param
,
1845 (struct lttng_kernel_old_context __user
*) arg
,
1846 sizeof(struct lttng_kernel_old_context
))) {
1848 goto old_ctx_error_free_old_param
;
1850 ucontext_param
->ctx
= old_ucontext_param
->ctx
;
1851 memcpy(ucontext_param
->padding
, old_ucontext_param
->padding
,
1852 sizeof(ucontext_param
->padding
));
1853 /* only type that uses the union */
1854 if (old_ucontext_param
->ctx
== LTTNG_KERNEL_CONTEXT_PERF_COUNTER
) {
1855 ucontext_param
->u
.perf_counter
.type
=
1856 old_ucontext_param
->u
.perf_counter
.type
;
1857 ucontext_param
->u
.perf_counter
.config
=
1858 old_ucontext_param
->u
.perf_counter
.config
;
1859 memcpy(ucontext_param
->u
.perf_counter
.name
,
1860 old_ucontext_param
->u
.perf_counter
.name
,
1861 sizeof(ucontext_param
->u
.perf_counter
.name
));
1864 ret
= lttng_abi_add_context(file
,
1866 &channel
->ctx
, channel
->session
);
1868 old_ctx_error_free_old_param
:
1869 kfree(old_ucontext_param
);
1870 old_ctx_error_free_param
:
1871 kfree(ucontext_param
);
1875 case LTTNG_KERNEL_CONTEXT
:
1877 struct lttng_kernel_context ucontext_param
;
1879 if (copy_from_user(&ucontext_param
,
1880 (struct lttng_kernel_context __user
*) arg
,
1881 sizeof(ucontext_param
)))
1883 return lttng_abi_add_context(file
,
1885 &channel
->ctx
, channel
->session
);
1887 case LTTNG_KERNEL_OLD_ENABLE
:
1888 case LTTNG_KERNEL_ENABLE
:
1889 return lttng_channel_enable(channel
);
1890 case LTTNG_KERNEL_OLD_DISABLE
:
1891 case LTTNG_KERNEL_DISABLE
:
1892 return lttng_channel_disable(channel
);
1893 case LTTNG_KERNEL_SYSCALL_MASK
:
1894 return lttng_channel_syscall_mask(channel
,
1895 (struct lttng_kernel_syscall_mask __user
*) arg
);
1897 return -ENOIOCTLCMD
;
1902 * lttng_metadata_ioctl - lttng syscall through ioctl
1908 * This ioctl implements lttng commands:
1909 * LTTNG_KERNEL_STREAM
1910 * Returns an event stream file descriptor or failure.
1912 * Channel and event file descriptors also hold a reference on the session.
1915 long lttng_metadata_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1918 case LTTNG_KERNEL_OLD_STREAM
:
1919 case LTTNG_KERNEL_STREAM
:
1920 return lttng_abi_open_metadata_stream(file
);
1922 return -ENOIOCTLCMD
;
1927 * lttng_channel_poll - lttng stream addition/removal monitoring
1932 unsigned int lttng_channel_poll(struct file
*file
, poll_table
*wait
)
1934 struct lttng_channel
*channel
= file
->private_data
;
1935 unsigned int mask
= 0;
1937 if (file
->f_mode
& FMODE_READ
) {
1938 poll_wait_set_exclusive(wait
);
1939 poll_wait(file
, channel
->ops
->get_hp_wait_queue(channel
->chan
),
1942 if (channel
->ops
->is_disabled(channel
->chan
))
1944 if (channel
->ops
->is_finalized(channel
->chan
))
1946 if (channel
->ops
->buffer_has_read_closed_stream(channel
->chan
))
1947 return POLLIN
| POLLRDNORM
;
1955 int lttng_channel_release(struct inode
*inode
, struct file
*file
)
1957 struct lttng_channel
*channel
= file
->private_data
;
1960 fput(channel
->session
->file
);
1965 int lttng_metadata_channel_release(struct inode
*inode
, struct file
*file
)
1967 struct lttng_channel
*channel
= file
->private_data
;
1970 fput(channel
->session
->file
);
1971 lttng_metadata_channel_destroy(channel
);
1977 static const struct file_operations lttng_channel_fops
= {
1978 .owner
= THIS_MODULE
,
1979 .release
= lttng_channel_release
,
1980 .poll
= lttng_channel_poll
,
1981 .unlocked_ioctl
= lttng_channel_ioctl
,
1982 #ifdef CONFIG_COMPAT
1983 .compat_ioctl
= lttng_channel_ioctl
,
1987 static const struct file_operations lttng_metadata_fops
= {
1988 .owner
= THIS_MODULE
,
1989 .release
= lttng_metadata_channel_release
,
1990 .unlocked_ioctl
= lttng_metadata_ioctl
,
1991 #ifdef CONFIG_COMPAT
1992 .compat_ioctl
= lttng_metadata_ioctl
,
1997 * lttng_event_ioctl - lttng syscall through ioctl
2003 * This ioctl implements lttng commands:
2004 * LTTNG_KERNEL_CONTEXT
2005 * Prepend a context field to each record of this event
2006 * LTTNG_KERNEL_ENABLE
2007 * Enable recording for this event (weak enable)
2008 * LTTNG_KERNEL_DISABLE
2009 * Disable recording for this event (strong disable)
2012 long lttng_event_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
2014 struct lttng_event
*event
;
2015 struct lttng_event_enabler
*event_enabler
;
2016 enum lttng_event_type
*evtype
= file
->private_data
;
2019 case LTTNG_KERNEL_OLD_CONTEXT
:
2021 /* Not implemented */
2024 case LTTNG_KERNEL_CONTEXT
:
2026 /* Not implemented */
2029 case LTTNG_KERNEL_OLD_ENABLE
:
2030 case LTTNG_KERNEL_ENABLE
:
2032 case LTTNG_TYPE_EVENT
:
2033 event
= file
->private_data
;
2034 return lttng_event_enable(event
);
2035 case LTTNG_TYPE_ENABLER
:
2036 event_enabler
= file
->private_data
;
2037 return lttng_event_enabler_enable(event_enabler
);
2042 case LTTNG_KERNEL_OLD_DISABLE
:
2043 case LTTNG_KERNEL_DISABLE
:
2045 case LTTNG_TYPE_EVENT
:
2046 event
= file
->private_data
;
2047 return lttng_event_disable(event
);
2048 case LTTNG_TYPE_ENABLER
:
2049 event_enabler
= file
->private_data
;
2050 return lttng_event_enabler_disable(event_enabler
);
2055 case LTTNG_KERNEL_FILTER
:
2057 case LTTNG_TYPE_EVENT
:
2059 case LTTNG_TYPE_ENABLER
:
2061 event_enabler
= file
->private_data
;
2062 return lttng_event_enabler_attach_bytecode(event_enabler
,
2063 (struct lttng_kernel_filter_bytecode __user
*) arg
);
2069 case LTTNG_KERNEL_ADD_CALLSITE
:
2071 case LTTNG_TYPE_EVENT
:
2072 event
= file
->private_data
;
2073 return lttng_event_add_callsite(event
,
2074 (struct lttng_kernel_event_callsite __user
*) arg
);
2075 case LTTNG_TYPE_ENABLER
:
2082 return -ENOIOCTLCMD
;
2087 int lttng_event_release(struct inode
*inode
, struct file
*file
)
2089 struct lttng_event
*event
;
2090 struct lttng_event_enabler
*event_enabler
;
2091 enum lttng_event_type
*evtype
= file
->private_data
;
2097 case LTTNG_TYPE_EVENT
:
2098 event
= file
->private_data
;
2100 fput(event
->chan
->file
);
2102 case LTTNG_TYPE_ENABLER
:
2103 event_enabler
= file
->private_data
;
2105 fput(event_enabler
->chan
->file
);
2115 /* TODO: filter control ioctl */
2116 static const struct file_operations lttng_event_fops
= {
2117 .owner
= THIS_MODULE
,
2118 .release
= lttng_event_release
,
2119 .unlocked_ioctl
= lttng_event_ioctl
,
2120 #ifdef CONFIG_COMPAT
2121 .compat_ioctl
= lttng_event_ioctl
,
2125 static int put_u64(uint64_t val
, unsigned long arg
)
2127 return put_user(val
, (uint64_t __user
*) arg
);
2130 static int put_u32(uint32_t val
, unsigned long arg
)
2132 return put_user(val
, (uint32_t __user
*) arg
);
2135 static long lttng_stream_ring_buffer_ioctl(struct file
*filp
,
2136 unsigned int cmd
, unsigned long arg
)
2138 struct lib_ring_buffer
*buf
= filp
->private_data
;
2139 struct channel
*chan
= buf
->backend
.chan
;
2140 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
2141 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
2144 if (atomic_read(&chan
->record_disabled
))
2148 case LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN
:
2152 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
2155 return put_u64(ts
, arg
);
2157 case LTTNG_RING_BUFFER_GET_TIMESTAMP_END
:
2161 ret
= ops
->timestamp_end(config
, buf
, &ts
);
2164 return put_u64(ts
, arg
);
2166 case LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED
:
2170 ret
= ops
->events_discarded(config
, buf
, &ed
);
2173 return put_u64(ed
, arg
);
2175 case LTTNG_RING_BUFFER_GET_CONTENT_SIZE
:
2179 ret
= ops
->content_size(config
, buf
, &cs
);
2182 return put_u64(cs
, arg
);
2184 case LTTNG_RING_BUFFER_GET_PACKET_SIZE
:
2188 ret
= ops
->packet_size(config
, buf
, &ps
);
2191 return put_u64(ps
, arg
);
2193 case LTTNG_RING_BUFFER_GET_STREAM_ID
:
2197 ret
= ops
->stream_id(config
, buf
, &si
);
2200 return put_u64(si
, arg
);
2202 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
2206 ret
= ops
->current_timestamp(config
, buf
, &ts
);
2209 return put_u64(ts
, arg
);
2211 case LTTNG_RING_BUFFER_GET_SEQ_NUM
:
2215 ret
= ops
->sequence_number(config
, buf
, &seq
);
2218 return put_u64(seq
, arg
);
2220 case LTTNG_RING_BUFFER_INSTANCE_ID
:
2224 ret
= ops
->instance_id(config
, buf
, &id
);
2227 return put_u64(id
, arg
);
2230 return lib_ring_buffer_file_operations
.unlocked_ioctl(filp
,
2238 #ifdef CONFIG_COMPAT
2239 static long lttng_stream_ring_buffer_compat_ioctl(struct file
*filp
,
2240 unsigned int cmd
, unsigned long arg
)
2242 struct lib_ring_buffer
*buf
= filp
->private_data
;
2243 struct channel
*chan
= buf
->backend
.chan
;
2244 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
2245 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
2248 if (atomic_read(&chan
->record_disabled
))
2252 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN
:
2256 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
2259 return put_u64(ts
, arg
);
2261 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END
:
2265 ret
= ops
->timestamp_end(config
, buf
, &ts
);
2268 return put_u64(ts
, arg
);
2270 case LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED
:
2274 ret
= ops
->events_discarded(config
, buf
, &ed
);
2277 return put_u64(ed
, arg
);
2279 case LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE
:
2283 ret
= ops
->content_size(config
, buf
, &cs
);
2286 return put_u64(cs
, arg
);
2288 case LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE
:
2292 ret
= ops
->packet_size(config
, buf
, &ps
);
2295 return put_u64(ps
, arg
);
2297 case LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID
:
2301 ret
= ops
->stream_id(config
, buf
, &si
);
2304 return put_u64(si
, arg
);
2306 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
2310 ret
= ops
->current_timestamp(config
, buf
, &ts
);
2313 return put_u64(ts
, arg
);
2315 case LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM
:
2319 ret
= ops
->sequence_number(config
, buf
, &seq
);
2322 return put_u64(seq
, arg
);
2324 case LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID
:
2328 ret
= ops
->instance_id(config
, buf
, &id
);
2331 return put_u64(id
, arg
);
2334 return lib_ring_buffer_file_operations
.compat_ioctl(filp
,
2341 #endif /* CONFIG_COMPAT */
2343 static void lttng_stream_override_ring_buffer_fops(void)
2345 lttng_stream_ring_buffer_file_operations
.owner
= THIS_MODULE
;
2346 lttng_stream_ring_buffer_file_operations
.open
=
2347 lib_ring_buffer_file_operations
.open
;
2348 lttng_stream_ring_buffer_file_operations
.release
=
2349 lib_ring_buffer_file_operations
.release
;
2350 lttng_stream_ring_buffer_file_operations
.poll
=
2351 lib_ring_buffer_file_operations
.poll
;
2352 lttng_stream_ring_buffer_file_operations
.splice_read
=
2353 lib_ring_buffer_file_operations
.splice_read
;
2354 lttng_stream_ring_buffer_file_operations
.mmap
=
2355 lib_ring_buffer_file_operations
.mmap
;
2356 lttng_stream_ring_buffer_file_operations
.unlocked_ioctl
=
2357 lttng_stream_ring_buffer_ioctl
;
2358 lttng_stream_ring_buffer_file_operations
.llseek
=
2359 lib_ring_buffer_file_operations
.llseek
;
2360 #ifdef CONFIG_COMPAT
2361 lttng_stream_ring_buffer_file_operations
.compat_ioctl
=
2362 lttng_stream_ring_buffer_compat_ioctl
;
2366 int __init
lttng_abi_init(void)
2370 wrapper_vmalloc_sync_mappings();
2373 ret
= lttng_tp_mempool_init();
2378 lttng_proc_dentry
= proc_create_data("lttng", S_IRUSR
| S_IWUSR
, NULL
,
2379 <tng_proc_ops
, NULL
);
2381 if (!lttng_proc_dentry
) {
2382 printk(KERN_ERR
"LTTng: Error creating control file\n");
2386 lttng_stream_override_ring_buffer_fops();
2390 lttng_tp_mempool_destroy();
2391 lttng_clock_unref();
2395 /* No __exit annotation because used by init error path too. */
2396 void lttng_abi_exit(void)
2398 lttng_tp_mempool_destroy();
2399 lttng_clock_unref();
2400 if (lttng_proc_dentry
)
2401 remove_proc_entry("lttng", NULL
);