Refactoring: struct lttng_bytecode_runtime
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Mar 2021 03:06:59 +0000 (23:06 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Mar 2021 03:10:40 +0000 (23:10 -0400)
- Namespace this structure with lttng_ust_ prefix,
- Use struct_size extensibility scheme. There was no prior padding, so
  extensibility was an issue in the past.

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

include/lttng/ust-events.h
include/lttng/ust-tracepoint-event.h
liblttng-ust/event-notifier-notification.c
liblttng-ust/lttng-bytecode.c
liblttng-ust/lttng-bytecode.h
liblttng-ust/lttng-events.c

index c928fadb246c0ed5ff7fac57878987757348b91a..13ecb6d7f05077d4e4bd2ef883b5485630f4f5f4 100644 (file)
@@ -362,14 +362,18 @@ struct lttng_interpreter_output;
 struct lttng_ust_bytecode_runtime_private;
 
 /*
- * This structure is used in the probes. More specifically, the
- * `interpreter_funcs` and `node` fields are explicity used in the
- * probes. When modifying this structure we must not change the layout
- * of these two fields as it is considered ABI.
+ * 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_bytecode_runtime {
-       struct lttng_ust_bytecode_runtime_private *priv;
+struct lttng_ust_bytecode_runtime {
+       uint32_t struct_size;                   /* Size of this structure. */
 
+       struct lttng_ust_bytecode_runtime_private *priv;
        /* Associated bytecode */
        union {
                uint64_t (*filter)(void *interpreter_data,
@@ -379,6 +383,8 @@ struct lttng_bytecode_runtime {
                                struct lttng_interpreter_output *interpreter_output);
        } interpreter_funcs;
        struct cds_list_head node;      /* list of bytecode runtime in event */
+
+       /* End of base ABI. Fields below should be used after checking struct_size. */
 };
 
 /*
@@ -421,7 +427,7 @@ struct lttng_ust_event_common {
 
        int enabled;
        int has_enablers_without_bytecode;
-       /* list of struct lttng_bytecode_runtime, sorted by seqnum */
+       /* list of struct lttng_ust_bytecode_runtime, sorted by seqnum */
        struct cds_list_head filter_bytecode_runtime_head;
 
        /* End of base ABI. Fields below should be used after checking struct_size. */
index e743ffdad43a6982b87a6ca35a69cfb0c436ba52..428ff0b1a7e05a7e3615d8af6685b42f8d6d0bff 100644 (file)
@@ -824,7 +824,7 @@ void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))           \
        if (caa_unlikely(!TP_RCU_LINK_TEST()))                                \
                return;                                                       \
        if (caa_unlikely(!cds_list_empty(&__event->filter_bytecode_runtime_head))) { \
-               struct lttng_bytecode_runtime *__filter_bc_runtime;           \
+               struct lttng_ust_bytecode_runtime *__filter_bc_runtime;       \
                int __filter_record = __event->has_enablers_without_bytecode; \
                                                                              \
                __event_prepare_interpreter_stack__##_provider##___##_name(__stackvar.__interpreter_stack_data, \
index 570e5861cbc9974108afe65b97277e952201cca5..eb3c0bce1da35436cec17a21bb72f470349195d8 100644 (file)
@@ -368,7 +368,7 @@ void lttng_event_notifier_notification_send(
        notification_init(&notif, event_notifier);
 
        if (caa_unlikely(!cds_list_empty(&event_notifier->capture_bytecode_runtime_head))) {
-               struct lttng_bytecode_runtime *capture_bc_runtime;
+               struct lttng_ust_bytecode_runtime *capture_bc_runtime;
 
                /*
                 * Iterate over all the capture bytecodes. If the interpreter
index 39881be021d896420c97b45aa074da227a1a0cfd..a16b35cc2fd752c1375660903aed2010a76ef497 100644 (file)
@@ -381,7 +381,7 @@ static
 int bytecode_is_linked(struct lttng_ust_bytecode_node *bytecode,
                struct cds_list_head *bytecode_runtime_head)
 {
-       struct lttng_bytecode_runtime *bc_runtime;
+       struct lttng_ust_bytecode_runtime *bc_runtime;
 
        cds_list_for_each_entry(bc_runtime, bytecode_runtime_head, node) {
                if (bc_runtime->priv->bc == bytecode)
@@ -429,6 +429,7 @@ int link_bytecode(const struct lttng_ust_event_desc *event_desc,
                goto alloc_error;
        }
        runtime->p.priv = runtime_priv;
+       runtime->p.struct_size = sizeof(struct lttng_ust_bytecode_runtime);
        runtime_priv->pub = runtime;
        runtime_priv->bc = bytecode;
        runtime_priv->pctx = ctx;
@@ -499,7 +500,7 @@ alloc_error:
        return ret;
 }
 
-void lttng_bytecode_filter_sync_state(struct lttng_bytecode_runtime *runtime)
+void lttng_bytecode_filter_sync_state(struct lttng_ust_bytecode_runtime *runtime)
 {
        struct lttng_ust_bytecode_node *bc = runtime->priv->bc;
 
@@ -509,7 +510,7 @@ void lttng_bytecode_filter_sync_state(struct lttng_bytecode_runtime *runtime)
                runtime->interpreter_funcs.filter = lttng_bytecode_filter_interpret;
 }
 
-void lttng_bytecode_capture_sync_state(struct lttng_bytecode_runtime *runtime)
+void lttng_bytecode_capture_sync_state(struct lttng_ust_bytecode_runtime *runtime)
 {
        struct lttng_ust_bytecode_node *bc = runtime->priv->bc;
 
@@ -533,7 +534,7 @@ void lttng_enabler_link_bytecode(const struct lttng_ust_event_desc *event_desc,
                struct cds_list_head *enabler_bytecode_head)
 {
        struct lttng_ust_bytecode_node *enabler_bc;
-       struct lttng_bytecode_runtime *runtime;
+       struct lttng_ust_bytecode_runtime *runtime;
 
        assert(event_desc);
 
index 90b4c332d7b6879786db2f7187ffce152ffb37a7..b84a9930292f14c810fedada2d838b4b095dd1c8 100644 (file)
@@ -59,7 +59,7 @@ do {                                                          \
 
 /* Linked bytecode. Child of struct lttng_bytecode_runtime. */
 struct bytecode_runtime {
-       struct lttng_bytecode_runtime p;
+       struct lttng_ust_bytecode_runtime p;
        size_t data_len;
        size_t data_alloc_len;
        char *data;
@@ -318,9 +318,9 @@ LTTNG_HIDDEN
 const char *lttng_bytecode_print_op(enum bytecode_op op);
 
 LTTNG_HIDDEN
-void lttng_bytecode_filter_sync_state(struct lttng_bytecode_runtime *runtime);
+void lttng_bytecode_filter_sync_state(struct lttng_ust_bytecode_runtime *runtime);
 LTTNG_HIDDEN
-void lttng_bytecode_capture_sync_state(struct lttng_bytecode_runtime *runtime);
+void lttng_bytecode_capture_sync_state(struct lttng_ust_bytecode_runtime *runtime);
 
 LTTNG_HIDDEN
 int lttng_bytecode_validate(struct bytecode_runtime *bytecode);
index 762395d657330b0aca25959661d8d2ebe587bb53..e7b59b1b806a9d713f07879774c4c179d470d59d 100644 (file)
@@ -1654,7 +1654,7 @@ void lttng_session_sync_event_enablers(struct lttng_session *session)
         */
        cds_list_for_each_entry(event_recorder_priv, &session->priv->events_head, node) {
                struct lttng_enabler_ref *enabler_ref;
-               struct lttng_bytecode_runtime *runtime;
+               struct lttng_ust_bytecode_runtime *runtime;
                int enabled = 0, has_enablers_without_bytecode = 0;
 
                /* Enable events */
@@ -1872,7 +1872,7 @@ void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group
         */
        cds_list_for_each_entry(event_notifier_priv, &event_notifier_group->event_notifiers_head, node) {
                struct lttng_enabler_ref *enabler_ref;
-               struct lttng_bytecode_runtime *runtime;
+               struct lttng_ust_bytecode_runtime *runtime;
                int enabled = 0, has_enablers_without_bytecode = 0;
 
                /* Enable event_notifiers */
This page took 0.029279 seconds and 4 git commands to generate.