Adapt to LTTng-UST ABI/control API updates
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 29 Jul 2024 13:55:50 +0000 (09:55 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 29 Jul 2024 18:47:41 +0000 (14:47 -0400)
Adapt to ABI/control API updates introduced by LTTng-UST commit
24f7193c9b91 ("Introduce extension points for trace hit counters")

Note that this commit reverts back to uint32_t for channel event ids.

UST notification LTTNG_UST_CTL_NOTIFY_CMD_KEY is currently handled as
-LTTNG_UST_ERR_NOSYS (TODO).

The type of the argument to is_max_event_id() is changed to
lttng::sessiond::ust::event_id to match the newly introduced event_id
type definition. Likewise for the registry_channel _next_event_id
member.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6299b07c02d35b067aed5e94f11353d3cc14f24c

src/bin/lttng-sessiond/ust-abi-internal.hpp
src/bin/lttng-sessiond/ust-app.cpp
src/bin/lttng-sessiond/ust-ctl-internal.hpp
src/bin/lttng-sessiond/ust-registry-channel.cpp
src/bin/lttng-sessiond/ust-registry-channel.hpp

index b69d6b1483fe6088a8e803a49e9f5355b20155a6..474dfd6f115458579bf0e6e684a926fd4ae612b9 100644 (file)
@@ -138,33 +138,80 @@ enum lttng_ust_abi_counter_bitness {
        LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
 };
 
-struct lttng_ust_abi_counter_key_string {
-       uint32_t string_len; /* string length (includes \0) */
-       char str[]; /* Null-terminated string. */
+struct lttng_ust_abi_key_token {
+       uint32_t len;                           /* length of child structure. */
+       uint32_t type;                          /* enum lttng_ust_abi_key_token_type */
+       /*
+        * The size of this structure is fixed because it is embedded into
+        * children structures.
+        */
 } LTTNG_PACKED;
 
-struct lttng_ust_abi_key_token {
-       uint32_t len; /* length of this structure. */
-       uint32_t type; /* enum lttng_ust_key_token_type */
+/* Length of this structure excludes the following string. */
+struct lttng_ust_abi_key_token_string {
+       struct lttng_ust_abi_key_token parent;
+       uint32_t string_len;            /* string length (includes \0) */
 
-       /* Followed by a struct lttng_ust_abi_counter_key_string for LTTNG_UST_ABI_KEY_TOKEN_STRING.
-        */
+       char str[];                     /* Null-terminated string following this structure. */
 } LTTNG_PACKED;
 
+/*
+ * token types event_name and provider_name don't have specific fields,
+ * so they do not need to derive their own specific child structure.
+ */
+
+/*
+ * Dimension indexing: All events should use the same key type to index
+ * a given map dimension.
+ */
+enum lttng_ust_abi_key_type {
+       LTTNG_UST_ABI_KEY_TYPE_TOKENS = 0,              /* Dimension key is a set of tokens. */
+       LTTNG_UST_ABI_KEY_TYPE_INTEGER = 1,             /* Dimension key is an integer value. */
+};
+
 struct lttng_ust_abi_counter_key_dimension {
-       uint32_t len; /* length of this structure */
+       uint32_t len;                           /* length of child structure */
+       uint32_t key_type;                      /* enum lttng_ust_abi_key_type */
+       /*
+        * The size of this structure is fixed because it is embedded into
+        * children structures.
+        */
+} LTTNG_PACKED;
+
+struct lttng_ust_abi_counter_key_dimension_tokens {
+       struct lttng_ust_abi_counter_key_dimension parent;
        uint32_t nr_key_tokens;
 
-       /* Followed by a variable-length array of key tokens */
+       /* Followed by an array of nr_key_tokens struct lttng_ust_abi_key_token elements. */
 } LTTNG_PACKED;
 
+/*
+ * The "integer" key type is not implemented yet, but when it will be
+ * introduced in the future, its specific key dimension will allow
+ * defining the function to apply over input argument, bytecode to run
+ * and so on.
+ */
+
+enum lttng_ust_abi_counter_action {
+       LTTNG_UST_ABI_COUNTER_ACTION_INCREMENT = 0,
+
+       /*
+        * Can be extended with additional actions, such as decrement,
+        * set value, run bytecode, and so on.
+        */
+};
+
 struct lttng_ust_abi_counter_event {
-       uint32_t len; /* length of this structure */
+       uint32_t len;                           /* length of this structure */
+       uint32_t action;                        /* enum lttng_ust_abi_counter_action */
 
        struct lttng_ust_abi_event event;
-       uint32_t number_key_dimensions; /* array of dimensions is an array of var. len. elements. */
+       uint32_t number_key_dimensions;         /* array of dimensions is an array of var. len. elements. */
 
-       /* Followed by a variable-length array of key dimensions */
+       /*
+        * Followed by additional data specific to the action, and by a
+        * variable-length array of key dimensions.
+        */
 } LTTNG_PACKED;
 
 enum lttng_ust_abi_counter_dimension_flags {
@@ -173,8 +220,9 @@ enum lttng_ust_abi_counter_dimension_flags {
 };
 
 struct lttng_ust_abi_counter_dimension {
-       uint32_t flags; /* enum lttng_ust_abi_counter_dimension_flags */
-       uint64_t size; /* dimension size */
+       uint32_t key_type;                      /* enum lttng_ust_abi_key_type */
+       uint32_t flags;                         /* enum lttng_ust_abi_counter_dimension_flags */
+       uint64_t size;                          /* dimension size (count of entries) */
        uint64_t underflow_index;
        uint64_t overflow_index;
 } LTTNG_PACKED;
index 9fef3cdcb386b0606b51934ed99b1ad9d8eaf870..61d3774bf6a25c88c2c3b8dee99aee2b59ba9895 100644 (file)
@@ -6994,6 +6994,13 @@ int ust_app_recv_notify(int sock)
 
                break;
        }
+       case LTTNG_UST_CTL_NOTIFY_CMD_KEY:
+       {
+               DBG2("UST app ustctl register key received");
+               ret = -LTTNG_UST_ERR_NOSYS;
+               //TODO
+               goto error;
+       }
        default:
                /* Should NEVER happen. */
                abort();
@@ -7906,4 +7913,4 @@ void ust_app_put(struct ust_app *app)
 lttng_ht *ust_app_get_all()
 {
        return ust_app_ht;
-}
\ No newline at end of file
+}
index 998f884a28b5f55fa01f0fdb251e91981ee09bac..79e07d9e81f149d9d9b7b702ac03411d3026ee9d 100644 (file)
@@ -300,6 +300,7 @@ enum lttng_ust_ctl_notify_cmd {
        LTTNG_UST_CTL_NOTIFY_CMD_EVENT = 0,
        LTTNG_UST_CTL_NOTIFY_CMD_CHANNEL = 1,
        LTTNG_UST_CTL_NOTIFY_CMD_ENUM = 2,
+       LTTNG_UST_CTL_NOTIFY_CMD_KEY = 3,
 };
 
 enum lttng_ust_ctl_channel_header {
@@ -531,9 +532,44 @@ int lttng_ust_ctl_recv_register_event(int sock,
  * Returns 0 on success, negative error value on error.
  */
 int lttng_ust_ctl_reply_register_event(int sock,
-                                      uint64_t id, /* id (input) */
+                                      uint32_t id, /* id (input) */
                                       int ret_code); /* return code. 0 ok, negative error */
 
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int lttng_ust_ctl_recv_register_key(int sock,
+       int *session_objd,              /* session descriptor (output) */
+       int *map_objd,                  /* map descriptor (output) */
+       uint32_t *dimension,            /*
+                                        * Against which dimension is
+                                        * this key expressed. (output)
+                                        */
+       uint64_t **dimension_indexes,   /*
+                                        * Indexes (output,
+                                        * dynamically
+                                        * allocated, must be
+                                        * free(3)'d by the
+                                        * caller if function
+                                        * returns success.)
+                                        * Contains @dimension
+                                        * elements.
+                                        */
+       char **key_string,              /*
+                                        * key string (output,
+                                        * dynamically allocated, must
+                                        * be free(3)'d by the caller if
+                                        * function returns success.)
+                                        */
+       uint64_t *user_token);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int lttng_ust_ctl_reply_register_key(int sock,
+       uint64_t index,                 /* Index within dimension (input) */
+       int ret_code);                  /* return code. 0 ok, negative error */
+
 /*
  * Returns 0 on success, negative UST or system error value on error.
  */
@@ -581,6 +617,11 @@ enum lttng_ust_ctl_counter_arithmetic {
        LTTNG_UST_CTL_COUNTER_ARITHMETIC_SATURATION = 1,
 };
 
+enum lttng_ust_ctl_key_type {
+       LTTNG_UST_CTL_KEY_TYPE_TOKENS = 0,
+       LTTNG_UST_CTL_KEY_TYPE_INTEGER = 1,
+};
+
 /* Used as alloc flags. */
 enum lttng_ust_ctl_counter_alloc {
        LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU = (1 << 0),
@@ -595,6 +636,7 @@ struct lttng_ust_ctl_counter_dimension {
        uint64_t size;
        uint64_t underflow_index;
        uint64_t overflow_index;
+       enum lttng_ust_ctl_key_type key_type;
        uint8_t has_underflow;
        uint8_t has_overflow;
 };
index 84ae5a4483d985b6fa2923e04e4a7cc92e0ab1bd..29c90756f197baa22fa945feb066b2120011bc70 100644 (file)
@@ -22,7 +22,7 @@ namespace lst = lttng::sessiond::trace;
 namespace lsu = lttng::sessiond::ust;
 
 namespace {
-bool is_max_event_id(uint32_t id)
+bool is_max_event_id(lttng::sessiond::ust::event_id id)
 {
        return id == UINT32_MAX;
 }
index 4d847a2b067d5dd5afec145f7f17bd29231f9bd8..f0a5350a00e5d6590b2086c867b9a1134b64b4ff 100644 (file)
@@ -26,7 +26,7 @@ namespace ust {
 
 class registry_event;
 
-using event_id = uint64_t;
+using event_id = uint32_t;
 
 class registry_channel : public lttng::sessiond::trace::stream_class {
 public:
@@ -74,7 +74,7 @@ public:
        /* For delayed reclaim */
        struct rcu_head _rcu_head;
        /* Once this value reaches UINT32_MAX, no more id can be allocated. */
-       uint32_t _next_event_id;
+       event_id _next_event_id;
 
 private:
        void _accept_on_event_classes(
This page took 0.031293 seconds and 4 git commands to generate.