hoitaja: Use global affinity space for filtering affinities.

This commit is contained in:
Michael Mueller
2024-03-11 14:31:54 +01:00
parent b38f6ee39a
commit 0dbbca2af4

View File

@@ -1,12 +1,13 @@
#include "habitat.h" #include "habitat.h"
#include <sandbox/utils.h> #include <sandbox/utils.h>
#include <suoritin/request_task.h>
::Sandbox::Child &Hoitaja::Habitat::create_child(Genode::Xml_node const &start_node) ::Sandbox::Child &Hoitaja::Habitat::create_child(Genode::Xml_node const &start_node)
{ {
if (_affinity_space.constructed() && !_core_allocator.constructed()) if (_affinity_space.constructed() && !_core_allocator.constructed())
_core_allocator.construct(*_affinity_space, _prio_levels); _core_allocator.construct(*_affinity_space, _prio_levels);
Genode::Affinity::Location allocation = _core_allocator->allocate_cores_for_cell(start_node); Genode::Affinity::Location allocation = _core_allocator->allocate_cores_for_cell(start_node);
@@ -23,7 +24,7 @@
Hoitaja::Cell(_env, _heap, *_verbose, Hoitaja::Cell(_env, _heap, *_verbose,
Child::Id { ++_child_cnt }, _state_reporter, Child::Id { ++_child_cnt }, _state_reporter,
start_node, *this, *this, _children, *this, *this, *this, *this, start_node, *this, *this, _children, *this, *this, *this, *this,
_prio_levels, _effective_affinity_space(), allocation, _prio_levels, _env.topo().global_affinity_space(), allocation,
_parent_services, _child_services, _local_services, _habitat_handler); _parent_services, _child_services, _local_services, _habitat_handler);
_children.insert(static_cast<::Sandbox::Child *>(&child)); _children.insert(static_cast<::Sandbox::Child *>(&child));
@@ -60,6 +61,7 @@
warning("failed to create session during child construction"); } warning("failed to create session during child construction"); }
throw ::Sandbox::Start_model::Factory::Creation_failed(); throw ::Sandbox::Start_model::Factory::Creation_failed();
} }
void Hoitaja::Habitat::_destroy_abandoned_children() void Hoitaja::Habitat::_destroy_abandoned_children()
@@ -91,7 +93,7 @@ void Hoitaja::Habitat::_destroy_abandoned_children()
}); });
/* We might have formerly occupied resources again now, so redistribute them */ /* We might have formerly occupied resources again now, so redistribute them */
maintain_cells(); //maintain_cells();
} }
void Hoitaja::Habitat::maintain_cells() void Hoitaja::Habitat::maintain_cells()
@@ -99,20 +101,22 @@ void Hoitaja::Habitat::maintain_cells()
int xpos = _affinity_space->total(); int xpos = _affinity_space->total();
_children.for_each_child([&](Child &child) _children.for_each_child([&](Child &child)
{ {
log(child.name(), " ram: ", child.ram_quota()); //log(child.name(), " ram: ", child.ram_quota());
Cell &cell = static_cast<Cell&>(child); Cell &cell = static_cast<Cell&>(child);
_core_allocator->update(cell, &xpos); }); _core_allocator->update(cell, &xpos); });
suoritin.for_each([&](Tukija::Suoritin::Session_component &client) /*suoritin.for_each([&](Tukija::Suoritin::Session_component &client)
{ Genode::log("Cell ", client.label(), "\n------------"); { Genode::log("Cell ", client.label(), "\n------------");
for (unsigned long channel_id = 0; channel_id < client.channels(); channel_id++) { for (unsigned long channel_id = 0; channel_id < client.channels(); channel_id++)
{
Tukija::Suoritin::Channel &channel = client.channels_if()[channel_id]; Tukija::Suoritin::Channel &channel = client.channels_if()[channel_id];
Genode::log("\t", "Channel ", channel_id, ": length=", channel.length(), " worker=", client.worker(channel._worker).name(), ",", client.worker(channel._worker).cap() ); Genode::log("\t", "Channel ", channel_id, ": length=", channel.length(), " worker=", client.worker(channel._worker).name(), ",", client.worker(channel._worker).cap() );
if (channel.length() > 0xFFFF) { if (channel.length() > 0xFFFF) {
Genode::Parent::Resource_args grant_args("cpu_quota=10"); Genode::Parent::Resource_args grant_args("cpu_quota=10");
client.send_request(grant_args); client.send_request(grant_args);
} }
} }
}); });*/
} }
void Hoitaja::Habitat::update(Cell &cell) void Hoitaja::Habitat::update(Cell &cell)
@@ -128,3 +132,9 @@ void Hoitaja::Habitat::update(Cell &cell)
maintain_cells(); maintain_cells();
} }
} }
void Hoitaja::Core_allocation_request::handle(Hoitaja::Cell&, Hoitaja::Habitat&)
{
Genode::Parent::Resource_args grant_args("cpu_quota=10");
client().send_request(grant_args);
}