X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust-ctl%2Fustctl.c;h=a12e9dd377a008a308e2a9433ca5f370c7d49dd9;hb=6ba6fd60507f8e045bdc4f1be14e9d99c6a15f7f;hp=d1e7eb4ef6143b4c9f3478ee2252a6f4d0c312b4;hpb=4c4f4917501326b2ede0486a18478e4a6941c287;p=lttng-ust.git diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index d1e7eb4e..a12e9dd3 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -30,6 +30,7 @@ #include "../liblttng-ust/clock.h" #include "../liblttng-ust/getenv.h" #include "../liblttng-ust/lttng-tracer-core.h" +#include "../liblttng-ust/lttng-counter-client.h" #include "../libcounter/shm.h" #include "../libcounter/smp.h" @@ -45,7 +46,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; @@ -57,7 +58,6 @@ struct ustctl_consumer_channel { * Stream representation within consumer. */ struct ustctl_consumer_stream { - struct lttng_ust_shm_handle *handle; /* shared-memory handle */ struct lttng_ust_lib_ring_buffer *buf; struct ustctl_consumer_channel *chan; int shm_fd, wait_fd, wakeup_fd; @@ -84,29 +84,6 @@ struct ustctl_daemon_counter { struct ustctl_counter_attr *attr; /* initial attributes */ }; -extern void lttng_ring_buffer_client_overwrite_init(void); -extern void lttng_ring_buffer_client_overwrite_rt_init(void); -extern void lttng_ring_buffer_client_discard_init(void); -extern void lttng_ring_buffer_client_discard_rt_init(void); -extern void lttng_ring_buffer_metadata_client_init(void); -extern void lttng_ring_buffer_client_overwrite_exit(void); -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); - -__attribute__((visibility("hidden"))) -extern void lttng_counter_client_percpu_32_modular_init(void); - -__attribute__((visibility("hidden"))) -extern void lttng_counter_client_percpu_32_modular_exit(void); - -__attribute__((visibility("hidden"))) -extern void lttng_counter_client_percpu_64_modular_init(void); - -__attribute__((visibility("hidden"))) -extern void lttng_counter_client_percpu_64_modular_exit(void); - int ustctl_release_handle(int sock, int handle) { struct ustcomm_ust_msg lum; @@ -587,7 +564,7 @@ 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); @@ -730,7 +707,8 @@ int ustctl_wait_quiescent(int sock) return 0; } -int ustctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate) +int ustctl_calibrate(int sock __attribute__((unused)), + struct lttng_ust_abi_calibrate *calibrate) { if (!calibrate) return -EINVAL; @@ -1314,7 +1292,7 @@ int ustctl_send_channel_to_sessiond(int sock, { struct shm_object_table *table; - table = channel->chan->handle->table; + table = channel->chan->priv->rb_chan->handle->table; if (table->size <= 0) return -EINVAL; return ustctl_send_channel(sock, @@ -1344,17 +1322,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; + struct lttng_ust_lib_ring_buffer_channel *rb_chan = lttng_chan_buf->priv->rb_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->priv->packet_avail_size(chan->chan, chan->handle), + lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf), len - pos); - lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len, - sizeof(char), -1, chan->handle); + lttng_ust_lib_ring_buffer_ctx_init(&ctx, rb_chan, reserve_len, sizeof(char), NULL); /* * We don't care about metadata buffer's records lost * count, because we always retry here. Report error if @@ -1363,7 +1341,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); ret != -ENOBUFS || !ret; }), LTTNG_METADATA_TIMEOUT_MSEC); @@ -1375,8 +1353,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, 1); + lttng_chan_buf->ops->event_commit(&ctx); } end: return ret; @@ -1392,25 +1370,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; + struct lttng_ust_lib_ring_buffer_channel *rb_chan = lttng_chan_buf->priv->rb_chan; const char *str = metadata_str; ssize_t reserve_len; int ret; reserve_len = min_t(ssize_t, - chan->ops->priv->packet_avail_size(chan->chan, chan->handle), + lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf), len); - lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len, - sizeof(char), -1, chan->handle); - ret = chan->ops->event_reserve(&ctx, 0); + lttng_ust_lib_ring_buffer_ctx_init(&ctx, rb_chan, reserve_len, sizeof(char), NULL); + ret = lttng_chan_buf->ops->event_reserve(&ctx); 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, 1); + lttng_chan_buf->ops->event_commit(&ctx); end: return reserve_len; @@ -1421,7 +1399,7 @@ int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan) struct lttng_ust_lib_ring_buffer_channel *chan; int ret; - chan = consumer_chan->chan->chan; + chan = consumer_chan->chan->priv->rb_chan; ret = ring_buffer_channel_close_wait_fd(&chan->backend.config, chan, chan->handle); if (!ret) @@ -1434,7 +1412,7 @@ int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan struct lttng_ust_lib_ring_buffer_channel *chan; int ret; - chan = consumer_chan->chan->chan; + chan = consumer_chan->chan->priv->rb_chan; ret = ring_buffer_channel_close_wakeup_fd(&chan->backend.config, chan, chan->handle); if (!ret) @@ -1446,18 +1424,18 @@ int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream) { struct lttng_ust_lib_ring_buffer_channel *chan; - chan = stream->chan->chan->chan; + chan = stream->chan->chan->priv->rb_chan; return ring_buffer_stream_close_wait_fd(&chan->backend.config, - chan, stream->handle, stream->cpu); + chan, chan->handle, stream->cpu); } int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream) { struct lttng_ust_lib_ring_buffer_channel *chan; - chan = stream->chan->chan->chan; + chan = stream->chan->chan->priv->rb_chan; return ring_buffer_stream_close_wakeup_fd(&chan->backend.config, - chan, stream->handle, stream->cpu); + chan, chan->handle, stream->cpu); } struct ustctl_consumer_stream * @@ -1466,7 +1444,7 @@ struct ustctl_consumer_stream * { struct ustctl_consumer_stream *stream; struct lttng_ust_shm_handle *handle; - struct lttng_ust_lib_ring_buffer_channel *chan; + struct lttng_ust_lib_ring_buffer_channel *rb_chan; int shm_fd, wait_fd, wakeup_fd; uint64_t memory_map_size; struct lttng_ust_lib_ring_buffer *buf; @@ -1474,13 +1452,13 @@ struct ustctl_consumer_stream * if (!channel) return NULL; - handle = channel->chan->handle; + rb_chan = channel->chan->priv->rb_chan; + handle = rb_chan->handle; if (!handle) return NULL; - chan = channel->chan->chan; - buf = channel_get_ring_buffer(&chan->backend.config, - chan, cpu, handle, &shm_fd, &wait_fd, + buf = channel_get_ring_buffer(&rb_chan->backend.config, + rb_chan, cpu, handle, &shm_fd, &wait_fd, &wakeup_fd, &memory_map_size); if (!buf) return NULL; @@ -1491,7 +1469,6 @@ struct ustctl_consumer_stream * stream = zmalloc(sizeof(*stream)); if (!stream) goto alloc_error; - stream->handle = handle; stream->buf = buf; stream->chan = channel; stream->shm_fd = shm_fd; @@ -1515,7 +1492,7 @@ void ustctl_destroy_stream(struct ustctl_consumer_stream *stream) consumer_chan = stream->chan; (void) ustctl_stream_close_wait_fd(stream); (void) ustctl_stream_close_wakeup_fd(stream); - lib_ring_buffer_release_read(buf, consumer_chan->chan->handle); + lib_ring_buffer_release_read(buf, consumer_chan->chan->priv->rb_chan->handle); free(stream); } @@ -1523,16 +1500,16 @@ int ustctl_channel_get_wait_fd(struct ustctl_consumer_channel *chan) { if (!chan) return -EINVAL; - return shm_get_wait_fd(chan->chan->handle, - &chan->chan->handle->chan._ref); + return shm_get_wait_fd(chan->chan->priv->rb_chan->handle, + &chan->chan->priv->rb_chan->handle->chan._ref); } int ustctl_channel_get_wakeup_fd(struct ustctl_consumer_channel *chan) { if (!chan) return -EINVAL; - return shm_get_wakeup_fd(chan->chan->handle, - &chan->chan->handle->chan._ref); + return shm_get_wakeup_fd(chan->chan->priv->rb_chan->handle, + &chan->chan->priv->rb_chan->handle->chan._ref); } int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream) @@ -1544,7 +1521,7 @@ int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - return shm_get_wait_fd(consumer_chan->chan->handle, &buf->self._ref); + return shm_get_wait_fd(consumer_chan->chan->priv->rb_chan->handle, &buf->self._ref); } int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream) @@ -1556,7 +1533,7 @@ int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - return shm_get_wakeup_fd(consumer_chan->chan->handle, &buf->self._ref); + return shm_get_wakeup_fd(consumer_chan->chan->priv->rb_chan->handle, &buf->self._ref); } /* For mmap mode, readable without "get" operation */ @@ -1570,7 +1547,7 @@ void *ustctl_get_mmap_base(struct ustctl_consumer_stream *stream) return NULL; buf = stream->buf; consumer_chan = stream->chan; - return shmp(consumer_chan->chan->handle, buf->backend.memory_map); + return shmp(consumer_chan->chan->priv->rb_chan->handle, buf->backend.memory_map); } /* returns the length to mmap. */ @@ -1579,17 +1556,17 @@ int ustctl_get_mmap_len(struct ustctl_consumer_stream *stream, { struct ustctl_consumer_channel *consumer_chan; unsigned long mmap_buf_len; - struct lttng_ust_lib_ring_buffer_channel *chan; + struct lttng_ust_lib_ring_buffer_channel *rb_chan; if (!stream) return -EINVAL; consumer_chan = stream->chan; - chan = consumer_chan->chan->chan; - if (chan->backend.config.output != RING_BUFFER_MMAP) + rb_chan = consumer_chan->chan->priv->rb_chan; + if (rb_chan->backend.config.output != RING_BUFFER_MMAP) return -EINVAL; - mmap_buf_len = chan->backend.buf_size; - if (chan->backend.extra_reader_sb) - mmap_buf_len += chan->backend.subbuf_size; + mmap_buf_len = rb_chan->backend.buf_size; + if (rb_chan->backend.extra_reader_sb) + mmap_buf_len += rb_chan->backend.subbuf_size; if (mmap_buf_len > INT_MAX) return -EFBIG; *len = mmap_buf_len; @@ -1601,13 +1578,13 @@ int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream, unsigned long *len) { struct ustctl_consumer_channel *consumer_chan; - struct lttng_ust_lib_ring_buffer_channel *chan; + struct lttng_ust_lib_ring_buffer_channel *rb_chan; if (!stream) return -EINVAL; consumer_chan = stream->chan; - chan = consumer_chan->chan->chan; - *len = chan->backend.subbuf_size; + rb_chan = consumer_chan->chan->priv->rb_chan; + *len = rb_chan->backend.subbuf_size; return 0; } @@ -1620,7 +1597,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 lttng_ust_lib_ring_buffer_channel *chan; + struct lttng_ust_lib_ring_buffer_channel *rb_chan; unsigned long sb_bindex; struct lttng_ust_lib_ring_buffer *buf; struct ustctl_consumer_channel *consumer_chan; @@ -1631,16 +1608,16 @@ int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream, return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - chan = consumer_chan->chan->chan; - if (chan->backend.config.output != RING_BUFFER_MMAP) + rb_chan = consumer_chan->chan->priv->rb_chan; + if (rb_chan->backend.config.output != RING_BUFFER_MMAP) return -EINVAL; - sb_bindex = subbuffer_id_get_index(&chan->backend.config, + sb_bindex = subbuffer_id_get_index(&rb_chan->backend.config, buf->backend.buf_rsb.id); - barray_idx = shmp_index(consumer_chan->chan->handle, buf->backend.array, + barray_idx = shmp_index(rb_chan->handle, buf->backend.array, sb_bindex); if (!barray_idx) return -EINVAL; - pages = shmp(consumer_chan->chan->handle, barray_idx->shmp); + pages = shmp(rb_chan->handle, barray_idx->shmp); if (!pages) return -EINVAL; *off = pages->mmap_offset; @@ -1652,7 +1629,7 @@ int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream, unsigned long *len) { struct ustctl_consumer_channel *consumer_chan; - struct lttng_ust_lib_ring_buffer_channel *chan; + struct lttng_ust_lib_ring_buffer_channel *rb_chan; struct lttng_ust_lib_ring_buffer *buf; if (!stream) @@ -1660,9 +1637,9 @@ int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream, buf = stream->buf; consumer_chan = stream->chan; - chan = consumer_chan->chan->chan; - *len = lib_ring_buffer_get_read_data_size(&chan->backend.config, buf, - consumer_chan->chan->handle); + rb_chan = consumer_chan->chan->priv->rb_chan; + *len = lib_ring_buffer_get_read_data_size(&rb_chan->backend.config, buf, + rb_chan->handle); return 0; } @@ -1671,16 +1648,16 @@ int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream, unsigned long *len) { struct ustctl_consumer_channel *consumer_chan; - struct lttng_ust_lib_ring_buffer_channel *chan; + struct lttng_ust_lib_ring_buffer_channel *rb_chan; struct lttng_ust_lib_ring_buffer *buf; if (!stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - chan = consumer_chan->chan->chan; - *len = lib_ring_buffer_get_read_data_size(&chan->backend.config, buf, - consumer_chan->chan->handle); + rb_chan = consumer_chan->chan->priv->rb_chan; + *len = lib_ring_buffer_get_read_data_size(&rb_chan->backend.config, buf, + rb_chan->handle); *len = LTTNG_UST_PAGE_ALIGN(*len); return 0; } @@ -1696,7 +1673,7 @@ int ustctl_get_next_subbuf(struct ustctl_consumer_stream *stream) buf = stream->buf; consumer_chan = stream->chan; return lib_ring_buffer_get_next_subbuf(buf, - consumer_chan->chan->handle); + consumer_chan->chan->priv->rb_chan->handle); } @@ -1710,7 +1687,7 @@ int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - lib_ring_buffer_put_next_subbuf(buf, consumer_chan->chan->handle); + lib_ring_buffer_put_next_subbuf(buf, consumer_chan->chan->priv->rb_chan->handle); return 0; } @@ -1727,7 +1704,7 @@ int ustctl_snapshot(struct ustctl_consumer_stream *stream) buf = stream->buf; consumer_chan = stream->chan; return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot, - &buf->prod_snapshot, consumer_chan->chan->handle); + &buf->prod_snapshot, consumer_chan->chan->priv->rb_chan->handle); } /* @@ -1746,7 +1723,7 @@ int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream) consumer_chan = stream->chan; return lib_ring_buffer_snapshot_sample_positions(buf, &buf->cons_snapshot, &buf->prod_snapshot, - consumer_chan->chan->handle); + consumer_chan->chan->priv->rb_chan->handle); } /* Get the consumer position (iteration start) */ @@ -1787,7 +1764,7 @@ int ustctl_get_subbuf(struct ustctl_consumer_stream *stream, buf = stream->buf; consumer_chan = stream->chan; return lib_ring_buffer_get_subbuf(buf, *pos, - consumer_chan->chan->handle); + consumer_chan->chan->priv->rb_chan->handle); } /* Release exclusive sub-buffer access */ @@ -1800,7 +1777,7 @@ int ustctl_put_subbuf(struct ustctl_consumer_stream *stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - lib_ring_buffer_put_subbuf(buf, consumer_chan->chan->handle); + lib_ring_buffer_put_subbuf(buf, consumer_chan->chan->priv->rb_chan->handle); return 0; } @@ -1815,7 +1792,7 @@ void ustctl_flush_buffer(struct ustctl_consumer_stream *stream, consumer_chan = stream->chan; lib_ring_buffer_switch_slow(buf, producer_active ? SWITCH_ACTIVE : SWITCH_FLUSH, - consumer_chan->chan->handle); + consumer_chan->chan->priv->rb_chan->handle); } void ustctl_clear_buffer(struct ustctl_consumer_stream *stream) @@ -1827,22 +1804,18 @@ void ustctl_clear_buffer(struct ustctl_consumer_stream *stream) buf = stream->buf; consumer_chan = stream->chan; lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE, - consumer_chan->chan->handle); - lib_ring_buffer_clear_reader(buf, consumer_chan->chan->handle); + consumer_chan->chan->priv->rb_chan->handle); + lib_ring_buffer_clear_reader(buf, consumer_chan->chan->priv->rb_chan->handle); } static 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 lttng_ust_lib_ring_buffer *buf __attribute__((unused)), + struct lttng_ust_lib_ring_buffer_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; - chan = shmp(handle, buf->backend.chan); - if (!chan) - return NULL; config = &chan->backend.config; if (!config->cb_ptr) return NULL; @@ -1856,156 +1829,156 @@ int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream, uint64_t *timestamp_begin) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !timestamp_begin) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb) return -ENOSYS; - return client_cb->timestamp_begin(buf, handle, timestamp_begin); + return client_cb->timestamp_begin(buf, chan, timestamp_begin); } int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream, uint64_t *timestamp_end) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !timestamp_end) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb) return -ENOSYS; - return client_cb->timestamp_end(buf, handle, timestamp_end); + return client_cb->timestamp_end(buf, chan, timestamp_end); } int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream, uint64_t *events_discarded) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !events_discarded) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb) return -ENOSYS; - return client_cb->events_discarded(buf, handle, events_discarded); + return client_cb->events_discarded(buf, chan, events_discarded); } int ustctl_get_content_size(struct ustctl_consumer_stream *stream, uint64_t *content_size) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !content_size) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb) return -ENOSYS; - return client_cb->content_size(buf, handle, content_size); + return client_cb->content_size(buf, chan, content_size); } int ustctl_get_packet_size(struct ustctl_consumer_stream *stream, uint64_t *packet_size) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !packet_size) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb) return -ENOSYS; - return client_cb->packet_size(buf, handle, packet_size); + return client_cb->packet_size(buf, chan, packet_size); } int ustctl_get_stream_id(struct ustctl_consumer_stream *stream, uint64_t *stream_id) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !stream_id) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb) return -ENOSYS; - return client_cb->stream_id(buf, handle, stream_id); + return client_cb->stream_id(buf, chan, stream_id); } int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream, uint64_t *ts) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !ts) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb || !client_cb->current_timestamp) return -ENOSYS; - return client_cb->current_timestamp(buf, handle, ts); + return client_cb->current_timestamp(buf, chan, ts); } int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream, uint64_t *seq) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !seq) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb || !client_cb->sequence_number) return -ENOSYS; - return client_cb->sequence_number(buf, handle, seq); + return client_cb->sequence_number(buf, chan, seq); } int ustctl_get_instance_id(struct ustctl_consumer_stream *stream, uint64_t *id) { struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; - struct lttng_ust_shm_handle *handle; if (!stream || !id) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; - client_cb = get_client_cb(buf, handle); + chan = stream->chan->chan->priv->rb_chan; + client_cb = get_client_cb(buf, chan); if (!client_cb) return -ENOSYS; - return client_cb->instance_id(buf, handle, id); + return client_cb->instance_id(buf, chan, id); } -#ifdef HAVE_PERF_EVENT +#ifdef HAVE_LINUX_PERF_EVENT_H int ustctl_has_perf_counters(void) { @@ -2928,30 +2901,26 @@ int ustctl_counter_clear(struct ustctl_daemon_counter *counter, return counter->ops->counter_clear(counter->counter, dimension_indexes); } -static __attribute__((constructor)) +static +void ustctl_init(void) + __attribute__((constructor)); +static void ustctl_init(void) { ust_err_init(); lttng_ust_getenv_init(); /* Needs ust_err_init() to be completed. */ lttng_ust_clock_init(); - lttng_ring_buffer_metadata_client_init(); - lttng_ring_buffer_client_overwrite_init(); - lttng_ring_buffer_client_overwrite_rt_init(); - lttng_ring_buffer_client_discard_init(); - lttng_ring_buffer_client_discard_rt_init(); - lttng_counter_client_percpu_32_modular_init(); - lttng_counter_client_percpu_64_modular_init(); + lttng_ust_ring_buffer_clients_init(); + lttng_ust_counter_clients_init(); lib_ringbuffer_signal_init(); } -static __attribute__((destructor)) +static +void ustctl_exit(void) + __attribute__((destructor)); +static void ustctl_exit(void) { - lttng_ring_buffer_client_discard_rt_exit(); - lttng_ring_buffer_client_discard_exit(); - lttng_ring_buffer_client_overwrite_rt_exit(); - lttng_ring_buffer_client_overwrite_exit(); - lttng_ring_buffer_metadata_client_exit(); - lttng_counter_client_percpu_32_modular_exit(); - lttng_counter_client_percpu_64_modular_exit(); + lttng_ust_counter_clients_exit(); + lttng_ust_ring_buffer_clients_exit(); }