From: Mathieu Desnoyers Date: Tue, 2 Nov 2021 20:42:52 +0000 (-0400) Subject: Refactoring: combine hlist_node into common event structure X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=19bef247a29761d0f9ecca993e7088b46456f199;p=lttng-modules.git Refactoring: combine hlist_node into common event structure Signed-off-by: Mathieu Desnoyers Change-Id: I998d4ff59f51da8e1c6068f0a4dbb52a759e2c3f --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index 30f56e15..3c741e66 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -77,6 +77,9 @@ struct lttng_kernel_event_common_private { int has_enablers_without_filter_bytecode; /* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */ struct list_head filter_bytecode_runtime_head; + + struct hlist_node hlist_node; /* node in events hash table */ + enum lttng_kernel_abi_instrumentation instrumentation; /* Selected by instrumentation */ union { @@ -100,7 +103,6 @@ struct lttng_kernel_event_recorder_private { struct lttng_kernel_event_recorder *pub; /* Public event interface */ struct list_head node; /* Event recorder list */ - struct hlist_node hlist; /* Hash table of event recorders */ struct lttng_kernel_ctx *ctx; unsigned int id; unsigned int metadata_dumped:1; @@ -114,9 +116,7 @@ struct lttng_kernel_event_notifier_private { size_t num_captures; /* Needed to allocate the msgpack array. */ uint64_t error_counter_index; struct list_head node; /* Event notifier list */ - struct hlist_node hlist; /* Hash table of event notifiers */ struct list_head capture_bytecode_runtime_head; - }; struct lttng_kernel_syscall_table { diff --git a/src/lttng-events.c b/src/lttng-events.c index 78ee916f..b6fbd347 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -881,6 +881,7 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l struct lttng_kernel_session *session = chan->parent.session; struct lttng_kernel_event_recorder *event_recorder; struct lttng_kernel_event_recorder_private *event_recorder_priv; + struct lttng_kernel_event_common_private *event_priv; const char *event_name; struct hlist_head *head; int ret; @@ -917,9 +918,11 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l head = utils_borrow_hash_table_bucket(session->priv->events_ht.table, LTTNG_EVENT_HT_SIZE, event_name); - lttng_hlist_for_each_entry(event_recorder_priv, head, hlist) { - WARN_ON_ONCE(!event_recorder_priv->parent.desc); - if (!strncmp(event_recorder_priv->parent.desc->event_name, event_name, + lttng_hlist_for_each_entry(event_priv, head, hlist_node) { + event_recorder_priv = container_of(event_priv, struct lttng_kernel_event_recorder_private, parent); + + WARN_ON_ONCE(!event_priv->desc); + if (!strncmp(event_priv->desc->event_name, event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1) && chan == event_recorder_priv->pub->chan) { ret = -EEXIST; @@ -1134,7 +1137,7 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l if (ret) { goto statedump_error; } - hlist_add_head(&event_recorder->priv->hlist, head); + hlist_add_head(&event_recorder->priv->parent.hlist_node, head); list_add(&event_recorder->priv->node, &chan->parent.session->priv->events); return event_recorder; @@ -1160,6 +1163,7 @@ struct lttng_kernel_event_notifier *_lttng_event_notifier_create(struct lttng_ev enum lttng_kernel_abi_instrumentation itype = event_param->instrumentation; struct lttng_kernel_event_notifier *event_notifier; struct lttng_kernel_event_notifier_private *event_notifier_priv; + struct lttng_kernel_event_common_private *event_priv; struct lttng_counter *error_counter; const char *event_name; struct hlist_head *head; @@ -1192,12 +1196,14 @@ struct lttng_kernel_event_notifier *_lttng_event_notifier_create(struct lttng_ev head = utils_borrow_hash_table_bucket(event_notifier_group->events_ht.table, LTTNG_EVENT_HT_SIZE, event_name); - lttng_hlist_for_each_entry(event_notifier_priv, head, hlist) { - WARN_ON_ONCE(!event_notifier_priv->parent.desc); - if (!strncmp(event_notifier_priv->parent.desc->event_name, event_name, + lttng_hlist_for_each_entry(event_priv, head, hlist_node) { + event_notifier_priv = container_of(event_priv, struct lttng_kernel_event_notifier_private, parent); + + WARN_ON_ONCE(!event_priv->desc); + if (!strncmp(event_priv->desc->event_name, event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1) && event_notifier_group == event_notifier_priv->group - && token == event_notifier_priv->parent.user_token) { + && token == event_priv->user_token) { ret = -EEXIST; goto exist; } @@ -1342,7 +1348,7 @@ struct lttng_kernel_event_notifier *_lttng_event_notifier_create(struct lttng_ev } list_add(&event_notifier->priv->node, &event_notifier_group->event_notifiers_head); - hlist_add_head(&event_notifier->priv->hlist, head); + hlist_add_head(&event_notifier->priv->parent.hlist_node, head); /* * Clear the error counter bucket. The sessiond keeps track of which @@ -2071,8 +2077,9 @@ void lttng_create_tracepoint_event_if_missing(struct lttng_event_recorder_enable for (i = 0; i < probe_desc->nr_events; i++) { int found = 0; struct hlist_head *head; - struct lttng_kernel_event_recorder_private *event_recorder_private; + struct lttng_kernel_event_recorder_private *event_recorder_priv; struct lttng_kernel_event_recorder *event_recorder; + struct lttng_kernel_event_common_private *event_priv; desc = probe_desc->event_desc[i]; if (!lttng_desc_match_enabler(desc, @@ -2085,9 +2092,10 @@ void lttng_create_tracepoint_event_if_missing(struct lttng_event_recorder_enable head = utils_borrow_hash_table_bucket( session->priv->events_ht.table, LTTNG_EVENT_HT_SIZE, desc->event_name); - lttng_hlist_for_each_entry(event_recorder_private, head, hlist) { - if (event_recorder_private->parent.desc == desc - && event_recorder_private->pub->chan == event_enabler->chan) + lttng_hlist_for_each_entry(event_priv, head, hlist_node) { + event_recorder_priv = container_of(event_priv, struct lttng_kernel_event_recorder_private, parent); + if (event_priv->desc == desc + && event_recorder_priv->pub->chan == event_enabler->chan) found = 1; } if (found) @@ -2125,8 +2133,8 @@ void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifi for (i = 0; i < probe_desc->nr_events; i++) { int found = 0; struct hlist_head *head; - struct lttng_kernel_event_notifier_private *event_notifier_priv; struct lttng_kernel_event_notifier *event_notifier; + struct lttng_kernel_event_common_private *event_priv; desc = probe_desc->event_desc[i]; if (!lttng_desc_match_enabler(desc, @@ -2139,9 +2147,9 @@ void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifi head = utils_borrow_hash_table_bucket( event_notifier_group->events_ht.table, LTTNG_EVENT_HT_SIZE, desc->event_name); - lttng_hlist_for_each_entry(event_notifier_priv, head, hlist) { - if (event_notifier_priv->parent.desc == desc - && event_notifier_priv->parent.user_token == event_notifier_enabler->parent.user_token) + lttng_hlist_for_each_entry(event_priv, head, hlist_node) { + if (event_priv->desc == desc + && event_priv->user_token == event_notifier_enabler->parent.user_token) found = 1; } if (found) diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 360f12b4..7fa6d7e5 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -546,8 +546,8 @@ int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *tabl const struct lttng_kernel_event_desc *desc = table[i].desc; struct lttng_event_recorder_enabler *event_enabler; struct lttng_kernel_abi_event ev; - struct lttng_kernel_event_recorder_private *event_recorder_priv; struct lttng_kernel_event_recorder *event_recorder; + struct lttng_kernel_event_common_private *event_priv; struct hlist_head *head; bool found = false; @@ -564,9 +564,9 @@ int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *tabl head = utils_borrow_hash_table_bucket( session->priv->events_ht.table, LTTNG_EVENT_HT_SIZE, desc->event_name); - lttng_hlist_for_each_entry(event_recorder_priv, head, hlist) { - if (event_recorder_priv->parent.desc == desc - && get_syscall_table_from_event(event_recorder_priv->parent.pub) == syscall_table) + lttng_hlist_for_each_entry(event_priv, head, hlist_node) { + if (event_priv->desc == desc + && get_syscall_table_from_event(event_priv->pub) == syscall_table) found = true; } if (found) @@ -832,7 +832,7 @@ int create_unknown_event_notifier( struct lttng_event_notifier_enabler *event_notifier_enabler, enum sc_type type) { - struct lttng_kernel_event_notifier_private *event_notifier_priv; + struct lttng_kernel_event_common_private *event_priv; struct lttng_kernel_event_notifier *event_notifier; const struct lttng_kernel_event_desc *desc; struct lttng_event_notifier_group *group = event_notifier_enabler->group; @@ -883,9 +883,9 @@ int create_unknown_event_notifier( */ head = utils_borrow_hash_table_bucket(group->events_ht.table, LTTNG_EVENT_HT_SIZE, desc->event_name); - lttng_hlist_for_each_entry(event_notifier_priv, head, hlist) { - if (event_notifier_priv->parent.desc == desc && - event_notifier_priv->parent.user_token == base_enabler->user_token) + lttng_hlist_for_each_entry(event_priv, head, hlist_node) { + if (event_priv->desc == desc && + event_priv->user_token == base_enabler->user_token) found = true; } if (found) @@ -936,7 +936,7 @@ static int create_matching_event_notifiers( /* iterate over all syscall and create event_notifier that match */ for (i = 0; i < table_len; i++) { struct lttng_event_notifier_enabler *event_notifier_enabler; - struct lttng_kernel_event_notifier_private *event_notifier_priv; + struct lttng_kernel_event_common_private *event_priv; struct lttng_kernel_event_notifier *event_notifier; struct lttng_kernel_abi_event_notifier event_notifier_param; struct hlist_head *head; @@ -957,9 +957,9 @@ static int create_matching_event_notifiers( */ head = utils_borrow_hash_table_bucket(group->events_ht.table, LTTNG_EVENT_HT_SIZE, desc->event_name); - lttng_hlist_for_each_entry(event_notifier_priv, head, hlist) { - if (event_notifier_priv->parent.desc == desc - && event_notifier_priv->parent.user_token == syscall_event_notifier_enabler->parent.user_token) + lttng_hlist_for_each_entry(event_priv, head, hlist_node) { + if (event_priv->desc == desc + && event_priv->user_token == syscall_event_notifier_enabler->parent.user_token) found = 1; } if (found)