From: Mathieu Desnoyers Date: Thu, 18 Mar 2021 19:57:06 +0000 (-0400) Subject: Move event context to private structures X-Git-Tag: v2.13.0-rc1~244 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a40b5b8cd4af87564b297e343de14779c1bfc11a;p=lttng-ust.git Move event context to private structures The list of contexts active for an event can be moved to a private structure by keeping the temporary pointer to the RCU dereferenced context in the ring buffer client's internal context rather than within the context shared between the probe and the ring buffer client. Signed-off-by: Mathieu Desnoyers Change-Id: I3040edf42ea59786a4ee1b5b3f9a90e1834821ab --- diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 0fa83bbe..367d2d1a 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -406,7 +406,6 @@ struct lttng_ust_event_recorder { unsigned int id; struct lttng_ust_channel_buffer *chan; - struct lttng_ust_ctx *ctx; /* End of base ABI. Fields below should be used after checking struct_size. */ }; @@ -534,7 +533,6 @@ struct lttng_ust_stack_ctx { uint32_t struct_size; /* Size of this structure */ struct lttng_ust_event_recorder *event_recorder; - struct lttng_ust_ctx *event_ctx; /* RCU dereferenced. */ /* End of base ABI. Fields below should be used after checking struct_size. */ }; diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index ff46179d..af51f9bc 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -852,7 +852,6 @@ void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) \ memset(&__lttng_ctx, 0, sizeof(__lttng_ctx)); \ __lttng_ctx.struct_size = sizeof(struct lttng_ust_stack_ctx); \ __lttng_ctx.event_recorder = __event_recorder; \ - __lttng_ctx.event_ctx = tp_rcu_dereference(__event_recorder->ctx); \ lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_ctx, __event_len, \ __event_align, -1, __chan->handle); \ __ctx.ip = _TP_IP_PARAM(TP_IP_PARAM); \ diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 30cc224a..bf74a1d9 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -1321,7 +1321,7 @@ void _lttng_event_destroy(struct lttng_ust_event_common *event) /* Remove from event hash table. */ cds_hlist_del(&event_recorder->priv->hlist); - lttng_destroy_context(event_recorder->ctx); + lttng_destroy_context(event_recorder->priv->ctx); free(event_recorder->parent); free(event_recorder->priv); free(event_recorder); @@ -1971,7 +1971,7 @@ void lttng_ust_context_set_session_provider(const char *name, abort(); } cds_list_for_each_entry(event_recorder_priv, &session_priv->events_head, node) { - ret = lttng_ust_context_set_provider_rcu(&event_recorder_priv->pub->ctx, + ret = lttng_ust_context_set_provider_rcu(&event_recorder_priv->ctx, name, get_size, record, get_value); if (ret) abort(); diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h index 87117036..73f3deb8 100644 --- a/liblttng-ust/lttng-ring-buffer-client.h +++ b/liblttng-ust/lttng-ring-buffer-client.h @@ -64,6 +64,7 @@ struct lttng_client_ctx { size_t packet_context_len; size_t event_context_len; struct lttng_ust_ctx *chan_ctx; + struct lttng_ust_ctx *event_ctx; }; static inline uint64_t lib_ring_buffer_clock_read(struct lttng_ust_lib_ring_buffer_channel *chan) @@ -175,7 +176,6 @@ size_t record_header_size(const struct lttng_ust_lib_ring_buffer_config *config, struct lttng_client_ctx *client_ctx) { struct lttng_ust_channel_buffer *lttng_chan = channel_get_private(chan); - struct lttng_ust_stack_ctx *lttng_ctx = ctx->priv; size_t orig_offset = offset; size_t padding; @@ -216,7 +216,7 @@ size_t record_header_size(const struct lttng_ust_lib_ring_buffer_config *config, } offset += ctx_get_aligned_size(offset, client_ctx->chan_ctx, client_ctx->packet_context_len); - offset += ctx_get_aligned_size(offset, lttng_ctx->event_ctx, + offset += ctx_get_aligned_size(offset, client_ctx->event_ctx, client_ctx->event_context_len); *pre_header_padding = padding; return offset - orig_offset; @@ -247,7 +247,6 @@ void lttng_write_event_header(const struct lttng_ust_lib_ring_buffer_config *con uint32_t event_id) { struct lttng_ust_channel_buffer *lttng_chan = channel_get_private(ctx->chan); - struct lttng_ust_stack_ctx *lttng_ctx = ctx->priv; if (caa_unlikely(ctx->rflags)) goto slow_path; @@ -283,7 +282,7 @@ void lttng_write_event_header(const struct lttng_ust_lib_ring_buffer_config *con } ctx_record(ctx, lttng_chan, client_ctx->chan_ctx, APP_CTX_ENABLED); - ctx_record(ctx, lttng_chan, lttng_ctx->event_ctx, APP_CTX_ENABLED); + ctx_record(ctx, lttng_chan, client_ctx->event_ctx, APP_CTX_ENABLED); lib_ring_buffer_align_ctx(ctx, ctx->largest_align); return; @@ -299,7 +298,6 @@ void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config uint32_t event_id) { struct lttng_ust_channel_buffer *lttng_chan = channel_get_private(ctx->chan); - struct lttng_ust_stack_ctx *lttng_ctx = ctx->priv; switch (lttng_chan->priv->header_type) { case 1: /* compact */ @@ -357,7 +355,7 @@ void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config WARN_ON_ONCE(1); } ctx_record(ctx, lttng_chan, client_ctx->chan_ctx, APP_CTX_ENABLED); - ctx_record(ctx, lttng_chan, lttng_ctx->event_ctx, APP_CTX_ENABLED); + ctx_record(ctx, lttng_chan, client_ctx->event_ctx, APP_CTX_ENABLED); lib_ring_buffer_align_ctx(ctx, ctx->largest_align); } @@ -699,14 +697,16 @@ int lttng_event_reserve(struct lttng_ust_lib_ring_buffer_ctx *ctx, { struct lttng_ust_channel_buffer *lttng_chan = channel_get_private(ctx->chan); struct lttng_ust_stack_ctx *lttng_ctx = ctx->priv; + struct lttng_ust_event_recorder *event_recorder = lttng_ctx->event_recorder; struct lttng_client_ctx client_ctx; int ret, cpu; client_ctx.chan_ctx = lttng_ust_rcu_dereference(lttng_chan->priv->ctx); + client_ctx.event_ctx = lttng_ust_rcu_dereference(event_recorder->priv->ctx); /* Compute internal size of context structures. */ ctx_get_struct_size(client_ctx.chan_ctx, &client_ctx.packet_context_len, APP_CTX_ENABLED); - ctx_get_struct_size(lttng_ctx->event_ctx, &client_ctx.event_context_len, + ctx_get_struct_size(client_ctx.event_ctx, &client_ctx.event_context_len, APP_CTX_ENABLED); cpu = lib_ring_buffer_get_cpu(&client_config); diff --git a/liblttng-ust/ust-events-internal.h b/liblttng-ust/ust-events-internal.h index cac869db..97e3974c 100644 --- a/liblttng-ust/ust-events-internal.h +++ b/liblttng-ust/ust-events-internal.h @@ -258,6 +258,7 @@ struct lttng_ust_event_recorder_private { struct lttng_ust_event_recorder *pub; /* Public event interface */ struct cds_list_head node; /* Event recorder list */ struct cds_hlist_node hlist; /* Hash table of event recorders */ + struct lttng_ust_ctx *ctx; }; struct lttng_ust_event_notifier_private {