X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=libringbuffer%2Fring_buffer_frontend.c;h=1fc44912b51f2db96eb30348740645e18f6a25bd;hb=38fae1d354502ffb37f471fbd0fef03412606cc0;hp=0b4b89f7306fee1b77bf4e9b44c9ec48e47af643;hpb=e095d8031307428069e549360284388e06683293;p=lttng-ust.git diff --git a/libringbuffer/ring_buffer_frontend.c b/libringbuffer/ring_buffer_frontend.c index 0b4b89f7..1fc44912 100644 --- a/libringbuffer/ring_buffer_frontend.c +++ b/libringbuffer/ring_buffer_frontend.c @@ -86,13 +86,13 @@ __thread unsigned int lib_ring_buffer_nesting; static void lib_ring_buffer_print_errors(struct channel *chan, struct lib_ring_buffer *buf, int cpu, - struct shm_handle *handle); + struct lttng_ust_shm_handle *handle); /* * Must be called under cpu hotplug protection. */ void lib_ring_buffer_free(struct lib_ring_buffer *buf, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); @@ -113,7 +113,7 @@ void lib_ring_buffer_free(struct lib_ring_buffer *buf, * current iterator record is reset. */ void lib_ring_buffer_reset(struct lib_ring_buffer *buf, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); const struct lib_ring_buffer_config *config = &chan->backend.config; @@ -169,7 +169,7 @@ void channel_reset(struct channel *chan) */ int lib_ring_buffer_create(struct lib_ring_buffer *buf, struct channel_backend *chanb, int cpu, - struct shm_handle *handle, + struct lttng_ust_shm_handle *handle, struct shm_object *shmobj) { const struct lib_ring_buffer_config *config = &chanb->config; @@ -263,10 +263,10 @@ static void switch_buffer_timer(unsigned long data) #endif //0 static void lib_ring_buffer_start_switch_timer(struct lib_ring_buffer *buf, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); - const struct lib_ring_buffer_config *config = &chan->backend.config; + //const struct lib_ring_buffer_config *config = &chan->backend.config; if (!chan->switch_timer_interval || buf->switch_timer_enabled) return; @@ -283,7 +283,7 @@ static void lib_ring_buffer_start_switch_timer(struct lib_ring_buffer *buf, } static void lib_ring_buffer_stop_switch_timer(struct lib_ring_buffer *buf, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); @@ -325,7 +325,7 @@ static void read_buffer_timer(unsigned long data) #endif //0 static void lib_ring_buffer_start_read_timer(struct lib_ring_buffer *buf, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); const struct lib_ring_buffer_config *config = &chan->backend.config; @@ -349,7 +349,7 @@ static void lib_ring_buffer_start_read_timer(struct lib_ring_buffer *buf, } static void lib_ring_buffer_stop_read_timer(struct lib_ring_buffer *buf, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); const struct lib_ring_buffer_config *config = &chan->backend.config; @@ -374,7 +374,7 @@ static void lib_ring_buffer_stop_read_timer(struct lib_ring_buffer *buf, } static void channel_unregister_notifiers(struct channel *chan, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { const struct lib_ring_buffer_config *config = &chan->backend.config; int cpu; @@ -395,11 +395,9 @@ static void channel_unregister_notifiers(struct channel *chan, //channel_backend_unregister_notifiers(&chan->backend); } -static void channel_free(struct channel *chan, struct shm_handle *handle, +static void channel_free(struct channel *chan, struct lttng_ust_shm_handle *handle, int shadow) { - int ret; - if (!shadow) channel_backend_free(&chan->backend, handle); /* chan is freed by shm teardown */ @@ -425,7 +423,7 @@ static void channel_free(struct channel *chan, struct shm_handle *handle, * Holds cpu hotplug. * Returns NULL on failure. */ -struct shm_handle *channel_create(const struct lib_ring_buffer_config *config, +struct lttng_ust_shm_handle *channel_create(const struct lib_ring_buffer_config *config, const char *name, void *priv, void *buf_addr, size_t subbuf_size, size_t num_subbuf, unsigned int switch_timer_interval, @@ -435,7 +433,7 @@ struct shm_handle *channel_create(const struct lib_ring_buffer_config *config, int ret, cpu; size_t shmsize; struct channel *chan; - struct shm_handle *handle; + struct lttng_ust_shm_handle *handle; struct shm_object *shmobj; struct shm_ref *ref; @@ -443,7 +441,7 @@ struct shm_handle *channel_create(const struct lib_ring_buffer_config *config, read_timer_interval)) return NULL; - handle = zmalloc(sizeof(struct shm_handle)); + handle = zmalloc(sizeof(struct lttng_ust_shm_handle)); if (!handle) return NULL; @@ -462,7 +460,10 @@ struct shm_handle *channel_create(const struct lib_ring_buffer_config *config, shmobj = shm_object_table_append(handle->table, shmsize); if (!shmobj) goto error_append; + /* struct channel is at object 0, offset 0 (hardcoded) */ set_shmp(handle->chan, zalloc_shm(shmobj, sizeof(struct channel))); + assert(handle->chan._ref.index == 0); + assert(handle->chan._ref.offset == 0); chan = shmp(handle, handle->chan); if (!chan) goto error_append; @@ -509,13 +510,13 @@ error_table_alloc: return NULL; } -struct shm_handle *channel_handle_create(int shm_fd, int wait_fd, +struct lttng_ust_shm_handle *channel_handle_create(int shm_fd, int wait_fd, uint64_t memory_map_size) { - struct shm_handle *handle; + struct lttng_ust_shm_handle *handle; struct shm_object *object; - handle = zmalloc(sizeof(struct shm_handle)); + handle = zmalloc(sizeof(struct lttng_ust_shm_handle)); if (!handle) return NULL; @@ -528,7 +529,9 @@ struct shm_handle *channel_handle_create(int shm_fd, int wait_fd, shm_fd, wait_fd, memory_map_size); if (!object) goto error_table_object; - + /* struct channel is at object 0, offset 0 (hardcoded) */ + handle->chan._ref.index = 0; + handle->chan._ref.offset = 0; return handle; error_table_object: @@ -538,7 +541,7 @@ error_table_alloc: return NULL; } -int channel_handle_add_stream(struct shm_handle *handle, +int channel_handle_add_stream(struct lttng_ust_shm_handle *handle, int shm_fd, int wait_fd, uint64_t memory_map_size) { struct shm_object *object; @@ -552,7 +555,7 @@ int channel_handle_add_stream(struct shm_handle *handle, } static -void channel_release(struct channel *chan, struct shm_handle *handle, +void channel_release(struct channel *chan, struct lttng_ust_shm_handle *handle, int shadow) { channel_free(chan, handle, shadow); @@ -569,7 +572,7 @@ void channel_release(struct channel *chan, struct shm_handle *handle, * They should release their handle at that point. Returns the private * data pointer. */ -void *channel_destroy(struct channel *chan, struct shm_handle *handle, +void *channel_destroy(struct channel *chan, struct lttng_ust_shm_handle *handle, int shadow) { const struct lib_ring_buffer_config *config = &chan->backend.config; @@ -631,7 +634,7 @@ void *channel_destroy(struct channel *chan, struct shm_handle *handle, struct lib_ring_buffer *channel_get_ring_buffer( const struct lib_ring_buffer_config *config, struct channel *chan, int cpu, - struct shm_handle *handle, + struct lttng_ust_shm_handle *handle, int *shm_fd, int *wait_fd, uint64_t *memory_map_size) { @@ -653,11 +656,9 @@ struct lib_ring_buffer *channel_get_ring_buffer( } int lib_ring_buffer_open_read(struct lib_ring_buffer *buf, - struct shm_handle *handle, + struct lttng_ust_shm_handle *handle, int shadow) { - struct channel *chan = shmp(handle, buf->backend.chan); - if (shadow) { if (uatomic_cmpxchg(&buf->active_shadow_readers, 0, 1) != 0) return -EBUSY; @@ -671,7 +672,7 @@ int lib_ring_buffer_open_read(struct lib_ring_buffer *buf, } void lib_ring_buffer_release_read(struct lib_ring_buffer *buf, - struct shm_handle *handle, + struct lttng_ust_shm_handle *handle, int shadow) { struct channel *chan = shmp(handle, buf->backend.chan); @@ -699,7 +700,7 @@ void lib_ring_buffer_release_read(struct lib_ring_buffer *buf, int lib_ring_buffer_snapshot(struct lib_ring_buffer *buf, unsigned long *consumed, unsigned long *produced, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); const struct lib_ring_buffer_config *config = &chan->backend.config; @@ -753,7 +754,7 @@ nodata: */ void lib_ring_buffer_move_consumer(struct lib_ring_buffer *buf, unsigned long consumed_new, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct lib_ring_buffer_backend *bufb = &buf->backend; struct channel *chan = shmp(handle, bufb->chan); @@ -783,7 +784,7 @@ void lib_ring_buffer_move_consumer(struct lib_ring_buffer *buf, */ int lib_ring_buffer_get_subbuf(struct lib_ring_buffer *buf, unsigned long consumed, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); const struct lib_ring_buffer_config *config = &chan->backend.config; @@ -876,7 +877,7 @@ nodata: * @buf: ring buffer */ void lib_ring_buffer_put_subbuf(struct lib_ring_buffer *buf, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct lib_ring_buffer_backend *bufb = &buf->backend; struct channel *chan = shmp(handle, bufb->chan); @@ -939,7 +940,7 @@ void lib_ring_buffer_print_subbuffer_errors(struct lib_ring_buffer *buf, struct channel *chan, unsigned long cons_offset, int cpu, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { const struct lib_ring_buffer_config *config = &chan->backend.config; unsigned long cons_idx, commit_count, commit_count_sb; @@ -965,7 +966,7 @@ static void lib_ring_buffer_print_buffer_errors(struct lib_ring_buffer *buf, struct channel *chan, void *priv, int cpu, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { const struct lib_ring_buffer_config *config = &chan->backend.config; unsigned long write_offset, cons_offset; @@ -1001,7 +1002,7 @@ void lib_ring_buffer_print_buffer_errors(struct lib_ring_buffer *buf, static void lib_ring_buffer_print_errors(struct channel *chan, struct lib_ring_buffer *buf, int cpu, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { const struct lib_ring_buffer_config *config = &chan->backend.config; void *priv = chan->backend.priv; @@ -1036,7 +1037,7 @@ void lib_ring_buffer_switch_old_start(struct lib_ring_buffer *buf, struct channel *chan, struct switch_offsets *offsets, u64 tsc, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { const struct lib_ring_buffer_config *config = &chan->backend.config; unsigned long oldidx = subbuf_index(offsets->old, chan); @@ -1074,7 +1075,7 @@ void lib_ring_buffer_switch_old_end(struct lib_ring_buffer *buf, struct channel *chan, struct switch_offsets *offsets, u64 tsc, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { const struct lib_ring_buffer_config *config = &chan->backend.config; unsigned long oldidx = subbuf_index(offsets->old - 1, chan); @@ -1111,7 +1112,7 @@ void lib_ring_buffer_switch_new_start(struct lib_ring_buffer *buf, struct channel *chan, struct switch_offsets *offsets, u64 tsc, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { const struct lib_ring_buffer_config *config = &chan->backend.config; unsigned long beginidx = subbuf_index(offsets->begin, chan); @@ -1147,7 +1148,7 @@ void lib_ring_buffer_switch_new_end(struct lib_ring_buffer *buf, struct channel *chan, struct switch_offsets *offsets, u64 tsc, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { const struct lib_ring_buffer_config *config = &chan->backend.config; unsigned long endidx = subbuf_index(offsets->end - 1, chan); @@ -1241,7 +1242,7 @@ int lib_ring_buffer_try_switch_slow(enum switch_mode mode, * for a ACTIVE flush. */ void lib_ring_buffer_switch_slow(struct lib_ring_buffer *buf, enum switch_mode mode, - struct shm_handle *handle) + struct lttng_ust_shm_handle *handle) { struct channel *chan = shmp(handle, buf->backend.chan); const struct lib_ring_buffer_config *config = &chan->backend.config; @@ -1305,7 +1306,7 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf, struct lib_ring_buffer_ctx *ctx) { const struct lib_ring_buffer_config *config = &chan->backend.config; - struct shm_handle *handle = ctx->handle; + struct lttng_ust_shm_handle *handle = ctx->handle; unsigned long reserve_commit_diff; offsets->begin = v_read(config, &buf->offset); @@ -1440,7 +1441,7 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf, int lib_ring_buffer_reserve_slow(struct lib_ring_buffer_ctx *ctx) { struct channel *chan = ctx->chan; - struct shm_handle *handle = ctx->handle; + struct lttng_ust_shm_handle *handle = ctx->handle; const struct lib_ring_buffer_config *config = &chan->backend.config; struct lib_ring_buffer *buf; struct switch_offsets offsets;