Move event context to private structures
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 18 Mar 2021 19:57:06 +0000 (15:57 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 18 Mar 2021 19:57:06 +0000 (15:57 -0400)
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 <mathieu.desnoyers@efficios.com>
Change-Id: I3040edf42ea59786a4ee1b5b3f9a90e1834821ab

include/lttng/ust-events.h
include/lttng/ust-tracepoint-event.h
liblttng-ust/lttng-events.c
liblttng-ust/lttng-ring-buffer-client.h
liblttng-ust/ust-events-internal.h

index 0fa83bbeeeb9bc6e1372a14e469c77d21c6eebae..367d2d1aaa33512d4374ba4bcabe2cdbe8e137aa 100644 (file)
@@ -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. */
 };
index ff46179da4269db8954a81c55edf5142108ac052..af51f9bc95cf5dae50ae9f231f5498639b9d2592 100644 (file)
@@ -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);                         \
index 30cc224a2f7c755c3190071711022e08b1b46f6e..bf74a1d9cfc3ec48b13d04accda4d6303cafc4b3 100644 (file)
@@ -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();
index 871170366429a4b329561395acf243c839e2ac5d..73f3deb8e341d4d337af9329a07fa7cd296707bc 100644 (file)
@@ -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);
index cac869db2c688ad400284f13b8aa44a573a730a7..97e3974c2333f77ed15e51aca9c7f5a9a0de2ffb 100644 (file)
@@ -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 {
This page took 0.031012 seconds and 4 git commands to generate.