Match event keys for syscall events
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 10 Feb 2022 19:35:09 +0000 (14:35 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 15 Jul 2024 20:58:48 +0000 (16:58 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia0b3df16abeda9e0a404eeed156e33c17f4f47e3

include/lttng/events-internal.h
src/lttng-events.c
src/lttng-syscalls.c

index 9a28b197cecf22b12d868fd9a0a91c25eb35291a..c2dd3b945469d9da6b0b9f3b448591940384e633 100644 (file)
@@ -930,9 +930,6 @@ bool lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
                struct lttng_event_enabler_common *enabler);
 bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_enabler,
                struct lttng_kernel_event_common *event);
-bool lttng_event_enabler_desc_match_event(struct lttng_event_enabler_common *event_enabler,
-               const struct lttng_kernel_event_desc *desc,
-               struct lttng_kernel_event_common *event);
 bool lttng_event_enabler_event_name_match_event(struct lttng_event_enabler_common *event_enabler,
                const char *event_name,
                struct lttng_kernel_event_common *event);
@@ -1225,6 +1222,11 @@ struct lttng_kernel_channel_buffer *lttng_kernel_alloc_channel_buffer(void);
 struct lttng_kernel_channel_counter *lttng_kernel_alloc_channel_counter(void);
 void lttng_kernel_free_channel_common(struct lttng_kernel_channel_common *chan);
 
+int format_event_key(struct lttng_event_enabler_common *event_enabler, char *key_string,
+                    const char *event_name);
+bool lttng_event_enabler_event_name_key_match_event(struct lttng_event_enabler_common *event_enabler,
+               const char *event_name, const char *key_string, struct lttng_kernel_event_common *event);
+
 #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv)   \
        __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, {                                 \
                .event_field = (_event_field),                                                          \
index d7c488eca44bbdb187d9c701d529cb2e3568c69c..1da03651bcbe476cfbafefb7eaf4868a5a2f0d0c 100644 (file)
@@ -1131,7 +1131,6 @@ int lttng_kernel_event_notifier_clear_error_counter(struct lttng_kernel_event_co
        }
 }
 
-static
 int format_event_key(struct lttng_event_enabler_common *event_enabler, char *key_string,
                     const char *event_name)
 {
@@ -1210,7 +1209,6 @@ bool match_event_session_token(struct lttng_kernel_event_session_common_private
        return false;
 }
 
-static
 bool lttng_event_enabler_event_name_key_match_event(struct lttng_event_enabler_common *event_enabler,
                const char *event_name, const char *key_string, struct lttng_kernel_event_common *event)
 {
@@ -2156,47 +2154,6 @@ bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_en
        }
 }
 
-bool lttng_event_enabler_desc_match_event(struct lttng_event_enabler_common *event_enabler,
-               const struct lttng_kernel_event_desc *desc,
-               struct lttng_kernel_event_common *event)
-{
-       if (event_enabler->event_param.instrumentation != event->priv->instrumentation)
-               return false;
-
-       switch (event_enabler->enabler_type) {
-       case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
-       {
-               struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
-               struct lttng_kernel_event_recorder *event_recorder =
-                       container_of(event, struct lttng_kernel_event_recorder, parent);
-
-               if (event->priv->desc == desc && event_recorder->chan == event_recorder_enabler->chan)
-                       return true;
-               else
-                       return false;
-       }
-       //TODO: LTTNG_EVENT_ENABLER_TYPE_COUNTER
-       case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
-       {
-               struct lttng_event_notifier_enabler *event_notifier_enabler =
-                       container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
-               struct lttng_kernel_event_notifier *event_notifier =
-                       container_of(event, struct lttng_kernel_event_notifier, parent);
-
-               if (event->priv->desc == desc
-                               && event_notifier->priv->group == event_notifier_enabler->group
-                               && event->priv->user_token == event_enabler->user_token)
-                       return true;
-               else
-                       return false;
-       }
-       default:
-               WARN_ON_ONCE(1);
-               return false;
-       }
-}
-
 bool lttng_event_enabler_event_name_match_event(struct lttng_event_enabler_common *event_enabler,
                const char *event_name,
                struct lttng_kernel_event_common *event)
index 7098ee7c0bfc9efcd144bf0c084178f8b96c1438..7904108debcf3339b66dc6ed5c7da99e8ed17dba 100644 (file)
@@ -653,6 +653,7 @@ void lttng_syscall_event_enabler_create_matching_syscall_table_events(struct ltt
 #endif
        /* iterate over all syscall and create event that match */
        for (i = 0; i < table_len; i++) {
+               char key_string[LTTNG_KEY_TOKEN_STRING_LEN_MAX] = { 0 };
                struct lttng_kernel_event_common_private *event_priv;
                struct hlist_head *head;
                bool found = false;
@@ -666,12 +667,15 @@ void lttng_syscall_event_enabler_create_matching_syscall_table_events(struct ltt
                if (!lttng_desc_match_enabler(desc, syscall_event_enabler_common))
                        continue;
 
+               if (format_event_key(syscall_event_enabler_common, key_string, desc->event_name))
+                       continue;
+
                /*
                 * Check if already created.
                 */
                head = utils_borrow_hash_table_bucket(events_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
                lttng_hlist_for_each_entry(event_priv, head, hlist_node) {
-                       if (lttng_event_enabler_desc_match_event(syscall_event_enabler_common, desc, event_priv->pub)) {
+                       if (lttng_event_enabler_event_name_key_match_event(syscall_event_enabler_common, desc->event_name, key_string, event_priv->pub)) {
                                found = true;
                                break;
                        }
@@ -700,6 +704,7 @@ bool lttng_syscall_event_enabler_is_wildcard_all(struct lttng_event_enabler_comm
 static
 void create_unknown_syscall_event(struct lttng_event_enabler_common *event_enabler, enum sc_type type)
 {
+       char key_string[LTTNG_KEY_TOKEN_STRING_LEN_MAX] = { 0 };
        struct lttng_event_ht *events_ht = lttng_get_event_ht_from_enabler(event_enabler);
        struct lttng_kernel_event_common_private *event_priv;
        const struct lttng_kernel_event_desc *desc;
@@ -739,12 +744,15 @@ void create_unknown_syscall_event(struct lttng_event_enabler_common *event_enabl
                WARN_ON_ONCE(1);
        }
 
+       if (format_event_key(event_enabler, key_string, desc->event_name))
+               return;
+
        /*
         * Check if already created.
         */
        head = utils_borrow_hash_table_bucket(events_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
        lttng_hlist_for_each_entry(event_priv, head, hlist_node) {
-               if (lttng_event_enabler_desc_match_event(event_enabler, desc, event_priv->pub)) {
+               if (lttng_event_enabler_event_name_key_match_event(event_enabler, desc->event_name, key_string, event_priv->pub)) {
                        found = true;
                        break;
                }
This page took 0.029508 seconds and 4 git commands to generate.