From: Mathieu Desnoyers Date: Tue, 2 Nov 2021 18:16:38 +0000 (-0400) Subject: Refactoring: combine event hash tables common code X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=33af697f72163d725389878666a4ce9dce42a442;p=lttng-modules.git Refactoring: combine event hash tables common code Combine common code across notifier and recorder. Signed-off-by: Mathieu Desnoyers Change-Id: I1b781cf0481cc6d532622975376cc834d1b33603 --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index 35ed8879..873adc31 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -410,11 +410,11 @@ struct lttng_counter { struct lttng_counter_ops *ops; }; -#define LTTNG_EVENT_NOTIFIER_HT_BITS 12 -#define LTTNG_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_EVENT_NOTIFIER_HT_BITS) +#define LTTNG_EVENT_HT_BITS 12 +#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) -struct lttng_event_notifier_ht { - struct hlist_head table[LTTNG_EVENT_NOTIFIER_HT_SIZE]; +struct lttng_event_ht { + struct hlist_head table[LTTNG_EVENT_HT_SIZE]; }; struct lttng_event_notifier_group { @@ -423,7 +423,7 @@ struct lttng_event_notifier_group { struct list_head node; /* event notifier group list */ struct list_head enablers_head; /* List of enablers */ struct list_head event_notifiers_head; /* List of event notifier */ - struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */ + struct lttng_event_ht events_ht; /* Hash table of event notifiers */ struct lttng_kernel_channel_buffer_ops *ops; struct lttng_transport *transport; struct lttng_kernel_ring_buffer_channel *chan; /* Ring buffer channel for event notifier group. */ @@ -451,13 +451,6 @@ struct lttng_counter_transport { struct lttng_counter_ops ops; }; -#define LTTNG_EVENT_HT_BITS 12 -#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) - -struct lttng_event_ht { - struct hlist_head table[LTTNG_EVENT_HT_SIZE]; -}; - struct lttng_kernel_session_private { struct lttng_kernel_session *pub; /* Public session interface */ diff --git a/src/lttng-events.c b/src/lttng-events.c index 28df29fe..9f9e8947 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -321,8 +321,8 @@ struct lttng_event_notifier_group *lttng_event_notifier_group_create(void) INIT_LIST_HEAD(&event_notifier_group->enablers_head); INIT_LIST_HEAD(&event_notifier_group->event_notifiers_head); - for (i = 0; i < LTTNG_EVENT_NOTIFIER_HT_SIZE; i++) - INIT_HLIST_HEAD(&event_notifier_group->event_notifiers_ht.table[i]); + for (i = 0; i < LTTNG_EVENT_HT_SIZE; i++) + INIT_HLIST_HEAD(&event_notifier_group->events_ht.table[i]); list_add(&event_notifier_group->node, &event_notifier_groups); @@ -1190,8 +1190,8 @@ struct lttng_kernel_event_notifier *_lttng_event_notifier_create( goto type_error; } - head = utils_borrow_hash_table_bucket(event_notifier_group->event_notifiers_ht.table, - LTTNG_EVENT_NOTIFIER_HT_SIZE, event_name); + 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, @@ -2143,8 +2143,8 @@ void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifi * Check if already created. */ head = utils_borrow_hash_table_bucket( - event_notifier_group->event_notifiers_ht.table, - LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->event_name); + 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) diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 70bbdd33..ff14dbbb 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -881,8 +881,8 @@ int create_unknown_event_notifier( /* * Check if already created. */ - head = utils_borrow_hash_table_bucket(group->event_notifiers_ht.table, - LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->event_name); + 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) @@ -950,8 +950,8 @@ static int create_matching_event_notifiers( /* * Check if already created. */ - head = utils_borrow_hash_table_bucket(group->event_notifiers_ht.table, - LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->event_name); + 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 == event_notifier_enabler->parent.user_token)