2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; only version 2
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include <lttng/ust-ctl.h>
23 #include <lttng/ust-abi.h>
24 #include <lttng/ust-events.h>
27 #include <usterr-signal-safe.h>
30 #include "../libringbuffer/backend.h"
31 #include "../libringbuffer/frontend.h"
33 volatile enum ust_loglevel ust_loglevel
;
36 void init_object(struct lttng_ust_object_data
*data
)
41 data
->memory_map_size
= 0;
44 int ustctl_release_handle(int sock
, int handle
)
46 struct ustcomm_ust_msg lum
;
47 struct ustcomm_ust_reply lur
;
51 memset(&lum
, 0, sizeof(lum
));
53 lum
.cmd
= LTTNG_UST_RELEASE
;
54 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
62 * If sock is negative, it means we don't have to notify the other side
63 * (e.g. application has already vanished).
65 int ustctl_release_object(int sock
, struct lttng_ust_object_data
*data
)
72 if (data
->shm_fd
>= 0) {
73 ret
= close(data
->shm_fd
);
78 if (data
->wait_fd
>= 0) {
79 ret
= close(data
->wait_fd
);
84 return ustctl_release_handle(sock
, data
->handle
);
88 * Send registration done packet to the application.
90 int ustctl_register_done(int sock
)
92 struct ustcomm_ust_msg lum
;
93 struct ustcomm_ust_reply lur
;
96 DBG("Sending register done command to %d", sock
);
97 memset(&lum
, 0, sizeof(lum
));
98 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
99 lum
.cmd
= LTTNG_UST_REGISTER_DONE
;
100 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
103 if (lur
.ret_code
!= USTCOMM_OK
) {
104 DBG("Return code: %s", ustcomm_get_readable_code(lur
.ret_code
));
114 * returns session handle.
116 int ustctl_create_session(int sock
)
118 struct ustcomm_ust_msg lum
;
119 struct ustcomm_ust_reply lur
;
120 int ret
, session_handle
;
123 memset(&lum
, 0, sizeof(lum
));
124 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
125 lum
.cmd
= LTTNG_UST_SESSION
;
126 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
129 session_handle
= lur
.ret_val
;
130 DBG("received session handle %u", session_handle
);
131 return session_handle
;
134 /* open the metadata global channel */
135 int ustctl_open_metadata(int sock
, int session_handle
,
136 struct lttng_ust_channel_attr
*chops
,
137 struct lttng_ust_object_data
**_metadata_data
)
139 struct ustcomm_ust_msg lum
;
140 struct ustcomm_ust_reply lur
;
141 struct lttng_ust_object_data
*metadata_data
;
144 if (!chops
|| !_metadata_data
)
147 metadata_data
= malloc(sizeof(*metadata_data
));
150 init_object(metadata_data
);
151 /* Create metadata channel */
152 memset(&lum
, 0, sizeof(lum
));
153 lum
.handle
= session_handle
;
154 lum
.cmd
= LTTNG_UST_METADATA
;
155 lum
.u
.channel
.overwrite
= chops
->overwrite
;
156 lum
.u
.channel
.subbuf_size
= chops
->subbuf_size
;
157 lum
.u
.channel
.num_subbuf
= chops
->num_subbuf
;
158 lum
.u
.channel
.switch_timer_interval
= chops
->switch_timer_interval
;
159 lum
.u
.channel
.read_timer_interval
= chops
->read_timer_interval
;
160 lum
.u
.channel
.output
= chops
->output
;
161 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
166 if (lur
.ret_code
!= USTCOMM_OK
) {
170 metadata_data
->handle
= lur
.ret_val
;
171 DBG("received metadata handle %u", metadata_data
->handle
);
172 metadata_data
->memory_map_size
= lur
.u
.channel
.memory_map_size
;
174 ret
= ustcomm_recv_fd(sock
);
178 metadata_data
->shm_fd
= ret
;
180 * We need to get the second FD even if the first fails, because
181 * libust expects us to read the two FDs.
184 ret
= ustcomm_recv_fd(sock
);
188 metadata_data
->wait_fd
= ret
;
191 *_metadata_data
= metadata_data
;
195 (void) ustctl_release_object(sock
, metadata_data
);
200 int ustctl_create_channel(int sock
, int session_handle
,
201 struct lttng_ust_channel_attr
*chops
,
202 struct lttng_ust_object_data
**_channel_data
)
204 struct ustcomm_ust_msg lum
;
205 struct ustcomm_ust_reply lur
;
206 struct lttng_ust_object_data
*channel_data
;
209 if (!chops
|| !_channel_data
)
212 channel_data
= malloc(sizeof(*channel_data
));
215 init_object(channel_data
);
216 /* Create metadata channel */
217 memset(&lum
, 0, sizeof(lum
));
218 lum
.handle
= session_handle
;
219 lum
.cmd
= LTTNG_UST_CHANNEL
;
220 lum
.u
.channel
.overwrite
= chops
->overwrite
;
221 lum
.u
.channel
.subbuf_size
= chops
->subbuf_size
;
222 lum
.u
.channel
.num_subbuf
= chops
->num_subbuf
;
223 lum
.u
.channel
.switch_timer_interval
= chops
->switch_timer_interval
;
224 lum
.u
.channel
.read_timer_interval
= chops
->read_timer_interval
;
225 lum
.u
.channel
.output
= chops
->output
;
226 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
231 if (lur
.ret_code
!= USTCOMM_OK
) {
235 channel_data
->handle
= lur
.ret_val
;
236 DBG("received channel handle %u", channel_data
->handle
);
237 channel_data
->memory_map_size
= lur
.u
.channel
.memory_map_size
;
239 ret
= ustcomm_recv_fd(sock
);
243 channel_data
->shm_fd
= ret
;
245 * We need to get the second FD even if the first fails, because
246 * libust expects us to read the two FDs.
249 ret
= ustcomm_recv_fd(sock
);
253 channel_data
->wait_fd
= ret
;
256 *_channel_data
= channel_data
;
260 (void) ustctl_release_object(sock
, channel_data
);
266 * Return -ENOENT if no more stream is available for creation.
267 * Return 0 on success.
268 * Return negative error value on error.
270 int ustctl_create_stream(int sock
, struct lttng_ust_object_data
*channel_data
,
271 struct lttng_ust_object_data
**_stream_data
)
273 struct ustcomm_ust_msg lum
;
274 struct ustcomm_ust_reply lur
;
275 struct lttng_ust_object_data
*stream_data
;
276 int ret
, fd
, err
= 0;
278 if (!channel_data
|| !_stream_data
)
281 stream_data
= malloc(sizeof(*stream_data
));
284 init_object(stream_data
);
285 memset(&lum
, 0, sizeof(lum
));
286 lum
.handle
= channel_data
->handle
;
287 lum
.cmd
= LTTNG_UST_STREAM
;
288 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
293 if (lur
.ret_code
!= USTCOMM_OK
) {
298 stream_data
->handle
= lur
.ret_val
;
299 DBG("received stream handle %u", stream_data
->handle
);
300 stream_data
->memory_map_size
= lur
.u
.stream
.memory_map_size
;
302 fd
= ustcomm_recv_fd(sock
);
306 stream_data
->shm_fd
= fd
;
308 * We need to get the second FD even if the first fails, because
309 * libust expects us to read the two FDs.
312 fd
= ustcomm_recv_fd(sock
);
316 stream_data
->wait_fd
= fd
;
319 *_stream_data
= stream_data
;
323 (void) ustctl_release_object(sock
, stream_data
);
328 int ustctl_create_event(int sock
, struct lttng_ust_event
*ev
,
329 struct lttng_ust_object_data
*channel_data
,
330 struct lttng_ust_object_data
**_event_data
)
332 struct ustcomm_ust_msg lum
;
333 struct ustcomm_ust_reply lur
;
334 struct lttng_ust_object_data
*event_data
;
337 if (!channel_data
|| !_event_data
)
340 event_data
= malloc(sizeof(*event_data
));
343 init_object(event_data
);
344 memset(&lum
, 0, sizeof(lum
));
345 lum
.handle
= channel_data
->handle
;
346 lum
.cmd
= LTTNG_UST_EVENT
;
347 strncpy(lum
.u
.event
.name
, ev
->name
,
348 LTTNG_UST_SYM_NAME_LEN
);
349 lum
.u
.event
.instrumentation
= ev
->instrumentation
;
350 lum
.u
.event
.loglevel_type
= ev
->loglevel_type
;
351 lum
.u
.event
.loglevel
= ev
->loglevel
;
352 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
357 event_data
->handle
= lur
.ret_val
;
358 DBG("received event handle %u", event_data
->handle
);
359 *_event_data
= event_data
;
363 int ustctl_add_context(int sock
, struct lttng_ust_context
*ctx
,
364 struct lttng_ust_object_data
*obj_data
,
365 struct lttng_ust_object_data
**_context_data
)
367 struct ustcomm_ust_msg lum
;
368 struct ustcomm_ust_reply lur
;
369 struct lttng_ust_object_data
*context_data
;
372 if (!obj_data
|| !_context_data
)
375 context_data
= malloc(sizeof(*context_data
));
378 init_object(context_data
);
379 memset(&lum
, 0, sizeof(lum
));
380 lum
.handle
= obj_data
->handle
;
381 lum
.cmd
= LTTNG_UST_CONTEXT
;
382 lum
.u
.context
.ctx
= ctx
->ctx
;
383 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
388 context_data
->handle
= lur
.ret_val
;
389 DBG("received context handle %u", context_data
->handle
);
390 *_context_data
= context_data
;
394 /* Enable event, channel and session ioctl */
395 int ustctl_enable(int sock
, struct lttng_ust_object_data
*object
)
397 struct ustcomm_ust_msg lum
;
398 struct ustcomm_ust_reply lur
;
404 memset(&lum
, 0, sizeof(lum
));
405 lum
.handle
= object
->handle
;
406 lum
.cmd
= LTTNG_UST_ENABLE
;
407 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
410 DBG("enabled handle %u", object
->handle
);
414 /* Disable event, channel and session ioctl */
415 int ustctl_disable(int sock
, struct lttng_ust_object_data
*object
)
417 struct ustcomm_ust_msg lum
;
418 struct ustcomm_ust_reply lur
;
424 memset(&lum
, 0, sizeof(lum
));
425 lum
.handle
= object
->handle
;
426 lum
.cmd
= LTTNG_UST_DISABLE
;
427 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
430 DBG("disable handle %u", object
->handle
);
434 int ustctl_start_session(int sock
, int handle
)
436 struct lttng_ust_object_data obj
;
439 return ustctl_enable(sock
, &obj
);
442 int ustctl_stop_session(int sock
, int handle
)
444 struct lttng_ust_object_data obj
;
447 return ustctl_disable(sock
, &obj
);
450 int ustctl_tracepoint_list(int sock
)
452 struct ustcomm_ust_msg lum
;
453 struct ustcomm_ust_reply lur
;
454 int ret
, tp_list_handle
;
456 memset(&lum
, 0, sizeof(lum
));
457 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
458 lum
.cmd
= LTTNG_UST_TRACEPOINT_LIST
;
459 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
462 tp_list_handle
= lur
.ret_val
;
463 DBG("received tracepoint list handle %u", tp_list_handle
);
464 return tp_list_handle
;
467 int ustctl_tracepoint_list_get(int sock
, int tp_list_handle
,
468 struct lttng_ust_tracepoint_iter
*iter
)
470 struct ustcomm_ust_msg lum
;
471 struct ustcomm_ust_reply lur
;
477 memset(&lum
, 0, sizeof(lum
));
478 lum
.handle
= tp_list_handle
;
479 lum
.cmd
= LTTNG_UST_TRACEPOINT_LIST_GET
;
480 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
483 DBG("received tracepoint list entry name %s loglevel %d",
484 lur
.u
.tracepoint
.name
,
485 lur
.u
.tracepoint
.loglevel
);
486 memcpy(iter
, &lur
.u
.tracepoint
, sizeof(*iter
));
490 int ustctl_tracer_version(int sock
, struct lttng_ust_tracer_version
*v
)
492 struct ustcomm_ust_msg lum
;
493 struct ustcomm_ust_reply lur
;
499 memset(&lum
, 0, sizeof(lum
));
500 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
501 lum
.cmd
= LTTNG_UST_TRACER_VERSION
;
502 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
505 memcpy(v
, &lur
.u
.version
, sizeof(*v
));
506 DBG("received tracer version");
510 int ustctl_wait_quiescent(int sock
)
512 struct ustcomm_ust_msg lum
;
513 struct ustcomm_ust_reply lur
;
516 memset(&lum
, 0, sizeof(lum
));
517 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
518 lum
.cmd
= LTTNG_UST_WAIT_QUIESCENT
;
519 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
522 DBG("waited for quiescent state");
526 int ustctl_calibrate(int sock
, struct lttng_ust_calibrate
*calibrate
)
534 int ustctl_sock_flush_buffer(int sock
, struct lttng_ust_object_data
*object
)
536 struct ustcomm_ust_msg lum
;
537 struct ustcomm_ust_reply lur
;
543 memset(&lum
, 0, sizeof(lum
));
544 lum
.handle
= object
->handle
;
545 lum
.cmd
= LTTNG_UST_FLUSH_BUFFER
;
546 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
549 DBG("flushed buffer handle %u", object
->handle
);
553 /* Buffer operations */
555 /* Map channel shm into process memory */
556 struct lttng_ust_shm_handle
*ustctl_map_channel(struct lttng_ust_object_data
*chan_data
)
558 struct lttng_ust_shm_handle
*handle
;
559 struct channel
*chan
;
561 struct lttng_ust_lib_ring_buffer_config
*config
;
567 handle
= channel_handle_create(chan_data
->shm_fd
,
569 chan_data
->memory_map_size
);
571 ERR("create handle error");
575 * Set to -1, and then close the shm fd, and set the handle shm
576 * fd to -1 too. We don't need the shm fds after they have been
578 * The wait_fd is set to -1 in chan_data because it is now owned
581 chan_data
->shm_fd
= -1;
582 chan_data
->wait_fd
= -1;
584 /* chan is object 0. This is hardcoded. */
585 if (handle
->table
->objects
[0].shm_fd
>= 0) {
586 ret
= close(handle
->table
->objects
[0].shm_fd
);
588 perror("Error closing shm_fd");
590 handle
->table
->objects
[0].shm_fd
= -1;
594 * TODO: add consistency checks to be resilient if the
595 * application try to feed us with incoherent channel structure
598 chan
= shmp(handle
, handle
->chan
);
599 /* chan is object 0. This is hardcoded. */
600 chan_size
= handle
->table
->objects
[0].allocated_len
;
601 handle
->shadow_chan
= malloc(chan_size
);
602 if (!handle
->shadow_chan
) {
603 channel_destroy(chan
, handle
, 1);
606 memcpy(handle
->shadow_chan
, chan
, chan_size
);
608 * The callback pointers in the producer are invalid in the
609 * consumer. We need to look them up here.
611 config
= &handle
->shadow_chan
->backend
.config
;
612 switch (config
->client_type
) {
613 case LTTNG_CLIENT_METADATA
:
614 memcpy(&config
->cb
, lttng_client_callbacks_metadata
,
617 case LTTNG_CLIENT_DISCARD
:
618 memcpy(&config
->cb
, lttng_client_callbacks_discard
,
621 case LTTNG_CLIENT_OVERWRITE
:
622 memcpy(&config
->cb
, lttng_client_callbacks_overwrite
,
626 ERR("Unknown client type %d", config
->client_type
);
627 channel_destroy(chan
, handle
, 1);
630 /* Replace the object table pointer. */
631 ret
= munmap(handle
->table
->objects
[0].memory_map
,
632 handle
->table
->objects
[0].memory_map_size
);
637 handle
->table
->objects
[0].memory_map
= (char *) handle
->shadow_chan
;
638 handle
->table
->objects
[0].is_shadow
= 1;
642 /* Add stream to channel shm and map its shm into process memory */
643 int ustctl_add_stream(struct lttng_ust_shm_handle
*handle
,
644 struct lttng_ust_object_data
*stream_data
)
648 if (!handle
|| !stream_data
)
651 if (!stream_data
->handle
)
654 ret
= channel_handle_add_stream(handle
,
656 stream_data
->wait_fd
,
657 stream_data
->memory_map_size
);
659 ERR("add stream error\n");
663 * Set to -1 because the lttng_ust_shm_handle destruction will take care
664 * of closing shm_fd and wait_fd.
666 stream_data
->shm_fd
= -1;
667 stream_data
->wait_fd
= -1;
671 void ustctl_unmap_channel(struct lttng_ust_shm_handle
*handle
)
673 struct channel
*chan
;
676 chan
= shmp(handle
, handle
->chan
);
677 channel_destroy(chan
, handle
, 1);
681 * ustctl closes the shm_fd fds after mapping it.
683 struct lttng_ust_lib_ring_buffer
*ustctl_open_stream_read(struct lttng_ust_shm_handle
*handle
,
686 struct channel
*chan
= handle
->shadow_chan
;
687 int *shm_fd
, *wait_fd
;
688 uint64_t *memory_map_size
;
689 struct lttng_ust_lib_ring_buffer
*buf
;
695 buf
= channel_get_ring_buffer(&chan
->backend
.config
,
696 chan
, cpu
, handle
, &shm_fd
, &wait_fd
, &memory_map_size
);
699 ret
= lib_ring_buffer_open_read(buf
, handle
, 1);
703 * We can close shm_fd early, right after is has been mapped.
706 ret
= close(*shm_fd
);
708 perror("Error closing shm_fd");
715 void ustctl_close_stream_read(struct lttng_ust_shm_handle
*handle
,
716 struct lttng_ust_lib_ring_buffer
*buf
)
718 assert(handle
&& buf
);
719 lib_ring_buffer_release_read(buf
, handle
, 1);
722 /* For mmap mode, readable without "get" operation */
724 void *ustctl_get_mmap_base(struct lttng_ust_shm_handle
*handle
,
725 struct lttng_ust_lib_ring_buffer
*buf
)
729 return shmp(handle
, buf
->backend
.memory_map
);
732 /* returns the length to mmap. */
733 int ustctl_get_mmap_len(struct lttng_ust_shm_handle
*handle
,
734 struct lttng_ust_lib_ring_buffer
*buf
,
737 unsigned long mmap_buf_len
;
738 struct channel
*chan
= handle
->shadow_chan
;
740 if (!handle
|| !buf
|| !len
)
743 if (chan
->backend
.config
.output
!= RING_BUFFER_MMAP
)
745 mmap_buf_len
= chan
->backend
.buf_size
;
746 if (chan
->backend
.extra_reader_sb
)
747 mmap_buf_len
+= chan
->backend
.subbuf_size
;
748 if (mmap_buf_len
> INT_MAX
)
754 /* returns the maximum size for sub-buffers. */
755 int ustctl_get_max_subbuf_size(struct lttng_ust_shm_handle
*handle
,
756 struct lttng_ust_lib_ring_buffer
*buf
,
759 struct channel
*chan
= handle
->shadow_chan
;
761 if (!handle
|| !buf
|| !len
)
764 *len
= chan
->backend
.subbuf_size
;
769 * For mmap mode, operate on the current packet (between get/put or
770 * get_next/put_next).
773 /* returns the offset of the subbuffer belonging to the mmap reader. */
774 int ustctl_get_mmap_read_offset(struct lttng_ust_shm_handle
*handle
,
775 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *off
)
777 struct channel
*chan
= handle
->shadow_chan
;
778 unsigned long sb_bindex
;
780 if (!handle
|| !buf
|| !off
)
783 if (chan
->backend
.config
.output
!= RING_BUFFER_MMAP
)
785 sb_bindex
= subbuffer_id_get_index(&chan
->backend
.config
,
786 buf
->backend
.buf_rsb
.id
);
787 *off
= shmp(handle
, shmp_index(handle
, buf
->backend
.array
, sb_bindex
)->shmp
)->mmap_offset
;
791 /* returns the size of the current sub-buffer, without padding (for mmap). */
792 int ustctl_get_subbuf_size(struct lttng_ust_shm_handle
*handle
,
793 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *len
)
795 struct channel
*chan
= handle
->shadow_chan
;
797 if (!handle
|| !buf
|| !len
)
800 *len
= lib_ring_buffer_get_read_data_size(&chan
->backend
.config
, buf
,
805 /* returns the size of the current sub-buffer, without padding (for mmap). */
806 int ustctl_get_padded_subbuf_size(struct lttng_ust_shm_handle
*handle
,
807 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *len
)
809 struct channel
*chan
= handle
->shadow_chan
;
811 if (!handle
|| !buf
|| !len
)
814 *len
= lib_ring_buffer_get_read_data_size(&chan
->backend
.config
, buf
,
816 *len
= PAGE_ALIGN(*len
);
820 /* Get exclusive read access to the next sub-buffer that can be read. */
821 int ustctl_get_next_subbuf(struct lttng_ust_shm_handle
*handle
,
822 struct lttng_ust_lib_ring_buffer
*buf
)
827 return lib_ring_buffer_get_next_subbuf(buf
, handle
);
831 /* Release exclusive sub-buffer access, move consumer forward. */
832 int ustctl_put_next_subbuf(struct lttng_ust_shm_handle
*handle
,
833 struct lttng_ust_lib_ring_buffer
*buf
)
838 lib_ring_buffer_put_next_subbuf(buf
, handle
);
844 /* Get a snapshot of the current ring buffer producer and consumer positions */
845 int ustctl_snapshot(struct lttng_ust_shm_handle
*handle
,
846 struct lttng_ust_lib_ring_buffer
*buf
)
851 return lib_ring_buffer_snapshot(buf
, &buf
->cons_snapshot
,
852 &buf
->prod_snapshot
, handle
);
855 /* Get the consumer position (iteration start) */
856 int ustctl_snapshot_get_consumed(struct lttng_ust_shm_handle
*handle
,
857 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *pos
)
859 if (!handle
|| !buf
|| !pos
)
862 *pos
= buf
->cons_snapshot
;
866 /* Get the producer position (iteration end) */
867 int ustctl_snapshot_get_produced(struct lttng_ust_shm_handle
*handle
,
868 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *pos
)
870 if (!handle
|| !buf
|| !pos
)
873 *pos
= buf
->prod_snapshot
;
877 /* Get exclusive read access to the specified sub-buffer position */
878 int ustctl_get_subbuf(struct lttng_ust_shm_handle
*handle
,
879 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *pos
)
881 if (!handle
|| !buf
|| !pos
)
884 return lib_ring_buffer_get_subbuf(buf
, *pos
, handle
);
887 /* Release exclusive sub-buffer access */
888 int ustctl_put_subbuf(struct lttng_ust_shm_handle
*handle
,
889 struct lttng_ust_lib_ring_buffer
*buf
)
894 lib_ring_buffer_put_subbuf(buf
, handle
);
898 void ustctl_flush_buffer(struct lttng_ust_shm_handle
*handle
,
899 struct lttng_ust_lib_ring_buffer
*buf
,
902 assert(handle
&& buf
);
903 lib_ring_buffer_switch_slow(buf
,
904 producer_active
? SWITCH_ACTIVE
: SWITCH_FLUSH
,