From de5ba5d9c83f4efc5ea7e31a5d0192f5cb0b60b5 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 27 Mar 2023 16:33:13 +0200 Subject: [PATCH] Worker and channel allocation adopted to Genode's memory management. --- src/mx/tasking/channel.h | 2 ++ src/mx/tasking/scheduler.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mx/tasking/channel.h b/src/mx/tasking/channel.h index 1f19045..ed51949 100644 --- a/src/mx/tasking/channel.h +++ b/src/mx/tasking/channel.h @@ -138,6 +138,8 @@ public: return _occupancy.has_excessive_usage_prediction(); } + std::uint8_t numa_node_id() { return _numa_node_id; } + private: // Backend queues for multiple produces in different NUMA regions and different priorities, alignas(64) diff --git a/src/mx/tasking/scheduler.cpp b/src/mx/tasking/scheduler.cpp index beafa7c..a156cef 100644 --- a/src/mx/tasking/scheduler.cpp +++ b/src/mx/tasking/scheduler.cpp @@ -2,10 +2,10 @@ #include #include #include -#include #include #include #include +#include using namespace mx::tasking; @@ -16,13 +16,13 @@ Scheduler::Scheduler(const mx::util::core_set &core_set, const std::uint16_t pre { this->_worker.fill(nullptr); this->_channel_numa_node_map.fill(0U); - for (auto worker_id = 0U; worker_id < this->_count_channels; ++worker_id) { const auto core_id = this->_core_set[worker_id]; this->_channel_numa_node_map[worker_id] = system::topology::node_id(core_id); + auto ptr = memory::GlobalHeap::allocate(this->_channel_numa_node_map[worker_id], sizeof(Worker)); this->_worker[worker_id] = - new (memory::GlobalHeap::allocate(this->_channel_numa_node_map[worker_id], sizeof(Worker))) + new (ptr) Worker(worker_id, core_id, this->_channel_numa_node_map[worker_id], this->_is_running, prefetch_distance, this->_epoch_manager[worker_id], this->_epoch_manager.global_epoch(), this->_statistic); @@ -33,8 +33,9 @@ Scheduler::~Scheduler() noexcept { for (auto *worker : this->_worker) { + std::uint8_t node_id = worker->channel().numa_node_id(); worker->~Worker(); - memory::GlobalHeap::free(worker, sizeof(Worker)); + memory::GlobalHeap::free(worker, sizeof(Worker), node_id); } } @@ -47,7 +48,7 @@ void Scheduler::start_and_wait() { worker_threads[channel_id] = std::thread([this, channel_id] { this->_worker[channel_id]->execute(); }); - system::thread::pin(worker_threads[channel_id], this->_worker[channel_id]->core_id()); + //system::thread::pin(worker_threads[channel_id], this->_worker[channel_id]->core_id()); } // ... and epoch management (if enabled).