From: Mathieu Desnoyers Date: Tue, 16 Mar 2021 03:06:59 +0000 (-0400) Subject: Refactoring: struct lttng_bytecode_runtime X-Git-Tag: v2.13.0-rc1~284 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5469a374cdfeb3daa5d0f908f38ad427e3b753c9;p=lttng-ust.git Refactoring: struct lttng_bytecode_runtime - 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 Change-Id: I27f28092894332ec1ba6f9f9d0a5fae3f04df6fd --- diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index c928fadb..13ecb6d7 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -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. */ diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index e743ffda..428ff0b1 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -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, \ diff --git a/liblttng-ust/event-notifier-notification.c b/liblttng-ust/event-notifier-notification.c index 570e5861..eb3c0bce 100644 --- a/liblttng-ust/event-notifier-notification.c +++ b/liblttng-ust/event-notifier-notification.c @@ -368,7 +368,7 @@ void lttng_event_notifier_notification_send( notification_init(¬if, 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 diff --git a/liblttng-ust/lttng-bytecode.c b/liblttng-ust/lttng-bytecode.c index 39881be0..a16b35cc 100644 --- a/liblttng-ust/lttng-bytecode.c +++ b/liblttng-ust/lttng-bytecode.c @@ -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); diff --git a/liblttng-ust/lttng-bytecode.h b/liblttng-ust/lttng-bytecode.h index 90b4c332..b84a9930 100644 --- a/liblttng-ust/lttng-bytecode.h +++ b/liblttng-ust/lttng-bytecode.h @@ -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); diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 762395d6..e7b59b1b 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -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 */