Refactoring: combine event hash tables common code
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 2 Nov 2021 18:16:38 +0000 (14:16 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 2 Nov 2021 18:16:38 +0000 (14:16 -0400)
Combine common code across notifier and recorder.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1b781cf0481cc6d532622975376cc834d1b33603

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

index 35ed887930b9f8fa9d3f358832e6cd148eccfe3d..873adc31201238d2506538ba5e26df15d5aafe0c 100644 (file)
@@ -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 */
 
index 28df29fef012c70e91cf70f18c2c63a4ed132c1d..9f9e89471afb840b110fe7a4c4d7de0bcb2348ca 100644 (file)
@@ -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)
index 70bbdd33b568b8924abd9a017e6ff72778db7ecd..ff14dbbb0998782de88d72feae3aeef86c82f711 100644 (file)
@@ -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)
This page took 0.030497 seconds and 4 git commands to generate.