6 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * Mimic system calls for:
24 * - session creation, returns a file descriptor or failure.
25 * - channel creation, returns a file descriptor or failure.
26 * - Operates on a session file descriptor
27 * - Takes all channel options as parameters.
28 * - stream get, returns a file descriptor or failure.
29 * - Operates on a channel file descriptor.
30 * - stream notifier get, returns a file descriptor or failure.
31 * - Operates on a channel file descriptor.
32 * - event creation, returns a file descriptor or failure.
33 * - Operates on a channel file descriptor
34 * - Takes an event name as parameter
35 * - Takes an instrumentation source as parameter
36 * - e.g. tracepoints, dynamic_probes...
37 * - Takes instrumentation source specific arguments.
40 #include <linux/module.h>
41 #include <linux/proc_fs.h>
42 #include <linux/anon_inodes.h>
43 #include <linux/file.h>
44 #include <linux/uaccess.h>
45 #include <linux/slab.h>
46 #include <linux/err.h>
47 #include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */
48 #include "wrapper/ringbuffer/vfs.h"
49 #include "wrapper/ringbuffer/backend.h"
50 #include "wrapper/ringbuffer/frontend.h"
51 #include "wrapper/poll.h"
52 #include "wrapper/file.h"
53 #include "lttng-abi.h"
54 #include "lttng-abi-old.h"
55 #include "lttng-events.h"
56 #include "lttng-tracer.h"
57 #include "lib/ringbuffer/frontend_types.h"
60 * This is LTTng's own personal way to create a system call as an external
61 * module. We use ioctl() on /proc/lttng.
64 static struct proc_dir_entry
*lttng_proc_dentry
;
65 static const struct file_operations lttng_fops
;
66 static const struct file_operations lttng_session_fops
;
67 static const struct file_operations lttng_channel_fops
;
68 static const struct file_operations lttng_metadata_fops
;
69 static const struct file_operations lttng_event_fops
;
70 static struct file_operations lttng_stream_ring_buffer_file_operations
;
72 static int put_u64(uint64_t val
, unsigned long arg
);
75 * Teardown management: opened file descriptors keep a refcount on the module,
76 * so it can only exit when all file descriptors are closed.
80 int lttng_abi_create_session(void)
82 struct lttng_session
*session
;
83 struct file
*session_file
;
86 session
= lttng_session_create();
89 session_fd
= lttng_get_unused_fd();
94 session_file
= anon_inode_getfile("[lttng_session]",
97 if (IS_ERR(session_file
)) {
98 ret
= PTR_ERR(session_file
);
101 session
->file
= session_file
;
102 fd_install(session_fd
, session_file
);
106 put_unused_fd(session_fd
);
108 lttng_session_destroy(session
);
113 int lttng_abi_tracepoint_list(void)
115 struct file
*tracepoint_list_file
;
118 file_fd
= lttng_get_unused_fd();
124 tracepoint_list_file
= anon_inode_getfile("[lttng_tracepoint_list]",
125 <tng_tracepoint_list_fops
,
127 if (IS_ERR(tracepoint_list_file
)) {
128 ret
= PTR_ERR(tracepoint_list_file
);
131 ret
= lttng_tracepoint_list_fops
.open(NULL
, tracepoint_list_file
);
134 fd_install(file_fd
, tracepoint_list_file
);
138 fput(tracepoint_list_file
);
140 put_unused_fd(file_fd
);
145 #ifndef CONFIG_HAVE_SYSCALL_TRACEPOINTS
147 int lttng_abi_syscall_list(void)
153 int lttng_abi_syscall_list(void)
155 struct file
*syscall_list_file
;
158 file_fd
= lttng_get_unused_fd();
164 syscall_list_file
= anon_inode_getfile("[lttng_syscall_list]",
165 <tng_syscall_list_fops
,
167 if (IS_ERR(syscall_list_file
)) {
168 ret
= PTR_ERR(syscall_list_file
);
171 ret
= lttng_syscall_list_fops
.open(NULL
, syscall_list_file
);
174 fd_install(file_fd
, syscall_list_file
);
178 fput(syscall_list_file
);
180 put_unused_fd(file_fd
);
187 void lttng_abi_tracer_version(struct lttng_kernel_tracer_version
*v
)
189 v
->major
= LTTNG_MODULES_MAJOR_VERSION
;
190 v
->minor
= LTTNG_MODULES_MINOR_VERSION
;
191 v
->patchlevel
= LTTNG_MODULES_PATCHLEVEL_VERSION
;
195 void lttng_abi_tracer_abi_version(struct lttng_kernel_tracer_abi_version
*v
)
197 v
->major
= LTTNG_MODULES_ABI_MAJOR_VERSION
;
198 v
->minor
= LTTNG_MODULES_ABI_MINOR_VERSION
;
202 long lttng_abi_add_context(struct file
*file
,
203 struct lttng_kernel_context
*context_param
,
204 struct lttng_ctx
**ctx
, struct lttng_session
*session
)
207 if (session
->been_active
)
210 switch (context_param
->ctx
) {
211 case LTTNG_KERNEL_CONTEXT_PID
:
212 return lttng_add_pid_to_ctx(ctx
);
213 case LTTNG_KERNEL_CONTEXT_PRIO
:
214 return lttng_add_prio_to_ctx(ctx
);
215 case LTTNG_KERNEL_CONTEXT_NICE
:
216 return lttng_add_nice_to_ctx(ctx
);
217 case LTTNG_KERNEL_CONTEXT_VPID
:
218 return lttng_add_vpid_to_ctx(ctx
);
219 case LTTNG_KERNEL_CONTEXT_TID
:
220 return lttng_add_tid_to_ctx(ctx
);
221 case LTTNG_KERNEL_CONTEXT_VTID
:
222 return lttng_add_vtid_to_ctx(ctx
);
223 case LTTNG_KERNEL_CONTEXT_PPID
:
224 return lttng_add_ppid_to_ctx(ctx
);
225 case LTTNG_KERNEL_CONTEXT_VPPID
:
226 return lttng_add_vppid_to_ctx(ctx
);
227 case LTTNG_KERNEL_CONTEXT_PERF_COUNTER
:
228 context_param
->u
.perf_counter
.name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
229 return lttng_add_perf_counter_to_ctx(context_param
->u
.perf_counter
.type
,
230 context_param
->u
.perf_counter
.config
,
231 context_param
->u
.perf_counter
.name
,
233 case LTTNG_KERNEL_CONTEXT_PROCNAME
:
234 return lttng_add_procname_to_ctx(ctx
);
235 case LTTNG_KERNEL_CONTEXT_HOSTNAME
:
236 return lttng_add_hostname_to_ctx(ctx
);
237 case LTTNG_KERNEL_CONTEXT_CPU_ID
:
238 return lttng_add_cpu_id_to_ctx(ctx
);
239 case LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE
:
240 return lttng_add_interruptible_to_ctx(ctx
);
241 case LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE
:
242 return lttng_add_need_reschedule_to_ctx(ctx
);
243 case LTTNG_KERNEL_CONTEXT_PREEMPTIBLE
:
244 return lttng_add_preemptible_to_ctx(ctx
);
245 case LTTNG_KERNEL_CONTEXT_MIGRATABLE
:
246 return lttng_add_migratable_to_ctx(ctx
);
253 * lttng_ioctl - lttng syscall through ioctl
259 * This ioctl implements lttng commands:
260 * LTTNG_KERNEL_SESSION
261 * Returns a LTTng trace session file descriptor
262 * LTTNG_KERNEL_TRACER_VERSION
263 * Returns the LTTng kernel tracer version
264 * LTTNG_KERNEL_TRACEPOINT_LIST
265 * Returns a file descriptor listing available tracepoints
266 * LTTNG_KERNEL_WAIT_QUIESCENT
267 * Returns after all previously running probes have completed
268 * LTTNG_KERNEL_TRACER_ABI_VERSION
269 * Returns the LTTng kernel tracer ABI version
271 * The returned session will be deleted when its file descriptor is closed.
274 long lttng_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
277 case LTTNG_KERNEL_OLD_SESSION
:
278 case LTTNG_KERNEL_SESSION
:
279 return lttng_abi_create_session();
280 case LTTNG_KERNEL_OLD_TRACER_VERSION
:
282 struct lttng_kernel_tracer_version v
;
283 struct lttng_kernel_old_tracer_version oldv
;
284 struct lttng_kernel_old_tracer_version
*uversion
=
285 (struct lttng_kernel_old_tracer_version __user
*) arg
;
287 lttng_abi_tracer_version(&v
);
288 oldv
.major
= v
.major
;
289 oldv
.minor
= v
.minor
;
290 oldv
.patchlevel
= v
.patchlevel
;
292 if (copy_to_user(uversion
, &oldv
, sizeof(oldv
)))
296 case LTTNG_KERNEL_TRACER_VERSION
:
298 struct lttng_kernel_tracer_version version
;
299 struct lttng_kernel_tracer_version
*uversion
=
300 (struct lttng_kernel_tracer_version __user
*) arg
;
302 lttng_abi_tracer_version(&version
);
304 if (copy_to_user(uversion
, &version
, sizeof(version
)))
308 case LTTNG_KERNEL_TRACER_ABI_VERSION
:
310 struct lttng_kernel_tracer_abi_version version
;
311 struct lttng_kernel_tracer_abi_version
*uversion
=
312 (struct lttng_kernel_tracer_abi_version __user
*) arg
;
314 lttng_abi_tracer_abi_version(&version
);
316 if (copy_to_user(uversion
, &version
, sizeof(version
)))
320 case LTTNG_KERNEL_OLD_TRACEPOINT_LIST
:
321 case LTTNG_KERNEL_TRACEPOINT_LIST
:
322 return lttng_abi_tracepoint_list();
323 case LTTNG_KERNEL_SYSCALL_LIST
:
324 return lttng_abi_syscall_list();
325 case LTTNG_KERNEL_OLD_WAIT_QUIESCENT
:
326 case LTTNG_KERNEL_WAIT_QUIESCENT
:
329 case LTTNG_KERNEL_OLD_CALIBRATE
:
331 struct lttng_kernel_old_calibrate __user
*ucalibrate
=
332 (struct lttng_kernel_old_calibrate __user
*) arg
;
333 struct lttng_kernel_old_calibrate old_calibrate
;
334 struct lttng_kernel_calibrate calibrate
;
337 if (copy_from_user(&old_calibrate
, ucalibrate
, sizeof(old_calibrate
)))
339 calibrate
.type
= old_calibrate
.type
;
340 ret
= lttng_calibrate(&calibrate
);
341 if (copy_to_user(ucalibrate
, &old_calibrate
, sizeof(old_calibrate
)))
345 case LTTNG_KERNEL_CALIBRATE
:
347 struct lttng_kernel_calibrate __user
*ucalibrate
=
348 (struct lttng_kernel_calibrate __user
*) arg
;
349 struct lttng_kernel_calibrate calibrate
;
352 if (copy_from_user(&calibrate
, ucalibrate
, sizeof(calibrate
)))
354 ret
= lttng_calibrate(&calibrate
);
355 if (copy_to_user(ucalibrate
, &calibrate
, sizeof(calibrate
)))
364 static const struct file_operations lttng_fops
= {
365 .owner
= THIS_MODULE
,
366 .unlocked_ioctl
= lttng_ioctl
,
368 .compat_ioctl
= lttng_ioctl
,
373 int lttng_abi_create_channel(struct file
*session_file
,
374 struct lttng_kernel_channel
*chan_param
,
375 enum channel_type channel_type
)
377 struct lttng_session
*session
= session_file
->private_data
;
378 const struct file_operations
*fops
= NULL
;
379 const char *transport_name
;
380 struct lttng_channel
*chan
;
381 struct file
*chan_file
;
385 chan_fd
= lttng_get_unused_fd();
390 switch (channel_type
) {
391 case PER_CPU_CHANNEL
:
392 fops
= <tng_channel_fops
;
394 case METADATA_CHANNEL
:
395 fops
= <tng_metadata_fops
;
399 chan_file
= anon_inode_getfile("[lttng_channel]",
402 if (IS_ERR(chan_file
)) {
403 ret
= PTR_ERR(chan_file
);
406 switch (channel_type
) {
407 case PER_CPU_CHANNEL
:
408 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
) {
409 transport_name
= chan_param
->overwrite
?
410 "relay-overwrite" : "relay-discard";
411 } else if (chan_param
->output
== LTTNG_KERNEL_MMAP
) {
412 transport_name
= chan_param
->overwrite
?
413 "relay-overwrite-mmap" : "relay-discard-mmap";
418 case METADATA_CHANNEL
:
419 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
)
420 transport_name
= "relay-metadata";
421 else if (chan_param
->output
== LTTNG_KERNEL_MMAP
)
422 transport_name
= "relay-metadata-mmap";
427 transport_name
= "<unknown>";
431 * We tolerate no failure path after channel creation. It will stay
432 * invariant for the rest of the session.
434 chan
= lttng_channel_create(session
, transport_name
, NULL
,
435 chan_param
->subbuf_size
,
436 chan_param
->num_subbuf
,
437 chan_param
->switch_timer_interval
,
438 chan_param
->read_timer_interval
,
444 chan
->file
= chan_file
;
445 chan_file
->private_data
= chan
;
446 fd_install(chan_fd
, chan_file
);
447 atomic_long_inc(&session_file
->f_count
);
454 put_unused_fd(chan_fd
);
460 * lttng_session_ioctl - lttng session fd ioctl
466 * This ioctl implements lttng commands:
467 * LTTNG_KERNEL_CHANNEL
468 * Returns a LTTng channel file descriptor
469 * LTTNG_KERNEL_ENABLE
470 * Enables tracing for a session (weak enable)
471 * LTTNG_KERNEL_DISABLE
472 * Disables tracing for a session (strong disable)
473 * LTTNG_KERNEL_METADATA
474 * Returns a LTTng metadata file descriptor
475 * LTTNG_KERNEL_SESSION_TRACK_PID
476 * Add PID to session tracker
477 * LTTNG_KERNEL_SESSION_UNTRACK_PID
478 * Remove PID from session tracker
480 * The returned channel will be deleted when its file descriptor is closed.
483 long lttng_session_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
485 struct lttng_session
*session
= file
->private_data
;
488 case LTTNG_KERNEL_OLD_CHANNEL
:
490 struct lttng_kernel_channel chan_param
;
491 struct lttng_kernel_old_channel old_chan_param
;
493 if (copy_from_user(&old_chan_param
,
494 (struct lttng_kernel_old_channel __user
*) arg
,
495 sizeof(struct lttng_kernel_old_channel
)))
497 chan_param
.overwrite
= old_chan_param
.overwrite
;
498 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
499 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
500 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
501 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
502 chan_param
.output
= old_chan_param
.output
;
504 return lttng_abi_create_channel(file
, &chan_param
,
507 case LTTNG_KERNEL_CHANNEL
:
509 struct lttng_kernel_channel chan_param
;
511 if (copy_from_user(&chan_param
,
512 (struct lttng_kernel_channel __user
*) arg
,
513 sizeof(struct lttng_kernel_channel
)))
515 return lttng_abi_create_channel(file
, &chan_param
,
518 case LTTNG_KERNEL_OLD_SESSION_START
:
519 case LTTNG_KERNEL_OLD_ENABLE
:
520 case LTTNG_KERNEL_SESSION_START
:
521 case LTTNG_KERNEL_ENABLE
:
522 return lttng_session_enable(session
);
523 case LTTNG_KERNEL_OLD_SESSION_STOP
:
524 case LTTNG_KERNEL_OLD_DISABLE
:
525 case LTTNG_KERNEL_SESSION_STOP
:
526 case LTTNG_KERNEL_DISABLE
:
527 return lttng_session_disable(session
);
528 case LTTNG_KERNEL_OLD_METADATA
:
530 struct lttng_kernel_channel chan_param
;
531 struct lttng_kernel_old_channel old_chan_param
;
533 if (copy_from_user(&old_chan_param
,
534 (struct lttng_kernel_old_channel __user
*) arg
,
535 sizeof(struct lttng_kernel_old_channel
)))
537 chan_param
.overwrite
= old_chan_param
.overwrite
;
538 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
539 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
540 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
541 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
542 chan_param
.output
= old_chan_param
.output
;
544 return lttng_abi_create_channel(file
, &chan_param
,
547 case LTTNG_KERNEL_METADATA
:
549 struct lttng_kernel_channel chan_param
;
551 if (copy_from_user(&chan_param
,
552 (struct lttng_kernel_channel __user
*) arg
,
553 sizeof(struct lttng_kernel_channel
)))
555 return lttng_abi_create_channel(file
, &chan_param
,
558 case LTTNG_KERNEL_SESSION_TRACK_PID
:
559 return lttng_session_track_pid(session
, (int) arg
);
560 case LTTNG_KERNEL_SESSION_UNTRACK_PID
:
561 return lttng_session_untrack_pid(session
, (int) arg
);
562 case LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS
:
563 return lttng_session_list_tracker_pids(session
);
564 case LTTNG_KERNEL_SESSION_METADATA_REGEN
:
565 return lttng_session_metadata_regenerate(session
);
572 * Called when the last file reference is dropped.
574 * Big fat note: channels and events are invariant for the whole session after
575 * their creation. So this session destruction also destroys all channel and
576 * event structures specific to this session (they are not destroyed when their
577 * individual file is released).
580 int lttng_session_release(struct inode
*inode
, struct file
*file
)
582 struct lttng_session
*session
= file
->private_data
;
585 lttng_session_destroy(session
);
589 static const struct file_operations lttng_session_fops
= {
590 .owner
= THIS_MODULE
,
591 .release
= lttng_session_release
,
592 .unlocked_ioctl
= lttng_session_ioctl
,
594 .compat_ioctl
= lttng_session_ioctl
,
599 * lttng_metadata_ring_buffer_poll - LTTng ring buffer poll file operation
603 * Handles the poll operations for the metadata channels.
606 unsigned int lttng_metadata_ring_buffer_poll(struct file
*filp
,
609 struct lttng_metadata_stream
*stream
= filp
->private_data
;
610 struct lib_ring_buffer
*buf
= stream
->priv
;
612 unsigned int mask
= 0;
614 if (filp
->f_mode
& FMODE_READ
) {
615 poll_wait_set_exclusive(wait
);
616 poll_wait(filp
, &stream
->read_wait
, wait
);
618 finalized
= stream
->finalized
;
621 * lib_ring_buffer_is_finalized() contains a smp_rmb()
622 * ordering finalized load before offsets loads.
624 WARN_ON(atomic_long_read(&buf
->active_readers
) != 1);
629 mutex_lock(&stream
->metadata_cache
->lock
);
630 if (stream
->metadata_cache
->metadata_written
>
631 stream
->metadata_out
)
633 mutex_unlock(&stream
->metadata_cache
->lock
);
640 void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file
*filp
,
641 unsigned int cmd
, unsigned long arg
)
643 struct lttng_metadata_stream
*stream
= filp
->private_data
;
645 stream
->metadata_out
= stream
->metadata_in
;
649 long lttng_metadata_ring_buffer_ioctl(struct file
*filp
,
650 unsigned int cmd
, unsigned long arg
)
653 struct lttng_metadata_stream
*stream
= filp
->private_data
;
654 struct lib_ring_buffer
*buf
= stream
->priv
;
657 case RING_BUFFER_GET_NEXT_SUBBUF
:
659 struct lttng_metadata_stream
*stream
= filp
->private_data
;
660 struct lib_ring_buffer
*buf
= stream
->priv
;
661 struct channel
*chan
= buf
->backend
.chan
;
663 ret
= lttng_metadata_output_channel(stream
, chan
);
665 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
671 case RING_BUFFER_GET_SUBBUF
:
674 * Random access is not allowed for metadata channel.
678 case RING_BUFFER_FLUSH
:
680 struct lttng_metadata_stream
*stream
= filp
->private_data
;
681 struct lib_ring_buffer
*buf
= stream
->priv
;
682 struct channel
*chan
= buf
->backend
.chan
;
685 * Before doing the actual ring buffer flush, write up to one
686 * packet of metadata in the ring buffer.
688 ret
= lttng_metadata_output_channel(stream
, chan
);
693 case RING_BUFFER_GET_METADATA_VERSION
:
695 struct lttng_metadata_stream
*stream
= filp
->private_data
;
697 return put_u64(stream
->version
, arg
);
702 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
704 /* Performing lib ring buffer ioctl after our own. */
705 ret
= lib_ring_buffer_ioctl(filp
, cmd
, arg
, buf
);
710 case RING_BUFFER_PUT_NEXT_SUBBUF
:
712 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
725 long lttng_metadata_ring_buffer_compat_ioctl(struct file
*filp
,
726 unsigned int cmd
, unsigned long arg
)
729 struct lttng_metadata_stream
*stream
= filp
->private_data
;
730 struct lib_ring_buffer
*buf
= stream
->priv
;
733 case RING_BUFFER_GET_NEXT_SUBBUF
:
735 struct lttng_metadata_stream
*stream
= filp
->private_data
;
736 struct lib_ring_buffer
*buf
= stream
->priv
;
737 struct channel
*chan
= buf
->backend
.chan
;
739 ret
= lttng_metadata_output_channel(stream
, chan
);
741 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
747 case RING_BUFFER_GET_SUBBUF
:
750 * Random access is not allowed for metadata channel.
757 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
759 /* Performing lib ring buffer ioctl after our own. */
760 ret
= lib_ring_buffer_compat_ioctl(filp
, cmd
, arg
, buf
);
765 case RING_BUFFER_PUT_NEXT_SUBBUF
:
767 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
771 case RING_BUFFER_GET_METADATA_VERSION
:
773 struct lttng_metadata_stream
*stream
= filp
->private_data
;
775 return put_u64(stream
->version
, arg
);
786 * This is not used by anonymous file descriptors. This code is left
787 * there if we ever want to implement an inode with open() operation.
790 int lttng_metadata_ring_buffer_open(struct inode
*inode
, struct file
*file
)
792 struct lttng_metadata_stream
*stream
= inode
->i_private
;
793 struct lib_ring_buffer
*buf
= stream
->priv
;
795 file
->private_data
= buf
;
797 * Since life-time of metadata cache differs from that of
798 * session, we need to keep our own reference on the transport.
800 if (!try_module_get(stream
->transport
->owner
)) {
801 printk(KERN_WARNING
"LTT : Can't lock transport module.\n");
804 return lib_ring_buffer_open(inode
, file
, buf
);
808 int lttng_metadata_ring_buffer_release(struct inode
*inode
, struct file
*file
)
810 struct lttng_metadata_stream
*stream
= file
->private_data
;
811 struct lib_ring_buffer
*buf
= stream
->priv
;
813 kref_put(&stream
->metadata_cache
->refcount
, metadata_cache_destroy
);
814 module_put(stream
->transport
->owner
);
815 return lib_ring_buffer_release(inode
, file
, buf
);
819 ssize_t
lttng_metadata_ring_buffer_splice_read(struct file
*in
, loff_t
*ppos
,
820 struct pipe_inode_info
*pipe
, size_t len
,
823 struct lttng_metadata_stream
*stream
= in
->private_data
;
824 struct lib_ring_buffer
*buf
= stream
->priv
;
826 return lib_ring_buffer_splice_read(in
, ppos
, pipe
, len
,
831 int lttng_metadata_ring_buffer_mmap(struct file
*filp
,
832 struct vm_area_struct
*vma
)
834 struct lttng_metadata_stream
*stream
= filp
->private_data
;
835 struct lib_ring_buffer
*buf
= stream
->priv
;
837 return lib_ring_buffer_mmap(filp
, vma
, buf
);
841 const struct file_operations lttng_metadata_ring_buffer_file_operations
= {
842 .owner
= THIS_MODULE
,
843 .open
= lttng_metadata_ring_buffer_open
,
844 .release
= lttng_metadata_ring_buffer_release
,
845 .poll
= lttng_metadata_ring_buffer_poll
,
846 .splice_read
= lttng_metadata_ring_buffer_splice_read
,
847 .mmap
= lttng_metadata_ring_buffer_mmap
,
848 .unlocked_ioctl
= lttng_metadata_ring_buffer_ioctl
,
849 .llseek
= vfs_lib_ring_buffer_no_llseek
,
851 .compat_ioctl
= lttng_metadata_ring_buffer_compat_ioctl
,
856 int lttng_abi_create_stream_fd(struct file
*channel_file
, void *stream_priv
,
857 const struct file_operations
*fops
)
860 struct file
*stream_file
;
862 stream_fd
= lttng_get_unused_fd();
867 stream_file
= anon_inode_getfile("[lttng_stream]", fops
,
868 stream_priv
, O_RDWR
);
869 if (IS_ERR(stream_file
)) {
870 ret
= PTR_ERR(stream_file
);
874 * OPEN_FMODE, called within anon_inode_getfile/alloc_file, don't honor
875 * FMODE_LSEEK, FMODE_PREAD nor FMODE_PWRITE. We need to read from this
876 * file descriptor, so we set FMODE_PREAD here.
878 stream_file
->f_mode
|= FMODE_PREAD
;
879 fd_install(stream_fd
, stream_file
);
881 * The stream holds a reference to the channel within the generic ring
882 * buffer library, so no need to hold a refcount on the channel and
883 * session files here.
888 put_unused_fd(stream_fd
);
894 int lttng_abi_open_stream(struct file
*channel_file
)
896 struct lttng_channel
*channel
= channel_file
->private_data
;
897 struct lib_ring_buffer
*buf
;
901 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
906 ret
= lttng_abi_create_stream_fd(channel_file
, stream_priv
,
907 <tng_stream_ring_buffer_file_operations
);
914 channel
->ops
->buffer_read_close(buf
);
919 int lttng_abi_open_metadata_stream(struct file
*channel_file
)
921 struct lttng_channel
*channel
= channel_file
->private_data
;
922 struct lttng_session
*session
= channel
->session
;
923 struct lib_ring_buffer
*buf
;
925 struct lttng_metadata_stream
*metadata_stream
;
928 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
932 metadata_stream
= kzalloc(sizeof(struct lttng_metadata_stream
),
934 if (!metadata_stream
) {
938 metadata_stream
->metadata_cache
= session
->metadata_cache
;
939 init_waitqueue_head(&metadata_stream
->read_wait
);
940 metadata_stream
->priv
= buf
;
941 stream_priv
= metadata_stream
;
942 metadata_stream
->transport
= channel
->transport
;
945 * Since life-time of metadata cache differs from that of
946 * session, we need to keep our own reference on the transport.
948 if (!try_module_get(metadata_stream
->transport
->owner
)) {
949 printk(KERN_WARNING
"LTT : Can't lock transport module.\n");
954 ret
= lttng_abi_create_stream_fd(channel_file
, stream_priv
,
955 <tng_metadata_ring_buffer_file_operations
);
959 kref_get(&session
->metadata_cache
->refcount
);
960 list_add(&metadata_stream
->list
,
961 &session
->metadata_cache
->metadata_stream
);
965 module_put(metadata_stream
->transport
->owner
);
967 kfree(metadata_stream
);
969 channel
->ops
->buffer_read_close(buf
);
974 int lttng_abi_create_event(struct file
*channel_file
,
975 struct lttng_kernel_event
*event_param
)
977 struct lttng_channel
*channel
= channel_file
->private_data
;
979 struct file
*event_file
;
982 event_param
->name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
983 switch (event_param
->instrumentation
) {
984 case LTTNG_KERNEL_KRETPROBE
:
985 event_param
->u
.kretprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
987 case LTTNG_KERNEL_KPROBE
:
988 event_param
->u
.kprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
990 case LTTNG_KERNEL_FUNCTION
:
991 event_param
->u
.ftrace
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
996 event_fd
= lttng_get_unused_fd();
1001 event_file
= anon_inode_getfile("[lttng_event]",
1004 if (IS_ERR(event_file
)) {
1005 ret
= PTR_ERR(event_file
);
1008 if (event_param
->instrumentation
== LTTNG_KERNEL_TRACEPOINT
1009 || event_param
->instrumentation
== LTTNG_KERNEL_SYSCALL
) {
1010 struct lttng_enabler
*enabler
;
1012 if (event_param
->name
[strlen(event_param
->name
) - 1] == '*') {
1013 enabler
= lttng_enabler_create(LTTNG_ENABLER_WILDCARD
,
1014 event_param
, channel
);
1016 enabler
= lttng_enabler_create(LTTNG_ENABLER_NAME
,
1017 event_param
, channel
);
1021 struct lttng_event
*event
;
1024 * We tolerate no failure path after event creation. It
1025 * will stay invariant for the rest of the session.
1027 event
= lttng_event_create(channel
, event_param
,
1029 event_param
->instrumentation
);
1030 WARN_ON_ONCE(!event
);
1031 if (IS_ERR(event
)) {
1032 ret
= PTR_ERR(event
);
1037 event_file
->private_data
= priv
;
1038 fd_install(event_fd
, event_file
);
1039 /* The event holds a reference on the channel */
1040 atomic_long_inc(&channel_file
->f_count
);
1046 put_unused_fd(event_fd
);
1052 * lttng_channel_ioctl - lttng syscall through ioctl
1058 * This ioctl implements lttng commands:
1059 * LTTNG_KERNEL_STREAM
1060 * Returns an event stream file descriptor or failure.
1061 * (typically, one event stream records events from one CPU)
1062 * LTTNG_KERNEL_EVENT
1063 * Returns an event file descriptor or failure.
1064 * LTTNG_KERNEL_CONTEXT
1065 * Prepend a context field to each event in the channel
1066 * LTTNG_KERNEL_ENABLE
1067 * Enable recording for events in this channel (weak enable)
1068 * LTTNG_KERNEL_DISABLE
1069 * Disable recording for events in this channel (strong disable)
1071 * Channel and event file descriptors also hold a reference on the session.
1074 long lttng_channel_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1076 struct lttng_channel
*channel
= file
->private_data
;
1079 case LTTNG_KERNEL_OLD_STREAM
:
1080 case LTTNG_KERNEL_STREAM
:
1081 return lttng_abi_open_stream(file
);
1082 case LTTNG_KERNEL_OLD_EVENT
:
1084 struct lttng_kernel_event
*uevent_param
;
1085 struct lttng_kernel_old_event
*old_uevent_param
;
1088 uevent_param
= kmalloc(sizeof(struct lttng_kernel_event
),
1090 if (!uevent_param
) {
1094 old_uevent_param
= kmalloc(
1095 sizeof(struct lttng_kernel_old_event
),
1097 if (!old_uevent_param
) {
1099 goto old_event_error_free_param
;
1101 if (copy_from_user(old_uevent_param
,
1102 (struct lttng_kernel_old_event __user
*) arg
,
1103 sizeof(struct lttng_kernel_old_event
))) {
1105 goto old_event_error_free_old_param
;
1108 memcpy(uevent_param
->name
, old_uevent_param
->name
,
1109 sizeof(uevent_param
->name
));
1110 uevent_param
->instrumentation
=
1111 old_uevent_param
->instrumentation
;
1113 switch (old_uevent_param
->instrumentation
) {
1114 case LTTNG_KERNEL_KPROBE
:
1115 uevent_param
->u
.kprobe
.addr
=
1116 old_uevent_param
->u
.kprobe
.addr
;
1117 uevent_param
->u
.kprobe
.offset
=
1118 old_uevent_param
->u
.kprobe
.offset
;
1119 memcpy(uevent_param
->u
.kprobe
.symbol_name
,
1120 old_uevent_param
->u
.kprobe
.symbol_name
,
1121 sizeof(uevent_param
->u
.kprobe
.symbol_name
));
1123 case LTTNG_KERNEL_KRETPROBE
:
1124 uevent_param
->u
.kretprobe
.addr
=
1125 old_uevent_param
->u
.kretprobe
.addr
;
1126 uevent_param
->u
.kretprobe
.offset
=
1127 old_uevent_param
->u
.kretprobe
.offset
;
1128 memcpy(uevent_param
->u
.kretprobe
.symbol_name
,
1129 old_uevent_param
->u
.kretprobe
.symbol_name
,
1130 sizeof(uevent_param
->u
.kretprobe
.symbol_name
));
1132 case LTTNG_KERNEL_FUNCTION
:
1133 memcpy(uevent_param
->u
.ftrace
.symbol_name
,
1134 old_uevent_param
->u
.ftrace
.symbol_name
,
1135 sizeof(uevent_param
->u
.ftrace
.symbol_name
));
1140 ret
= lttng_abi_create_event(file
, uevent_param
);
1142 old_event_error_free_old_param
:
1143 kfree(old_uevent_param
);
1144 old_event_error_free_param
:
1145 kfree(uevent_param
);
1149 case LTTNG_KERNEL_EVENT
:
1151 struct lttng_kernel_event uevent_param
;
1153 if (copy_from_user(&uevent_param
,
1154 (struct lttng_kernel_event __user
*) arg
,
1155 sizeof(uevent_param
)))
1157 return lttng_abi_create_event(file
, &uevent_param
);
1159 case LTTNG_KERNEL_OLD_CONTEXT
:
1161 struct lttng_kernel_context
*ucontext_param
;
1162 struct lttng_kernel_old_context
*old_ucontext_param
;
1165 ucontext_param
= kmalloc(sizeof(struct lttng_kernel_context
),
1167 if (!ucontext_param
) {
1171 old_ucontext_param
= kmalloc(sizeof(struct lttng_kernel_old_context
),
1173 if (!old_ucontext_param
) {
1175 goto old_ctx_error_free_param
;
1178 if (copy_from_user(old_ucontext_param
,
1179 (struct lttng_kernel_old_context __user
*) arg
,
1180 sizeof(struct lttng_kernel_old_context
))) {
1182 goto old_ctx_error_free_old_param
;
1184 ucontext_param
->ctx
= old_ucontext_param
->ctx
;
1185 memcpy(ucontext_param
->padding
, old_ucontext_param
->padding
,
1186 sizeof(ucontext_param
->padding
));
1187 /* only type that uses the union */
1188 if (old_ucontext_param
->ctx
== LTTNG_KERNEL_CONTEXT_PERF_COUNTER
) {
1189 ucontext_param
->u
.perf_counter
.type
=
1190 old_ucontext_param
->u
.perf_counter
.type
;
1191 ucontext_param
->u
.perf_counter
.config
=
1192 old_ucontext_param
->u
.perf_counter
.config
;
1193 memcpy(ucontext_param
->u
.perf_counter
.name
,
1194 old_ucontext_param
->u
.perf_counter
.name
,
1195 sizeof(ucontext_param
->u
.perf_counter
.name
));
1198 ret
= lttng_abi_add_context(file
,
1200 &channel
->ctx
, channel
->session
);
1202 old_ctx_error_free_old_param
:
1203 kfree(old_ucontext_param
);
1204 old_ctx_error_free_param
:
1205 kfree(ucontext_param
);
1209 case LTTNG_KERNEL_CONTEXT
:
1211 struct lttng_kernel_context ucontext_param
;
1213 if (copy_from_user(&ucontext_param
,
1214 (struct lttng_kernel_context __user
*) arg
,
1215 sizeof(ucontext_param
)))
1217 return lttng_abi_add_context(file
,
1219 &channel
->ctx
, channel
->session
);
1221 case LTTNG_KERNEL_OLD_ENABLE
:
1222 case LTTNG_KERNEL_ENABLE
:
1223 return lttng_channel_enable(channel
);
1224 case LTTNG_KERNEL_OLD_DISABLE
:
1225 case LTTNG_KERNEL_DISABLE
:
1226 return lttng_channel_disable(channel
);
1227 case LTTNG_KERNEL_SYSCALL_MASK
:
1228 return lttng_channel_syscall_mask(channel
,
1229 (struct lttng_kernel_syscall_mask __user
*) arg
);
1231 return -ENOIOCTLCMD
;
1237 * lttng_metadata_ioctl - lttng syscall through ioctl
1243 * This ioctl implements lttng commands:
1244 * LTTNG_KERNEL_STREAM
1245 * Returns an event stream file descriptor or failure.
1247 * Channel and event file descriptors also hold a reference on the session.
1250 long lttng_metadata_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1253 case LTTNG_KERNEL_OLD_STREAM
:
1254 case LTTNG_KERNEL_STREAM
:
1255 return lttng_abi_open_metadata_stream(file
);
1257 return -ENOIOCTLCMD
;
1262 * lttng_channel_poll - lttng stream addition/removal monitoring
1267 unsigned int lttng_channel_poll(struct file
*file
, poll_table
*wait
)
1269 struct lttng_channel
*channel
= file
->private_data
;
1270 unsigned int mask
= 0;
1272 if (file
->f_mode
& FMODE_READ
) {
1273 poll_wait_set_exclusive(wait
);
1274 poll_wait(file
, channel
->ops
->get_hp_wait_queue(channel
->chan
),
1277 if (channel
->ops
->is_disabled(channel
->chan
))
1279 if (channel
->ops
->is_finalized(channel
->chan
))
1281 if (channel
->ops
->buffer_has_read_closed_stream(channel
->chan
))
1282 return POLLIN
| POLLRDNORM
;
1290 int lttng_channel_release(struct inode
*inode
, struct file
*file
)
1292 struct lttng_channel
*channel
= file
->private_data
;
1295 fput(channel
->session
->file
);
1300 int lttng_metadata_channel_release(struct inode
*inode
, struct file
*file
)
1302 struct lttng_channel
*channel
= file
->private_data
;
1305 fput(channel
->session
->file
);
1306 lttng_metadata_channel_destroy(channel
);
1312 static const struct file_operations lttng_channel_fops
= {
1313 .owner
= THIS_MODULE
,
1314 .release
= lttng_channel_release
,
1315 .poll
= lttng_channel_poll
,
1316 .unlocked_ioctl
= lttng_channel_ioctl
,
1317 #ifdef CONFIG_COMPAT
1318 .compat_ioctl
= lttng_channel_ioctl
,
1322 static const struct file_operations lttng_metadata_fops
= {
1323 .owner
= THIS_MODULE
,
1324 .release
= lttng_metadata_channel_release
,
1325 .unlocked_ioctl
= lttng_metadata_ioctl
,
1326 #ifdef CONFIG_COMPAT
1327 .compat_ioctl
= lttng_metadata_ioctl
,
1332 * lttng_event_ioctl - lttng syscall through ioctl
1338 * This ioctl implements lttng commands:
1339 * LTTNG_KERNEL_CONTEXT
1340 * Prepend a context field to each record of this event
1341 * LTTNG_KERNEL_ENABLE
1342 * Enable recording for this event (weak enable)
1343 * LTTNG_KERNEL_DISABLE
1344 * Disable recording for this event (strong disable)
1347 long lttng_event_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1349 struct lttng_event
*event
;
1350 struct lttng_enabler
*enabler
;
1351 enum lttng_event_type
*evtype
= file
->private_data
;
1354 case LTTNG_KERNEL_OLD_CONTEXT
:
1356 /* Not implemented */
1359 case LTTNG_KERNEL_CONTEXT
:
1361 /* Not implemented */
1364 case LTTNG_KERNEL_OLD_ENABLE
:
1365 case LTTNG_KERNEL_ENABLE
:
1367 case LTTNG_TYPE_EVENT
:
1368 event
= file
->private_data
;
1369 return lttng_event_enable(event
);
1370 case LTTNG_TYPE_ENABLER
:
1371 enabler
= file
->private_data
;
1372 return lttng_enabler_enable(enabler
);
1377 case LTTNG_KERNEL_OLD_DISABLE
:
1378 case LTTNG_KERNEL_DISABLE
:
1380 case LTTNG_TYPE_EVENT
:
1381 event
= file
->private_data
;
1382 return lttng_event_disable(event
);
1383 case LTTNG_TYPE_ENABLER
:
1384 enabler
= file
->private_data
;
1385 return lttng_enabler_disable(enabler
);
1390 case LTTNG_KERNEL_FILTER
:
1392 case LTTNG_TYPE_EVENT
:
1394 case LTTNG_TYPE_ENABLER
:
1396 enabler
= file
->private_data
;
1397 return lttng_enabler_attach_bytecode(enabler
,
1398 (struct lttng_kernel_filter_bytecode __user
*) arg
);
1403 return -ENOIOCTLCMD
;
1408 int lttng_event_release(struct inode
*inode
, struct file
*file
)
1410 struct lttng_event
*event
;
1411 struct lttng_enabler
*enabler
;
1412 enum lttng_event_type
*evtype
= file
->private_data
;
1418 case LTTNG_TYPE_EVENT
:
1419 event
= file
->private_data
;
1421 fput(event
->chan
->file
);
1423 case LTTNG_TYPE_ENABLER
:
1424 enabler
= file
->private_data
;
1426 fput(enabler
->chan
->file
);
1436 /* TODO: filter control ioctl */
1437 static const struct file_operations lttng_event_fops
= {
1438 .owner
= THIS_MODULE
,
1439 .release
= lttng_event_release
,
1440 .unlocked_ioctl
= lttng_event_ioctl
,
1441 #ifdef CONFIG_COMPAT
1442 .compat_ioctl
= lttng_event_ioctl
,
1446 static int put_u64(uint64_t val
, unsigned long arg
)
1448 return put_user(val
, (uint64_t __user
*) arg
);
1451 static long lttng_stream_ring_buffer_ioctl(struct file
*filp
,
1452 unsigned int cmd
, unsigned long arg
)
1454 struct lib_ring_buffer
*buf
= filp
->private_data
;
1455 struct channel
*chan
= buf
->backend
.chan
;
1456 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
1457 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
1460 if (atomic_read(&chan
->record_disabled
))
1464 case LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN
:
1468 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
1471 return put_u64(ts
, arg
);
1473 case LTTNG_RING_BUFFER_GET_TIMESTAMP_END
:
1477 ret
= ops
->timestamp_end(config
, buf
, &ts
);
1480 return put_u64(ts
, arg
);
1482 case LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED
:
1486 ret
= ops
->events_discarded(config
, buf
, &ed
);
1489 return put_u64(ed
, arg
);
1491 case LTTNG_RING_BUFFER_GET_CONTENT_SIZE
:
1495 ret
= ops
->content_size(config
, buf
, &cs
);
1498 return put_u64(cs
, arg
);
1500 case LTTNG_RING_BUFFER_GET_PACKET_SIZE
:
1504 ret
= ops
->packet_size(config
, buf
, &ps
);
1507 return put_u64(ps
, arg
);
1509 case LTTNG_RING_BUFFER_GET_STREAM_ID
:
1513 ret
= ops
->stream_id(config
, buf
, &si
);
1516 return put_u64(si
, arg
);
1518 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
1522 ret
= ops
->current_timestamp(config
, buf
, &ts
);
1525 return put_u64(ts
, arg
);
1527 case LTTNG_RING_BUFFER_GET_SEQ_NUM
:
1531 ret
= ops
->sequence_number(config
, buf
, &seq
);
1534 return put_u64(seq
, arg
);
1536 case LTTNG_RING_BUFFER_INSTANCE_ID
:
1540 ret
= ops
->instance_id(config
, buf
, &id
);
1543 return put_u64(id
, arg
);
1546 return lib_ring_buffer_file_operations
.unlocked_ioctl(filp
,
1554 #ifdef CONFIG_COMPAT
1555 static long lttng_stream_ring_buffer_compat_ioctl(struct file
*filp
,
1556 unsigned int cmd
, unsigned long arg
)
1558 struct lib_ring_buffer
*buf
= filp
->private_data
;
1559 struct channel
*chan
= buf
->backend
.chan
;
1560 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
1561 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
1564 if (atomic_read(&chan
->record_disabled
))
1568 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN
:
1572 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
1575 return put_u64(ts
, arg
);
1577 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END
:
1581 ret
= ops
->timestamp_end(config
, buf
, &ts
);
1584 return put_u64(ts
, arg
);
1586 case LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED
:
1590 ret
= ops
->events_discarded(config
, buf
, &ed
);
1593 return put_u64(ed
, arg
);
1595 case LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE
:
1599 ret
= ops
->content_size(config
, buf
, &cs
);
1602 return put_u64(cs
, arg
);
1604 case LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE
:
1608 ret
= ops
->packet_size(config
, buf
, &ps
);
1611 return put_u64(ps
, arg
);
1613 case LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID
:
1617 ret
= ops
->stream_id(config
, buf
, &si
);
1620 return put_u64(si
, arg
);
1622 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
1626 ret
= ops
->current_timestamp(config
, buf
, &ts
);
1629 return put_u64(ts
, arg
);
1631 case LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM
:
1635 ret
= ops
->sequence_number(config
, buf
, &seq
);
1638 return put_u64(seq
, arg
);
1640 case LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID
:
1644 ret
= ops
->instance_id(config
, buf
, &id
);
1647 return put_u64(id
, arg
);
1650 return lib_ring_buffer_file_operations
.compat_ioctl(filp
,
1657 #endif /* CONFIG_COMPAT */
1659 static void lttng_stream_override_ring_buffer_fops(void)
1661 lttng_stream_ring_buffer_file_operations
.owner
= THIS_MODULE
;
1662 lttng_stream_ring_buffer_file_operations
.open
=
1663 lib_ring_buffer_file_operations
.open
;
1664 lttng_stream_ring_buffer_file_operations
.release
=
1665 lib_ring_buffer_file_operations
.release
;
1666 lttng_stream_ring_buffer_file_operations
.poll
=
1667 lib_ring_buffer_file_operations
.poll
;
1668 lttng_stream_ring_buffer_file_operations
.splice_read
=
1669 lib_ring_buffer_file_operations
.splice_read
;
1670 lttng_stream_ring_buffer_file_operations
.mmap
=
1671 lib_ring_buffer_file_operations
.mmap
;
1672 lttng_stream_ring_buffer_file_operations
.unlocked_ioctl
=
1673 lttng_stream_ring_buffer_ioctl
;
1674 lttng_stream_ring_buffer_file_operations
.llseek
=
1675 lib_ring_buffer_file_operations
.llseek
;
1676 #ifdef CONFIG_COMPAT
1677 lttng_stream_ring_buffer_file_operations
.compat_ioctl
=
1678 lttng_stream_ring_buffer_compat_ioctl
;
1682 int __init
lttng_abi_init(void)
1686 wrapper_vmalloc_sync_all();
1688 lttng_proc_dentry
= proc_create_data("lttng", S_IRUSR
| S_IWUSR
, NULL
,
1691 if (!lttng_proc_dentry
) {
1692 printk(KERN_ERR
"Error creating LTTng control file\n");
1696 lttng_stream_override_ring_buffer_fops();
1700 lttng_clock_unref();
1704 /* No __exit annotation because used by init error path too. */
1705 void lttng_abi_exit(void)
1707 lttng_clock_unref();
1708 if (lttng_proc_dentry
)
1709 remove_proc_entry("lttng", NULL
);