From: Mathieu Desnoyers Date: Thu, 10 Feb 2022 19:35:09 +0000 (-0500) Subject: Match event keys for syscall events X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d9f47662bd2076e2c18297f8fc4f3c3dfd95e157;p=lttng-modules.git Match event keys for syscall events Signed-off-by: Mathieu Desnoyers Change-Id: Ia0b3df16abeda9e0a404eeed156e33c17f4f47e3 --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index 9a28b197..c2dd3b94 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -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), \ diff --git a/src/lttng-events.c b/src/lttng-events.c index d7c488ec..1da03651 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -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) diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 7098ee7c..7904108d 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -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; }