From 3b5babf8592ca27acaf01fca24406922fc5cc89c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 26 Mar 2021 16:30:21 -0400 Subject: [PATCH] API cleanup: Remove handle from struct lttng_ust_channel_buffer Now that the handle is fetched from struct lttng_ust_lib_ring_buffer_channel by the ring buffer client callbacks, there is no need to keep it around in the public API struct lttng_ust_channel_buffer. Signed-off-by: Mathieu Desnoyers Change-Id: Id41d1ffb171ea64150e2ceebd51c9679071ee337 --- include/lttng/ringbuffer-context.h | 1 - include/lttng/ust-ctl.h | 1 - include/lttng/ust-events.h | 1 - liblttng-ust-ctl/ustctl.c | 70 ++++++++++--------- liblttng-ust/lttng-events.c | 3 +- liblttng-ust/lttng-ring-buffer-client.h | 3 +- .../lttng-ring-buffer-metadata-client.h | 3 +- liblttng-ust/lttng-ust-abi.c | 7 +- 8 files changed, 43 insertions(+), 46 deletions(-) diff --git a/include/lttng/ringbuffer-context.h b/include/lttng/ringbuffer-context.h index b335d81a..228bc8aa 100644 --- a/include/lttng/ringbuffer-context.h +++ b/include/lttng/ringbuffer-context.h @@ -22,7 +22,6 @@ struct lttng_ust_lib_ring_buffer; struct lttng_ust_lib_ring_buffer_channel; struct lttng_ust_lib_ring_buffer_ctx; -struct lttng_ust_shm_handle; /* * ring buffer context diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h index 39952fa3..bb9cf3ac 100644 --- a/include/lttng/ust-ctl.h +++ b/include/lttng/ust-ctl.h @@ -33,7 +33,6 @@ "lttng-ust-wait-" \ __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION) -struct lttng_ust_shm_handle; struct lttng_ust_lib_ring_buffer; struct ustctl_consumer_channel_attr { diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index a418bb98..36380568 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -505,7 +505,6 @@ struct lttng_ust_channel_buffer { struct lttng_ust_channel_buffer_ops *ops; struct lttng_ust_lib_ring_buffer_channel *chan; /* Channel buffers */ - struct lttng_ust_shm_handle *handle; /* shared-memory handle */ /* End of base ABI. Fields below should be used after checking struct_size. */ }; diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index f43170ae..0a76437d 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -1314,7 +1314,7 @@ int ustctl_send_channel_to_sessiond(int sock, { struct shm_object_table *table; - table = channel->chan->handle->table; + table = channel->chan->chan->handle->table; if (table->size <= 0) return -EINVAL; return ustctl_send_channel(sock, @@ -1351,7 +1351,8 @@ int ustctl_write_metadata_to_channel( for (pos = 0; pos < len; pos += reserve_len) { reserve_len = min_t(size_t, - lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf->chan, lttng_chan_buf->handle), + lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf->chan, + lttng_chan_buf->chan->handle), len - pos); lib_ring_buffer_ctx_init(&ctx, lttng_chan_buf->chan, NULL, reserve_len, sizeof(char)); /* @@ -1397,7 +1398,8 @@ ssize_t ustctl_write_one_packet_to_channel( int ret; reserve_len = min_t(ssize_t, - lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf->chan, lttng_chan_buf->handle), + lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf->chan, + lttng_chan_buf->chan->handle), len); lib_ring_buffer_ctx_init(&ctx, lttng_chan_buf->chan, NULL, reserve_len, sizeof(char)); ret = lttng_chan_buf->ops->event_reserve(&ctx, 0); @@ -1472,7 +1474,7 @@ struct ustctl_consumer_stream * if (!channel) return NULL; - handle = channel->chan->handle; + handle = channel->chan->chan->handle; if (!handle) return NULL; @@ -1513,7 +1515,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->chan->handle); free(stream); } @@ -1521,16 +1523,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->chan->handle, + &chan->chan->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->chan->handle, + &chan->chan->chan->handle->chan._ref); } int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream) @@ -1542,7 +1544,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->chan->handle, &buf->self._ref); } int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream) @@ -1554,7 +1556,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->chan->handle, &buf->self._ref); } /* For mmap mode, readable without "get" operation */ @@ -1568,7 +1570,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->chan->handle, buf->backend.memory_map); } /* returns the length to mmap. */ @@ -1634,11 +1636,11 @@ int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream, return -EINVAL; sb_bindex = subbuffer_id_get_index(&chan->backend.config, buf->backend.buf_rsb.id); - barray_idx = shmp_index(consumer_chan->chan->handle, buf->backend.array, + barray_idx = shmp_index(consumer_chan->chan->chan->handle, buf->backend.array, sb_bindex); if (!barray_idx) return -EINVAL; - pages = shmp(consumer_chan->chan->handle, barray_idx->shmp); + pages = shmp(consumer_chan->chan->chan->handle, barray_idx->shmp); if (!pages) return -EINVAL; *off = pages->mmap_offset; @@ -1660,7 +1662,7 @@ int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream, 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); + consumer_chan->chan->chan->handle); return 0; } @@ -1678,7 +1680,7 @@ int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream, 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); + consumer_chan->chan->chan->handle); *len = LTTNG_UST_PAGE_ALIGN(*len); return 0; } @@ -1694,7 +1696,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->chan->handle); } @@ -1708,7 +1710,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->chan->handle); return 0; } @@ -1725,7 +1727,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->chan->handle); } /* @@ -1744,7 +1746,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->chan->handle); } /* Get the consumer position (iteration start) */ @@ -1785,7 +1787,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->chan->handle); } /* Release exclusive sub-buffer access */ @@ -1798,7 +1800,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->chan->handle); return 0; } @@ -1813,7 +1815,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->chan->handle); } void ustctl_clear_buffer(struct ustctl_consumer_stream *stream) @@ -1825,8 +1827,8 @@ 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->chan->handle); + lib_ring_buffer_clear_reader(buf, consumer_chan->chan->chan->handle); } static @@ -1860,7 +1862,7 @@ int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream, if (!stream || !timestamp_begin) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1877,7 +1879,7 @@ int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream, if (!stream || !timestamp_end) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1894,7 +1896,7 @@ int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream, if (!stream || !events_discarded) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1911,7 +1913,7 @@ int ustctl_get_content_size(struct ustctl_consumer_stream *stream, if (!stream || !content_size) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1928,7 +1930,7 @@ int ustctl_get_packet_size(struct ustctl_consumer_stream *stream, if (!stream || !packet_size) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1945,7 +1947,7 @@ int ustctl_get_stream_id(struct ustctl_consumer_stream *stream, if (!stream || !stream_id) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1962,7 +1964,7 @@ int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream, if (!stream || !ts) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb || !client_cb->current_timestamp) return -ENOSYS; @@ -1979,7 +1981,7 @@ int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream, if (!stream || !seq) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb || !client_cb->sequence_number) return -ENOSYS; @@ -1996,7 +1998,7 @@ int ustctl_get_instance_id(struct ustctl_consumer_stream *stream, if (!stream || !id) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 70e2f3a9..e4893574 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -53,6 +53,7 @@ #include "ust-events-internal.h" #include "wait.h" #include "../libringbuffer/shm.h" +#include "../libringbuffer/frontend_types.h" #include "../libcounter/counter.h" #include "jhash.h" #include @@ -238,7 +239,7 @@ void _lttng_channel_unmap(struct lttng_ust_channel_buffer *lttng_chan) cds_list_del(<tng_chan->priv->node); lttng_destroy_context(lttng_chan->priv->ctx); chan = lttng_chan->chan; - handle = lttng_chan->handle; + handle = chan->handle; channel_destroy(chan, handle, 0); free(lttng_chan->parent); free(lttng_chan->priv); diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h index 4e2b86a2..0be36aa2 100644 --- a/liblttng-ust/lttng-ring-buffer-client.h +++ b/liblttng-ust/lttng-ring-buffer-client.h @@ -675,7 +675,6 @@ struct lttng_ust_channel_buffer *_channel_create(const char *name, stream_fds, nr_stream_fds, blocking_timeout); if (!handle) goto error; - lttng_chan_buf->handle = handle; lttng_chan_buf->chan = shmp(handle, handle->chan); return lttng_chan_buf; @@ -687,7 +686,7 @@ error: static void lttng_channel_destroy(struct lttng_ust_channel_buffer *lttng_chan_buf) { - channel_destroy(lttng_chan_buf->chan, lttng_chan_buf->handle, 1); + channel_destroy(lttng_chan_buf->chan, lttng_chan_buf->chan->handle, 1); lttng_ust_free_channel_common(lttng_chan_buf->parent); } diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h index 40213e80..40365203 100644 --- a/liblttng-ust/lttng-ring-buffer-metadata-client.h +++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h @@ -223,7 +223,6 @@ struct lttng_ust_channel_buffer *_channel_create(const char *name, stream_fds, nr_stream_fds, blocking_timeout); if (!handle) goto error; - lttng_chan_buf->handle = handle; lttng_chan_buf->chan = shmp(handle, handle->chan); return lttng_chan_buf; @@ -235,7 +234,7 @@ error: static void lttng_channel_destroy(struct lttng_ust_channel_buffer *lttng_chan_buf) { - channel_destroy(lttng_chan_buf->chan, lttng_chan_buf->handle, 1); + channel_destroy(lttng_chan_buf->chan, lttng_chan_buf->chan->handle, 1); lttng_ust_free_channel_common(lttng_chan_buf->parent); } diff --git a/liblttng-ust/lttng-ust-abi.c b/liblttng-ust/lttng-ust-abi.c index af2a47dc..323e6a22 100644 --- a/liblttng-ust/lttng-ust-abi.c +++ b/liblttng-ust/lttng-ust-abi.c @@ -293,7 +293,7 @@ int lttng_is_channel_ready(struct lttng_ust_channel_buffer *lttng_chan) unsigned int nr_streams, exp_streams; chan = lttng_chan->chan; - nr_streams = channel_handle_get_nr_streams(lttng_chan->handle); + nr_streams = channel_handle_get_nr_streams(lttng_chan->chan->handle); exp_streams = chan->nr_streams; return nr_streams == exp_streams; } @@ -557,7 +557,6 @@ int lttng_abi_map_channel(int session_objd, lttng_chan_buf->ops = &transport->ops; lttng_chan_buf->chan = chan; - lttng_chan_buf->handle = channel_handle; memcpy(&chan->backend.config, transport->client_config, @@ -1120,7 +1119,7 @@ int lttng_abi_map_stream(int channel_objd, struct lttng_ust_abi_stream *info, struct lttng_ust_channel_buffer *lttng_chan_buf = objd_private(channel_objd); int ret; - ret = channel_handle_add_stream(lttng_chan_buf->handle, + ret = channel_handle_add_stream(lttng_chan_buf->chan->handle, uargs->stream.shm_fd, uargs->stream.wakeup_fd, info->stream_nr, info->len); if (ret) @@ -1252,7 +1251,7 @@ long lttng_channel_cmd(int objd, unsigned int cmd, unsigned long arg, return lttng_channel_disable(lttng_chan_buf->parent); case LTTNG_UST_ABI_FLUSH_BUFFER: return lttng_chan_buf->ops->priv->flush_buffer(lttng_chan_buf->chan, - lttng_chan_buf->handle); + lttng_chan_buf->chan->handle); default: return -EINVAL; } -- 2.34.1