sessiond: registry_event: remove lttng_ht_node_u64 wrapper
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 14 Jun 2022 15:56:51 +0000 (11:56 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 15 Jun 2022 15:07:53 +0000 (11:07 -0400)
Use rcu_head and cds_lfht_node directly since the lttng_ht_node_u64
utils is unused anyhow: its key is never initialized.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id8b8d4b2f9ca9137b859844bc70e9d02e9fa2975

src/bin/lttng-sessiond/ust-registry-channel.cpp
src/bin/lttng-sessiond/ust-registry-event.cpp
src/bin/lttng-sessiond/ust-registry-event.hpp
src/bin/lttng-sessiond/ust-registry-session.cpp
src/bin/lttng-sessiond/ust-registry.cpp

index d03c89c6e832cbc28cfcda045eec4a1096fb9de6..a2a1707dcbc180b3508c900b6fc0ff97bb982e9b 100644 (file)
@@ -48,12 +48,7 @@ int ht_match_event(struct cds_lfht_node *node, const void *_key)
        LTTNG_ASSERT(node);
        LTTNG_ASSERT(_key);
 
-       DIAGNOSTIC_PUSH
-       DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-       event = caa_container_of(node, lttng::sessiond::ust::registry_event, _node.node);
-       DIAGNOSTIC_POP
-
-       LTTNG_ASSERT(event);
+       event = lttng::utils::container_of(node, &lttng::sessiond::ust::registry_event::_node);
        key = (lttng::sessiond::ust::registry_event *) _key;
 
        /* It has to be a perfect match. First, compare the event names. */
@@ -158,18 +153,15 @@ void lsu::registry_channel::add_event(
         * are matched using the event name and signature.
         */
        nptr = cds_lfht_add_unique(_events->ht, _events->hash_fct(event.get(), lttng_ht_seed),
-                       _events->match_fct, event.get(), &event->_node.node);
-       if (nptr != &event->_node.node) {
+                       _events->match_fct, event.get(), &event->_node);
+       if (nptr != &event->_node) {
                if (buffer_type == LTTNG_BUFFER_PER_UID) {
                        /*
                         * This is normal, we just have to send the event id of the
                         * returned node.
                         */
-                       DIAGNOSTIC_PUSH
-                       DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-                       const auto existing_event = caa_container_of(
-                                       nptr, lttng::sessiond::ust::registry_event, _node.node);
-                       DIAGNOSTIC_POP
+                       const auto existing_event = lttng::utils::container_of(
+                                       nptr, &lttng::sessiond::ust::registry_event::_node);
                        event_id = existing_event->id;
                } else {
                        LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
@@ -239,7 +231,7 @@ void lsu::registry_channel::_accept_on_event_classes(
 
                DIAGNOSTIC_PUSH
                DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-               cds_lfht_for_each_entry(_events->ht, &iter.iter, event, _node.node) {
+               cds_lfht_for_each_entry(_events->ht, &iter.iter, event, _node) {
                        sorted_event_classes.emplace_back(event);
                }
                DIAGNOSTIC_POP
index 891e9e5b065d9ba26d5b0bac421eb96de08313fc..543da2f6670b36bf19088f0fc20a285ed7adf07e 100644 (file)
@@ -34,7 +34,8 @@ lsu::registry_event::registry_event(unsigned int in_id,
        signature{std::move(in_signature)},
        _metadata_dumped{false}
 {
-       cds_lfht_node_init(&this->_node.node);
+       cds_lfht_node_init(&_node);
+       _head = {};
 }
 
 /*
index 08b18a5c7504da8cfa5c3efd10ac021f64a1d35f..340c6b455a5b515a70d51cc0ebd2b2ca977dc0f1 100644 (file)
@@ -53,7 +53,8 @@ public:
         * Node in the ust-registry hash table. The event name is used to
         * initialize the node and the event_name/signature for the match function.
         */
-       struct lttng_ht_node_u64 _node;
+       struct cds_lfht_node _node;
+       struct rcu_head _head;
 };
 
 void registry_event_destroy(registry_event *event);
index 6e21cee00c6d314419761d6a494d7b41c2084bec..5bb8e6094e43726d93f7dc503e3a66dd39415de8 100644 (file)
@@ -125,7 +125,7 @@ void destroy_channel(lsu::registry_channel *chan, bool notify) noexcept
                DIAGNOSTIC_PUSH
                DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
                cds_lfht_for_each_entry(
-                               chan->_events->ht, &iter.iter, event, _node.node) {
+                               chan->_events->ht, &iter.iter, event, _node) {
                        /* Delete the node from the ht and free it. */
                        ust_registry_channel_destroy_event(chan, event);
                }
@@ -762,4 +762,4 @@ void lsu::registry_session::create_or_find_enum(
        DBG("UST registry reply with enum %s with id %" PRIu64 " in sess_objd: %u",
                        enum_name, reg_enum->id, session_objd);
        *enum_id = reg_enum->id;
-}
\ No newline at end of file
+}
index 2a7d6217a501b605eca4dd50c763b3d94025f5e7..a6ceece9882dad64dfd20606eb2148446bad05e4 100644 (file)
@@ -33,11 +33,10 @@ namespace lsu = lttng::sessiond::ust;
  */
 static void ust_registry_event_destroy_rcu(struct rcu_head *head)
 {
-       struct lttng_ht_node_u64 *node = lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
        lttng::sessiond::ust::registry_event *event =
-                       lttng::utils::container_of(node, &lttng::sessiond::ust::registry_event::_node);
+                       lttng::utils::container_of(head, &lttng::sessiond::ust::registry_event::_head);
        DIAGNOSTIC_POP
 
        lttng::sessiond::ust::registry_event_destroy(event);
@@ -58,11 +57,11 @@ void ust_registry_channel_destroy_event(lsu::registry_channel *chan,
        ASSERT_RCU_READ_LOCKED();
 
        /* Delete the node first. */
-       iter.iter.node = &event->_node.node;
+       iter.iter.node = &event->_node;
        ret = lttng_ht_del(chan->_events, &iter);
        LTTNG_ASSERT(!ret);
 
-       call_rcu(&event->_node.head, ust_registry_event_destroy_rcu);
+       call_rcu(&event->_head, ust_registry_event_destroy_rcu);
 
        return;
 }
This page took 0.029972 seconds and 4 git commands to generate.