Refactoring: struct lttng_stack_ctx
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Mar 2021 03:13:54 +0000 (23:13 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Mar 2021 03:15:37 +0000 (23:15 -0400)
- Namespace this structure with lttng_ust_ prefix,
- Use struct_size extensibility scheme.
- Remove padding.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ieb0679f78a18553c6d60a70d78e0f7f99181d646

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

index 13ecb6d7f05077d4e4bd2ef883b5485630f4f5f4..624af8bb1bc18b37578d9741891ef5bd73a4effd 100644 (file)
@@ -566,12 +566,23 @@ struct lttng_channel {
        int tstate:1;                   /* Transient enable state */
 };
 
-#define LTTNG_UST_STACK_CTX_PADDING    32
-struct lttng_stack_ctx {
+/*
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Fields need to be only added at the end, never reordered, never
+ * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
+ */
+struct lttng_ust_stack_ctx {
+       uint32_t struct_size;                   /* Size of this structure */
+
        struct lttng_ust_event_recorder *event_recorder;
        struct lttng_ctx *chan_ctx;     /* RCU dereferenced. */
        struct lttng_ctx *event_ctx;    /* RCU dereferenced. */
-       char padding[LTTNG_UST_STACK_CTX_PADDING];
+
+       /* End of base ABI. Fields below should be used after checking struct_size. */
 };
 
 struct lttng_ust_session_private;
index 428ff0b1a7e05a7e3615d8af6685b42f8d6d0bff..c4e4f1ed5c655bc49daee568010c957565875cbd 100644 (file)
@@ -846,12 +846,13 @@ void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))         \
                struct lttng_ust_event_recorder *__event_recorder = (struct lttng_ust_event_recorder *) __event->child; \
                struct lttng_channel *__chan = __event_recorder->chan;        \
                struct lttng_ust_lib_ring_buffer_ctx __ctx;                   \
-               struct lttng_stack_ctx __lttng_ctx;                           \
+               struct lttng_ust_stack_ctx __lttng_ctx;                       \
                                                                              \
                __event_len = __event_get_size__##_provider##___##_name(__stackvar.__dynamic_len, \
                         _TP_ARGS_DATA_VAR(_args));                           \
                __event_align = __event_get_align__##_provider##___##_name(_TP_ARGS_VAR(_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.chan_ctx = tp_rcu_dereference(__chan->ctx);       \
                __lttng_ctx.event_ctx = tp_rcu_dereference(__event_recorder->ctx); \
index c3b77182c2b0223fec775a678d477a66cff60950..ad33673774396cb25fe32097ed90c4ff01b48642 100644 (file)
@@ -172,7 +172,7 @@ size_t record_header_size(const struct lttng_ust_lib_ring_buffer_config *config,
                                 struct lttng_client_ctx *client_ctx)
 {
        struct lttng_channel *lttng_chan = channel_get_private(chan);
-       struct lttng_stack_ctx *lttng_ctx = ctx->priv;
+       struct lttng_ust_stack_ctx *lttng_ctx = ctx->priv;
        size_t orig_offset = offset;
        size_t padding;
 
@@ -242,7 +242,7 @@ void lttng_write_event_header(const struct lttng_ust_lib_ring_buffer_config *con
                            uint32_t event_id)
 {
        struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
-       struct lttng_stack_ctx *lttng_ctx = ctx->priv;
+       struct lttng_ust_stack_ctx *lttng_ctx = ctx->priv;
 
        if (caa_unlikely(ctx->rflags))
                goto slow_path;
@@ -293,7 +293,7 @@ void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config
                                 uint32_t event_id)
 {
        struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
-       struct lttng_stack_ctx *lttng_ctx = ctx->priv;
+       struct lttng_ust_stack_ctx *lttng_ctx = ctx->priv;
 
        switch (lttng_chan->header_type) {
        case 1: /* compact */
@@ -680,7 +680,7 @@ int lttng_event_reserve(struct lttng_ust_lib_ring_buffer_ctx *ctx,
                      uint32_t event_id)
 {
        struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
-       struct lttng_stack_ctx *lttng_ctx = ctx->priv;
+       struct lttng_ust_stack_ctx *lttng_ctx = ctx->priv;
        struct lttng_client_ctx client_ctx;
        int ret, cpu;
 
This page took 0.029132 seconds and 4 git commands to generate.