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 <wrapper/barrier.h>
41 #include <lttng/string-utils.h>
42 #include <lttng/abi.h>
43 #include <lttng/abi-old.h>
44 #include <lttng/events.h>
45 #include <lttng/tracer.h>
46 #include <lttng/tp-mempool.h>
47 #include <ringbuffer/frontend_types.h>
48 #include <ringbuffer/iterator.h>
51 * This is LTTng's own personal way to create a system call as an external
52 * module. We use ioctl() on /proc/lttng.
55 static struct proc_dir_entry
*lttng_proc_dentry
;
57 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0))
58 static const struct proc_ops lttng_proc_ops
;
60 static const struct file_operations lttng_proc_ops
;
63 static const struct file_operations lttng_session_fops
;
64 static const struct file_operations lttng_event_notifier_group_fops
;
65 static const struct file_operations lttng_channel_fops
;
66 static const struct file_operations lttng_metadata_fops
;
67 static const struct file_operations lttng_event_fops
;
68 static struct file_operations lttng_stream_ring_buffer_file_operations
;
70 static int put_u64(uint64_t val
, unsigned long arg
);
71 static int put_u32(uint32_t val
, unsigned long arg
);
73 static int validate_zeroed_padding(char *p
, size_t len
)
77 for (i
= 0; i
< len
; i
++) {
85 * Teardown management: opened file descriptors keep a refcount on the module,
86 * so it can only exit when all file descriptors are closed.
90 int lttng_abi_create_session(void)
92 struct lttng_session
*session
;
93 struct file
*session_file
;
96 session
= lttng_session_create();
99 session_fd
= lttng_get_unused_fd();
100 if (session_fd
< 0) {
104 session_file
= anon_inode_getfile("[lttng_session]",
107 if (IS_ERR(session_file
)) {
108 ret
= PTR_ERR(session_file
);
111 session
->file
= session_file
;
112 fd_install(session_fd
, session_file
);
116 put_unused_fd(session_fd
);
118 lttng_session_destroy(session
);
122 void event_notifier_send_notification_work_wakeup(struct irq_work
*entry
)
124 struct lttng_event_notifier_group
*event_notifier_group
=
125 container_of(entry
, struct lttng_event_notifier_group
,
127 wake_up_interruptible(&event_notifier_group
->read_wait
);
131 int lttng_abi_create_event_notifier_group(void)
133 struct lttng_event_notifier_group
*event_notifier_group
;
134 struct file
*event_notifier_group_file
;
135 int event_notifier_group_fd
, ret
;
137 event_notifier_group
= lttng_event_notifier_group_create();
138 if (!event_notifier_group
)
141 event_notifier_group_fd
= lttng_get_unused_fd();
142 if (event_notifier_group_fd
< 0) {
143 ret
= event_notifier_group_fd
;
146 event_notifier_group_file
= anon_inode_getfile("[lttng_event_notifier_group]",
147 <tng_event_notifier_group_fops
,
148 event_notifier_group
, O_RDWR
);
149 if (IS_ERR(event_notifier_group_file
)) {
150 ret
= PTR_ERR(event_notifier_group_file
);
154 event_notifier_group
->file
= event_notifier_group_file
;
155 init_waitqueue_head(&event_notifier_group
->read_wait
);
156 init_irq_work(&event_notifier_group
->wakeup_pending
,
157 event_notifier_send_notification_work_wakeup
);
158 fd_install(event_notifier_group_fd
, event_notifier_group_file
);
159 return event_notifier_group_fd
;
162 put_unused_fd(event_notifier_group_fd
);
164 lttng_event_notifier_group_destroy(event_notifier_group
);
169 int lttng_abi_tracepoint_list(void)
171 struct file
*tracepoint_list_file
;
174 file_fd
= lttng_get_unused_fd();
180 tracepoint_list_file
= anon_inode_getfile("[lttng_tracepoint_list]",
181 <tng_tracepoint_list_fops
,
183 if (IS_ERR(tracepoint_list_file
)) {
184 ret
= PTR_ERR(tracepoint_list_file
);
187 ret
= lttng_tracepoint_list_fops
.open(NULL
, tracepoint_list_file
);
190 fd_install(file_fd
, tracepoint_list_file
);
194 fput(tracepoint_list_file
);
196 put_unused_fd(file_fd
);
201 #ifndef CONFIG_HAVE_SYSCALL_TRACEPOINTS
203 int lttng_abi_syscall_list(void)
209 int lttng_abi_syscall_list(void)
211 struct file
*syscall_list_file
;
214 file_fd
= lttng_get_unused_fd();
220 syscall_list_file
= anon_inode_getfile("[lttng_syscall_list]",
221 <tng_syscall_list_fops
,
223 if (IS_ERR(syscall_list_file
)) {
224 ret
= PTR_ERR(syscall_list_file
);
227 ret
= lttng_syscall_list_fops
.open(NULL
, syscall_list_file
);
230 fd_install(file_fd
, syscall_list_file
);
234 fput(syscall_list_file
);
236 put_unused_fd(file_fd
);
243 void lttng_abi_tracer_version(struct lttng_kernel_tracer_version
*v
)
245 v
->major
= LTTNG_MODULES_MAJOR_VERSION
;
246 v
->minor
= LTTNG_MODULES_MINOR_VERSION
;
247 v
->patchlevel
= LTTNG_MODULES_PATCHLEVEL_VERSION
;
251 void lttng_abi_tracer_abi_version(struct lttng_kernel_tracer_abi_version
*v
)
253 v
->major
= LTTNG_MODULES_ABI_MAJOR_VERSION
;
254 v
->minor
= LTTNG_MODULES_ABI_MINOR_VERSION
;
258 long lttng_abi_add_context(struct file
*file
,
259 struct lttng_kernel_context
*context_param
,
260 struct lttng_ctx
**ctx
, struct lttng_session
*session
)
263 if (session
->been_active
)
266 switch (context_param
->ctx
) {
267 case LTTNG_KERNEL_CONTEXT_PID
:
268 return lttng_add_pid_to_ctx(ctx
);
269 case LTTNG_KERNEL_CONTEXT_PRIO
:
270 return lttng_add_prio_to_ctx(ctx
);
271 case LTTNG_KERNEL_CONTEXT_NICE
:
272 return lttng_add_nice_to_ctx(ctx
);
273 case LTTNG_KERNEL_CONTEXT_VPID
:
274 return lttng_add_vpid_to_ctx(ctx
);
275 case LTTNG_KERNEL_CONTEXT_TID
:
276 return lttng_add_tid_to_ctx(ctx
);
277 case LTTNG_KERNEL_CONTEXT_VTID
:
278 return lttng_add_vtid_to_ctx(ctx
);
279 case LTTNG_KERNEL_CONTEXT_PPID
:
280 return lttng_add_ppid_to_ctx(ctx
);
281 case LTTNG_KERNEL_CONTEXT_VPPID
:
282 return lttng_add_vppid_to_ctx(ctx
);
283 case LTTNG_KERNEL_CONTEXT_PERF_COUNTER
:
284 context_param
->u
.perf_counter
.name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
285 return lttng_add_perf_counter_to_ctx(context_param
->u
.perf_counter
.type
,
286 context_param
->u
.perf_counter
.config
,
287 context_param
->u
.perf_counter
.name
,
289 case LTTNG_KERNEL_CONTEXT_PROCNAME
:
290 return lttng_add_procname_to_ctx(ctx
);
291 case LTTNG_KERNEL_CONTEXT_HOSTNAME
:
292 return lttng_add_hostname_to_ctx(ctx
);
293 case LTTNG_KERNEL_CONTEXT_CPU_ID
:
294 return lttng_add_cpu_id_to_ctx(ctx
);
295 case LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE
:
296 return lttng_add_interruptible_to_ctx(ctx
);
297 case LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE
:
298 return lttng_add_need_reschedule_to_ctx(ctx
);
299 case LTTNG_KERNEL_CONTEXT_PREEMPTIBLE
:
300 return lttng_add_preemptible_to_ctx(ctx
);
301 case LTTNG_KERNEL_CONTEXT_MIGRATABLE
:
302 return lttng_add_migratable_to_ctx(ctx
);
303 case LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL
:
304 case LTTNG_KERNEL_CONTEXT_CALLSTACK_USER
:
305 return lttng_add_callstack_to_ctx(ctx
, context_param
->ctx
);
306 case LTTNG_KERNEL_CONTEXT_CGROUP_NS
:
307 return lttng_add_cgroup_ns_to_ctx(ctx
);
308 case LTTNG_KERNEL_CONTEXT_IPC_NS
:
309 return lttng_add_ipc_ns_to_ctx(ctx
);
310 case LTTNG_KERNEL_CONTEXT_MNT_NS
:
311 return lttng_add_mnt_ns_to_ctx(ctx
);
312 case LTTNG_KERNEL_CONTEXT_NET_NS
:
313 return lttng_add_net_ns_to_ctx(ctx
);
314 case LTTNG_KERNEL_CONTEXT_PID_NS
:
315 return lttng_add_pid_ns_to_ctx(ctx
);
316 case LTTNG_KERNEL_CONTEXT_USER_NS
:
317 return lttng_add_user_ns_to_ctx(ctx
);
318 case LTTNG_KERNEL_CONTEXT_UTS_NS
:
319 return lttng_add_uts_ns_to_ctx(ctx
);
320 case LTTNG_KERNEL_CONTEXT_UID
:
321 return lttng_add_uid_to_ctx(ctx
);
322 case LTTNG_KERNEL_CONTEXT_EUID
:
323 return lttng_add_euid_to_ctx(ctx
);
324 case LTTNG_KERNEL_CONTEXT_SUID
:
325 return lttng_add_suid_to_ctx(ctx
);
326 case LTTNG_KERNEL_CONTEXT_GID
:
327 return lttng_add_gid_to_ctx(ctx
);
328 case LTTNG_KERNEL_CONTEXT_EGID
:
329 return lttng_add_egid_to_ctx(ctx
);
330 case LTTNG_KERNEL_CONTEXT_SGID
:
331 return lttng_add_sgid_to_ctx(ctx
);
332 case LTTNG_KERNEL_CONTEXT_VUID
:
333 return lttng_add_vuid_to_ctx(ctx
);
334 case LTTNG_KERNEL_CONTEXT_VEUID
:
335 return lttng_add_veuid_to_ctx(ctx
);
336 case LTTNG_KERNEL_CONTEXT_VSUID
:
337 return lttng_add_vsuid_to_ctx(ctx
);
338 case LTTNG_KERNEL_CONTEXT_VGID
:
339 return lttng_add_vgid_to_ctx(ctx
);
340 case LTTNG_KERNEL_CONTEXT_VEGID
:
341 return lttng_add_vegid_to_ctx(ctx
);
342 case LTTNG_KERNEL_CONTEXT_VSGID
:
343 return lttng_add_vsgid_to_ctx(ctx
);
344 case LTTNG_KERNEL_CONTEXT_TIME_NS
:
345 return lttng_add_time_ns_to_ctx(ctx
);
352 * lttng_ioctl - lttng syscall through ioctl
358 * This ioctl implements lttng commands:
359 * LTTNG_KERNEL_SESSION
360 * Returns a LTTng trace session file descriptor
361 * LTTNG_KERNEL_TRACER_VERSION
362 * Returns the LTTng kernel tracer version
363 * LTTNG_KERNEL_TRACEPOINT_LIST
364 * Returns a file descriptor listing available tracepoints
365 * LTTNG_KERNEL_WAIT_QUIESCENT
366 * Returns after all previously running probes have completed
367 * LTTNG_KERNEL_TRACER_ABI_VERSION
368 * Returns the LTTng kernel tracer ABI version
369 * LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_CREATE
370 * Returns a LTTng event notifier group file descriptor
372 * The returned session will be deleted when its file descriptor is closed.
375 long lttng_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
378 case LTTNG_KERNEL_OLD_SESSION
:
379 case LTTNG_KERNEL_SESSION
:
380 return lttng_abi_create_session();
381 case LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_CREATE
:
382 return lttng_abi_create_event_notifier_group();
383 case LTTNG_KERNEL_OLD_TRACER_VERSION
:
385 struct lttng_kernel_tracer_version v
;
386 struct lttng_kernel_old_tracer_version oldv
;
387 struct lttng_kernel_old_tracer_version
*uversion
=
388 (struct lttng_kernel_old_tracer_version __user
*) arg
;
390 lttng_abi_tracer_version(&v
);
391 oldv
.major
= v
.major
;
392 oldv
.minor
= v
.minor
;
393 oldv
.patchlevel
= v
.patchlevel
;
395 if (copy_to_user(uversion
, &oldv
, sizeof(oldv
)))
399 case LTTNG_KERNEL_TRACER_VERSION
:
401 struct lttng_kernel_tracer_version version
;
402 struct lttng_kernel_tracer_version
*uversion
=
403 (struct lttng_kernel_tracer_version __user
*) arg
;
405 lttng_abi_tracer_version(&version
);
407 if (copy_to_user(uversion
, &version
, sizeof(version
)))
411 case LTTNG_KERNEL_TRACER_ABI_VERSION
:
413 struct lttng_kernel_tracer_abi_version version
;
414 struct lttng_kernel_tracer_abi_version
*uversion
=
415 (struct lttng_kernel_tracer_abi_version __user
*) arg
;
417 lttng_abi_tracer_abi_version(&version
);
419 if (copy_to_user(uversion
, &version
, sizeof(version
)))
423 case LTTNG_KERNEL_OLD_TRACEPOINT_LIST
:
424 case LTTNG_KERNEL_TRACEPOINT_LIST
:
425 return lttng_abi_tracepoint_list();
426 case LTTNG_KERNEL_SYSCALL_LIST
:
427 return lttng_abi_syscall_list();
428 case LTTNG_KERNEL_OLD_WAIT_QUIESCENT
:
429 case LTTNG_KERNEL_WAIT_QUIESCENT
:
432 case LTTNG_KERNEL_OLD_CALIBRATE
:
434 struct lttng_kernel_old_calibrate __user
*ucalibrate
=
435 (struct lttng_kernel_old_calibrate __user
*) arg
;
436 struct lttng_kernel_old_calibrate old_calibrate
;
437 struct lttng_kernel_calibrate calibrate
;
440 if (copy_from_user(&old_calibrate
, ucalibrate
, sizeof(old_calibrate
)))
442 calibrate
.type
= old_calibrate
.type
;
443 ret
= lttng_calibrate(&calibrate
);
444 if (copy_to_user(ucalibrate
, &old_calibrate
, sizeof(old_calibrate
)))
448 case LTTNG_KERNEL_CALIBRATE
:
450 struct lttng_kernel_calibrate __user
*ucalibrate
=
451 (struct lttng_kernel_calibrate __user
*) arg
;
452 struct lttng_kernel_calibrate calibrate
;
455 if (copy_from_user(&calibrate
, ucalibrate
, sizeof(calibrate
)))
457 ret
= lttng_calibrate(&calibrate
);
458 if (copy_to_user(ucalibrate
, &calibrate
, sizeof(calibrate
)))
467 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0))
468 static const struct proc_ops lttng_proc_ops
= {
469 .proc_ioctl
= lttng_ioctl
,
471 .proc_compat_ioctl
= lttng_ioctl
,
472 #endif /* CONFIG_COMPAT */
475 static const struct file_operations lttng_proc_ops
= {
476 .owner
= THIS_MODULE
,
477 .unlocked_ioctl
= lttng_ioctl
,
479 .compat_ioctl
= lttng_ioctl
,
480 #endif /* CONFIG_COMPAT */
485 int lttng_abi_create_channel(struct file
*session_file
,
486 struct lttng_kernel_channel
*chan_param
,
487 enum channel_type channel_type
)
489 struct lttng_session
*session
= session_file
->private_data
;
490 const struct file_operations
*fops
= NULL
;
491 const char *transport_name
;
492 struct lttng_channel
*chan
;
493 struct lttng_event_container
*container
;
494 struct file
*chan_file
;
498 chan_fd
= lttng_get_unused_fd();
503 switch (channel_type
) {
504 case PER_CPU_CHANNEL
:
505 fops
= <tng_channel_fops
;
507 case METADATA_CHANNEL
:
508 fops
= <tng_metadata_fops
;
512 chan_file
= anon_inode_getfile("[lttng_channel]",
515 if (IS_ERR(chan_file
)) {
516 ret
= PTR_ERR(chan_file
);
519 switch (channel_type
) {
520 case PER_CPU_CHANNEL
:
521 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
) {
522 transport_name
= chan_param
->overwrite
?
523 "relay-overwrite" : "relay-discard";
524 } else if (chan_param
->output
== LTTNG_KERNEL_MMAP
) {
525 transport_name
= chan_param
->overwrite
?
526 "relay-overwrite-mmap" : "relay-discard-mmap";
531 case METADATA_CHANNEL
:
532 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
)
533 transport_name
= "relay-metadata";
534 else if (chan_param
->output
== LTTNG_KERNEL_MMAP
)
535 transport_name
= "relay-metadata-mmap";
540 transport_name
= "<unknown>";
543 if (!atomic_long_add_unless(&session_file
->f_count
, 1, LONG_MAX
)) {
548 * We tolerate no failure path after channel creation. It will stay
549 * invariant for the rest of the session.
551 chan
= lttng_channel_create(session
, transport_name
, NULL
,
552 chan_param
->subbuf_size
,
553 chan_param
->num_subbuf
,
554 chan_param
->switch_timer_interval
,
555 chan_param
->read_timer_interval
,
561 container
= lttng_channel_get_event_container(chan
);
562 container
->file
= chan_file
;
563 chan_file
->private_data
= chan
;
564 fd_install(chan_fd
, chan_file
);
569 atomic_long_dec(&session_file
->f_count
);
573 put_unused_fd(chan_fd
);
579 int lttng_abi_session_set_name(struct lttng_session
*session
,
580 struct lttng_kernel_session_name
*name
)
584 len
= strnlen(name
->name
, LTTNG_KERNEL_SESSION_NAME_LEN
);
586 if (len
== LTTNG_KERNEL_SESSION_NAME_LEN
) {
587 /* Name is too long/malformed */
591 strcpy(session
->name
, name
->name
);
596 int lttng_abi_session_set_creation_time(struct lttng_session
*session
,
597 struct lttng_kernel_session_creation_time
*time
)
601 len
= strnlen(time
->iso8601
, LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
);
603 if (len
== LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
) {
604 /* Time is too long/malformed */
608 strcpy(session
->creation_time
, time
->iso8601
);
613 int lttng_abi_validate_event_param(struct lttng_kernel_event
*event_param
)
615 /* Limit ABI to implemented features. */
616 switch (event_param
->instrumentation
) {
617 case LTTNG_KERNEL_SYSCALL
:
618 switch (event_param
->u
.syscall
.entryexit
) {
619 case LTTNG_KERNEL_SYSCALL_ENTRY
:
620 case LTTNG_KERNEL_SYSCALL_EXIT
:
621 case LTTNG_KERNEL_SYSCALL_ENTRYEXIT
:
626 switch (event_param
->u
.syscall
.abi
) {
627 case LTTNG_KERNEL_SYSCALL_ABI_ALL
:
632 switch (event_param
->u
.syscall
.match
) {
633 case LTTNG_KERNEL_SYSCALL_MATCH_NAME
:
640 case LTTNG_KERNEL_TRACEPOINT
: /* Fallthrough */
641 case LTTNG_KERNEL_KPROBE
: /* Fallthrough */
642 case LTTNG_KERNEL_KRETPROBE
: /* Fallthrough */
643 case LTTNG_KERNEL_NOOP
: /* Fallthrough */
644 case LTTNG_KERNEL_UPROBE
:
647 case LTTNG_KERNEL_FUNCTION
: /* Fallthrough */
655 int lttng_abi_create_event(struct file
*event_container_file
,
656 struct lttng_event_container
*container
,
657 struct lttng_kernel_event
*event_param
,
658 const struct lttng_counter_key
*key
)
661 struct file
*event_file
;
664 event_param
->name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
665 switch (event_param
->instrumentation
) {
666 case LTTNG_KERNEL_KRETPROBE
:
667 event_param
->u
.kretprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
669 case LTTNG_KERNEL_KPROBE
:
670 event_param
->u
.kprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
672 case LTTNG_KERNEL_FUNCTION
:
674 /* Not implemented. */
679 event_fd
= lttng_get_unused_fd();
684 event_file
= anon_inode_getfile("[lttng_event]",
687 if (IS_ERR(event_file
)) {
688 ret
= PTR_ERR(event_file
);
691 /* The event holds a reference on the container */
692 if (!atomic_long_add_unless(&event_container_file
->f_count
, 1, LONG_MAX
)) {
696 ret
= lttng_abi_validate_event_param(event_param
);
699 if (event_param
->instrumentation
== LTTNG_KERNEL_TRACEPOINT
700 || event_param
->instrumentation
== LTTNG_KERNEL_SYSCALL
) {
701 struct lttng_event_enabler
*event_enabler
;
703 if (strutils_is_star_glob_pattern(event_param
->name
)) {
705 * If the event name is a star globbing pattern,
706 * we create the special star globbing enabler.
708 event_enabler
= lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_STAR_GLOB
,
709 event_param
, key
, container
);
711 event_enabler
= lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_NAME
,
712 event_param
, key
, container
);
714 priv
= event_enabler
;
716 struct lttng_event
*event
;
719 * We tolerate no failure path after event creation. It
720 * will stay invariant for the rest of the session.
722 event
= lttng_event_create(container
, event_param
, key
,
724 event_param
->instrumentation
, event_param
->token
);
726 ret
= PTR_ERR(event
);
731 event_file
->private_data
= priv
;
732 fd_install(event_fd
, event_file
);
736 atomic_long_dec(&event_container_file
->f_count
);
740 put_unused_fd(event_fd
);
746 int lttng_counter_release(struct inode
*inode
, struct file
*file
)
748 struct lttng_counter
*counter
= file
->private_data
;
752 * Do not destroy the counter itself. Wait of the owner
753 * (event_notifier group) to be destroyed.
755 fput(counter
->owner
);
762 int copy_counter_key(struct lttng_counter_key
*key
,
763 const struct lttng_kernel_counter_key
*ukey
)
765 size_t i
, j
, nr_dimensions
;
767 nr_dimensions
= ukey
->nr_dimensions
;
768 if (nr_dimensions
> LTTNG_COUNTER_DIMENSION_MAX
)
770 key
->nr_dimensions
= nr_dimensions
;
771 for (i
= 0; i
< nr_dimensions
; i
++) {
772 const struct lttng_kernel_counter_key_dimension
*udim
=
773 &ukey
->key_dimensions
[i
];
774 struct lttng_counter_key_dimension
*dim
=
775 &key
->key_dimensions
[i
];
776 size_t nr_key_tokens
;
778 nr_key_tokens
= udim
->nr_key_tokens
;
779 if (!nr_key_tokens
|| nr_key_tokens
> LTTNG_NR_KEY_TOKEN
)
781 dim
->nr_key_tokens
= nr_key_tokens
;
782 for (j
= 0; j
< nr_key_tokens
; j
++) {
783 const struct lttng_kernel_key_token
*utoken
=
784 &udim
->key_tokens
[j
];
785 struct lttng_key_token
*token
=
788 switch (utoken
->type
) {
789 case LTTNG_KERNEL_KEY_TOKEN_STRING
:
793 token
->type
= LTTNG_KEY_TOKEN_STRING
;
794 ret
= strncpy_from_user(token
->arg
.string
,
795 (char __user
*)(unsigned long)utoken
->arg
.string_ptr
,
796 LTTNG_KEY_TOKEN_STRING_LEN_MAX
);
799 if (!ret
|| ret
== LTTNG_KEY_TOKEN_STRING_LEN_MAX
)
803 case LTTNG_KERNEL_KEY_TOKEN_EVENT_NAME
:
804 token
->type
= LTTNG_KEY_TOKEN_EVENT_NAME
;
806 case LTTNG_KERNEL_KEY_TOKEN_PROVIDER_NAME
:
807 printk(KERN_ERR
"LTTng: Provider name token not supported.\n");
818 long lttng_counter_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
820 struct lttng_counter
*counter
= file
->private_data
;
821 struct lttng_event_container
*container
= lttng_counter_get_event_container(counter
);
822 size_t indexes
[LTTNG_KERNEL_COUNTER_DIMENSION_MAX
] = { 0 };
826 case LTTNG_KERNEL_COUNTER_READ
:
828 struct lttng_kernel_counter_read local_counter_read
;
829 struct lttng_kernel_counter_read __user
*ucounter_read
=
830 (struct lttng_kernel_counter_read __user
*) arg
;
831 bool overflow
, underflow
;
836 if (copy_from_user(&local_counter_read
, ucounter_read
,
837 sizeof(local_counter_read
)))
839 if (validate_zeroed_padding(local_counter_read
.padding
,
840 sizeof(local_counter_read
.padding
)))
843 /* Cast all indexes into size_t. */
844 for (i
= 0; i
< local_counter_read
.index
.number_dimensions
; i
++)
845 indexes
[i
] = (size_t) local_counter_read
.index
.dimension_indexes
[i
];
846 cpu
= local_counter_read
.cpu
;
848 ret
= lttng_kernel_counter_read(counter
, indexes
, cpu
, &value
,
849 &overflow
, &underflow
);
852 local_counter_read
.value
.value
= value
;
853 local_counter_read
.value
.overflow
= overflow
;
854 local_counter_read
.value
.underflow
= underflow
;
856 if (copy_to_user(&ucounter_read
->value
, &local_counter_read
.value
,
857 sizeof(local_counter_read
.value
)))
862 case LTTNG_KERNEL_COUNTER_AGGREGATE
:
864 struct lttng_kernel_counter_aggregate local_counter_aggregate
;
865 struct lttng_kernel_counter_aggregate __user
*ucounter_aggregate
=
866 (struct lttng_kernel_counter_aggregate __user
*) arg
;
867 bool overflow
, underflow
;
871 if (copy_from_user(&local_counter_aggregate
, ucounter_aggregate
,
872 sizeof(local_counter_aggregate
)))
874 if (validate_zeroed_padding(local_counter_aggregate
.padding
,
875 sizeof(local_counter_aggregate
.padding
)))
878 /* Cast all indexes into size_t. */
879 for (i
= 0; i
< local_counter_aggregate
.index
.number_dimensions
; i
++)
880 indexes
[i
] = (size_t) local_counter_aggregate
.index
.dimension_indexes
[i
];
882 ret
= lttng_kernel_counter_aggregate(counter
, indexes
, &value
,
883 &overflow
, &underflow
);
886 local_counter_aggregate
.value
.value
= value
;
887 local_counter_aggregate
.value
.overflow
= overflow
;
888 local_counter_aggregate
.value
.underflow
= underflow
;
890 if (copy_to_user(&ucounter_aggregate
->value
, &local_counter_aggregate
.value
,
891 sizeof(local_counter_aggregate
.value
)))
896 case LTTNG_KERNEL_COUNTER_CLEAR
:
898 struct lttng_kernel_counter_clear local_counter_clear
;
899 struct lttng_kernel_counter_clear __user
*ucounter_clear
=
900 (struct lttng_kernel_counter_clear __user
*) arg
;
902 if (copy_from_user(&local_counter_clear
, ucounter_clear
,
903 sizeof(local_counter_clear
)))
905 if (validate_zeroed_padding(local_counter_clear
.padding
,
906 sizeof(local_counter_clear
.padding
)))
909 /* Cast all indexes into size_t. */
910 for (i
= 0; i
< local_counter_clear
.index
.number_dimensions
; i
++)
911 indexes
[i
] = (size_t) local_counter_clear
.index
.dimension_indexes
[i
];
913 return lttng_kernel_counter_clear(counter
, indexes
);
915 case LTTNG_KERNEL_COUNTER_EVENT
:
917 struct lttng_kernel_counter_event
*ucounter_event_param
;
918 struct lttng_counter_key
*key
;
921 key
= kzalloc(sizeof(*key
), GFP_KERNEL
);
924 ucounter_event_param
= kzalloc(sizeof(*ucounter_event_param
), GFP_KERNEL
);
925 if (!ucounter_event_param
) {
929 if (copy_from_user(ucounter_event_param
,
930 (struct lttng_kernel_counter_event __user
*) arg
,
931 sizeof(*ucounter_event_param
))) {
935 ret
= copy_counter_key(key
, &ucounter_event_param
->key
);
938 ret
= lttng_abi_create_event(file
, container
, &ucounter_event_param
->event
, key
);
940 kfree(ucounter_event_param
);
945 case LTTNG_KERNEL_ENABLE
:
946 return lttng_event_container_enable(container
);
947 case LTTNG_KERNEL_DISABLE
:
948 return lttng_event_container_disable(container
);
949 case LTTNG_KERNEL_SYSCALL_MASK
:
950 return lttng_event_container_syscall_mask(container
,
951 (struct lttng_kernel_syscall_mask __user
*) arg
);
952 case LTTNG_KERNEL_COUNTER_MAP_NR_DESCRIPTORS
:
954 uint64_t __user
*user_nr_descriptors
= (uint64_t __user
*) arg
;
955 uint64_t nr_descriptors
;
957 mutex_lock(&counter
->map
.lock
);
958 nr_descriptors
= counter
->map
.nr_descriptors
;
959 mutex_unlock(&counter
->map
.lock
);
960 return put_user(nr_descriptors
, user_nr_descriptors
);
962 case LTTNG_KERNEL_COUNTER_MAP_DESCRIPTOR
:
964 struct lttng_kernel_counter_map_descriptor __user
*user_descriptor
=
965 (struct lttng_kernel_counter_map_descriptor __user
*) arg
;
966 struct lttng_kernel_counter_map_descriptor local_descriptor
;
967 struct lttng_counter_map_descriptor
*kernel_descriptor
;
970 if (copy_from_user(&local_descriptor
, user_descriptor
,
971 sizeof(local_descriptor
)))
973 if (validate_zeroed_padding(local_descriptor
.padding
,
974 sizeof(local_descriptor
.padding
)))
977 mutex_lock(&counter
->map
.lock
);
978 if (local_descriptor
.descriptor_index
>= counter
->map
.nr_descriptors
) {
980 goto map_descriptor_error_unlock
;
982 kernel_descriptor
= &counter
->map
.descriptors
[local_descriptor
.descriptor_index
];
983 local_descriptor
.user_token
= kernel_descriptor
->user_token
;
984 local_descriptor
.array_index
= kernel_descriptor
->array_index
;
985 memcpy(local_descriptor
.key
, kernel_descriptor
->key
, LTTNG_KERNEL_COUNTER_KEY_LEN
);
986 mutex_unlock(&counter
->map
.lock
);
988 if (copy_to_user(user_descriptor
, &local_descriptor
,
989 sizeof(local_descriptor
)))
994 map_descriptor_error_unlock
:
995 mutex_unlock(&counter
->map
.lock
);
1004 static const struct file_operations lttng_counter_fops
= {
1005 .owner
= THIS_MODULE
,
1006 .release
= lttng_counter_release
,
1007 .unlocked_ioctl
= lttng_counter_ioctl
,
1008 #ifdef CONFIG_COMPAT
1009 .compat_ioctl
= lttng_counter_ioctl
,
1014 long lttng_abi_session_create_counter(
1015 struct lttng_session
*session
,
1016 const struct lttng_kernel_counter_conf
*counter_conf
)
1018 int counter_fd
, ret
, i
;
1019 char *counter_transport_name
;
1020 struct lttng_event_container
*container
;
1021 struct lttng_counter
*counter
;
1022 struct file
*counter_file
;
1023 size_t dimension_sizes
[LTTNG_KERNEL_COUNTER_DIMENSION_MAX
] = { 0 };
1024 size_t number_dimensions
;
1026 counter_fd
= lttng_get_unused_fd();
1027 if (counter_fd
< 0) {
1032 counter_file
= anon_inode_getfile("[lttng_counter]",
1033 <tng_counter_fops
,
1035 if (IS_ERR(counter_file
)) {
1036 ret
= PTR_ERR(counter_file
);
1040 if (counter_conf
->arithmetic
!= LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR
) {
1041 printk(KERN_ERR
"LTTng: Map: Error counter of the wrong type.\n");
1045 switch (counter_conf
->bitness
) {
1046 case LTTNG_KERNEL_COUNTER_BITNESS_64
:
1047 counter_transport_name
= "counter-per-cpu-64-modular";
1049 case LTTNG_KERNEL_COUNTER_BITNESS_32
:
1050 counter_transport_name
= "counter-per-cpu-32-modular";
1056 number_dimensions
= (size_t) counter_conf
->number_dimensions
;
1058 for (i
= 0; i
< counter_conf
->number_dimensions
; i
++) {
1059 if (counter_conf
->dimensions
[i
].has_underflow
)
1061 if (counter_conf
->dimensions
[i
].has_overflow
)
1063 dimension_sizes
[i
] = counter_conf
->dimensions
[i
].size
;
1066 if (!atomic_long_add_unless(&session
->file
->f_count
, 1, LONG_MAX
)) {
1068 goto refcount_error
;
1071 counter
= lttng_session_create_counter(session
,
1072 counter_transport_name
,
1073 number_dimensions
, dimension_sizes
,
1074 counter_conf
->coalesce_hits
);
1080 counter
->owner
= session
->file
;
1081 container
= lttng_counter_get_event_container(counter
);
1082 container
->file
= counter_file
;
1083 counter_file
->private_data
= counter
;
1085 fd_install(counter_fd
, counter_file
);
1090 atomic_long_dec(&session
->file
->f_count
);
1094 put_unused_fd(counter_fd
);
1100 enum tracker_type
get_tracker_type(struct lttng_kernel_tracker_args
*tracker
)
1102 switch (tracker
->type
) {
1103 case LTTNG_KERNEL_TRACKER_PID
:
1105 case LTTNG_KERNEL_TRACKER_VPID
:
1106 return TRACKER_VPID
;
1107 case LTTNG_KERNEL_TRACKER_UID
:
1109 case LTTNG_KERNEL_TRACKER_VUID
:
1110 return TRACKER_VUID
;
1111 case LTTNG_KERNEL_TRACKER_GID
:
1113 case LTTNG_KERNEL_TRACKER_VGID
:
1114 return TRACKER_VGID
;
1116 return TRACKER_UNKNOWN
;
1121 * lttng_session_ioctl - lttng session fd ioctl
1127 * This ioctl implements lttng commands:
1128 * LTTNG_KERNEL_CHANNEL
1129 * Returns a LTTng channel file descriptor
1130 * LTTNG_KERNEL_ENABLE
1131 * Enables tracing for a session (weak enable)
1132 * LTTNG_KERNEL_DISABLE
1133 * Disables tracing for a session (strong disable)
1134 * LTTNG_KERNEL_METADATA
1135 * Returns a LTTng metadata file descriptor
1136 * LTTNG_KERNEL_SESSION_TRACK_PID
1137 * Add PID to session PID tracker
1138 * LTTNG_KERNEL_SESSION_UNTRACK_PID
1139 * Remove PID from session PID tracker
1140 * LTTNG_KERNEL_SESSION_TRACK_ID
1142 * LTTNG_KERNEL_SESSION_UNTRACK_ID
1143 * Remove ID from tracker
1145 * The returned channel will be deleted when its file descriptor is closed.
1148 long lttng_session_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1150 struct lttng_session
*session
= file
->private_data
;
1151 struct lttng_kernel_channel chan_param
;
1152 struct lttng_kernel_old_channel old_chan_param
;
1155 case LTTNG_KERNEL_OLD_CHANNEL
:
1157 if (copy_from_user(&old_chan_param
,
1158 (struct lttng_kernel_old_channel __user
*) arg
,
1159 sizeof(struct lttng_kernel_old_channel
)))
1161 chan_param
.overwrite
= old_chan_param
.overwrite
;
1162 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
1163 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
1164 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
1165 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
1166 chan_param
.output
= old_chan_param
.output
;
1168 return lttng_abi_create_channel(file
, &chan_param
,
1171 case LTTNG_KERNEL_CHANNEL
:
1173 if (copy_from_user(&chan_param
,
1174 (struct lttng_kernel_channel __user
*) arg
,
1175 sizeof(struct lttng_kernel_channel
)))
1177 return lttng_abi_create_channel(file
, &chan_param
,
1180 case LTTNG_KERNEL_OLD_SESSION_START
:
1181 case LTTNG_KERNEL_OLD_ENABLE
:
1182 case LTTNG_KERNEL_SESSION_START
:
1183 case LTTNG_KERNEL_ENABLE
:
1184 return lttng_session_enable(session
);
1185 case LTTNG_KERNEL_OLD_SESSION_STOP
:
1186 case LTTNG_KERNEL_OLD_DISABLE
:
1187 case LTTNG_KERNEL_SESSION_STOP
:
1188 case LTTNG_KERNEL_DISABLE
:
1189 return lttng_session_disable(session
);
1190 case LTTNG_KERNEL_OLD_METADATA
:
1192 if (copy_from_user(&old_chan_param
,
1193 (struct lttng_kernel_old_channel __user
*) arg
,
1194 sizeof(struct lttng_kernel_old_channel
)))
1196 chan_param
.overwrite
= old_chan_param
.overwrite
;
1197 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
1198 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
1199 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
1200 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
1201 chan_param
.output
= old_chan_param
.output
;
1203 return lttng_abi_create_channel(file
, &chan_param
,
1206 case LTTNG_KERNEL_METADATA
:
1208 if (copy_from_user(&chan_param
,
1209 (struct lttng_kernel_channel __user
*) arg
,
1210 sizeof(struct lttng_kernel_channel
)))
1212 return lttng_abi_create_channel(file
, &chan_param
,
1215 case LTTNG_KERNEL_SESSION_TRACK_PID
:
1216 return lttng_session_track_id(session
, TRACKER_PID
, (int) arg
);
1217 case LTTNG_KERNEL_SESSION_UNTRACK_PID
:
1218 return lttng_session_untrack_id(session
, TRACKER_PID
, (int) arg
);
1219 case LTTNG_KERNEL_SESSION_TRACK_ID
:
1221 struct lttng_kernel_tracker_args tracker
;
1222 enum tracker_type tracker_type
;
1224 if (copy_from_user(&tracker
,
1225 (struct lttng_kernel_tracker_args __user
*) arg
,
1226 sizeof(struct lttng_kernel_tracker_args
)))
1228 tracker_type
= get_tracker_type(&tracker
);
1229 if (tracker_type
== TRACKER_UNKNOWN
)
1231 return lttng_session_track_id(session
, tracker_type
, tracker
.id
);
1233 case LTTNG_KERNEL_SESSION_UNTRACK_ID
:
1235 struct lttng_kernel_tracker_args tracker
;
1236 enum tracker_type tracker_type
;
1238 if (copy_from_user(&tracker
,
1239 (struct lttng_kernel_tracker_args __user
*) arg
,
1240 sizeof(struct lttng_kernel_tracker_args
)))
1242 tracker_type
= get_tracker_type(&tracker
);
1243 if (tracker_type
== TRACKER_UNKNOWN
)
1245 return lttng_session_untrack_id(session
, tracker_type
,
1248 case LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS
:
1249 return lttng_session_list_tracker_ids(session
, TRACKER_PID
);
1250 case LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS
:
1252 struct lttng_kernel_tracker_args tracker
;
1253 enum tracker_type tracker_type
;
1255 if (copy_from_user(&tracker
,
1256 (struct lttng_kernel_tracker_args __user
*) arg
,
1257 sizeof(struct lttng_kernel_tracker_args
)))
1259 tracker_type
= get_tracker_type(&tracker
);
1260 if (tracker_type
== TRACKER_UNKNOWN
)
1262 return lttng_session_list_tracker_ids(session
, tracker_type
);
1264 case LTTNG_KERNEL_SESSION_METADATA_REGEN
:
1265 return lttng_session_metadata_regenerate(session
);
1266 case LTTNG_KERNEL_SESSION_STATEDUMP
:
1267 return lttng_session_statedump(session
);
1268 case LTTNG_KERNEL_SESSION_SET_NAME
:
1270 struct lttng_kernel_session_name name
;
1272 if (copy_from_user(&name
,
1273 (struct lttng_kernel_session_name __user
*) arg
,
1274 sizeof(struct lttng_kernel_session_name
)))
1276 return lttng_abi_session_set_name(session
, &name
);
1278 case LTTNG_KERNEL_SESSION_SET_CREATION_TIME
:
1280 struct lttng_kernel_session_creation_time time
;
1282 if (copy_from_user(&time
,
1283 (struct lttng_kernel_session_creation_time __user
*) arg
,
1284 sizeof(struct lttng_kernel_session_creation_time
)))
1286 return lttng_abi_session_set_creation_time(session
, &time
);
1288 case LTTNG_KERNEL_COUNTER
:
1290 struct lttng_kernel_counter_conf ucounter_conf
;
1292 if (copy_from_user(&ucounter_conf
,
1293 (struct lttng_kernel_counter_conf __user
*) arg
,
1294 sizeof(ucounter_conf
)))
1296 return lttng_abi_session_create_counter(session
,
1300 return -ENOIOCTLCMD
;
1305 * Called when the last file reference is dropped.
1307 * Big fat note: channels and events are invariant for the whole session after
1308 * their creation. So this session destruction also destroys all channel and
1309 * event structures specific to this session (they are not destroyed when their
1310 * individual file is released).
1313 int lttng_session_release(struct inode
*inode
, struct file
*file
)
1315 struct lttng_session
*session
= file
->private_data
;
1318 lttng_session_destroy(session
);
1322 static const struct file_operations lttng_session_fops
= {
1323 .owner
= THIS_MODULE
,
1324 .release
= lttng_session_release
,
1325 .unlocked_ioctl
= lttng_session_ioctl
,
1326 #ifdef CONFIG_COMPAT
1327 .compat_ioctl
= lttng_session_ioctl
,
1332 * When encountering empty buffer, flush current sub-buffer if non-empty
1333 * and retry (if new data available to read after flush).
1336 ssize_t
lttng_event_notifier_group_notif_read(struct file
*filp
, char __user
*user_buf
,
1337 size_t count
, loff_t
*ppos
)
1339 struct lttng_event_notifier_group
*event_notifier_group
= filp
->private_data
;
1340 struct channel
*chan
= event_notifier_group
->chan
;
1341 struct lib_ring_buffer
*buf
= event_notifier_group
->buf
;
1342 ssize_t read_count
= 0, len
;
1346 if (!lttng_access_ok(VERIFY_WRITE
, user_buf
, count
))
1349 /* Finish copy of previous record */
1351 if (read_count
< count
) {
1352 len
= chan
->iter
.len_left
;
1353 read_offset
= *ppos
;
1358 while (read_count
< count
) {
1359 size_t copy_len
, space_left
;
1361 len
= lib_ring_buffer_get_next_record(chan
, buf
);
1365 * Check if buffer is finalized (end of file).
1367 if (len
== -ENODATA
) {
1368 /* A 0 read_count will tell about end of file */
1371 if (filp
->f_flags
& O_NONBLOCK
) {
1373 read_count
= -EAGAIN
;
1379 * No data available at the moment, return what
1386 * Wait for returned len to be >= 0 or -ENODATA.
1388 error
= wait_event_interruptible(
1389 event_notifier_group
->read_wait
,
1390 ((len
= lib_ring_buffer_get_next_record(
1391 chan
, buf
)), len
!= -EAGAIN
));
1392 CHAN_WARN_ON(chan
, len
== -EBUSY
);
1397 CHAN_WARN_ON(chan
, len
< 0 && len
!= -ENODATA
);
1401 read_offset
= buf
->iter
.read_offset
;
1403 space_left
= count
- read_count
;
1404 if (len
<= space_left
) {
1406 chan
->iter
.len_left
= 0;
1409 copy_len
= space_left
;
1410 chan
->iter
.len_left
= len
- copy_len
;
1411 *ppos
= read_offset
+ copy_len
;
1413 if (__lib_ring_buffer_copy_to_user(&buf
->backend
, read_offset
,
1414 &user_buf
[read_count
],
1417 * Leave the len_left and ppos values at their current
1418 * state, as we currently have a valid event to read.
1422 read_count
+= copy_len
;
1428 chan
->iter
.len_left
= 0;
1431 lib_ring_buffer_put_current_record(buf
);
1436 * If the ring buffer is non empty (even just a partial subbuffer), return that
1437 * there is data available. Perform a ring buffer flush if we encounter a
1438 * non-empty ring buffer which does not have any consumeable subbuffer available.
1441 unsigned int lttng_event_notifier_group_notif_poll(struct file
*filp
,
1444 unsigned int mask
= 0;
1445 struct lttng_event_notifier_group
*event_notifier_group
= filp
->private_data
;
1446 struct channel
*chan
= event_notifier_group
->chan
;
1447 struct lib_ring_buffer
*buf
= event_notifier_group
->buf
;
1448 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
1449 int finalized
, disabled
;
1450 unsigned long consumed
, offset
;
1451 size_t subbuffer_header_size
= config
->cb
.subbuffer_header_size();
1453 if (filp
->f_mode
& FMODE_READ
) {
1454 poll_wait_set_exclusive(wait
);
1455 poll_wait(filp
, &event_notifier_group
->read_wait
, wait
);
1457 finalized
= lib_ring_buffer_is_finalized(config
, buf
);
1458 disabled
= lib_ring_buffer_channel_is_disabled(chan
);
1461 * lib_ring_buffer_is_finalized() contains a smp_rmb() ordering
1462 * finalized load before offsets loads.
1464 WARN_ON(atomic_long_read(&buf
->active_readers
) != 1);
1469 offset
= lib_ring_buffer_get_offset(config
, buf
);
1470 consumed
= lib_ring_buffer_get_consumed(config
, buf
);
1473 * If there is no buffer available to consume.
1475 if (subbuf_trunc(offset
, chan
) - subbuf_trunc(consumed
, chan
) == 0) {
1477 * If there is a non-empty subbuffer, flush and try again.
1479 if (subbuf_offset(offset
, chan
) > subbuffer_header_size
) {
1480 lib_ring_buffer_switch_remote(buf
);
1488 * The memory barriers
1489 * __wait_event()/wake_up_interruptible() take
1490 * care of "raw_spin_is_locked" memory ordering.
1492 if (raw_spin_is_locked(&buf
->raw_tick_nohz_spinlock
))
1498 if (subbuf_trunc(offset
, chan
) - subbuf_trunc(consumed
, chan
)
1499 >= chan
->backend
.buf_size
)
1500 return POLLPRI
| POLLRDBAND
;
1502 return POLLIN
| POLLRDNORM
;
1510 * lttng_event_notifier_group_notif_open - event_notifier ring buffer open file operation
1511 * @inode: opened inode
1512 * @file: opened file
1514 * Open implementation. Makes sure only one open instance of a buffer is
1515 * done at a given moment.
1517 static int lttng_event_notifier_group_notif_open(struct inode
*inode
, struct file
*file
)
1519 struct lttng_event_notifier_group
*event_notifier_group
= inode
->i_private
;
1520 struct lib_ring_buffer
*buf
= event_notifier_group
->buf
;
1522 file
->private_data
= event_notifier_group
;
1523 return lib_ring_buffer_open(inode
, file
, buf
);
1527 * lttng_event_notifier_group_notif_release - event_notifier ring buffer release file operation
1528 * @inode: opened inode
1529 * @file: opened file
1531 * Release implementation.
1533 static int lttng_event_notifier_group_notif_release(struct inode
*inode
, struct file
*file
)
1535 struct lttng_event_notifier_group
*event_notifier_group
= file
->private_data
;
1536 struct lib_ring_buffer
*buf
= event_notifier_group
->buf
;
1539 ret
= lib_ring_buffer_release(inode
, file
, buf
);
1542 fput(event_notifier_group
->file
);
1546 static const struct file_operations lttng_event_notifier_group_notif_fops
= {
1547 .owner
= THIS_MODULE
,
1548 .open
= lttng_event_notifier_group_notif_open
,
1549 .release
= lttng_event_notifier_group_notif_release
,
1550 .read
= lttng_event_notifier_group_notif_read
,
1551 .poll
= lttng_event_notifier_group_notif_poll
,
1555 * lttng_metadata_ring_buffer_poll - LTTng ring buffer poll file operation
1559 * Handles the poll operations for the metadata channels.
1562 unsigned int lttng_metadata_ring_buffer_poll(struct file
*filp
,
1565 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1566 struct lib_ring_buffer
*buf
= stream
->priv
;
1568 unsigned int mask
= 0;
1570 if (filp
->f_mode
& FMODE_READ
) {
1571 poll_wait_set_exclusive(wait
);
1572 poll_wait(filp
, &stream
->read_wait
, wait
);
1574 finalized
= stream
->finalized
;
1577 * lib_ring_buffer_is_finalized() contains a smp_rmb()
1578 * ordering finalized load before offsets loads.
1580 WARN_ON(atomic_long_read(&buf
->active_readers
) != 1);
1585 mutex_lock(&stream
->metadata_cache
->lock
);
1586 if (stream
->metadata_cache
->metadata_written
>
1587 stream
->metadata_out
)
1589 mutex_unlock(&stream
->metadata_cache
->lock
);
1596 void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file
*filp
,
1597 unsigned int cmd
, unsigned long arg
)
1599 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1601 stream
->metadata_out
= stream
->metadata_in
;
1605 * Reset the counter of how much metadata has been consumed to 0. That way,
1606 * the consumer receives the content of the metadata cache unchanged. This is
1607 * different from the metadata_regenerate where the offset from epoch is
1608 * resampled, here we want the exact same content as the last time the metadata
1609 * was generated. This command is only possible if all the metadata written
1610 * in the cache has been output to the metadata stream to avoid corrupting the
1613 * Return 0 on success, a negative value on error.
1616 int lttng_metadata_cache_dump(struct lttng_metadata_stream
*stream
)
1619 struct lttng_metadata_cache
*cache
= stream
->metadata_cache
;
1621 mutex_lock(&cache
->lock
);
1622 if (stream
->metadata_out
!= cache
->metadata_written
) {
1626 stream
->metadata_out
= 0;
1627 stream
->metadata_in
= 0;
1628 wake_up_interruptible(&stream
->read_wait
);
1632 mutex_unlock(&cache
->lock
);
1637 long lttng_metadata_ring_buffer_ioctl(struct file
*filp
,
1638 unsigned int cmd
, unsigned long arg
)
1641 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1642 struct lib_ring_buffer
*buf
= stream
->priv
;
1643 unsigned int rb_cmd
;
1646 if (cmd
== RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
)
1647 rb_cmd
= RING_BUFFER_GET_NEXT_SUBBUF
;
1652 case RING_BUFFER_GET_NEXT_SUBBUF
:
1654 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1655 struct lib_ring_buffer
*buf
= stream
->priv
;
1656 struct channel
*chan
= buf
->backend
.chan
;
1658 ret
= lttng_metadata_output_channel(stream
, chan
, NULL
);
1660 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
1666 case RING_BUFFER_GET_SUBBUF
:
1669 * Random access is not allowed for metadata channel.
1673 case RING_BUFFER_FLUSH_EMPTY
: /* Fall-through. */
1674 case RING_BUFFER_FLUSH
:
1676 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1677 struct lib_ring_buffer
*buf
= stream
->priv
;
1678 struct channel
*chan
= buf
->backend
.chan
;
1681 * Before doing the actual ring buffer flush, write up to one
1682 * packet of metadata in the ring buffer.
1684 ret
= lttng_metadata_output_channel(stream
, chan
, NULL
);
1689 case RING_BUFFER_GET_METADATA_VERSION
:
1691 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1693 return put_u64(stream
->version
, arg
);
1695 case RING_BUFFER_METADATA_CACHE_DUMP
:
1697 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1699 return lttng_metadata_cache_dump(stream
);
1701 case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
:
1703 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1704 struct lib_ring_buffer
*buf
= stream
->priv
;
1705 struct channel
*chan
= buf
->backend
.chan
;
1707 ret
= lttng_metadata_output_channel(stream
, chan
, &coherent
);
1709 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
1711 } else if (ret
< 0) {
1719 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
1721 /* Performing lib ring buffer ioctl after our own. */
1722 ret
= lib_ring_buffer_ioctl(filp
, rb_cmd
, arg
, buf
);
1727 case RING_BUFFER_PUT_NEXT_SUBBUF
:
1729 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
1733 case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
:
1735 return put_u32(coherent
, arg
);
1744 #ifdef CONFIG_COMPAT
1746 long lttng_metadata_ring_buffer_compat_ioctl(struct file
*filp
,
1747 unsigned int cmd
, unsigned long arg
)
1750 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1751 struct lib_ring_buffer
*buf
= stream
->priv
;
1752 unsigned int rb_cmd
;
1755 if (cmd
== RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
)
1756 rb_cmd
= RING_BUFFER_GET_NEXT_SUBBUF
;
1761 case RING_BUFFER_GET_NEXT_SUBBUF
:
1763 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1764 struct lib_ring_buffer
*buf
= stream
->priv
;
1765 struct channel
*chan
= buf
->backend
.chan
;
1767 ret
= lttng_metadata_output_channel(stream
, chan
, NULL
);
1769 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
1775 case RING_BUFFER_GET_SUBBUF
:
1778 * Random access is not allowed for metadata channel.
1782 case RING_BUFFER_FLUSH_EMPTY
: /* Fall-through. */
1783 case RING_BUFFER_FLUSH
:
1785 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1786 struct lib_ring_buffer
*buf
= stream
->priv
;
1787 struct channel
*chan
= buf
->backend
.chan
;
1790 * Before doing the actual ring buffer flush, write up to one
1791 * packet of metadata in the ring buffer.
1793 ret
= lttng_metadata_output_channel(stream
, chan
, NULL
);
1798 case RING_BUFFER_GET_METADATA_VERSION
:
1800 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1802 return put_u64(stream
->version
, arg
);
1804 case RING_BUFFER_METADATA_CACHE_DUMP
:
1806 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1808 return lttng_metadata_cache_dump(stream
);
1810 case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
:
1812 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1813 struct lib_ring_buffer
*buf
= stream
->priv
;
1814 struct channel
*chan
= buf
->backend
.chan
;
1816 ret
= lttng_metadata_output_channel(stream
, chan
, &coherent
);
1818 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
1820 } else if (ret
< 0) {
1828 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
1830 /* Performing lib ring buffer ioctl after our own. */
1831 ret
= lib_ring_buffer_compat_ioctl(filp
, rb_cmd
, arg
, buf
);
1836 case RING_BUFFER_PUT_NEXT_SUBBUF
:
1838 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
1842 case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
:
1844 return put_u32(coherent
, arg
);
1855 * This is not used by anonymous file descriptors. This code is left
1856 * there if we ever want to implement an inode with open() operation.
1859 int lttng_metadata_ring_buffer_open(struct inode
*inode
, struct file
*file
)
1861 struct lttng_metadata_stream
*stream
= inode
->i_private
;
1862 struct lib_ring_buffer
*buf
= stream
->priv
;
1864 file
->private_data
= buf
;
1866 * Since life-time of metadata cache differs from that of
1867 * session, we need to keep our own reference on the transport.
1869 if (!try_module_get(stream
->transport
->owner
)) {
1870 printk(KERN_WARNING
"LTTng: Can't lock transport module.\n");
1873 return lib_ring_buffer_open(inode
, file
, buf
);
1877 int lttng_metadata_ring_buffer_release(struct inode
*inode
, struct file
*file
)
1879 struct lttng_metadata_stream
*stream
= file
->private_data
;
1880 struct lib_ring_buffer
*buf
= stream
->priv
;
1882 mutex_lock(&stream
->metadata_cache
->lock
);
1883 list_del(&stream
->list
);
1884 mutex_unlock(&stream
->metadata_cache
->lock
);
1885 kref_put(&stream
->metadata_cache
->refcount
, metadata_cache_destroy
);
1886 module_put(stream
->transport
->owner
);
1888 return lib_ring_buffer_release(inode
, file
, buf
);
1892 ssize_t
lttng_metadata_ring_buffer_splice_read(struct file
*in
, loff_t
*ppos
,
1893 struct pipe_inode_info
*pipe
, size_t len
,
1896 struct lttng_metadata_stream
*stream
= in
->private_data
;
1897 struct lib_ring_buffer
*buf
= stream
->priv
;
1899 return lib_ring_buffer_splice_read(in
, ppos
, pipe
, len
,
1904 int lttng_metadata_ring_buffer_mmap(struct file
*filp
,
1905 struct vm_area_struct
*vma
)
1907 struct lttng_metadata_stream
*stream
= filp
->private_data
;
1908 struct lib_ring_buffer
*buf
= stream
->priv
;
1910 return lib_ring_buffer_mmap(filp
, vma
, buf
);
1914 const struct file_operations lttng_metadata_ring_buffer_file_operations
= {
1915 .owner
= THIS_MODULE
,
1916 .open
= lttng_metadata_ring_buffer_open
,
1917 .release
= lttng_metadata_ring_buffer_release
,
1918 .poll
= lttng_metadata_ring_buffer_poll
,
1919 .splice_read
= lttng_metadata_ring_buffer_splice_read
,
1920 .mmap
= lttng_metadata_ring_buffer_mmap
,
1921 .unlocked_ioctl
= lttng_metadata_ring_buffer_ioctl
,
1922 .llseek
= vfs_lib_ring_buffer_no_llseek
,
1923 #ifdef CONFIG_COMPAT
1924 .compat_ioctl
= lttng_metadata_ring_buffer_compat_ioctl
,
1929 int lttng_abi_create_stream_fd(struct file
*file
, void *stream_priv
,
1930 const struct file_operations
*fops
, const char *name
)
1933 struct file
*stream_file
;
1935 stream_fd
= lttng_get_unused_fd();
1936 if (stream_fd
< 0) {
1940 stream_file
= anon_inode_getfile(name
, fops
, stream_priv
, O_RDWR
);
1941 if (IS_ERR(stream_file
)) {
1942 ret
= PTR_ERR(stream_file
);
1946 * OPEN_FMODE, called within anon_inode_getfile/alloc_file, don't honor
1947 * FMODE_LSEEK, FMODE_PREAD nor FMODE_PWRITE. We need to read from this
1948 * file descriptor, so we set FMODE_PREAD here.
1950 stream_file
->f_mode
|= FMODE_PREAD
;
1951 fd_install(stream_fd
, stream_file
);
1953 * The stream holds a reference to the channel within the generic ring
1954 * buffer library, so no need to hold a refcount on the channel and
1955 * session files here.
1960 put_unused_fd(stream_fd
);
1966 int lttng_abi_open_stream(struct file
*file
)
1968 struct lttng_channel
*channel
= file
->private_data
;
1969 struct lib_ring_buffer
*buf
;
1973 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
1978 ret
= lttng_abi_create_stream_fd(file
, stream_priv
,
1979 <tng_stream_ring_buffer_file_operations
,
1987 channel
->ops
->buffer_read_close(buf
);
1992 int lttng_abi_open_metadata_stream(struct file
*file
)
1994 struct lttng_channel
*channel
= file
->private_data
;
1995 struct lttng_event_container
*container
= lttng_channel_get_event_container(channel
);
1996 struct lttng_session
*session
= container
->session
;
1997 struct lib_ring_buffer
*buf
;
1999 struct lttng_metadata_stream
*metadata_stream
;
2002 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
2006 metadata_stream
= kzalloc(sizeof(struct lttng_metadata_stream
),
2008 if (!metadata_stream
) {
2012 metadata_stream
->metadata_cache
= session
->metadata_cache
;
2013 init_waitqueue_head(&metadata_stream
->read_wait
);
2014 metadata_stream
->priv
= buf
;
2015 stream_priv
= metadata_stream
;
2016 metadata_stream
->transport
= channel
->transport
;
2017 /* Initial state is an empty metadata, considered as incoherent. */
2018 metadata_stream
->coherent
= false;
2021 * Since life-time of metadata cache differs from that of
2022 * session, we need to keep our own reference on the transport.
2024 if (!try_module_get(metadata_stream
->transport
->owner
)) {
2025 printk(KERN_WARNING
"LTTng: Can't lock transport module.\n");
2030 if (!lttng_kref_get(&session
->metadata_cache
->refcount
)) {
2035 ret
= lttng_abi_create_stream_fd(file
, stream_priv
,
2036 <tng_metadata_ring_buffer_file_operations
,
2037 "[lttng_metadata_stream]");
2041 mutex_lock(&session
->metadata_cache
->lock
);
2042 list_add(&metadata_stream
->list
,
2043 &session
->metadata_cache
->metadata_stream
);
2044 mutex_unlock(&session
->metadata_cache
->lock
);
2048 kref_put(&session
->metadata_cache
->refcount
, metadata_cache_destroy
);
2050 module_put(metadata_stream
->transport
->owner
);
2052 kfree(metadata_stream
);
2054 channel
->ops
->buffer_read_close(buf
);
2059 int lttng_abi_open_event_notifier_group_stream(struct file
*notif_file
)
2061 struct lttng_event_notifier_group
*event_notifier_group
= notif_file
->private_data
;
2062 struct channel
*chan
= event_notifier_group
->chan
;
2063 struct lib_ring_buffer
*buf
;
2067 buf
= event_notifier_group
->ops
->buffer_read_open(chan
);
2071 /* The event_notifier notification fd holds a reference on the event_notifier group */
2072 if (!atomic_long_add_unless(¬if_file
->f_count
, 1, LONG_MAX
)) {
2074 goto refcount_error
;
2076 event_notifier_group
->buf
= buf
;
2077 stream_priv
= event_notifier_group
;
2078 ret
= lttng_abi_create_stream_fd(notif_file
, stream_priv
,
2079 <tng_event_notifier_group_notif_fops
,
2080 "[lttng_event_notifier_stream]");
2087 atomic_long_dec(¬if_file
->f_count
);
2089 event_notifier_group
->ops
->buffer_read_close(buf
);
2094 long lttng_event_notifier_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
2096 struct lttng_event_notifier
*event_notifier
;
2097 struct lttng_event_notifier_enabler
*event_notifier_enabler
;
2098 enum lttng_event_type
*evtype
= file
->private_data
;
2101 case LTTNG_KERNEL_ENABLE
:
2103 case LTTNG_TYPE_EVENT
:
2104 event_notifier
= file
->private_data
;
2105 return lttng_event_notifier_enable(event_notifier
);
2106 case LTTNG_TYPE_ENABLER
:
2107 event_notifier_enabler
= file
->private_data
;
2108 return lttng_event_notifier_enabler_enable(event_notifier_enabler
);
2113 case LTTNG_KERNEL_DISABLE
:
2115 case LTTNG_TYPE_EVENT
:
2116 event_notifier
= file
->private_data
;
2117 return lttng_event_notifier_disable(event_notifier
);
2118 case LTTNG_TYPE_ENABLER
:
2119 event_notifier_enabler
= file
->private_data
;
2120 return lttng_event_notifier_enabler_disable(event_notifier_enabler
);
2125 case LTTNG_KERNEL_FILTER
:
2127 case LTTNG_TYPE_EVENT
:
2129 case LTTNG_TYPE_ENABLER
:
2130 event_notifier_enabler
= file
->private_data
;
2131 return lttng_event_notifier_enabler_attach_filter_bytecode(
2132 event_notifier_enabler
,
2133 (struct lttng_kernel_filter_bytecode __user
*) arg
);
2139 case LTTNG_KERNEL_CAPTURE
:
2141 case LTTNG_TYPE_EVENT
:
2143 case LTTNG_TYPE_ENABLER
:
2144 event_notifier_enabler
= file
->private_data
;
2145 return lttng_event_notifier_enabler_attach_capture_bytecode(
2146 event_notifier_enabler
,
2147 (struct lttng_kernel_capture_bytecode __user
*) arg
);
2152 case LTTNG_KERNEL_ADD_CALLSITE
:
2154 case LTTNG_TYPE_EVENT
:
2155 event_notifier
= file
->private_data
;
2156 return lttng_event_notifier_add_callsite(event_notifier
,
2157 (struct lttng_kernel_event_callsite __user
*) arg
);
2158 case LTTNG_TYPE_ENABLER
:
2165 return -ENOIOCTLCMD
;
2170 int lttng_event_notifier_release(struct inode
*inode
, struct file
*file
)
2172 struct lttng_event_notifier
*event_notifier
;
2173 struct lttng_event_notifier_enabler
*event_notifier_enabler
;
2174 enum lttng_event_type
*evtype
= file
->private_data
;
2180 case LTTNG_TYPE_EVENT
:
2181 event_notifier
= file
->private_data
;
2183 fput(event_notifier
->group
->file
);
2185 case LTTNG_TYPE_ENABLER
:
2186 event_notifier_enabler
= file
->private_data
;
2187 if (event_notifier_enabler
)
2188 fput(event_notifier_enabler
->group
->file
);
2198 static const struct file_operations lttng_event_notifier_fops
= {
2199 .owner
= THIS_MODULE
,
2200 .release
= lttng_event_notifier_release
,
2201 .unlocked_ioctl
= lttng_event_notifier_ioctl
,
2202 #ifdef CONFIG_COMPAT
2203 .compat_ioctl
= lttng_event_notifier_ioctl
,
2208 int lttng_abi_create_event_notifier(struct file
*event_notifier_group_file
,
2209 struct lttng_kernel_event_notifier
*event_notifier_param
)
2211 struct lttng_event_notifier_group
*event_notifier_group
=
2212 event_notifier_group_file
->private_data
;
2213 int event_notifier_fd
, ret
;
2214 struct file
*event_notifier_file
;
2217 switch (event_notifier_param
->event
.instrumentation
) {
2218 case LTTNG_KERNEL_TRACEPOINT
:
2219 case LTTNG_KERNEL_UPROBE
:
2221 case LTTNG_KERNEL_KPROBE
:
2222 event_notifier_param
->event
.u
.kprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
2224 case LTTNG_KERNEL_SYSCALL
:
2226 case LTTNG_KERNEL_KRETPROBE
:
2227 /* Placing an event notifier on kretprobe is not supported. */
2228 case LTTNG_KERNEL_FUNCTION
:
2229 case LTTNG_KERNEL_NOOP
:
2235 event_notifier_param
->event
.name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
2237 event_notifier_fd
= lttng_get_unused_fd();
2238 if (event_notifier_fd
< 0) {
2239 ret
= event_notifier_fd
;
2243 event_notifier_file
= anon_inode_getfile("[lttng_event_notifier]",
2244 <tng_event_notifier_fops
,
2246 if (IS_ERR(event_notifier_file
)) {
2247 ret
= PTR_ERR(event_notifier_file
);
2251 /* The event notifier holds a reference on the event notifier group. */
2252 if (!atomic_long_add_unless(&event_notifier_group_file
->f_count
, 1, LONG_MAX
)) {
2254 goto refcount_error
;
2257 if (event_notifier_param
->event
.instrumentation
== LTTNG_KERNEL_TRACEPOINT
2258 || event_notifier_param
->event
.instrumentation
== LTTNG_KERNEL_SYSCALL
) {
2259 struct lttng_event_notifier_enabler
*enabler
;
2261 if (strutils_is_star_glob_pattern(event_notifier_param
->event
.name
)) {
2263 * If the event name is a star globbing pattern,
2264 * we create the special star globbing enabler.
2266 enabler
= lttng_event_notifier_enabler_create(
2267 event_notifier_group
,
2268 LTTNG_ENABLER_FORMAT_STAR_GLOB
,
2269 event_notifier_param
);
2271 enabler
= lttng_event_notifier_enabler_create(
2272 event_notifier_group
,
2273 LTTNG_ENABLER_FORMAT_NAME
,
2274 event_notifier_param
);
2278 struct lttng_event_notifier
*event_notifier
;
2281 * We tolerate no failure path after event notifier creation.
2282 * It will stay invariant for the rest of the session.
2284 event_notifier
= lttng_event_notifier_create(NULL
,
2285 event_notifier_param
->event
.token
,
2286 event_notifier_param
->error_counter_index
,
2287 event_notifier_group
,
2288 event_notifier_param
, NULL
,
2289 event_notifier_param
->event
.instrumentation
);
2290 WARN_ON_ONCE(!event_notifier
);
2291 if (IS_ERR(event_notifier
)) {
2292 ret
= PTR_ERR(event_notifier
);
2293 goto event_notifier_error
;
2295 priv
= event_notifier
;
2297 event_notifier_file
->private_data
= priv
;
2298 fd_install(event_notifier_fd
, event_notifier_file
);
2299 return event_notifier_fd
;
2301 event_notifier_error
:
2302 atomic_long_dec(&event_notifier_group_file
->f_count
);
2304 fput(event_notifier_file
);
2306 put_unused_fd(event_notifier_fd
);
2313 long lttng_abi_event_notifier_group_create_error_counter(
2314 struct file
*event_notifier_group_file
,
2315 const struct lttng_kernel_counter_conf
*error_counter_conf
)
2317 int counter_fd
, ret
;
2318 char *counter_transport_name
;
2320 struct lttng_counter
*counter
;
2321 struct lttng_event_container
*container
;
2322 struct file
*counter_file
;
2323 struct lttng_event_notifier_group
*event_notifier_group
=
2324 (struct lttng_event_notifier_group
*) event_notifier_group_file
->private_data
;
2326 if (error_counter_conf
->arithmetic
!= LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR
) {
2327 printk(KERN_ERR
"LTTng: event_notifier: Error counter of the wrong arithmetic type.\n");
2331 if (error_counter_conf
->number_dimensions
!= 1) {
2332 printk(KERN_ERR
"LTTng: event_notifier: Error counter has more than one dimension.\n");
2336 switch (error_counter_conf
->bitness
) {
2337 case LTTNG_KERNEL_COUNTER_BITNESS_64
:
2338 counter_transport_name
= "counter-per-cpu-64-modular";
2340 case LTTNG_KERNEL_COUNTER_BITNESS_32
:
2341 counter_transport_name
= "counter-per-cpu-32-modular";
2347 counter_fd
= lttng_get_unused_fd();
2348 if (counter_fd
< 0) {
2353 counter_file
= anon_inode_getfile("[lttng_counter]",
2354 <tng_counter_fops
,
2356 if (IS_ERR(counter_file
)) {
2357 ret
= PTR_ERR(counter_file
);
2361 counter_len
= error_counter_conf
->dimensions
[0].size
;
2363 if (!atomic_long_add_unless(&event_notifier_group_file
->f_count
, 1, LONG_MAX
)) {
2365 goto refcount_error
;
2368 ret
= lttng_event_notifier_group_set_error_counter(event_notifier_group
,
2369 counter_transport_name
, counter_len
);
2373 counter
= event_notifier_group
->error_counter
;
2374 container
= lttng_counter_get_event_container(counter
);
2375 container
->file
= counter_file
;
2376 counter
->owner
= event_notifier_group
->file
;
2377 counter_file
->private_data
= counter
;
2379 fd_install(counter_fd
, counter_file
);
2384 atomic_long_dec(&event_notifier_group_file
->f_count
);
2388 put_unused_fd(counter_fd
);
2394 long lttng_event_notifier_group_ioctl(struct file
*file
, unsigned int cmd
,
2398 case LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD
:
2400 return lttng_abi_open_event_notifier_group_stream(file
);
2402 case LTTNG_KERNEL_EVENT_NOTIFIER_CREATE
:
2404 struct lttng_kernel_event_notifier uevent_notifier_param
;
2406 if (copy_from_user(&uevent_notifier_param
,
2407 (struct lttng_kernel_event_notifier __user
*) arg
,
2408 sizeof(uevent_notifier_param
)))
2410 return lttng_abi_create_event_notifier(file
, &uevent_notifier_param
);
2412 case LTTNG_KERNEL_COUNTER
:
2414 struct lttng_kernel_counter_conf uerror_counter_conf
;
2416 if (copy_from_user(&uerror_counter_conf
,
2417 (struct lttng_kernel_counter_conf __user
*) arg
,
2418 sizeof(uerror_counter_conf
)))
2420 return lttng_abi_event_notifier_group_create_error_counter(file
,
2421 &uerror_counter_conf
);
2424 return -ENOIOCTLCMD
;
2430 int lttng_event_notifier_group_release(struct inode
*inode
, struct file
*file
)
2432 struct lttng_event_notifier_group
*event_notifier_group
=
2435 if (event_notifier_group
)
2436 lttng_event_notifier_group_destroy(event_notifier_group
);
2440 static const struct file_operations lttng_event_notifier_group_fops
= {
2441 .owner
= THIS_MODULE
,
2442 .release
= lttng_event_notifier_group_release
,
2443 .unlocked_ioctl
= lttng_event_notifier_group_ioctl
,
2444 #ifdef CONFIG_COMPAT
2445 .compat_ioctl
= lttng_event_notifier_group_ioctl
,
2450 * lttng_channel_ioctl - lttng syscall through ioctl
2456 * This ioctl implements lttng commands:
2457 * LTTNG_KERNEL_STREAM
2458 * Returns an event stream file descriptor or failure.
2459 * (typically, one event stream records events from one CPU)
2460 * LTTNG_KERNEL_EVENT
2461 * Returns an event file descriptor or failure.
2462 * LTTNG_KERNEL_CONTEXT
2463 * Prepend a context field to each event in the channel
2464 * LTTNG_KERNEL_ENABLE
2465 * Enable recording for events in this channel (weak enable)
2466 * LTTNG_KERNEL_DISABLE
2467 * Disable recording for events in this channel (strong disable)
2469 * Channel and event file descriptors also hold a reference on the session.
2472 long lttng_channel_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
2474 struct lttng_channel
*channel
= file
->private_data
;
2475 struct lttng_event_container
*container
= lttng_channel_get_event_container(channel
);
2478 case LTTNG_KERNEL_OLD_STREAM
:
2479 case LTTNG_KERNEL_STREAM
:
2480 return lttng_abi_open_stream(file
);
2481 case LTTNG_KERNEL_OLD_EVENT
:
2483 struct lttng_kernel_event
*uevent_param
;
2484 struct lttng_kernel_old_event
*old_uevent_param
;
2487 uevent_param
= kmalloc(sizeof(struct lttng_kernel_event
),
2489 if (!uevent_param
) {
2493 old_uevent_param
= kmalloc(
2494 sizeof(struct lttng_kernel_old_event
),
2496 if (!old_uevent_param
) {
2498 goto old_event_error_free_param
;
2500 if (copy_from_user(old_uevent_param
,
2501 (struct lttng_kernel_old_event __user
*) arg
,
2502 sizeof(struct lttng_kernel_old_event
))) {
2504 goto old_event_error_free_old_param
;
2507 memcpy(uevent_param
->name
, old_uevent_param
->name
,
2508 sizeof(uevent_param
->name
));
2509 uevent_param
->instrumentation
=
2510 old_uevent_param
->instrumentation
;
2512 switch (old_uevent_param
->instrumentation
) {
2513 case LTTNG_KERNEL_KPROBE
:
2514 uevent_param
->u
.kprobe
.addr
=
2515 old_uevent_param
->u
.kprobe
.addr
;
2516 uevent_param
->u
.kprobe
.offset
=
2517 old_uevent_param
->u
.kprobe
.offset
;
2518 memcpy(uevent_param
->u
.kprobe
.symbol_name
,
2519 old_uevent_param
->u
.kprobe
.symbol_name
,
2520 sizeof(uevent_param
->u
.kprobe
.symbol_name
));
2522 case LTTNG_KERNEL_KRETPROBE
:
2523 uevent_param
->u
.kretprobe
.addr
=
2524 old_uevent_param
->u
.kretprobe
.addr
;
2525 uevent_param
->u
.kretprobe
.offset
=
2526 old_uevent_param
->u
.kretprobe
.offset
;
2527 memcpy(uevent_param
->u
.kretprobe
.symbol_name
,
2528 old_uevent_param
->u
.kretprobe
.symbol_name
,
2529 sizeof(uevent_param
->u
.kretprobe
.symbol_name
));
2531 case LTTNG_KERNEL_FUNCTION
:
2533 /* Not implemented. */
2538 ret
= lttng_abi_create_event(file
, container
, uevent_param
, NULL
);
2540 old_event_error_free_old_param
:
2541 kfree(old_uevent_param
);
2542 old_event_error_free_param
:
2543 kfree(uevent_param
);
2547 case LTTNG_KERNEL_EVENT
:
2549 struct lttng_kernel_event uevent_param
;
2551 if (copy_from_user(&uevent_param
,
2552 (struct lttng_kernel_event __user
*) arg
,
2553 sizeof(uevent_param
)))
2555 return lttng_abi_create_event(file
, container
, &uevent_param
, NULL
);
2557 case LTTNG_KERNEL_OLD_CONTEXT
:
2559 struct lttng_kernel_context
*ucontext_param
;
2560 struct lttng_kernel_old_context
*old_ucontext_param
;
2563 ucontext_param
= kmalloc(sizeof(struct lttng_kernel_context
),
2565 if (!ucontext_param
) {
2569 old_ucontext_param
= kmalloc(sizeof(struct lttng_kernel_old_context
),
2571 if (!old_ucontext_param
) {
2573 goto old_ctx_error_free_param
;
2576 if (copy_from_user(old_ucontext_param
,
2577 (struct lttng_kernel_old_context __user
*) arg
,
2578 sizeof(struct lttng_kernel_old_context
))) {
2580 goto old_ctx_error_free_old_param
;
2582 ucontext_param
->ctx
= old_ucontext_param
->ctx
;
2583 memcpy(ucontext_param
->padding
, old_ucontext_param
->padding
,
2584 sizeof(ucontext_param
->padding
));
2585 /* only type that uses the union */
2586 if (old_ucontext_param
->ctx
== LTTNG_KERNEL_CONTEXT_PERF_COUNTER
) {
2587 ucontext_param
->u
.perf_counter
.type
=
2588 old_ucontext_param
->u
.perf_counter
.type
;
2589 ucontext_param
->u
.perf_counter
.config
=
2590 old_ucontext_param
->u
.perf_counter
.config
;
2591 memcpy(ucontext_param
->u
.perf_counter
.name
,
2592 old_ucontext_param
->u
.perf_counter
.name
,
2593 sizeof(ucontext_param
->u
.perf_counter
.name
));
2596 ret
= lttng_abi_add_context(file
,
2598 &channel
->ctx
, container
->session
);
2600 old_ctx_error_free_old_param
:
2601 kfree(old_ucontext_param
);
2602 old_ctx_error_free_param
:
2603 kfree(ucontext_param
);
2607 case LTTNG_KERNEL_CONTEXT
:
2609 struct lttng_kernel_context ucontext_param
;
2611 if (copy_from_user(&ucontext_param
,
2612 (struct lttng_kernel_context __user
*) arg
,
2613 sizeof(ucontext_param
)))
2615 return lttng_abi_add_context(file
,
2617 &channel
->ctx
, container
->session
);
2619 case LTTNG_KERNEL_OLD_ENABLE
:
2620 case LTTNG_KERNEL_ENABLE
:
2621 return lttng_event_container_enable(container
);
2622 case LTTNG_KERNEL_OLD_DISABLE
:
2623 case LTTNG_KERNEL_DISABLE
:
2624 return lttng_event_container_disable(container
);
2625 case LTTNG_KERNEL_SYSCALL_MASK
:
2626 return lttng_event_container_syscall_mask(container
,
2627 (struct lttng_kernel_syscall_mask __user
*) arg
);
2629 return -ENOIOCTLCMD
;
2634 * lttng_metadata_ioctl - lttng syscall through ioctl
2640 * This ioctl implements lttng commands:
2641 * LTTNG_KERNEL_STREAM
2642 * Returns an event stream file descriptor or failure.
2644 * Channel and event file descriptors also hold a reference on the session.
2647 long lttng_metadata_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
2650 case LTTNG_KERNEL_OLD_STREAM
:
2651 case LTTNG_KERNEL_STREAM
:
2652 return lttng_abi_open_metadata_stream(file
);
2654 return -ENOIOCTLCMD
;
2659 * lttng_channel_poll - lttng stream addition/removal monitoring
2664 unsigned int lttng_channel_poll(struct file
*file
, poll_table
*wait
)
2666 struct lttng_channel
*channel
= file
->private_data
;
2667 unsigned int mask
= 0;
2669 if (file
->f_mode
& FMODE_READ
) {
2670 poll_wait_set_exclusive(wait
);
2671 poll_wait(file
, channel
->ops
->get_hp_wait_queue(channel
->chan
),
2674 if (channel
->ops
->is_disabled(channel
->chan
))
2676 if (channel
->ops
->is_finalized(channel
->chan
))
2678 if (channel
->ops
->buffer_has_read_closed_stream(channel
->chan
))
2679 return POLLIN
| POLLRDNORM
;
2687 int lttng_channel_release(struct inode
*inode
, struct file
*file
)
2689 struct lttng_channel
*chan
= file
->private_data
;
2692 struct lttng_event_container
*container
= lttng_channel_get_event_container(chan
);
2694 fput(container
->session
->file
);
2700 int lttng_metadata_channel_release(struct inode
*inode
, struct file
*file
)
2702 struct lttng_channel
*chan
= file
->private_data
;
2705 struct lttng_event_container
*container
= lttng_channel_get_event_container(chan
);
2707 fput(container
->session
->file
);
2708 lttng_metadata_channel_destroy(chan
);
2714 static const struct file_operations lttng_channel_fops
= {
2715 .owner
= THIS_MODULE
,
2716 .release
= lttng_channel_release
,
2717 .poll
= lttng_channel_poll
,
2718 .unlocked_ioctl
= lttng_channel_ioctl
,
2719 #ifdef CONFIG_COMPAT
2720 .compat_ioctl
= lttng_channel_ioctl
,
2724 static const struct file_operations lttng_metadata_fops
= {
2725 .owner
= THIS_MODULE
,
2726 .release
= lttng_metadata_channel_release
,
2727 .unlocked_ioctl
= lttng_metadata_ioctl
,
2728 #ifdef CONFIG_COMPAT
2729 .compat_ioctl
= lttng_metadata_ioctl
,
2734 * lttng_event_ioctl - lttng syscall through ioctl
2740 * This ioctl implements lttng commands:
2741 * LTTNG_KERNEL_CONTEXT
2742 * Prepend a context field to each record of this event
2743 * LTTNG_KERNEL_ENABLE
2744 * Enable recording for this event (weak enable)
2745 * LTTNG_KERNEL_DISABLE
2746 * Disable recording for this event (strong disable)
2749 long lttng_event_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
2751 struct lttng_event
*event
;
2752 struct lttng_event_enabler
*event_enabler
;
2753 enum lttng_event_type
*evtype
= file
->private_data
;
2756 case LTTNG_KERNEL_OLD_CONTEXT
:
2758 /* Not implemented */
2761 case LTTNG_KERNEL_CONTEXT
:
2763 /* Not implemented */
2766 case LTTNG_KERNEL_OLD_ENABLE
:
2767 case LTTNG_KERNEL_ENABLE
:
2769 case LTTNG_TYPE_EVENT
:
2770 event
= file
->private_data
;
2771 return lttng_event_enable(event
);
2772 case LTTNG_TYPE_ENABLER
:
2773 event_enabler
= file
->private_data
;
2774 return lttng_event_enabler_enable(event_enabler
);
2779 case LTTNG_KERNEL_OLD_DISABLE
:
2780 case LTTNG_KERNEL_DISABLE
:
2782 case LTTNG_TYPE_EVENT
:
2783 event
= file
->private_data
;
2784 return lttng_event_disable(event
);
2785 case LTTNG_TYPE_ENABLER
:
2786 event_enabler
= file
->private_data
;
2787 return lttng_event_enabler_disable(event_enabler
);
2792 case LTTNG_KERNEL_FILTER
:
2794 case LTTNG_TYPE_EVENT
:
2796 case LTTNG_TYPE_ENABLER
:
2798 event_enabler
= file
->private_data
;
2799 return lttng_event_enabler_attach_filter_bytecode(
2801 (struct lttng_kernel_filter_bytecode __user
*) arg
);
2807 case LTTNG_KERNEL_ADD_CALLSITE
:
2809 case LTTNG_TYPE_EVENT
:
2810 event
= file
->private_data
;
2811 return lttng_event_add_callsite(event
,
2812 (struct lttng_kernel_event_callsite __user
*) arg
);
2813 case LTTNG_TYPE_ENABLER
:
2820 return -ENOIOCTLCMD
;
2825 int lttng_event_release(struct inode
*inode
, struct file
*file
)
2827 struct lttng_event
*event
;
2828 struct lttng_event_enabler
*event_enabler
;
2829 enum lttng_event_type
*evtype
= file
->private_data
;
2835 case LTTNG_TYPE_EVENT
:
2836 event
= file
->private_data
;
2838 fput(event
->container
->file
);
2840 case LTTNG_TYPE_ENABLER
:
2841 event_enabler
= file
->private_data
;
2843 fput(event_enabler
->container
->file
);
2853 /* TODO: filter control ioctl */
2854 static const struct file_operations lttng_event_fops
= {
2855 .owner
= THIS_MODULE
,
2856 .release
= lttng_event_release
,
2857 .unlocked_ioctl
= lttng_event_ioctl
,
2858 #ifdef CONFIG_COMPAT
2859 .compat_ioctl
= lttng_event_ioctl
,
2863 static int put_u64(uint64_t val
, unsigned long arg
)
2865 return put_user(val
, (uint64_t __user
*) arg
);
2868 static int put_u32(uint32_t val
, unsigned long arg
)
2870 return put_user(val
, (uint32_t __user
*) arg
);
2873 static long lttng_stream_ring_buffer_ioctl(struct file
*filp
,
2874 unsigned int cmd
, unsigned long arg
)
2876 struct lib_ring_buffer
*buf
= filp
->private_data
;
2877 struct channel
*chan
= buf
->backend
.chan
;
2878 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
2879 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
2882 if (atomic_read(&chan
->record_disabled
))
2886 case LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN
:
2890 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
2893 return put_u64(ts
, arg
);
2895 case LTTNG_RING_BUFFER_GET_TIMESTAMP_END
:
2899 ret
= ops
->timestamp_end(config
, buf
, &ts
);
2902 return put_u64(ts
, arg
);
2904 case LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED
:
2908 ret
= ops
->events_discarded(config
, buf
, &ed
);
2911 return put_u64(ed
, arg
);
2913 case LTTNG_RING_BUFFER_GET_CONTENT_SIZE
:
2917 ret
= ops
->content_size(config
, buf
, &cs
);
2920 return put_u64(cs
, arg
);
2922 case LTTNG_RING_BUFFER_GET_PACKET_SIZE
:
2926 ret
= ops
->packet_size(config
, buf
, &ps
);
2929 return put_u64(ps
, arg
);
2931 case LTTNG_RING_BUFFER_GET_STREAM_ID
:
2935 ret
= ops
->stream_id(config
, buf
, &si
);
2938 return put_u64(si
, arg
);
2940 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
2944 ret
= ops
->current_timestamp(config
, buf
, &ts
);
2947 return put_u64(ts
, arg
);
2949 case LTTNG_RING_BUFFER_GET_SEQ_NUM
:
2953 ret
= ops
->sequence_number(config
, buf
, &seq
);
2956 return put_u64(seq
, arg
);
2958 case LTTNG_RING_BUFFER_INSTANCE_ID
:
2962 ret
= ops
->instance_id(config
, buf
, &id
);
2965 return put_u64(id
, arg
);
2968 return lib_ring_buffer_file_operations
.unlocked_ioctl(filp
,
2976 #ifdef CONFIG_COMPAT
2977 static long lttng_stream_ring_buffer_compat_ioctl(struct file
*filp
,
2978 unsigned int cmd
, unsigned long arg
)
2980 struct lib_ring_buffer
*buf
= filp
->private_data
;
2981 struct channel
*chan
= buf
->backend
.chan
;
2982 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
2983 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
2986 if (atomic_read(&chan
->record_disabled
))
2990 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN
:
2994 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
2997 return put_u64(ts
, arg
);
2999 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END
:
3003 ret
= ops
->timestamp_end(config
, buf
, &ts
);
3006 return put_u64(ts
, arg
);
3008 case LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED
:
3012 ret
= ops
->events_discarded(config
, buf
, &ed
);
3015 return put_u64(ed
, arg
);
3017 case LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE
:
3021 ret
= ops
->content_size(config
, buf
, &cs
);
3024 return put_u64(cs
, arg
);
3026 case LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE
:
3030 ret
= ops
->packet_size(config
, buf
, &ps
);
3033 return put_u64(ps
, arg
);
3035 case LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID
:
3039 ret
= ops
->stream_id(config
, buf
, &si
);
3042 return put_u64(si
, arg
);
3044 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
3048 ret
= ops
->current_timestamp(config
, buf
, &ts
);
3051 return put_u64(ts
, arg
);
3053 case LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM
:
3057 ret
= ops
->sequence_number(config
, buf
, &seq
);
3060 return put_u64(seq
, arg
);
3062 case LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID
:
3066 ret
= ops
->instance_id(config
, buf
, &id
);
3069 return put_u64(id
, arg
);
3072 return lib_ring_buffer_file_operations
.compat_ioctl(filp
,
3079 #endif /* CONFIG_COMPAT */
3081 static void lttng_stream_override_ring_buffer_fops(void)
3083 lttng_stream_ring_buffer_file_operations
.owner
= THIS_MODULE
;
3084 lttng_stream_ring_buffer_file_operations
.open
=
3085 lib_ring_buffer_file_operations
.open
;
3086 lttng_stream_ring_buffer_file_operations
.release
=
3087 lib_ring_buffer_file_operations
.release
;
3088 lttng_stream_ring_buffer_file_operations
.poll
=
3089 lib_ring_buffer_file_operations
.poll
;
3090 lttng_stream_ring_buffer_file_operations
.splice_read
=
3091 lib_ring_buffer_file_operations
.splice_read
;
3092 lttng_stream_ring_buffer_file_operations
.mmap
=
3093 lib_ring_buffer_file_operations
.mmap
;
3094 lttng_stream_ring_buffer_file_operations
.unlocked_ioctl
=
3095 lttng_stream_ring_buffer_ioctl
;
3096 lttng_stream_ring_buffer_file_operations
.llseek
=
3097 lib_ring_buffer_file_operations
.llseek
;
3098 #ifdef CONFIG_COMPAT
3099 lttng_stream_ring_buffer_file_operations
.compat_ioctl
=
3100 lttng_stream_ring_buffer_compat_ioctl
;
3104 int __init
lttng_abi_init(void)
3108 wrapper_vmalloc_sync_mappings();
3111 ret
= lttng_tp_mempool_init();
3116 lttng_proc_dentry
= proc_create_data("lttng", S_IRUSR
| S_IWUSR
, NULL
,
3117 <tng_proc_ops
, NULL
);
3119 if (!lttng_proc_dentry
) {
3120 printk(KERN_ERR
"LTTng: Error creating control file\n");
3124 lttng_stream_override_ring_buffer_fops();
3128 lttng_tp_mempool_destroy();
3129 lttng_clock_unref();
3133 /* No __exit annotation because used by init error path too. */
3134 void lttng_abi_exit(void)
3136 lttng_tp_mempool_destroy();
3137 lttng_clock_unref();
3138 if (lttng_proc_dentry
)
3139 remove_proc_entry("lttng", NULL
);