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
);
245 * lttng_ioctl - lttng syscall through ioctl
251 * This ioctl implements lttng commands:
252 * LTTNG_KERNEL_SESSION
253 * Returns a LTTng trace session file descriptor
254 * LTTNG_KERNEL_TRACER_VERSION
255 * Returns the LTTng kernel tracer version
256 * LTTNG_KERNEL_TRACEPOINT_LIST
257 * Returns a file descriptor listing available tracepoints
258 * LTTNG_KERNEL_WAIT_QUIESCENT
259 * Returns after all previously running probes have completed
260 * LTTNG_KERNEL_TRACER_ABI_VERSION
261 * Returns the LTTng kernel tracer ABI version
263 * The returned session will be deleted when its file descriptor is closed.
266 long lttng_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
269 case LTTNG_KERNEL_OLD_SESSION
:
270 case LTTNG_KERNEL_SESSION
:
271 return lttng_abi_create_session();
272 case LTTNG_KERNEL_OLD_TRACER_VERSION
:
274 struct lttng_kernel_tracer_version v
;
275 struct lttng_kernel_old_tracer_version oldv
;
276 struct lttng_kernel_old_tracer_version
*uversion
=
277 (struct lttng_kernel_old_tracer_version __user
*) arg
;
279 lttng_abi_tracer_version(&v
);
280 oldv
.major
= v
.major
;
281 oldv
.minor
= v
.minor
;
282 oldv
.patchlevel
= v
.patchlevel
;
284 if (copy_to_user(uversion
, &oldv
, sizeof(oldv
)))
288 case LTTNG_KERNEL_TRACER_VERSION
:
290 struct lttng_kernel_tracer_version version
;
291 struct lttng_kernel_tracer_version
*uversion
=
292 (struct lttng_kernel_tracer_version __user
*) arg
;
294 lttng_abi_tracer_version(&version
);
296 if (copy_to_user(uversion
, &version
, sizeof(version
)))
300 case LTTNG_KERNEL_TRACER_ABI_VERSION
:
302 struct lttng_kernel_tracer_abi_version version
;
303 struct lttng_kernel_tracer_abi_version
*uversion
=
304 (struct lttng_kernel_tracer_abi_version __user
*) arg
;
306 lttng_abi_tracer_abi_version(&version
);
308 if (copy_to_user(uversion
, &version
, sizeof(version
)))
312 case LTTNG_KERNEL_OLD_TRACEPOINT_LIST
:
313 case LTTNG_KERNEL_TRACEPOINT_LIST
:
314 return lttng_abi_tracepoint_list();
315 case LTTNG_KERNEL_SYSCALL_LIST
:
316 return lttng_abi_syscall_list();
317 case LTTNG_KERNEL_OLD_WAIT_QUIESCENT
:
318 case LTTNG_KERNEL_WAIT_QUIESCENT
:
321 case LTTNG_KERNEL_OLD_CALIBRATE
:
323 struct lttng_kernel_old_calibrate __user
*ucalibrate
=
324 (struct lttng_kernel_old_calibrate __user
*) arg
;
325 struct lttng_kernel_old_calibrate old_calibrate
;
326 struct lttng_kernel_calibrate calibrate
;
329 if (copy_from_user(&old_calibrate
, ucalibrate
, sizeof(old_calibrate
)))
331 calibrate
.type
= old_calibrate
.type
;
332 ret
= lttng_calibrate(&calibrate
);
333 if (copy_to_user(ucalibrate
, &old_calibrate
, sizeof(old_calibrate
)))
337 case LTTNG_KERNEL_CALIBRATE
:
339 struct lttng_kernel_calibrate __user
*ucalibrate
=
340 (struct lttng_kernel_calibrate __user
*) arg
;
341 struct lttng_kernel_calibrate calibrate
;
344 if (copy_from_user(&calibrate
, ucalibrate
, sizeof(calibrate
)))
346 ret
= lttng_calibrate(&calibrate
);
347 if (copy_to_user(ucalibrate
, &calibrate
, sizeof(calibrate
)))
356 static const struct file_operations lttng_fops
= {
357 .owner
= THIS_MODULE
,
358 .unlocked_ioctl
= lttng_ioctl
,
360 .compat_ioctl
= lttng_ioctl
,
365 int lttng_abi_create_channel(struct file
*session_file
,
366 struct lttng_kernel_channel
*chan_param
,
367 enum channel_type channel_type
)
369 struct lttng_session
*session
= session_file
->private_data
;
370 const struct file_operations
*fops
= NULL
;
371 const char *transport_name
;
372 struct lttng_channel
*chan
;
373 struct file
*chan_file
;
377 chan_fd
= lttng_get_unused_fd();
382 switch (channel_type
) {
383 case PER_CPU_CHANNEL
:
384 fops
= <tng_channel_fops
;
386 case METADATA_CHANNEL
:
387 fops
= <tng_metadata_fops
;
391 chan_file
= anon_inode_getfile("[lttng_channel]",
394 if (IS_ERR(chan_file
)) {
395 ret
= PTR_ERR(chan_file
);
398 switch (channel_type
) {
399 case PER_CPU_CHANNEL
:
400 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
) {
401 transport_name
= chan_param
->overwrite
?
402 "relay-overwrite" : "relay-discard";
403 } else if (chan_param
->output
== LTTNG_KERNEL_MMAP
) {
404 transport_name
= chan_param
->overwrite
?
405 "relay-overwrite-mmap" : "relay-discard-mmap";
410 case METADATA_CHANNEL
:
411 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
)
412 transport_name
= "relay-metadata";
413 else if (chan_param
->output
== LTTNG_KERNEL_MMAP
)
414 transport_name
= "relay-metadata-mmap";
419 transport_name
= "<unknown>";
423 * We tolerate no failure path after channel creation. It will stay
424 * invariant for the rest of the session.
426 chan
= lttng_channel_create(session
, transport_name
, NULL
,
427 chan_param
->subbuf_size
,
428 chan_param
->num_subbuf
,
429 chan_param
->switch_timer_interval
,
430 chan_param
->read_timer_interval
,
436 chan
->file
= chan_file
;
437 chan_file
->private_data
= chan
;
438 fd_install(chan_fd
, chan_file
);
439 atomic_long_inc(&session_file
->f_count
);
446 put_unused_fd(chan_fd
);
452 * lttng_session_ioctl - lttng session fd ioctl
458 * This ioctl implements lttng commands:
459 * LTTNG_KERNEL_CHANNEL
460 * Returns a LTTng channel file descriptor
461 * LTTNG_KERNEL_ENABLE
462 * Enables tracing for a session (weak enable)
463 * LTTNG_KERNEL_DISABLE
464 * Disables tracing for a session (strong disable)
465 * LTTNG_KERNEL_METADATA
466 * Returns a LTTng metadata file descriptor
467 * LTTNG_KERNEL_SESSION_TRACK_PID
468 * Add PID to session tracker
469 * LTTNG_KERNEL_SESSION_UNTRACK_PID
470 * Remove PID from session tracker
472 * The returned channel will be deleted when its file descriptor is closed.
475 long lttng_session_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
477 struct lttng_session
*session
= file
->private_data
;
480 case LTTNG_KERNEL_OLD_CHANNEL
:
482 struct lttng_kernel_channel chan_param
;
483 struct lttng_kernel_old_channel old_chan_param
;
485 if (copy_from_user(&old_chan_param
,
486 (struct lttng_kernel_old_channel __user
*) arg
,
487 sizeof(struct lttng_kernel_old_channel
)))
489 chan_param
.overwrite
= old_chan_param
.overwrite
;
490 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
491 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
492 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
493 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
494 chan_param
.output
= old_chan_param
.output
;
496 return lttng_abi_create_channel(file
, &chan_param
,
499 case LTTNG_KERNEL_CHANNEL
:
501 struct lttng_kernel_channel chan_param
;
503 if (copy_from_user(&chan_param
,
504 (struct lttng_kernel_channel __user
*) arg
,
505 sizeof(struct lttng_kernel_channel
)))
507 return lttng_abi_create_channel(file
, &chan_param
,
510 case LTTNG_KERNEL_OLD_SESSION_START
:
511 case LTTNG_KERNEL_OLD_ENABLE
:
512 case LTTNG_KERNEL_SESSION_START
:
513 case LTTNG_KERNEL_ENABLE
:
514 return lttng_session_enable(session
);
515 case LTTNG_KERNEL_OLD_SESSION_STOP
:
516 case LTTNG_KERNEL_OLD_DISABLE
:
517 case LTTNG_KERNEL_SESSION_STOP
:
518 case LTTNG_KERNEL_DISABLE
:
519 return lttng_session_disable(session
);
520 case LTTNG_KERNEL_OLD_METADATA
:
522 struct lttng_kernel_channel chan_param
;
523 struct lttng_kernel_old_channel old_chan_param
;
525 if (copy_from_user(&old_chan_param
,
526 (struct lttng_kernel_old_channel __user
*) arg
,
527 sizeof(struct lttng_kernel_old_channel
)))
529 chan_param
.overwrite
= old_chan_param
.overwrite
;
530 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
531 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
532 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
533 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
534 chan_param
.output
= old_chan_param
.output
;
536 return lttng_abi_create_channel(file
, &chan_param
,
539 case LTTNG_KERNEL_METADATA
:
541 struct lttng_kernel_channel chan_param
;
543 if (copy_from_user(&chan_param
,
544 (struct lttng_kernel_channel __user
*) arg
,
545 sizeof(struct lttng_kernel_channel
)))
547 return lttng_abi_create_channel(file
, &chan_param
,
550 case LTTNG_KERNEL_SESSION_TRACK_PID
:
551 return lttng_session_track_pid(session
, (int) arg
);
552 case LTTNG_KERNEL_SESSION_UNTRACK_PID
:
553 return lttng_session_untrack_pid(session
, (int) arg
);
554 case LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS
:
555 return lttng_session_list_tracker_pids(session
);
556 case LTTNG_KERNEL_SESSION_METADATA_REGEN
:
557 return lttng_session_metadata_regenerate(session
);
564 * Called when the last file reference is dropped.
566 * Big fat note: channels and events are invariant for the whole session after
567 * their creation. So this session destruction also destroys all channel and
568 * event structures specific to this session (they are not destroyed when their
569 * individual file is released).
572 int lttng_session_release(struct inode
*inode
, struct file
*file
)
574 struct lttng_session
*session
= file
->private_data
;
577 lttng_session_destroy(session
);
581 static const struct file_operations lttng_session_fops
= {
582 .owner
= THIS_MODULE
,
583 .release
= lttng_session_release
,
584 .unlocked_ioctl
= lttng_session_ioctl
,
586 .compat_ioctl
= lttng_session_ioctl
,
591 * lttng_metadata_ring_buffer_poll - LTTng ring buffer poll file operation
595 * Handles the poll operations for the metadata channels.
598 unsigned int lttng_metadata_ring_buffer_poll(struct file
*filp
,
601 struct lttng_metadata_stream
*stream
= filp
->private_data
;
602 struct lib_ring_buffer
*buf
= stream
->priv
;
604 unsigned int mask
= 0;
606 if (filp
->f_mode
& FMODE_READ
) {
607 poll_wait_set_exclusive(wait
);
608 poll_wait(filp
, &stream
->read_wait
, wait
);
610 finalized
= stream
->finalized
;
613 * lib_ring_buffer_is_finalized() contains a smp_rmb()
614 * ordering finalized load before offsets loads.
616 WARN_ON(atomic_long_read(&buf
->active_readers
) != 1);
621 mutex_lock(&stream
->metadata_cache
->lock
);
622 if (stream
->metadata_cache
->metadata_written
>
623 stream
->metadata_out
)
625 mutex_unlock(&stream
->metadata_cache
->lock
);
632 void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file
*filp
,
633 unsigned int cmd
, unsigned long arg
)
635 struct lttng_metadata_stream
*stream
= filp
->private_data
;
637 stream
->metadata_out
= stream
->metadata_in
;
641 long lttng_metadata_ring_buffer_ioctl(struct file
*filp
,
642 unsigned int cmd
, unsigned long arg
)
645 struct lttng_metadata_stream
*stream
= filp
->private_data
;
646 struct lib_ring_buffer
*buf
= stream
->priv
;
649 case RING_BUFFER_GET_NEXT_SUBBUF
:
651 struct lttng_metadata_stream
*stream
= filp
->private_data
;
652 struct lib_ring_buffer
*buf
= stream
->priv
;
653 struct channel
*chan
= buf
->backend
.chan
;
655 ret
= lttng_metadata_output_channel(stream
, chan
);
657 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
663 case RING_BUFFER_GET_SUBBUF
:
666 * Random access is not allowed for metadata channel.
670 case RING_BUFFER_FLUSH
:
672 struct lttng_metadata_stream
*stream
= filp
->private_data
;
673 struct lib_ring_buffer
*buf
= stream
->priv
;
674 struct channel
*chan
= buf
->backend
.chan
;
677 * Before doing the actual ring buffer flush, write up to one
678 * packet of metadata in the ring buffer.
680 ret
= lttng_metadata_output_channel(stream
, chan
);
685 case RING_BUFFER_GET_METADATA_VERSION
:
687 struct lttng_metadata_stream
*stream
= filp
->private_data
;
689 return put_u64(stream
->version
, arg
);
694 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
696 /* Performing lib ring buffer ioctl after our own. */
697 ret
= lib_ring_buffer_ioctl(filp
, cmd
, arg
, buf
);
702 case RING_BUFFER_PUT_NEXT_SUBBUF
:
704 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
717 long lttng_metadata_ring_buffer_compat_ioctl(struct file
*filp
,
718 unsigned int cmd
, unsigned long arg
)
721 struct lttng_metadata_stream
*stream
= filp
->private_data
;
722 struct lib_ring_buffer
*buf
= stream
->priv
;
725 case RING_BUFFER_GET_NEXT_SUBBUF
:
727 struct lttng_metadata_stream
*stream
= filp
->private_data
;
728 struct lib_ring_buffer
*buf
= stream
->priv
;
729 struct channel
*chan
= buf
->backend
.chan
;
731 ret
= lttng_metadata_output_channel(stream
, chan
);
733 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
739 case RING_BUFFER_GET_SUBBUF
:
742 * Random access is not allowed for metadata channel.
749 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
751 /* Performing lib ring buffer ioctl after our own. */
752 ret
= lib_ring_buffer_compat_ioctl(filp
, cmd
, arg
, buf
);
757 case RING_BUFFER_PUT_NEXT_SUBBUF
:
759 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
763 case RING_BUFFER_GET_METADATA_VERSION
:
765 struct lttng_metadata_stream
*stream
= filp
->private_data
;
767 return put_u64(stream
->version
, arg
);
778 * This is not used by anonymous file descriptors. This code is left
779 * there if we ever want to implement an inode with open() operation.
782 int lttng_metadata_ring_buffer_open(struct inode
*inode
, struct file
*file
)
784 struct lttng_metadata_stream
*stream
= inode
->i_private
;
785 struct lib_ring_buffer
*buf
= stream
->priv
;
787 file
->private_data
= buf
;
789 * Since life-time of metadata cache differs from that of
790 * session, we need to keep our own reference on the transport.
792 if (!try_module_get(stream
->transport
->owner
)) {
793 printk(KERN_WARNING
"LTT : Can't lock transport module.\n");
796 return lib_ring_buffer_open(inode
, file
, buf
);
800 int lttng_metadata_ring_buffer_release(struct inode
*inode
, struct file
*file
)
802 struct lttng_metadata_stream
*stream
= file
->private_data
;
803 struct lib_ring_buffer
*buf
= stream
->priv
;
805 kref_put(&stream
->metadata_cache
->refcount
, metadata_cache_destroy
);
806 module_put(stream
->transport
->owner
);
807 return lib_ring_buffer_release(inode
, file
, buf
);
811 ssize_t
lttng_metadata_ring_buffer_splice_read(struct file
*in
, loff_t
*ppos
,
812 struct pipe_inode_info
*pipe
, size_t len
,
815 struct lttng_metadata_stream
*stream
= in
->private_data
;
816 struct lib_ring_buffer
*buf
= stream
->priv
;
818 return lib_ring_buffer_splice_read(in
, ppos
, pipe
, len
,
823 int lttng_metadata_ring_buffer_mmap(struct file
*filp
,
824 struct vm_area_struct
*vma
)
826 struct lttng_metadata_stream
*stream
= filp
->private_data
;
827 struct lib_ring_buffer
*buf
= stream
->priv
;
829 return lib_ring_buffer_mmap(filp
, vma
, buf
);
833 const struct file_operations lttng_metadata_ring_buffer_file_operations
= {
834 .owner
= THIS_MODULE
,
835 .open
= lttng_metadata_ring_buffer_open
,
836 .release
= lttng_metadata_ring_buffer_release
,
837 .poll
= lttng_metadata_ring_buffer_poll
,
838 .splice_read
= lttng_metadata_ring_buffer_splice_read
,
839 .mmap
= lttng_metadata_ring_buffer_mmap
,
840 .unlocked_ioctl
= lttng_metadata_ring_buffer_ioctl
,
841 .llseek
= vfs_lib_ring_buffer_no_llseek
,
843 .compat_ioctl
= lttng_metadata_ring_buffer_compat_ioctl
,
848 int lttng_abi_create_stream_fd(struct file
*channel_file
, void *stream_priv
,
849 const struct file_operations
*fops
)
852 struct file
*stream_file
;
854 stream_fd
= lttng_get_unused_fd();
859 stream_file
= anon_inode_getfile("[lttng_stream]", fops
,
860 stream_priv
, O_RDWR
);
861 if (IS_ERR(stream_file
)) {
862 ret
= PTR_ERR(stream_file
);
866 * OPEN_FMODE, called within anon_inode_getfile/alloc_file, don't honor
867 * FMODE_LSEEK, FMODE_PREAD nor FMODE_PWRITE. We need to read from this
868 * file descriptor, so we set FMODE_PREAD here.
870 stream_file
->f_mode
|= FMODE_PREAD
;
871 fd_install(stream_fd
, stream_file
);
873 * The stream holds a reference to the channel within the generic ring
874 * buffer library, so no need to hold a refcount on the channel and
875 * session files here.
880 put_unused_fd(stream_fd
);
886 int lttng_abi_open_stream(struct file
*channel_file
)
888 struct lttng_channel
*channel
= channel_file
->private_data
;
889 struct lib_ring_buffer
*buf
;
893 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
898 ret
= lttng_abi_create_stream_fd(channel_file
, stream_priv
,
899 <tng_stream_ring_buffer_file_operations
);
906 channel
->ops
->buffer_read_close(buf
);
911 int lttng_abi_open_metadata_stream(struct file
*channel_file
)
913 struct lttng_channel
*channel
= channel_file
->private_data
;
914 struct lttng_session
*session
= channel
->session
;
915 struct lib_ring_buffer
*buf
;
917 struct lttng_metadata_stream
*metadata_stream
;
920 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
924 metadata_stream
= kzalloc(sizeof(struct lttng_metadata_stream
),
926 if (!metadata_stream
) {
930 metadata_stream
->metadata_cache
= session
->metadata_cache
;
931 init_waitqueue_head(&metadata_stream
->read_wait
);
932 metadata_stream
->priv
= buf
;
933 stream_priv
= metadata_stream
;
934 metadata_stream
->transport
= channel
->transport
;
937 * Since life-time of metadata cache differs from that of
938 * session, we need to keep our own reference on the transport.
940 if (!try_module_get(metadata_stream
->transport
->owner
)) {
941 printk(KERN_WARNING
"LTT : Can't lock transport module.\n");
946 ret
= lttng_abi_create_stream_fd(channel_file
, stream_priv
,
947 <tng_metadata_ring_buffer_file_operations
);
951 kref_get(&session
->metadata_cache
->refcount
);
952 list_add(&metadata_stream
->list
,
953 &session
->metadata_cache
->metadata_stream
);
957 module_put(metadata_stream
->transport
->owner
);
959 kfree(metadata_stream
);
961 channel
->ops
->buffer_read_close(buf
);
966 int lttng_abi_create_event(struct file
*channel_file
,
967 struct lttng_kernel_event
*event_param
)
969 struct lttng_channel
*channel
= channel_file
->private_data
;
971 struct file
*event_file
;
974 event_param
->name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
975 switch (event_param
->instrumentation
) {
976 case LTTNG_KERNEL_KRETPROBE
:
977 event_param
->u
.kretprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
979 case LTTNG_KERNEL_KPROBE
:
980 event_param
->u
.kprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
982 case LTTNG_KERNEL_FUNCTION
:
983 event_param
->u
.ftrace
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
988 event_fd
= lttng_get_unused_fd();
993 event_file
= anon_inode_getfile("[lttng_event]",
996 if (IS_ERR(event_file
)) {
997 ret
= PTR_ERR(event_file
);
1000 if (event_param
->instrumentation
== LTTNG_KERNEL_TRACEPOINT
1001 || event_param
->instrumentation
== LTTNG_KERNEL_SYSCALL
) {
1002 struct lttng_enabler
*enabler
;
1004 if (event_param
->name
[strlen(event_param
->name
) - 1] == '*') {
1005 enabler
= lttng_enabler_create(LTTNG_ENABLER_WILDCARD
,
1006 event_param
, channel
);
1008 enabler
= lttng_enabler_create(LTTNG_ENABLER_NAME
,
1009 event_param
, channel
);
1013 struct lttng_event
*event
;
1016 * We tolerate no failure path after event creation. It
1017 * will stay invariant for the rest of the session.
1019 event
= lttng_event_create(channel
, event_param
,
1021 event_param
->instrumentation
);
1022 WARN_ON_ONCE(!event
);
1023 if (IS_ERR(event
)) {
1024 ret
= PTR_ERR(event
);
1029 event_file
->private_data
= priv
;
1030 fd_install(event_fd
, event_file
);
1031 /* The event holds a reference on the channel */
1032 atomic_long_inc(&channel_file
->f_count
);
1038 put_unused_fd(event_fd
);
1044 * lttng_channel_ioctl - lttng syscall through ioctl
1050 * This ioctl implements lttng commands:
1051 * LTTNG_KERNEL_STREAM
1052 * Returns an event stream file descriptor or failure.
1053 * (typically, one event stream records events from one CPU)
1054 * LTTNG_KERNEL_EVENT
1055 * Returns an event file descriptor or failure.
1056 * LTTNG_KERNEL_CONTEXT
1057 * Prepend a context field to each event in the channel
1058 * LTTNG_KERNEL_ENABLE
1059 * Enable recording for events in this channel (weak enable)
1060 * LTTNG_KERNEL_DISABLE
1061 * Disable recording for events in this channel (strong disable)
1063 * Channel and event file descriptors also hold a reference on the session.
1066 long lttng_channel_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1068 struct lttng_channel
*channel
= file
->private_data
;
1071 case LTTNG_KERNEL_OLD_STREAM
:
1072 case LTTNG_KERNEL_STREAM
:
1073 return lttng_abi_open_stream(file
);
1074 case LTTNG_KERNEL_OLD_EVENT
:
1076 struct lttng_kernel_event
*uevent_param
;
1077 struct lttng_kernel_old_event
*old_uevent_param
;
1080 uevent_param
= kmalloc(sizeof(struct lttng_kernel_event
),
1082 if (!uevent_param
) {
1086 old_uevent_param
= kmalloc(
1087 sizeof(struct lttng_kernel_old_event
),
1089 if (!old_uevent_param
) {
1091 goto old_event_error_free_param
;
1093 if (copy_from_user(old_uevent_param
,
1094 (struct lttng_kernel_old_event __user
*) arg
,
1095 sizeof(struct lttng_kernel_old_event
))) {
1097 goto old_event_error_free_old_param
;
1100 memcpy(uevent_param
->name
, old_uevent_param
->name
,
1101 sizeof(uevent_param
->name
));
1102 uevent_param
->instrumentation
=
1103 old_uevent_param
->instrumentation
;
1105 switch (old_uevent_param
->instrumentation
) {
1106 case LTTNG_KERNEL_KPROBE
:
1107 uevent_param
->u
.kprobe
.addr
=
1108 old_uevent_param
->u
.kprobe
.addr
;
1109 uevent_param
->u
.kprobe
.offset
=
1110 old_uevent_param
->u
.kprobe
.offset
;
1111 memcpy(uevent_param
->u
.kprobe
.symbol_name
,
1112 old_uevent_param
->u
.kprobe
.symbol_name
,
1113 sizeof(uevent_param
->u
.kprobe
.symbol_name
));
1115 case LTTNG_KERNEL_KRETPROBE
:
1116 uevent_param
->u
.kretprobe
.addr
=
1117 old_uevent_param
->u
.kretprobe
.addr
;
1118 uevent_param
->u
.kretprobe
.offset
=
1119 old_uevent_param
->u
.kretprobe
.offset
;
1120 memcpy(uevent_param
->u
.kretprobe
.symbol_name
,
1121 old_uevent_param
->u
.kretprobe
.symbol_name
,
1122 sizeof(uevent_param
->u
.kretprobe
.symbol_name
));
1124 case LTTNG_KERNEL_FUNCTION
:
1125 memcpy(uevent_param
->u
.ftrace
.symbol_name
,
1126 old_uevent_param
->u
.ftrace
.symbol_name
,
1127 sizeof(uevent_param
->u
.ftrace
.symbol_name
));
1132 ret
= lttng_abi_create_event(file
, uevent_param
);
1134 old_event_error_free_old_param
:
1135 kfree(old_uevent_param
);
1136 old_event_error_free_param
:
1137 kfree(uevent_param
);
1141 case LTTNG_KERNEL_EVENT
:
1143 struct lttng_kernel_event uevent_param
;
1145 if (copy_from_user(&uevent_param
,
1146 (struct lttng_kernel_event __user
*) arg
,
1147 sizeof(uevent_param
)))
1149 return lttng_abi_create_event(file
, &uevent_param
);
1151 case LTTNG_KERNEL_OLD_CONTEXT
:
1153 struct lttng_kernel_context
*ucontext_param
;
1154 struct lttng_kernel_old_context
*old_ucontext_param
;
1157 ucontext_param
= kmalloc(sizeof(struct lttng_kernel_context
),
1159 if (!ucontext_param
) {
1163 old_ucontext_param
= kmalloc(sizeof(struct lttng_kernel_old_context
),
1165 if (!old_ucontext_param
) {
1167 goto old_ctx_error_free_param
;
1170 if (copy_from_user(old_ucontext_param
,
1171 (struct lttng_kernel_old_context __user
*) arg
,
1172 sizeof(struct lttng_kernel_old_context
))) {
1174 goto old_ctx_error_free_old_param
;
1176 ucontext_param
->ctx
= old_ucontext_param
->ctx
;
1177 memcpy(ucontext_param
->padding
, old_ucontext_param
->padding
,
1178 sizeof(ucontext_param
->padding
));
1179 /* only type that uses the union */
1180 if (old_ucontext_param
->ctx
== LTTNG_KERNEL_CONTEXT_PERF_COUNTER
) {
1181 ucontext_param
->u
.perf_counter
.type
=
1182 old_ucontext_param
->u
.perf_counter
.type
;
1183 ucontext_param
->u
.perf_counter
.config
=
1184 old_ucontext_param
->u
.perf_counter
.config
;
1185 memcpy(ucontext_param
->u
.perf_counter
.name
,
1186 old_ucontext_param
->u
.perf_counter
.name
,
1187 sizeof(ucontext_param
->u
.perf_counter
.name
));
1190 ret
= lttng_abi_add_context(file
,
1192 &channel
->ctx
, channel
->session
);
1194 old_ctx_error_free_old_param
:
1195 kfree(old_ucontext_param
);
1196 old_ctx_error_free_param
:
1197 kfree(ucontext_param
);
1201 case LTTNG_KERNEL_CONTEXT
:
1203 struct lttng_kernel_context ucontext_param
;
1205 if (copy_from_user(&ucontext_param
,
1206 (struct lttng_kernel_context __user
*) arg
,
1207 sizeof(ucontext_param
)))
1209 return lttng_abi_add_context(file
,
1211 &channel
->ctx
, channel
->session
);
1213 case LTTNG_KERNEL_OLD_ENABLE
:
1214 case LTTNG_KERNEL_ENABLE
:
1215 return lttng_channel_enable(channel
);
1216 case LTTNG_KERNEL_OLD_DISABLE
:
1217 case LTTNG_KERNEL_DISABLE
:
1218 return lttng_channel_disable(channel
);
1219 case LTTNG_KERNEL_SYSCALL_MASK
:
1220 return lttng_channel_syscall_mask(channel
,
1221 (struct lttng_kernel_syscall_mask __user
*) arg
);
1223 return -ENOIOCTLCMD
;
1229 * lttng_metadata_ioctl - lttng syscall through ioctl
1235 * This ioctl implements lttng commands:
1236 * LTTNG_KERNEL_STREAM
1237 * Returns an event stream file descriptor or failure.
1239 * Channel and event file descriptors also hold a reference on the session.
1242 long lttng_metadata_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1245 case LTTNG_KERNEL_OLD_STREAM
:
1246 case LTTNG_KERNEL_STREAM
:
1247 return lttng_abi_open_metadata_stream(file
);
1249 return -ENOIOCTLCMD
;
1254 * lttng_channel_poll - lttng stream addition/removal monitoring
1259 unsigned int lttng_channel_poll(struct file
*file
, poll_table
*wait
)
1261 struct lttng_channel
*channel
= file
->private_data
;
1262 unsigned int mask
= 0;
1264 if (file
->f_mode
& FMODE_READ
) {
1265 poll_wait_set_exclusive(wait
);
1266 poll_wait(file
, channel
->ops
->get_hp_wait_queue(channel
->chan
),
1269 if (channel
->ops
->is_disabled(channel
->chan
))
1271 if (channel
->ops
->is_finalized(channel
->chan
))
1273 if (channel
->ops
->buffer_has_read_closed_stream(channel
->chan
))
1274 return POLLIN
| POLLRDNORM
;
1282 int lttng_channel_release(struct inode
*inode
, struct file
*file
)
1284 struct lttng_channel
*channel
= file
->private_data
;
1287 fput(channel
->session
->file
);
1292 int lttng_metadata_channel_release(struct inode
*inode
, struct file
*file
)
1294 struct lttng_channel
*channel
= file
->private_data
;
1297 fput(channel
->session
->file
);
1298 lttng_metadata_channel_destroy(channel
);
1304 static const struct file_operations lttng_channel_fops
= {
1305 .owner
= THIS_MODULE
,
1306 .release
= lttng_channel_release
,
1307 .poll
= lttng_channel_poll
,
1308 .unlocked_ioctl
= lttng_channel_ioctl
,
1309 #ifdef CONFIG_COMPAT
1310 .compat_ioctl
= lttng_channel_ioctl
,
1314 static const struct file_operations lttng_metadata_fops
= {
1315 .owner
= THIS_MODULE
,
1316 .release
= lttng_metadata_channel_release
,
1317 .unlocked_ioctl
= lttng_metadata_ioctl
,
1318 #ifdef CONFIG_COMPAT
1319 .compat_ioctl
= lttng_metadata_ioctl
,
1324 * lttng_event_ioctl - lttng syscall through ioctl
1330 * This ioctl implements lttng commands:
1331 * LTTNG_KERNEL_CONTEXT
1332 * Prepend a context field to each record of this event
1333 * LTTNG_KERNEL_ENABLE
1334 * Enable recording for this event (weak enable)
1335 * LTTNG_KERNEL_DISABLE
1336 * Disable recording for this event (strong disable)
1339 long lttng_event_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1341 struct lttng_event
*event
;
1342 struct lttng_enabler
*enabler
;
1343 enum lttng_event_type
*evtype
= file
->private_data
;
1346 case LTTNG_KERNEL_OLD_CONTEXT
:
1348 /* Not implemented */
1351 case LTTNG_KERNEL_CONTEXT
:
1353 /* Not implemented */
1356 case LTTNG_KERNEL_OLD_ENABLE
:
1357 case LTTNG_KERNEL_ENABLE
:
1359 case LTTNG_TYPE_EVENT
:
1360 event
= file
->private_data
;
1361 return lttng_event_enable(event
);
1362 case LTTNG_TYPE_ENABLER
:
1363 enabler
= file
->private_data
;
1364 return lttng_enabler_enable(enabler
);
1369 case LTTNG_KERNEL_OLD_DISABLE
:
1370 case LTTNG_KERNEL_DISABLE
:
1372 case LTTNG_TYPE_EVENT
:
1373 event
= file
->private_data
;
1374 return lttng_event_disable(event
);
1375 case LTTNG_TYPE_ENABLER
:
1376 enabler
= file
->private_data
;
1377 return lttng_enabler_disable(enabler
);
1382 case LTTNG_KERNEL_FILTER
:
1384 case LTTNG_TYPE_EVENT
:
1386 case LTTNG_TYPE_ENABLER
:
1388 enabler
= file
->private_data
;
1389 return lttng_enabler_attach_bytecode(enabler
,
1390 (struct lttng_kernel_filter_bytecode __user
*) arg
);
1395 return -ENOIOCTLCMD
;
1400 int lttng_event_release(struct inode
*inode
, struct file
*file
)
1402 struct lttng_event
*event
;
1403 struct lttng_enabler
*enabler
;
1404 enum lttng_event_type
*evtype
= file
->private_data
;
1410 case LTTNG_TYPE_EVENT
:
1411 event
= file
->private_data
;
1413 fput(event
->chan
->file
);
1415 case LTTNG_TYPE_ENABLER
:
1416 enabler
= file
->private_data
;
1418 fput(enabler
->chan
->file
);
1428 /* TODO: filter control ioctl */
1429 static const struct file_operations lttng_event_fops
= {
1430 .owner
= THIS_MODULE
,
1431 .release
= lttng_event_release
,
1432 .unlocked_ioctl
= lttng_event_ioctl
,
1433 #ifdef CONFIG_COMPAT
1434 .compat_ioctl
= lttng_event_ioctl
,
1438 static int put_u64(uint64_t val
, unsigned long arg
)
1440 return put_user(val
, (uint64_t __user
*) arg
);
1443 static long lttng_stream_ring_buffer_ioctl(struct file
*filp
,
1444 unsigned int cmd
, unsigned long arg
)
1446 struct lib_ring_buffer
*buf
= filp
->private_data
;
1447 struct channel
*chan
= buf
->backend
.chan
;
1448 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
1449 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
1452 if (atomic_read(&chan
->record_disabled
))
1456 case LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN
:
1460 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
1463 return put_u64(ts
, arg
);
1465 case LTTNG_RING_BUFFER_GET_TIMESTAMP_END
:
1469 ret
= ops
->timestamp_end(config
, buf
, &ts
);
1472 return put_u64(ts
, arg
);
1474 case LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED
:
1478 ret
= ops
->events_discarded(config
, buf
, &ed
);
1481 return put_u64(ed
, arg
);
1483 case LTTNG_RING_BUFFER_GET_CONTENT_SIZE
:
1487 ret
= ops
->content_size(config
, buf
, &cs
);
1490 return put_u64(cs
, arg
);
1492 case LTTNG_RING_BUFFER_GET_PACKET_SIZE
:
1496 ret
= ops
->packet_size(config
, buf
, &ps
);
1499 return put_u64(ps
, arg
);
1501 case LTTNG_RING_BUFFER_GET_STREAM_ID
:
1505 ret
= ops
->stream_id(config
, buf
, &si
);
1508 return put_u64(si
, arg
);
1510 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
1514 ret
= ops
->current_timestamp(config
, buf
, &ts
);
1517 return put_u64(ts
, arg
);
1519 case LTTNG_RING_BUFFER_GET_SEQ_NUM
:
1523 ret
= ops
->sequence_number(config
, buf
, &seq
);
1526 return put_u64(seq
, arg
);
1528 case LTTNG_RING_BUFFER_INSTANCE_ID
:
1532 ret
= ops
->instance_id(config
, buf
, &id
);
1535 return put_u64(id
, arg
);
1538 return lib_ring_buffer_file_operations
.unlocked_ioctl(filp
,
1546 #ifdef CONFIG_COMPAT
1547 static long lttng_stream_ring_buffer_compat_ioctl(struct file
*filp
,
1548 unsigned int cmd
, unsigned long arg
)
1550 struct lib_ring_buffer
*buf
= filp
->private_data
;
1551 struct channel
*chan
= buf
->backend
.chan
;
1552 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
1553 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
1556 if (atomic_read(&chan
->record_disabled
))
1560 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN
:
1564 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
1567 return put_u64(ts
, arg
);
1569 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END
:
1573 ret
= ops
->timestamp_end(config
, buf
, &ts
);
1576 return put_u64(ts
, arg
);
1578 case LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED
:
1582 ret
= ops
->events_discarded(config
, buf
, &ed
);
1585 return put_u64(ed
, arg
);
1587 case LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE
:
1591 ret
= ops
->content_size(config
, buf
, &cs
);
1594 return put_u64(cs
, arg
);
1596 case LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE
:
1600 ret
= ops
->packet_size(config
, buf
, &ps
);
1603 return put_u64(ps
, arg
);
1605 case LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID
:
1609 ret
= ops
->stream_id(config
, buf
, &si
);
1612 return put_u64(si
, arg
);
1614 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
1618 ret
= ops
->current_timestamp(config
, buf
, &ts
);
1621 return put_u64(ts
, arg
);
1623 case LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM
:
1627 ret
= ops
->sequence_number(config
, buf
, &seq
);
1630 return put_u64(seq
, arg
);
1632 case LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID
:
1636 ret
= ops
->instance_id(config
, buf
, &id
);
1639 return put_u64(id
, arg
);
1642 return lib_ring_buffer_file_operations
.compat_ioctl(filp
,
1649 #endif /* CONFIG_COMPAT */
1651 static void lttng_stream_override_ring_buffer_fops(void)
1653 lttng_stream_ring_buffer_file_operations
.owner
= THIS_MODULE
;
1654 lttng_stream_ring_buffer_file_operations
.open
=
1655 lib_ring_buffer_file_operations
.open
;
1656 lttng_stream_ring_buffer_file_operations
.release
=
1657 lib_ring_buffer_file_operations
.release
;
1658 lttng_stream_ring_buffer_file_operations
.poll
=
1659 lib_ring_buffer_file_operations
.poll
;
1660 lttng_stream_ring_buffer_file_operations
.splice_read
=
1661 lib_ring_buffer_file_operations
.splice_read
;
1662 lttng_stream_ring_buffer_file_operations
.mmap
=
1663 lib_ring_buffer_file_operations
.mmap
;
1664 lttng_stream_ring_buffer_file_operations
.unlocked_ioctl
=
1665 lttng_stream_ring_buffer_ioctl
;
1666 lttng_stream_ring_buffer_file_operations
.llseek
=
1667 lib_ring_buffer_file_operations
.llseek
;
1668 #ifdef CONFIG_COMPAT
1669 lttng_stream_ring_buffer_file_operations
.compat_ioctl
=
1670 lttng_stream_ring_buffer_compat_ioctl
;
1674 int __init
lttng_abi_init(void)
1678 wrapper_vmalloc_sync_all();
1680 lttng_proc_dentry
= proc_create_data("lttng", S_IRUSR
| S_IWUSR
, NULL
,
1683 if (!lttng_proc_dentry
) {
1684 printk(KERN_ERR
"Error creating LTTng control file\n");
1688 lttng_stream_override_ring_buffer_fops();
1692 lttng_clock_unref();
1696 /* No __exit annotation because used by init error path too. */
1697 void lttng_abi_exit(void)
1699 lttng_clock_unref();
1700 if (lttng_proc_dentry
)
1701 remove_proc_entry("lttng", NULL
);