diff --git a/repos/base/include/topo_session/client.h b/repos/base/include/topo_session/client.h index fa6e011e47..35d00fcbb8 100644 --- a/repos/base/include/topo_session/client.h +++ b/repos/base/include/topo_session/client.h @@ -34,6 +34,10 @@ struct Genode::Topo_session_client : Rpc_client return call(loc); } + Topology::Numa_region node_at_id(unsigned node_id) override { + return call(node_id); + } + unsigned node_count() override { return call(); } diff --git a/repos/base/include/topo_session/connection.h b/repos/base/include/topo_session/connection.h index ce1bd38624..f20601f391 100644 --- a/repos/base/include/topo_session/connection.h +++ b/repos/base/include/topo_session/connection.h @@ -40,6 +40,10 @@ struct Genode::Topo_connection : Connection, Topo_session_client return Topo_session_client::node_affinity_of(loc); } + Topology::Numa_region node_at_id(unsigned node_id) override { + return Topo_session_client::node_at_id(node_id); + } + unsigned node_count() override { return Topo_session_client::node_count(); } diff --git a/repos/base/include/topo_session/topo_session.h b/repos/base/include/topo_session/topo_session.h index 8d0eeffff7..d6f90b9d06 100644 --- a/repos/base/include/topo_session/topo_session.h +++ b/repos/base/include/topo_session/topo_session.h @@ -47,10 +47,12 @@ struct Genode::Topo_session : Session virtual ~Topo_session() { } virtual Topology::Numa_region node_affinity_of(Affinity::Location const &) = 0; + virtual Topology::Numa_region node_at_id(unsigned node_id) = 0; virtual unsigned node_count() = 0; GENODE_RPC(Rpc_node_affinity, Topology::Numa_region, node_affinity_of, Affinity::Location const &); + GENODE_RPC(Rpc_node_id, Topology::Numa_region, node_at_id, unsigned); GENODE_RPC(Rpc_node_count, unsigned, node_count); - GENODE_RPC_INTERFACE(Rpc_node_affinity, Rpc_node_count); + GENODE_RPC_INTERFACE(Rpc_node_affinity, Rpc_node_id, Rpc_node_count); }; \ No newline at end of file diff --git a/repos/base/src/core/include/topo_session_component.h b/repos/base/src/core/include/topo_session_component.h index 1eb36b00de..10ffb0e7b0 100644 --- a/repos/base/src/core/include/topo_session_component.h +++ b/repos/base/src/core/include/topo_session_component.h @@ -34,6 +34,7 @@ class Genode::Topo_session_component : public Session_object Topology::Numa_region _node_affinities[64][64]; unsigned _node_count; + Topology::Numa_region _nodes[64]; public: Topo_session_component(Rpc_entrypoint &session_ep, @@ -53,11 +54,15 @@ class Genode::Topo_session_component : public Session_object Topology::Numa_region node_affinity_of(Affinity::Location const &loc) override { return _node_affinities[loc.xpos()][loc.ypos()]; - } + } - unsigned node_count() override - { - return _node_count; - } + Topology::Numa_region node_at_id(unsigned numa_id) override + { + return _nodes[numa_id]; + } + unsigned node_count() override + { + return _node_count; + } }; diff --git a/repos/base/src/core/topo_session_component.cc b/repos/base/src/core/topo_session_component.cc index bd0d362de0..f4caaf3fd4 100644 --- a/repos/base/src/core/topo_session_component.cc +++ b/repos/base/src/core/topo_session_component.cc @@ -15,6 +15,7 @@ #include #include #include +#include using namespace Genode; @@ -36,6 +37,8 @@ Topo_session_component::Topo_session_component(Rpc_entrypoint &session_ep, unsigned curr_node_id = 0; Topology::Numa_region *node_created = new (_md_alloc) Topology::Numa_region[64](); + Genode::log("[", label, "] Creating new topology model of size ", width, "x", height); + for (unsigned x = 0; x < width; x++) { for (unsigned y = 0; y < height; y++) @@ -50,17 +53,21 @@ Topo_session_component::Topo_session_component(Rpc_entrypoint &session_ep, unsigned cpu_id = platform_specific().kernel_cpu_id(loc); unsigned native_id = platform_specific().domain_of_cpu(cpu_id); + log("[", label, "] CPU (", x, "x", y, ") is native CPU ", cpu_id, " on node ", native_id); + if (node_created[native_id].core_count() == 0) { - _node_affinities[x][y] = Topology::Numa_region(curr_node_id, native_id); + _nodes[curr_node_id] = _node_affinities[x][y] = Topology::Numa_region(curr_node_id, native_id); _node_affinities[x][y].increment_core_count(); node_created[native_id] = _node_affinities[x][y]; + log("[", label, "] Found new native NUMA region ", native_id, " for CPU (", x, "x", y, ")"); _node_count++; curr_node_id++; } else { (_node_affinities[x][y] = node_created[native_id]).increment_core_count(); + _nodes[curr_node_id].increment_core_count(); } } }