ring buffer context: cpu number becomes an output of reserve
[lttng-ust.git] / liblttng-ust-ctl / ustctl.c
index e7ce1f887a5d3b85d896c1c4a264b81ebfd639d2..394e14174f6985bd0798e77c0ef1a99ebc2770a0 100644 (file)
@@ -45,7 +45,7 @@
  * Channel representation within consumer.
  */
 struct ustctl_consumer_channel {
-       struct lttng_channel *chan;             /* lttng channel buffers */
+       struct lttng_ust_channel_buffer *chan;  /* lttng channel buffers */
 
        /* initial attributes */
        struct ustctl_consumer_channel_attr attr;
@@ -94,13 +94,17 @@ extern void lttng_ring_buffer_client_overwrite_rt_exit(void);
 extern void lttng_ring_buffer_client_discard_exit(void);
 extern void lttng_ring_buffer_client_discard_rt_exit(void);
 extern void lttng_ring_buffer_metadata_client_exit(void);
-LTTNG_HIDDEN
+
+__attribute__((visibility("hidden")))
 extern void lttng_counter_client_percpu_32_modular_init(void);
-LTTNG_HIDDEN
+
+__attribute__((visibility("hidden")))
 extern void lttng_counter_client_percpu_32_modular_exit(void);
-LTTNG_HIDDEN
+
+__attribute__((visibility("hidden")))
 extern void lttng_counter_client_percpu_64_modular_init(void);
-LTTNG_HIDDEN
+
+__attribute__((visibility("hidden")))
 extern void lttng_counter_client_percpu_64_modular_exit(void);
 
 int ustctl_release_handle(int sock, int handle)
@@ -583,9 +587,10 @@ int ustctl_create_event_notifier(int sock, struct lttng_ust_abi_event_notifier *
                free(event_notifier_data);
                return ret;
        }
-       /* Send struct lttng_ust_event_notifier */
+       /* Send struct lttng_ust_abi_event_notifier */
        len = ustcomm_send_unix_sock(sock, event_notifier, sizeof(*event_notifier));
        if (len != sizeof(*event_notifier)) {
+               free(event_notifier_data);
                if (len < 0)
                        return len;
                else
@@ -1264,7 +1269,7 @@ struct ustctl_consumer_channel *
                return NULL;
        }
 
-       transport = lttng_transport_find(transport_name);
+       transport = lttng_ust_transport_find(transport_name);
        if (!transport) {
                DBG("LTTng transport %s not found\n",
                        transport_name);
@@ -1275,7 +1280,7 @@ struct ustctl_consumer_channel *
        if (!chan)
                return NULL;
 
-       chan->chan = transport->ops.channel_create(transport_name, NULL,
+       chan->chan = transport->ops.priv->channel_create(transport_name, NULL,
                        attr->subbuf_size, attr->num_subbuf,
                        attr->switch_timer_interval,
                        attr->read_timer_interval,
@@ -1300,7 +1305,7 @@ void ustctl_destroy_channel(struct ustctl_consumer_channel *chan)
 {
        (void) ustctl_channel_close_wait_fd(chan);
        (void) ustctl_channel_close_wakeup_fd(chan);
-       chan->chan->ops->channel_destroy(chan->chan);
+       chan->chan->ops->priv->channel_destroy(chan->chan);
        free(chan);
 }
 
@@ -1339,17 +1344,17 @@ int ustctl_write_metadata_to_channel(
                size_t len)                     /* metadata length */
 {
        struct lttng_ust_lib_ring_buffer_ctx ctx;
-       struct lttng_channel *chan = channel->chan;
+       struct lttng_ust_channel_buffer *lttng_chan_buf = channel->chan;
        const char *str = metadata_str;
        int ret = 0, waitret;
        size_t reserve_len, pos;
 
        for (pos = 0; pos < len; pos += reserve_len) {
                reserve_len = min_t(size_t,
-                               chan->ops->packet_avail_size(chan->chan, chan->handle),
+                               lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf->chan, lttng_chan_buf->handle),
                                len - pos);
-               lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len,
-                                        sizeof(char), -1, chan->handle, NULL);
+               lib_ring_buffer_ctx_init(&ctx, lttng_chan_buf->chan, NULL, reserve_len,
+                                        sizeof(char), lttng_chan_buf->handle);
                /*
                 * We don't care about metadata buffer's records lost
                 * count, because we always retry here. Report error if
@@ -1358,7 +1363,7 @@ int ustctl_write_metadata_to_channel(
                 */
                waitret = wait_cond_interruptible_timeout(
                        ({
-                               ret = chan->ops->event_reserve(&ctx, 0);
+                               ret = lttng_chan_buf->ops->event_reserve(&ctx, 0);
                                ret != -ENOBUFS || !ret;
                        }),
                        LTTNG_METADATA_TIMEOUT_MSEC);
@@ -1370,8 +1375,8 @@ int ustctl_write_metadata_to_channel(
                                ret = waitret;
                        goto end;
                }
-               chan->ops->event_write(&ctx, &str[pos], reserve_len);
-               chan->ops->event_commit(&ctx);
+               lttng_chan_buf->ops->event_write(&ctx, &str[pos], reserve_len);
+               lttng_chan_buf->ops->event_commit(&ctx);
        }
 end:
        return ret;
@@ -1387,25 +1392,25 @@ ssize_t ustctl_write_one_packet_to_channel(
                size_t len)                     /* metadata length */
 {
        struct lttng_ust_lib_ring_buffer_ctx ctx;
-       struct lttng_channel *chan = channel->chan;
+       struct lttng_ust_channel_buffer *lttng_chan_buf = channel->chan;
        const char *str = metadata_str;
        ssize_t reserve_len;
        int ret;
 
        reserve_len = min_t(ssize_t,
-                       chan->ops->packet_avail_size(chan->chan, chan->handle),
+                       lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf->chan, lttng_chan_buf->handle),
                        len);
-       lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len,
-                       sizeof(char), -1, chan->handle, NULL);
-       ret = chan->ops->event_reserve(&ctx, 0);
+       lib_ring_buffer_ctx_init(&ctx, lttng_chan_buf->chan, NULL, reserve_len,
+                       sizeof(char), lttng_chan_buf->handle);
+       ret = lttng_chan_buf->ops->event_reserve(&ctx, 0);
        if (ret != 0) {
                DBG("LTTng: event reservation failed");
                assert(ret < 0);
                reserve_len = ret;
                goto end;
        }
-       chan->ops->event_write(&ctx, str, reserve_len);
-       chan->ops->event_commit(&ctx);
+       lttng_chan_buf->ops->event_write(&ctx, str, reserve_len);
+       lttng_chan_buf->ops->event_commit(&ctx);
 
 end:
        return reserve_len;
@@ -1413,7 +1418,7 @@ end:
 
 int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan)
 {
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
        int ret;
 
        chan = consumer_chan->chan->chan;
@@ -1426,7 +1431,7 @@ int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan)
 
 int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan)
 {
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
        int ret;
 
        chan = consumer_chan->chan->chan;
@@ -1439,7 +1444,7 @@ int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan
 
 int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream)
 {
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
 
        chan = stream->chan->chan->chan;
        return ring_buffer_stream_close_wait_fd(&chan->backend.config,
@@ -1448,7 +1453,7 @@ int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream)
 
 int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream)
 {
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
 
        chan = stream->chan->chan->chan;
        return ring_buffer_stream_close_wakeup_fd(&chan->backend.config,
@@ -1461,7 +1466,7 @@ struct ustctl_consumer_stream *
 {
        struct ustctl_consumer_stream *stream;
        struct lttng_ust_shm_handle *handle;
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
        int shm_fd, wait_fd, wakeup_fd;
        uint64_t memory_map_size;
        struct lttng_ust_lib_ring_buffer *buf;
@@ -1574,7 +1579,7 @@ int ustctl_get_mmap_len(struct ustctl_consumer_stream *stream,
 {
        struct ustctl_consumer_channel *consumer_chan;
        unsigned long mmap_buf_len;
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
 
        if (!stream)
                return -EINVAL;
@@ -1596,7 +1601,7 @@ int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream,
                unsigned long *len)
 {
        struct ustctl_consumer_channel *consumer_chan;
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
 
        if (!stream)
                return -EINVAL;
@@ -1615,7 +1620,7 @@ int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream,
 int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream,
                unsigned long *off)
 {
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
        unsigned long sb_bindex;
        struct lttng_ust_lib_ring_buffer *buf;
        struct ustctl_consumer_channel *consumer_chan;
@@ -1647,7 +1652,7 @@ int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream,
                unsigned long *len)
 {
        struct ustctl_consumer_channel *consumer_chan;
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
        struct lttng_ust_lib_ring_buffer *buf;
 
        if (!stream)
@@ -1666,7 +1671,7 @@ int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream,
                unsigned long *len)
 {
        struct ustctl_consumer_channel *consumer_chan;
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
        struct lttng_ust_lib_ring_buffer *buf;
 
        if (!stream)
@@ -1831,7 +1836,7 @@ struct lttng_ust_client_lib_ring_buffer_client_cb *get_client_cb(
                struct lttng_ust_lib_ring_buffer *buf,
                struct lttng_ust_shm_handle *handle)
 {
-       struct channel *chan;
+       struct lttng_ust_lib_ring_buffer_channel *chan;
        const struct lttng_ust_lib_ring_buffer_config *config;
        struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
 
@@ -2000,7 +2005,7 @@ int ustctl_get_instance_id(struct ustctl_consumer_stream *stream,
        return client_cb->instance_id(buf, handle, id);
 }
 
-#ifdef HAVE_PERF_EVENT
+#ifdef HAVE_LINUX_PERF_EVENT_H
 
 int ustctl_has_perf_counters(void)
 {
This page took 0.027559 seconds and 4 git commands to generate.