topo: Added RPC to query the NUMA information to a given NUMA node ID.

This commit is contained in:
Michael Mueller
2022-10-20 16:58:45 +02:00
parent 20ef1af61b
commit 953afdaff3
5 changed files with 29 additions and 7 deletions

View File

@@ -34,6 +34,10 @@ struct Genode::Topo_session_client : Rpc_client<Topo_session>
return call<Rpc_node_affinity>(loc);
}
Topology::Numa_region node_at_id(unsigned node_id) override {
return call<Rpc_node_id>(node_id);
}
unsigned node_count() override {
return call<Rpc_node_count>();
}

View File

@@ -40,6 +40,10 @@ struct Genode::Topo_connection : Connection<Topo_session>, 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();
}

View File

@@ -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);
};

View File

@@ -34,6 +34,7 @@ class Genode::Topo_session_component : public Session_object<Topo_session>
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<Topo_session>
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;
}
};

View File

@@ -15,6 +15,7 @@
#include <topo_session_component.h>
#include <platform_generic.h>
#include <platform.h>
#include <base/log.h>
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();
}
}
}