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 <wrapper/kref.h>
54 #include <lttng-abi.h>
55 #include <lttng-abi-old.h>
56 #include <lttng-events.h>
57 #include <lttng-tracer.h>
58 #include <lib/ringbuffer/frontend_types.h>
61 * This is LTTng's own personal way to create a system call as an external
62 * module. We use ioctl() on /proc/lttng.
65 static struct proc_dir_entry
*lttng_proc_dentry
;
66 static const struct file_operations lttng_fops
;
67 static const struct file_operations lttng_session_fops
;
68 static const struct file_operations lttng_channel_fops
;
69 static const struct file_operations lttng_metadata_fops
;
70 static const struct file_operations lttng_event_fops
;
71 static struct file_operations lttng_stream_ring_buffer_file_operations
;
73 static int put_u64(uint64_t val
, unsigned long arg
);
76 * Teardown management: opened file descriptors keep a refcount on the module,
77 * so it can only exit when all file descriptors are closed.
81 int lttng_abi_create_session(void)
83 struct lttng_session
*session
;
84 struct file
*session_file
;
87 session
= lttng_session_create();
90 session_fd
= lttng_get_unused_fd();
95 session_file
= anon_inode_getfile("[lttng_session]",
98 if (IS_ERR(session_file
)) {
99 ret
= PTR_ERR(session_file
);
102 session
->file
= session_file
;
103 fd_install(session_fd
, session_file
);
107 put_unused_fd(session_fd
);
109 lttng_session_destroy(session
);
114 int lttng_abi_tracepoint_list(void)
116 struct file
*tracepoint_list_file
;
119 file_fd
= lttng_get_unused_fd();
125 tracepoint_list_file
= anon_inode_getfile("[lttng_tracepoint_list]",
126 <tng_tracepoint_list_fops
,
128 if (IS_ERR(tracepoint_list_file
)) {
129 ret
= PTR_ERR(tracepoint_list_file
);
132 ret
= lttng_tracepoint_list_fops
.open(NULL
, tracepoint_list_file
);
135 fd_install(file_fd
, tracepoint_list_file
);
139 fput(tracepoint_list_file
);
141 put_unused_fd(file_fd
);
146 #ifndef CONFIG_HAVE_SYSCALL_TRACEPOINTS
148 int lttng_abi_syscall_list(void)
154 int lttng_abi_syscall_list(void)
156 struct file
*syscall_list_file
;
159 file_fd
= lttng_get_unused_fd();
165 syscall_list_file
= anon_inode_getfile("[lttng_syscall_list]",
166 <tng_syscall_list_fops
,
168 if (IS_ERR(syscall_list_file
)) {
169 ret
= PTR_ERR(syscall_list_file
);
172 ret
= lttng_syscall_list_fops
.open(NULL
, syscall_list_file
);
175 fd_install(file_fd
, syscall_list_file
);
179 fput(syscall_list_file
);
181 put_unused_fd(file_fd
);
188 void lttng_abi_tracer_version(struct lttng_kernel_tracer_version
*v
)
190 v
->major
= LTTNG_MODULES_MAJOR_VERSION
;
191 v
->minor
= LTTNG_MODULES_MINOR_VERSION
;
192 v
->patchlevel
= LTTNG_MODULES_PATCHLEVEL_VERSION
;
196 void lttng_abi_tracer_abi_version(struct lttng_kernel_tracer_abi_version
*v
)
198 v
->major
= LTTNG_MODULES_ABI_MAJOR_VERSION
;
199 v
->minor
= LTTNG_MODULES_ABI_MINOR_VERSION
;
203 long lttng_abi_add_context(struct file
*file
,
204 struct lttng_kernel_context
*context_param
,
205 struct lttng_ctx
**ctx
, struct lttng_session
*session
)
208 if (session
->been_active
)
211 switch (context_param
->ctx
) {
212 case LTTNG_KERNEL_CONTEXT_PID
:
213 return lttng_add_pid_to_ctx(ctx
);
214 case LTTNG_KERNEL_CONTEXT_PRIO
:
215 return lttng_add_prio_to_ctx(ctx
);
216 case LTTNG_KERNEL_CONTEXT_NICE
:
217 return lttng_add_nice_to_ctx(ctx
);
218 case LTTNG_KERNEL_CONTEXT_VPID
:
219 return lttng_add_vpid_to_ctx(ctx
);
220 case LTTNG_KERNEL_CONTEXT_TID
:
221 return lttng_add_tid_to_ctx(ctx
);
222 case LTTNG_KERNEL_CONTEXT_VTID
:
223 return lttng_add_vtid_to_ctx(ctx
);
224 case LTTNG_KERNEL_CONTEXT_PPID
:
225 return lttng_add_ppid_to_ctx(ctx
);
226 case LTTNG_KERNEL_CONTEXT_VPPID
:
227 return lttng_add_vppid_to_ctx(ctx
);
228 case LTTNG_KERNEL_CONTEXT_PERF_COUNTER
:
229 context_param
->u
.perf_counter
.name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
230 return lttng_add_perf_counter_to_ctx(context_param
->u
.perf_counter
.type
,
231 context_param
->u
.perf_counter
.config
,
232 context_param
->u
.perf_counter
.name
,
234 case LTTNG_KERNEL_CONTEXT_PROCNAME
:
235 return lttng_add_procname_to_ctx(ctx
);
236 case LTTNG_KERNEL_CONTEXT_HOSTNAME
:
237 return lttng_add_hostname_to_ctx(ctx
);
238 case LTTNG_KERNEL_CONTEXT_CPU_ID
:
239 return lttng_add_cpu_id_to_ctx(ctx
);
240 case LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE
:
241 return lttng_add_interruptible_to_ctx(ctx
);
242 case LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE
:
243 return lttng_add_need_reschedule_to_ctx(ctx
);
244 case LTTNG_KERNEL_CONTEXT_PREEMPTIBLE
:
245 return lttng_add_preemptible_to_ctx(ctx
);
246 case LTTNG_KERNEL_CONTEXT_MIGRATABLE
:
247 return lttng_add_migratable_to_ctx(ctx
);
254 * lttng_ioctl - lttng syscall through ioctl
260 * This ioctl implements lttng commands:
261 * LTTNG_KERNEL_SESSION
262 * Returns a LTTng trace session file descriptor
263 * LTTNG_KERNEL_TRACER_VERSION
264 * Returns the LTTng kernel tracer version
265 * LTTNG_KERNEL_TRACEPOINT_LIST
266 * Returns a file descriptor listing available tracepoints
267 * LTTNG_KERNEL_WAIT_QUIESCENT
268 * Returns after all previously running probes have completed
269 * LTTNG_KERNEL_TRACER_ABI_VERSION
270 * Returns the LTTng kernel tracer ABI version
272 * The returned session will be deleted when its file descriptor is closed.
275 long lttng_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
278 case LTTNG_KERNEL_OLD_SESSION
:
279 case LTTNG_KERNEL_SESSION
:
280 return lttng_abi_create_session();
281 case LTTNG_KERNEL_OLD_TRACER_VERSION
:
283 struct lttng_kernel_tracer_version v
;
284 struct lttng_kernel_old_tracer_version oldv
;
285 struct lttng_kernel_old_tracer_version
*uversion
=
286 (struct lttng_kernel_old_tracer_version __user
*) arg
;
288 lttng_abi_tracer_version(&v
);
289 oldv
.major
= v
.major
;
290 oldv
.minor
= v
.minor
;
291 oldv
.patchlevel
= v
.patchlevel
;
293 if (copy_to_user(uversion
, &oldv
, sizeof(oldv
)))
297 case LTTNG_KERNEL_TRACER_VERSION
:
299 struct lttng_kernel_tracer_version version
;
300 struct lttng_kernel_tracer_version
*uversion
=
301 (struct lttng_kernel_tracer_version __user
*) arg
;
303 lttng_abi_tracer_version(&version
);
305 if (copy_to_user(uversion
, &version
, sizeof(version
)))
309 case LTTNG_KERNEL_TRACER_ABI_VERSION
:
311 struct lttng_kernel_tracer_abi_version version
;
312 struct lttng_kernel_tracer_abi_version
*uversion
=
313 (struct lttng_kernel_tracer_abi_version __user
*) arg
;
315 lttng_abi_tracer_abi_version(&version
);
317 if (copy_to_user(uversion
, &version
, sizeof(version
)))
321 case LTTNG_KERNEL_OLD_TRACEPOINT_LIST
:
322 case LTTNG_KERNEL_TRACEPOINT_LIST
:
323 return lttng_abi_tracepoint_list();
324 case LTTNG_KERNEL_SYSCALL_LIST
:
325 return lttng_abi_syscall_list();
326 case LTTNG_KERNEL_OLD_WAIT_QUIESCENT
:
327 case LTTNG_KERNEL_WAIT_QUIESCENT
:
330 case LTTNG_KERNEL_OLD_CALIBRATE
:
332 struct lttng_kernel_old_calibrate __user
*ucalibrate
=
333 (struct lttng_kernel_old_calibrate __user
*) arg
;
334 struct lttng_kernel_old_calibrate old_calibrate
;
335 struct lttng_kernel_calibrate calibrate
;
338 if (copy_from_user(&old_calibrate
, ucalibrate
, sizeof(old_calibrate
)))
340 calibrate
.type
= old_calibrate
.type
;
341 ret
= lttng_calibrate(&calibrate
);
342 if (copy_to_user(ucalibrate
, &old_calibrate
, sizeof(old_calibrate
)))
346 case LTTNG_KERNEL_CALIBRATE
:
348 struct lttng_kernel_calibrate __user
*ucalibrate
=
349 (struct lttng_kernel_calibrate __user
*) arg
;
350 struct lttng_kernel_calibrate calibrate
;
353 if (copy_from_user(&calibrate
, ucalibrate
, sizeof(calibrate
)))
355 ret
= lttng_calibrate(&calibrate
);
356 if (copy_to_user(ucalibrate
, &calibrate
, sizeof(calibrate
)))
365 static const struct file_operations lttng_fops
= {
366 .owner
= THIS_MODULE
,
367 .unlocked_ioctl
= lttng_ioctl
,
369 .compat_ioctl
= lttng_ioctl
,
374 int lttng_abi_create_channel(struct file
*session_file
,
375 struct lttng_kernel_channel
*chan_param
,
376 enum channel_type channel_type
)
378 struct lttng_session
*session
= session_file
->private_data
;
379 const struct file_operations
*fops
= NULL
;
380 const char *transport_name
;
381 struct lttng_channel
*chan
;
382 struct file
*chan_file
;
386 chan_fd
= lttng_get_unused_fd();
391 switch (channel_type
) {
392 case PER_CPU_CHANNEL
:
393 fops
= <tng_channel_fops
;
395 case METADATA_CHANNEL
:
396 fops
= <tng_metadata_fops
;
400 chan_file
= anon_inode_getfile("[lttng_channel]",
403 if (IS_ERR(chan_file
)) {
404 ret
= PTR_ERR(chan_file
);
407 switch (channel_type
) {
408 case PER_CPU_CHANNEL
:
409 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
) {
410 transport_name
= chan_param
->overwrite
?
411 "relay-overwrite" : "relay-discard";
412 } else if (chan_param
->output
== LTTNG_KERNEL_MMAP
) {
413 transport_name
= chan_param
->overwrite
?
414 "relay-overwrite-mmap" : "relay-discard-mmap";
419 case METADATA_CHANNEL
:
420 if (chan_param
->output
== LTTNG_KERNEL_SPLICE
)
421 transport_name
= "relay-metadata";
422 else if (chan_param
->output
== LTTNG_KERNEL_MMAP
)
423 transport_name
= "relay-metadata-mmap";
428 transport_name
= "<unknown>";
431 if (atomic_long_add_unless(&session_file
->f_count
,
432 1, INT_MAX
) == INT_MAX
) {
436 * We tolerate no failure path after channel creation. It will stay
437 * invariant for the rest of the session.
439 chan
= lttng_channel_create(session
, transport_name
, NULL
,
440 chan_param
->subbuf_size
,
441 chan_param
->num_subbuf
,
442 chan_param
->switch_timer_interval
,
443 chan_param
->read_timer_interval
,
449 chan
->file
= chan_file
;
450 chan_file
->private_data
= chan
;
451 fd_install(chan_fd
, chan_file
);
456 atomic_long_dec(&session_file
->f_count
);
460 put_unused_fd(chan_fd
);
466 * lttng_session_ioctl - lttng session fd ioctl
472 * This ioctl implements lttng commands:
473 * LTTNG_KERNEL_CHANNEL
474 * Returns a LTTng channel file descriptor
475 * LTTNG_KERNEL_ENABLE
476 * Enables tracing for a session (weak enable)
477 * LTTNG_KERNEL_DISABLE
478 * Disables tracing for a session (strong disable)
479 * LTTNG_KERNEL_METADATA
480 * Returns a LTTng metadata file descriptor
481 * LTTNG_KERNEL_SESSION_TRACK_PID
482 * Add PID to session tracker
483 * LTTNG_KERNEL_SESSION_UNTRACK_PID
484 * Remove PID from session tracker
486 * The returned channel will be deleted when its file descriptor is closed.
489 long lttng_session_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
491 struct lttng_session
*session
= file
->private_data
;
494 case LTTNG_KERNEL_OLD_CHANNEL
:
496 struct lttng_kernel_channel chan_param
;
497 struct lttng_kernel_old_channel old_chan_param
;
499 if (copy_from_user(&old_chan_param
,
500 (struct lttng_kernel_old_channel __user
*) arg
,
501 sizeof(struct lttng_kernel_old_channel
)))
503 chan_param
.overwrite
= old_chan_param
.overwrite
;
504 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
505 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
506 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
507 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
508 chan_param
.output
= old_chan_param
.output
;
510 return lttng_abi_create_channel(file
, &chan_param
,
513 case LTTNG_KERNEL_CHANNEL
:
515 struct lttng_kernel_channel chan_param
;
517 if (copy_from_user(&chan_param
,
518 (struct lttng_kernel_channel __user
*) arg
,
519 sizeof(struct lttng_kernel_channel
)))
521 return lttng_abi_create_channel(file
, &chan_param
,
524 case LTTNG_KERNEL_OLD_SESSION_START
:
525 case LTTNG_KERNEL_OLD_ENABLE
:
526 case LTTNG_KERNEL_SESSION_START
:
527 case LTTNG_KERNEL_ENABLE
:
528 return lttng_session_enable(session
);
529 case LTTNG_KERNEL_OLD_SESSION_STOP
:
530 case LTTNG_KERNEL_OLD_DISABLE
:
531 case LTTNG_KERNEL_SESSION_STOP
:
532 case LTTNG_KERNEL_DISABLE
:
533 return lttng_session_disable(session
);
534 case LTTNG_KERNEL_OLD_METADATA
:
536 struct lttng_kernel_channel chan_param
;
537 struct lttng_kernel_old_channel old_chan_param
;
539 if (copy_from_user(&old_chan_param
,
540 (struct lttng_kernel_old_channel __user
*) arg
,
541 sizeof(struct lttng_kernel_old_channel
)))
543 chan_param
.overwrite
= old_chan_param
.overwrite
;
544 chan_param
.subbuf_size
= old_chan_param
.subbuf_size
;
545 chan_param
.num_subbuf
= old_chan_param
.num_subbuf
;
546 chan_param
.switch_timer_interval
= old_chan_param
.switch_timer_interval
;
547 chan_param
.read_timer_interval
= old_chan_param
.read_timer_interval
;
548 chan_param
.output
= old_chan_param
.output
;
550 return lttng_abi_create_channel(file
, &chan_param
,
553 case LTTNG_KERNEL_METADATA
:
555 struct lttng_kernel_channel chan_param
;
557 if (copy_from_user(&chan_param
,
558 (struct lttng_kernel_channel __user
*) arg
,
559 sizeof(struct lttng_kernel_channel
)))
561 return lttng_abi_create_channel(file
, &chan_param
,
564 case LTTNG_KERNEL_SESSION_TRACK_PID
:
565 return lttng_session_track_pid(session
, (int) arg
);
566 case LTTNG_KERNEL_SESSION_UNTRACK_PID
:
567 return lttng_session_untrack_pid(session
, (int) arg
);
568 case LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS
:
569 return lttng_session_list_tracker_pids(session
);
570 case LTTNG_KERNEL_SESSION_METADATA_REGEN
:
571 return lttng_session_metadata_regenerate(session
);
578 * Called when the last file reference is dropped.
580 * Big fat note: channels and events are invariant for the whole session after
581 * their creation. So this session destruction also destroys all channel and
582 * event structures specific to this session (they are not destroyed when their
583 * individual file is released).
586 int lttng_session_release(struct inode
*inode
, struct file
*file
)
588 struct lttng_session
*session
= file
->private_data
;
591 lttng_session_destroy(session
);
595 static const struct file_operations lttng_session_fops
= {
596 .owner
= THIS_MODULE
,
597 .release
= lttng_session_release
,
598 .unlocked_ioctl
= lttng_session_ioctl
,
600 .compat_ioctl
= lttng_session_ioctl
,
605 * lttng_metadata_ring_buffer_poll - LTTng ring buffer poll file operation
609 * Handles the poll operations for the metadata channels.
612 unsigned int lttng_metadata_ring_buffer_poll(struct file
*filp
,
615 struct lttng_metadata_stream
*stream
= filp
->private_data
;
616 struct lib_ring_buffer
*buf
= stream
->priv
;
618 unsigned int mask
= 0;
620 if (filp
->f_mode
& FMODE_READ
) {
621 poll_wait_set_exclusive(wait
);
622 poll_wait(filp
, &stream
->read_wait
, wait
);
624 finalized
= stream
->finalized
;
627 * lib_ring_buffer_is_finalized() contains a smp_rmb()
628 * ordering finalized load before offsets loads.
630 WARN_ON(atomic_long_read(&buf
->active_readers
) != 1);
635 mutex_lock(&stream
->metadata_cache
->lock
);
636 if (stream
->metadata_cache
->metadata_written
>
637 stream
->metadata_out
)
639 mutex_unlock(&stream
->metadata_cache
->lock
);
646 void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file
*filp
,
647 unsigned int cmd
, unsigned long arg
)
649 struct lttng_metadata_stream
*stream
= filp
->private_data
;
651 stream
->metadata_out
= stream
->metadata_in
;
655 long lttng_metadata_ring_buffer_ioctl(struct file
*filp
,
656 unsigned int cmd
, unsigned long arg
)
659 struct lttng_metadata_stream
*stream
= filp
->private_data
;
660 struct lib_ring_buffer
*buf
= stream
->priv
;
663 case RING_BUFFER_GET_NEXT_SUBBUF
:
665 struct lttng_metadata_stream
*stream
= filp
->private_data
;
666 struct lib_ring_buffer
*buf
= stream
->priv
;
667 struct channel
*chan
= buf
->backend
.chan
;
669 ret
= lttng_metadata_output_channel(stream
, chan
);
671 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
677 case RING_BUFFER_GET_SUBBUF
:
680 * Random access is not allowed for metadata channel.
684 case RING_BUFFER_FLUSH_EMPTY
: /* Fall-through. */
685 case RING_BUFFER_FLUSH
:
687 struct lttng_metadata_stream
*stream
= filp
->private_data
;
688 struct lib_ring_buffer
*buf
= stream
->priv
;
689 struct channel
*chan
= buf
->backend
.chan
;
692 * Before doing the actual ring buffer flush, write up to one
693 * packet of metadata in the ring buffer.
695 ret
= lttng_metadata_output_channel(stream
, chan
);
700 case RING_BUFFER_GET_METADATA_VERSION
:
702 struct lttng_metadata_stream
*stream
= filp
->private_data
;
704 return put_u64(stream
->version
, arg
);
709 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
711 /* Performing lib ring buffer ioctl after our own. */
712 ret
= lib_ring_buffer_ioctl(filp
, cmd
, arg
, buf
);
717 case RING_BUFFER_PUT_NEXT_SUBBUF
:
719 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
732 long lttng_metadata_ring_buffer_compat_ioctl(struct file
*filp
,
733 unsigned int cmd
, unsigned long arg
)
736 struct lttng_metadata_stream
*stream
= filp
->private_data
;
737 struct lib_ring_buffer
*buf
= stream
->priv
;
740 case RING_BUFFER_GET_NEXT_SUBBUF
:
742 struct lttng_metadata_stream
*stream
= filp
->private_data
;
743 struct lib_ring_buffer
*buf
= stream
->priv
;
744 struct channel
*chan
= buf
->backend
.chan
;
746 ret
= lttng_metadata_output_channel(stream
, chan
);
748 lib_ring_buffer_switch_slow(buf
, SWITCH_ACTIVE
);
754 case RING_BUFFER_GET_SUBBUF
:
757 * Random access is not allowed for metadata channel.
761 case RING_BUFFER_FLUSH_EMPTY
: /* Fall-through. */
762 case RING_BUFFER_FLUSH
:
764 struct lttng_metadata_stream
*stream
= filp
->private_data
;
765 struct lib_ring_buffer
*buf
= stream
->priv
;
766 struct channel
*chan
= buf
->backend
.chan
;
769 * Before doing the actual ring buffer flush, write up to one
770 * packet of metadata in the ring buffer.
772 ret
= lttng_metadata_output_channel(stream
, chan
);
777 case RING_BUFFER_GET_METADATA_VERSION
:
779 struct lttng_metadata_stream
*stream
= filp
->private_data
;
781 return put_u64(stream
->version
, arg
);
786 /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
788 /* Performing lib ring buffer ioctl after our own. */
789 ret
= lib_ring_buffer_compat_ioctl(filp
, cmd
, arg
, buf
);
794 case RING_BUFFER_PUT_NEXT_SUBBUF
:
796 lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp
,
809 * This is not used by anonymous file descriptors. This code is left
810 * there if we ever want to implement an inode with open() operation.
813 int lttng_metadata_ring_buffer_open(struct inode
*inode
, struct file
*file
)
815 struct lttng_metadata_stream
*stream
= inode
->i_private
;
816 struct lib_ring_buffer
*buf
= stream
->priv
;
818 file
->private_data
= buf
;
820 * Since life-time of metadata cache differs from that of
821 * session, we need to keep our own reference on the transport.
823 if (!try_module_get(stream
->transport
->owner
)) {
824 printk(KERN_WARNING
"LTT : Can't lock transport module.\n");
827 return lib_ring_buffer_open(inode
, file
, buf
);
831 int lttng_metadata_ring_buffer_release(struct inode
*inode
, struct file
*file
)
833 struct lttng_metadata_stream
*stream
= file
->private_data
;
834 struct lib_ring_buffer
*buf
= stream
->priv
;
836 kref_put(&stream
->metadata_cache
->refcount
, metadata_cache_destroy
);
837 module_put(stream
->transport
->owner
);
838 return lib_ring_buffer_release(inode
, file
, buf
);
842 ssize_t
lttng_metadata_ring_buffer_splice_read(struct file
*in
, loff_t
*ppos
,
843 struct pipe_inode_info
*pipe
, size_t len
,
846 struct lttng_metadata_stream
*stream
= in
->private_data
;
847 struct lib_ring_buffer
*buf
= stream
->priv
;
849 return lib_ring_buffer_splice_read(in
, ppos
, pipe
, len
,
854 int lttng_metadata_ring_buffer_mmap(struct file
*filp
,
855 struct vm_area_struct
*vma
)
857 struct lttng_metadata_stream
*stream
= filp
->private_data
;
858 struct lib_ring_buffer
*buf
= stream
->priv
;
860 return lib_ring_buffer_mmap(filp
, vma
, buf
);
864 const struct file_operations lttng_metadata_ring_buffer_file_operations
= {
865 .owner
= THIS_MODULE
,
866 .open
= lttng_metadata_ring_buffer_open
,
867 .release
= lttng_metadata_ring_buffer_release
,
868 .poll
= lttng_metadata_ring_buffer_poll
,
869 .splice_read
= lttng_metadata_ring_buffer_splice_read
,
870 .mmap
= lttng_metadata_ring_buffer_mmap
,
871 .unlocked_ioctl
= lttng_metadata_ring_buffer_ioctl
,
872 .llseek
= vfs_lib_ring_buffer_no_llseek
,
874 .compat_ioctl
= lttng_metadata_ring_buffer_compat_ioctl
,
879 int lttng_abi_create_stream_fd(struct file
*channel_file
, void *stream_priv
,
880 const struct file_operations
*fops
)
883 struct file
*stream_file
;
885 stream_fd
= lttng_get_unused_fd();
890 stream_file
= anon_inode_getfile("[lttng_stream]", fops
,
891 stream_priv
, O_RDWR
);
892 if (IS_ERR(stream_file
)) {
893 ret
= PTR_ERR(stream_file
);
897 * OPEN_FMODE, called within anon_inode_getfile/alloc_file, don't honor
898 * FMODE_LSEEK, FMODE_PREAD nor FMODE_PWRITE. We need to read from this
899 * file descriptor, so we set FMODE_PREAD here.
901 stream_file
->f_mode
|= FMODE_PREAD
;
902 fd_install(stream_fd
, stream_file
);
904 * The stream holds a reference to the channel within the generic ring
905 * buffer library, so no need to hold a refcount on the channel and
906 * session files here.
911 put_unused_fd(stream_fd
);
917 int lttng_abi_open_stream(struct file
*channel_file
)
919 struct lttng_channel
*channel
= channel_file
->private_data
;
920 struct lib_ring_buffer
*buf
;
924 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
929 ret
= lttng_abi_create_stream_fd(channel_file
, stream_priv
,
930 <tng_stream_ring_buffer_file_operations
);
937 channel
->ops
->buffer_read_close(buf
);
942 int lttng_abi_open_metadata_stream(struct file
*channel_file
)
944 struct lttng_channel
*channel
= channel_file
->private_data
;
945 struct lttng_session
*session
= channel
->session
;
946 struct lib_ring_buffer
*buf
;
948 struct lttng_metadata_stream
*metadata_stream
;
951 buf
= channel
->ops
->buffer_read_open(channel
->chan
);
955 metadata_stream
= kzalloc(sizeof(struct lttng_metadata_stream
),
957 if (!metadata_stream
) {
961 metadata_stream
->metadata_cache
= session
->metadata_cache
;
962 init_waitqueue_head(&metadata_stream
->read_wait
);
963 metadata_stream
->priv
= buf
;
964 stream_priv
= metadata_stream
;
965 metadata_stream
->transport
= channel
->transport
;
968 * Since life-time of metadata cache differs from that of
969 * session, we need to keep our own reference on the transport.
971 if (!try_module_get(metadata_stream
->transport
->owner
)) {
972 printk(KERN_WARNING
"LTT : Can't lock transport module.\n");
977 if (!lttng_kref_get(&session
->metadata_cache
->refcount
)) {
982 ret
= lttng_abi_create_stream_fd(channel_file
, stream_priv
,
983 <tng_metadata_ring_buffer_file_operations
);
987 list_add(&metadata_stream
->list
,
988 &session
->metadata_cache
->metadata_stream
);
992 kref_put(&session
->metadata_cache
->refcount
, metadata_cache_destroy
);
994 module_put(metadata_stream
->transport
->owner
);
996 kfree(metadata_stream
);
998 channel
->ops
->buffer_read_close(buf
);
1003 int lttng_abi_create_event(struct file
*channel_file
,
1004 struct lttng_kernel_event
*event_param
)
1006 struct lttng_channel
*channel
= channel_file
->private_data
;
1008 struct file
*event_file
;
1011 event_param
->name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
1012 switch (event_param
->instrumentation
) {
1013 case LTTNG_KERNEL_KRETPROBE
:
1014 event_param
->u
.kretprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
1016 case LTTNG_KERNEL_KPROBE
:
1017 event_param
->u
.kprobe
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
1019 case LTTNG_KERNEL_FUNCTION
:
1020 event_param
->u
.ftrace
.symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
- 1] = '\0';
1025 event_fd
= lttng_get_unused_fd();
1030 event_file
= anon_inode_getfile("[lttng_event]",
1033 if (IS_ERR(event_file
)) {
1034 ret
= PTR_ERR(event_file
);
1037 /* The event holds a reference on the channel */
1038 if (atomic_long_add_unless(&channel_file
->f_count
,
1039 1, INT_MAX
) == INT_MAX
) {
1041 goto refcount_error
;
1043 if (event_param
->instrumentation
== LTTNG_KERNEL_TRACEPOINT
1044 || event_param
->instrumentation
== LTTNG_KERNEL_SYSCALL
) {
1045 struct lttng_enabler
*enabler
;
1047 if (event_param
->name
[strlen(event_param
->name
) - 1] == '*') {
1048 enabler
= lttng_enabler_create(LTTNG_ENABLER_WILDCARD
,
1049 event_param
, channel
);
1051 enabler
= lttng_enabler_create(LTTNG_ENABLER_NAME
,
1052 event_param
, channel
);
1056 struct lttng_event
*event
;
1059 * We tolerate no failure path after event creation. It
1060 * will stay invariant for the rest of the session.
1062 event
= lttng_event_create(channel
, event_param
,
1064 event_param
->instrumentation
);
1065 WARN_ON_ONCE(!event
);
1066 if (IS_ERR(event
)) {
1067 ret
= PTR_ERR(event
);
1072 event_file
->private_data
= priv
;
1073 fd_install(event_fd
, event_file
);
1077 atomic_long_dec(&channel_file
->f_count
);
1081 put_unused_fd(event_fd
);
1087 * lttng_channel_ioctl - lttng syscall through ioctl
1093 * This ioctl implements lttng commands:
1094 * LTTNG_KERNEL_STREAM
1095 * Returns an event stream file descriptor or failure.
1096 * (typically, one event stream records events from one CPU)
1097 * LTTNG_KERNEL_EVENT
1098 * Returns an event file descriptor or failure.
1099 * LTTNG_KERNEL_CONTEXT
1100 * Prepend a context field to each event in the channel
1101 * LTTNG_KERNEL_ENABLE
1102 * Enable recording for events in this channel (weak enable)
1103 * LTTNG_KERNEL_DISABLE
1104 * Disable recording for events in this channel (strong disable)
1106 * Channel and event file descriptors also hold a reference on the session.
1109 long lttng_channel_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1111 struct lttng_channel
*channel
= file
->private_data
;
1114 case LTTNG_KERNEL_OLD_STREAM
:
1115 case LTTNG_KERNEL_STREAM
:
1116 return lttng_abi_open_stream(file
);
1117 case LTTNG_KERNEL_OLD_EVENT
:
1119 struct lttng_kernel_event
*uevent_param
;
1120 struct lttng_kernel_old_event
*old_uevent_param
;
1123 uevent_param
= kmalloc(sizeof(struct lttng_kernel_event
),
1125 if (!uevent_param
) {
1129 old_uevent_param
= kmalloc(
1130 sizeof(struct lttng_kernel_old_event
),
1132 if (!old_uevent_param
) {
1134 goto old_event_error_free_param
;
1136 if (copy_from_user(old_uevent_param
,
1137 (struct lttng_kernel_old_event __user
*) arg
,
1138 sizeof(struct lttng_kernel_old_event
))) {
1140 goto old_event_error_free_old_param
;
1143 memcpy(uevent_param
->name
, old_uevent_param
->name
,
1144 sizeof(uevent_param
->name
));
1145 uevent_param
->instrumentation
=
1146 old_uevent_param
->instrumentation
;
1148 switch (old_uevent_param
->instrumentation
) {
1149 case LTTNG_KERNEL_KPROBE
:
1150 uevent_param
->u
.kprobe
.addr
=
1151 old_uevent_param
->u
.kprobe
.addr
;
1152 uevent_param
->u
.kprobe
.offset
=
1153 old_uevent_param
->u
.kprobe
.offset
;
1154 memcpy(uevent_param
->u
.kprobe
.symbol_name
,
1155 old_uevent_param
->u
.kprobe
.symbol_name
,
1156 sizeof(uevent_param
->u
.kprobe
.symbol_name
));
1158 case LTTNG_KERNEL_KRETPROBE
:
1159 uevent_param
->u
.kretprobe
.addr
=
1160 old_uevent_param
->u
.kretprobe
.addr
;
1161 uevent_param
->u
.kretprobe
.offset
=
1162 old_uevent_param
->u
.kretprobe
.offset
;
1163 memcpy(uevent_param
->u
.kretprobe
.symbol_name
,
1164 old_uevent_param
->u
.kretprobe
.symbol_name
,
1165 sizeof(uevent_param
->u
.kretprobe
.symbol_name
));
1167 case LTTNG_KERNEL_FUNCTION
:
1168 memcpy(uevent_param
->u
.ftrace
.symbol_name
,
1169 old_uevent_param
->u
.ftrace
.symbol_name
,
1170 sizeof(uevent_param
->u
.ftrace
.symbol_name
));
1175 ret
= lttng_abi_create_event(file
, uevent_param
);
1177 old_event_error_free_old_param
:
1178 kfree(old_uevent_param
);
1179 old_event_error_free_param
:
1180 kfree(uevent_param
);
1184 case LTTNG_KERNEL_EVENT
:
1186 struct lttng_kernel_event uevent_param
;
1188 if (copy_from_user(&uevent_param
,
1189 (struct lttng_kernel_event __user
*) arg
,
1190 sizeof(uevent_param
)))
1192 return lttng_abi_create_event(file
, &uevent_param
);
1194 case LTTNG_KERNEL_OLD_CONTEXT
:
1196 struct lttng_kernel_context
*ucontext_param
;
1197 struct lttng_kernel_old_context
*old_ucontext_param
;
1200 ucontext_param
= kmalloc(sizeof(struct lttng_kernel_context
),
1202 if (!ucontext_param
) {
1206 old_ucontext_param
= kmalloc(sizeof(struct lttng_kernel_old_context
),
1208 if (!old_ucontext_param
) {
1210 goto old_ctx_error_free_param
;
1213 if (copy_from_user(old_ucontext_param
,
1214 (struct lttng_kernel_old_context __user
*) arg
,
1215 sizeof(struct lttng_kernel_old_context
))) {
1217 goto old_ctx_error_free_old_param
;
1219 ucontext_param
->ctx
= old_ucontext_param
->ctx
;
1220 memcpy(ucontext_param
->padding
, old_ucontext_param
->padding
,
1221 sizeof(ucontext_param
->padding
));
1222 /* only type that uses the union */
1223 if (old_ucontext_param
->ctx
== LTTNG_KERNEL_CONTEXT_PERF_COUNTER
) {
1224 ucontext_param
->u
.perf_counter
.type
=
1225 old_ucontext_param
->u
.perf_counter
.type
;
1226 ucontext_param
->u
.perf_counter
.config
=
1227 old_ucontext_param
->u
.perf_counter
.config
;
1228 memcpy(ucontext_param
->u
.perf_counter
.name
,
1229 old_ucontext_param
->u
.perf_counter
.name
,
1230 sizeof(ucontext_param
->u
.perf_counter
.name
));
1233 ret
= lttng_abi_add_context(file
,
1235 &channel
->ctx
, channel
->session
);
1237 old_ctx_error_free_old_param
:
1238 kfree(old_ucontext_param
);
1239 old_ctx_error_free_param
:
1240 kfree(ucontext_param
);
1244 case LTTNG_KERNEL_CONTEXT
:
1246 struct lttng_kernel_context ucontext_param
;
1248 if (copy_from_user(&ucontext_param
,
1249 (struct lttng_kernel_context __user
*) arg
,
1250 sizeof(ucontext_param
)))
1252 return lttng_abi_add_context(file
,
1254 &channel
->ctx
, channel
->session
);
1256 case LTTNG_KERNEL_OLD_ENABLE
:
1257 case LTTNG_KERNEL_ENABLE
:
1258 return lttng_channel_enable(channel
);
1259 case LTTNG_KERNEL_OLD_DISABLE
:
1260 case LTTNG_KERNEL_DISABLE
:
1261 return lttng_channel_disable(channel
);
1262 case LTTNG_KERNEL_SYSCALL_MASK
:
1263 return lttng_channel_syscall_mask(channel
,
1264 (struct lttng_kernel_syscall_mask __user
*) arg
);
1266 return -ENOIOCTLCMD
;
1272 * lttng_metadata_ioctl - lttng syscall through ioctl
1278 * This ioctl implements lttng commands:
1279 * LTTNG_KERNEL_STREAM
1280 * Returns an event stream file descriptor or failure.
1282 * Channel and event file descriptors also hold a reference on the session.
1285 long lttng_metadata_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1288 case LTTNG_KERNEL_OLD_STREAM
:
1289 case LTTNG_KERNEL_STREAM
:
1290 return lttng_abi_open_metadata_stream(file
);
1292 return -ENOIOCTLCMD
;
1297 * lttng_channel_poll - lttng stream addition/removal monitoring
1302 unsigned int lttng_channel_poll(struct file
*file
, poll_table
*wait
)
1304 struct lttng_channel
*channel
= file
->private_data
;
1305 unsigned int mask
= 0;
1307 if (file
->f_mode
& FMODE_READ
) {
1308 poll_wait_set_exclusive(wait
);
1309 poll_wait(file
, channel
->ops
->get_hp_wait_queue(channel
->chan
),
1312 if (channel
->ops
->is_disabled(channel
->chan
))
1314 if (channel
->ops
->is_finalized(channel
->chan
))
1316 if (channel
->ops
->buffer_has_read_closed_stream(channel
->chan
))
1317 return POLLIN
| POLLRDNORM
;
1325 int lttng_channel_release(struct inode
*inode
, struct file
*file
)
1327 struct lttng_channel
*channel
= file
->private_data
;
1330 fput(channel
->session
->file
);
1335 int lttng_metadata_channel_release(struct inode
*inode
, struct file
*file
)
1337 struct lttng_channel
*channel
= file
->private_data
;
1340 fput(channel
->session
->file
);
1341 lttng_metadata_channel_destroy(channel
);
1347 static const struct file_operations lttng_channel_fops
= {
1348 .owner
= THIS_MODULE
,
1349 .release
= lttng_channel_release
,
1350 .poll
= lttng_channel_poll
,
1351 .unlocked_ioctl
= lttng_channel_ioctl
,
1352 #ifdef CONFIG_COMPAT
1353 .compat_ioctl
= lttng_channel_ioctl
,
1357 static const struct file_operations lttng_metadata_fops
= {
1358 .owner
= THIS_MODULE
,
1359 .release
= lttng_metadata_channel_release
,
1360 .unlocked_ioctl
= lttng_metadata_ioctl
,
1361 #ifdef CONFIG_COMPAT
1362 .compat_ioctl
= lttng_metadata_ioctl
,
1367 * lttng_event_ioctl - lttng syscall through ioctl
1373 * This ioctl implements lttng commands:
1374 * LTTNG_KERNEL_CONTEXT
1375 * Prepend a context field to each record of this event
1376 * LTTNG_KERNEL_ENABLE
1377 * Enable recording for this event (weak enable)
1378 * LTTNG_KERNEL_DISABLE
1379 * Disable recording for this event (strong disable)
1382 long lttng_event_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1384 struct lttng_event
*event
;
1385 struct lttng_enabler
*enabler
;
1386 enum lttng_event_type
*evtype
= file
->private_data
;
1389 case LTTNG_KERNEL_OLD_CONTEXT
:
1391 /* Not implemented */
1394 case LTTNG_KERNEL_CONTEXT
:
1396 /* Not implemented */
1399 case LTTNG_KERNEL_OLD_ENABLE
:
1400 case LTTNG_KERNEL_ENABLE
:
1402 case LTTNG_TYPE_EVENT
:
1403 event
= file
->private_data
;
1404 return lttng_event_enable(event
);
1405 case LTTNG_TYPE_ENABLER
:
1406 enabler
= file
->private_data
;
1407 return lttng_enabler_enable(enabler
);
1412 case LTTNG_KERNEL_OLD_DISABLE
:
1413 case LTTNG_KERNEL_DISABLE
:
1415 case LTTNG_TYPE_EVENT
:
1416 event
= file
->private_data
;
1417 return lttng_event_disable(event
);
1418 case LTTNG_TYPE_ENABLER
:
1419 enabler
= file
->private_data
;
1420 return lttng_enabler_disable(enabler
);
1425 case LTTNG_KERNEL_FILTER
:
1427 case LTTNG_TYPE_EVENT
:
1429 case LTTNG_TYPE_ENABLER
:
1431 enabler
= file
->private_data
;
1432 return lttng_enabler_attach_bytecode(enabler
,
1433 (struct lttng_kernel_filter_bytecode __user
*) arg
);
1438 return -ENOIOCTLCMD
;
1443 int lttng_event_release(struct inode
*inode
, struct file
*file
)
1445 struct lttng_event
*event
;
1446 struct lttng_enabler
*enabler
;
1447 enum lttng_event_type
*evtype
= file
->private_data
;
1453 case LTTNG_TYPE_EVENT
:
1454 event
= file
->private_data
;
1456 fput(event
->chan
->file
);
1458 case LTTNG_TYPE_ENABLER
:
1459 enabler
= file
->private_data
;
1461 fput(enabler
->chan
->file
);
1471 /* TODO: filter control ioctl */
1472 static const struct file_operations lttng_event_fops
= {
1473 .owner
= THIS_MODULE
,
1474 .release
= lttng_event_release
,
1475 .unlocked_ioctl
= lttng_event_ioctl
,
1476 #ifdef CONFIG_COMPAT
1477 .compat_ioctl
= lttng_event_ioctl
,
1481 static int put_u64(uint64_t val
, unsigned long arg
)
1483 return put_user(val
, (uint64_t __user
*) arg
);
1486 static long lttng_stream_ring_buffer_ioctl(struct file
*filp
,
1487 unsigned int cmd
, unsigned long arg
)
1489 struct lib_ring_buffer
*buf
= filp
->private_data
;
1490 struct channel
*chan
= buf
->backend
.chan
;
1491 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
1492 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
1495 if (atomic_read(&chan
->record_disabled
))
1499 case LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN
:
1503 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
1506 return put_u64(ts
, arg
);
1508 case LTTNG_RING_BUFFER_GET_TIMESTAMP_END
:
1512 ret
= ops
->timestamp_end(config
, buf
, &ts
);
1515 return put_u64(ts
, arg
);
1517 case LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED
:
1521 ret
= ops
->events_discarded(config
, buf
, &ed
);
1524 return put_u64(ed
, arg
);
1526 case LTTNG_RING_BUFFER_GET_CONTENT_SIZE
:
1530 ret
= ops
->content_size(config
, buf
, &cs
);
1533 return put_u64(cs
, arg
);
1535 case LTTNG_RING_BUFFER_GET_PACKET_SIZE
:
1539 ret
= ops
->packet_size(config
, buf
, &ps
);
1542 return put_u64(ps
, arg
);
1544 case LTTNG_RING_BUFFER_GET_STREAM_ID
:
1548 ret
= ops
->stream_id(config
, buf
, &si
);
1551 return put_u64(si
, arg
);
1553 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
1557 ret
= ops
->current_timestamp(config
, buf
, &ts
);
1560 return put_u64(ts
, arg
);
1562 case LTTNG_RING_BUFFER_GET_SEQ_NUM
:
1566 ret
= ops
->sequence_number(config
, buf
, &seq
);
1569 return put_u64(seq
, arg
);
1571 case LTTNG_RING_BUFFER_INSTANCE_ID
:
1575 ret
= ops
->instance_id(config
, buf
, &id
);
1578 return put_u64(id
, arg
);
1581 return lib_ring_buffer_file_operations
.unlocked_ioctl(filp
,
1589 #ifdef CONFIG_COMPAT
1590 static long lttng_stream_ring_buffer_compat_ioctl(struct file
*filp
,
1591 unsigned int cmd
, unsigned long arg
)
1593 struct lib_ring_buffer
*buf
= filp
->private_data
;
1594 struct channel
*chan
= buf
->backend
.chan
;
1595 const struct lib_ring_buffer_config
*config
= &chan
->backend
.config
;
1596 const struct lttng_channel_ops
*ops
= chan
->backend
.priv_ops
;
1599 if (atomic_read(&chan
->record_disabled
))
1603 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN
:
1607 ret
= ops
->timestamp_begin(config
, buf
, &ts
);
1610 return put_u64(ts
, arg
);
1612 case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END
:
1616 ret
= ops
->timestamp_end(config
, buf
, &ts
);
1619 return put_u64(ts
, arg
);
1621 case LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED
:
1625 ret
= ops
->events_discarded(config
, buf
, &ed
);
1628 return put_u64(ed
, arg
);
1630 case LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE
:
1634 ret
= ops
->content_size(config
, buf
, &cs
);
1637 return put_u64(cs
, arg
);
1639 case LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE
:
1643 ret
= ops
->packet_size(config
, buf
, &ps
);
1646 return put_u64(ps
, arg
);
1648 case LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID
:
1652 ret
= ops
->stream_id(config
, buf
, &si
);
1655 return put_u64(si
, arg
);
1657 case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
:
1661 ret
= ops
->current_timestamp(config
, buf
, &ts
);
1664 return put_u64(ts
, arg
);
1666 case LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM
:
1670 ret
= ops
->sequence_number(config
, buf
, &seq
);
1673 return put_u64(seq
, arg
);
1675 case LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID
:
1679 ret
= ops
->instance_id(config
, buf
, &id
);
1682 return put_u64(id
, arg
);
1685 return lib_ring_buffer_file_operations
.compat_ioctl(filp
,
1692 #endif /* CONFIG_COMPAT */
1694 static void lttng_stream_override_ring_buffer_fops(void)
1696 lttng_stream_ring_buffer_file_operations
.owner
= THIS_MODULE
;
1697 lttng_stream_ring_buffer_file_operations
.open
=
1698 lib_ring_buffer_file_operations
.open
;
1699 lttng_stream_ring_buffer_file_operations
.release
=
1700 lib_ring_buffer_file_operations
.release
;
1701 lttng_stream_ring_buffer_file_operations
.poll
=
1702 lib_ring_buffer_file_operations
.poll
;
1703 lttng_stream_ring_buffer_file_operations
.splice_read
=
1704 lib_ring_buffer_file_operations
.splice_read
;
1705 lttng_stream_ring_buffer_file_operations
.mmap
=
1706 lib_ring_buffer_file_operations
.mmap
;
1707 lttng_stream_ring_buffer_file_operations
.unlocked_ioctl
=
1708 lttng_stream_ring_buffer_ioctl
;
1709 lttng_stream_ring_buffer_file_operations
.llseek
=
1710 lib_ring_buffer_file_operations
.llseek
;
1711 #ifdef CONFIG_COMPAT
1712 lttng_stream_ring_buffer_file_operations
.compat_ioctl
=
1713 lttng_stream_ring_buffer_compat_ioctl
;
1717 int __init
lttng_abi_init(void)
1721 wrapper_vmalloc_sync_all();
1723 lttng_proc_dentry
= proc_create_data("lttng", S_IRUSR
| S_IWUSR
, NULL
,
1726 if (!lttng_proc_dentry
) {
1727 printk(KERN_ERR
"Error creating LTTng control file\n");
1731 lttng_stream_override_ring_buffer_fops();
1735 lttng_clock_unref();
1739 /* No __exit annotation because used by init error path too. */
1740 void lttng_abi_exit(void)
1742 lttng_clock_unref();
1743 if (lttng_proc_dentry
)
1744 remove_proc_entry("lttng", NULL
);