From f6889c4b9e5b5a40bb7632529b110c200da05efc Mon Sep 17 00:00:00 2001 From: Christian von Elm Date: Fri, 4 Mar 2022 12:52:00 +0100 Subject: [PATCH] Write system_tree_node hierarchy --- include/lo2s/trace/reg_keys.hpp | 7 ++++++- include/lo2s/trace/trace.hpp | 12 ++++++++++++ src/trace/trace.cpp | 31 +++++++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/include/lo2s/trace/reg_keys.hpp b/include/lo2s/trace/reg_keys.hpp index aa4d9dda..9e41b412 100644 --- a/include/lo2s/trace/reg_keys.hpp +++ b/include/lo2s/trace/reg_keys.hpp @@ -140,6 +140,11 @@ struct Holder using type = otf2::lookup_definition_holder; }; template <> +struct Holder +{ + using type = otf2::lookup_definition_holder; +}; +template <> struct Holder { using type = otf2::lookup_definition_holder; @@ -174,7 +179,7 @@ struct Holder template <> struct Holder { - using type = otf2::lookup_definition_holder; + using type = otf2::lookup_definition_holder; }; template <> struct Holder diff --git a/include/lo2s/trace/trace.hpp b/include/lo2s/trace/trace.hpp index 3eeba866..1b899b48 100644 --- a/include/lo2s/trace/trace.hpp +++ b/include/lo2s/trace/trace.hpp @@ -259,6 +259,18 @@ class Trace } } + const otf2::definition::system_tree_node bio_parent_node(BlockDevice& device) + { + if (device.type == BlockDeviceType::PARTITION) + { + if (registry_.has(ByDev(device.parent))) + { + return registry_.get(ByDev(device.parent)); + } + } + return bio_system_tree_node_; + } + void create_userspace_metric_class() { const auto& counter_collection_ = perf::counter::requested_userspace_counters(); diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 6ba10179..a555a73c 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -174,6 +174,15 @@ Trace::Trace() bio_comm_group_ = registry_.create( intern("block devices"), otf2::common::paradigm_type::hardware, otf2::common::group_flag_type::none); + + for (auto& device : get_block_devices()) + { + if (device.type == BlockDeviceType::DISK) + { + block_io_handle(device); + bio_writer(device); + } + } } } @@ -402,7 +411,7 @@ otf2::writer::local& Trace::bio_writer(BlockDevice& device) const auto& intern_location = registry_.emplace( ByDev(device.id), name, bio_location_group, - otf2::definition::location::location_type::cpu_thread); + otf2::definition::location::location_type::process); hardware_comm_locations_group_.add_member(intern_location); return archive_(intern_location); @@ -437,14 +446,28 @@ otf2::definition::io_handle& Trace::block_io_handle(BlockDevice& device) { std::lock_guard guard(mutex_); + + // io_pre_created_handle can not be emplaced because it has no ref. + // So we have to check if we already created everything + if (registry_.has(ByDev(device.id))) + { + return registry_.get(ByDev(device.id)); + } + const auto& device_name = intern(device.name); + const otf2::definition::system_tree_node& parent = bio_parent_node(device); + Log::error() << parent.name(); + std::string device_class = (device.type == BlockDeviceType::PARTITION) ? "partition" : "disk"; + const auto& node = registry_.emplace( - ByDev(device.id), device_name, intern("block device"), bio_system_tree_node_); + ByDev(device.id), device_name, intern(device_class), bio_system_tree_node_); - const auto& file = registry_.create(device_name, node); + const auto& file = + registry_.emplace(ByDev(device.id), device_name, node); - const auto& block_comm = registry_.create(device_name, bio_comm_group_); + const auto& block_comm = + registry_.emplace(ByDev(device.id), device_name, bio_comm_group_); // we could have io handle parents and childs here (block device being the parent (sda), // partition being the child (sda1)) but that seems like it would be overkill.