mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
base: Added RPC to allow to change affinity of CPU and TOPO session after creation. This is necessary, as a cell might be pushed out of its original CPU region by Hoitaja.
This commit is contained in:
@@ -42,6 +42,10 @@ struct Genode::Cpu_session_client : Rpc_client<Cpu_session>
|
||||
Affinity::Space affinity_space() const override {
|
||||
return call<Rpc_affinity_space>(); }
|
||||
|
||||
void move(const Affinity::Location loc) override {
|
||||
call<Rpc_move>(loc);
|
||||
}
|
||||
|
||||
Dataspace_capability trace_control() override {
|
||||
return call<Rpc_trace_control>(); }
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Genode { struct Cpu_connection; }
|
||||
|
||||
struct Genode::Cpu_connection : Connection<Cpu_session>, Cpu_session_client
|
||||
{
|
||||
enum { RAM_QUOTA = 36*1024 };
|
||||
enum { RAM_QUOTA = 72*1024 };
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@@ -138,6 +138,12 @@ struct Genode::Cpu_session : Session
|
||||
*/
|
||||
virtual Affinity::Space affinity_space() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Update affinity location of this CPU session
|
||||
*
|
||||
*/
|
||||
virtual void move(const Genode::Affinity::Location ) = 0;
|
||||
|
||||
/**
|
||||
* Translate generic priority value to kernel-specific priority levels
|
||||
*
|
||||
@@ -249,6 +255,7 @@ struct Genode::Cpu_session : Session
|
||||
GENODE_RPC(Rpc_migrate_thread, void, migrate_thread, Thread_capability, Affinity::Location);
|
||||
GENODE_RPC(Rpc_exception_sigh, void, exception_sigh, Signal_context_capability);
|
||||
GENODE_RPC(Rpc_affinity_space, Affinity::Space, affinity_space);
|
||||
GENODE_RPC(Rpc_move, void, move, Affinity::Location);
|
||||
GENODE_RPC(Rpc_trace_control, Dataspace_capability, trace_control);
|
||||
GENODE_RPC(Rpc_ref_account, int, ref_account, Cpu_session_capability);
|
||||
GENODE_RPC(Rpc_transfer_quota, int, transfer_quota, Cpu_session_capability, size_t);
|
||||
@@ -257,7 +264,7 @@ struct Genode::Cpu_session : Session
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_create_thread, Rpc_kill_thread, Rpc_exception_sigh,
|
||||
Rpc_affinity_space, Rpc_trace_control, Rpc_ref_account,
|
||||
Rpc_transfer_quota, Rpc_quota, Rpc_native_cpu, Rpc_migrate_thread);
|
||||
Rpc_transfer_quota, Rpc_quota, Rpc_native_cpu, Rpc_migrate_thread, Rpc_move);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -41,4 +41,9 @@ struct Genode::Topo_session_client : Rpc_client<Topo_session>
|
||||
unsigned node_count() override {
|
||||
return call<Rpc_node_count>();
|
||||
}
|
||||
|
||||
void reconstruct(const Affinity affinity) override
|
||||
{
|
||||
call<Rpc_reconstruct>(affinity);
|
||||
}
|
||||
};
|
||||
@@ -49,10 +49,12 @@ struct Genode::Topo_session : 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;
|
||||
virtual void reconstruct(const Affinity) = 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(Rpc_reconstruct, void, reconstruct, Affinity);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_node_affinity, Rpc_node_id, Rpc_node_count);
|
||||
GENODE_RPC_INTERFACE(Rpc_node_affinity, Rpc_node_id, Rpc_node_count, Rpc_reconstruct);
|
||||
};
|
||||
@@ -171,6 +171,10 @@ Affinity::Space Cpu_session_component::affinity_space() const
|
||||
return Affinity::Space(_location.width(), _location.height());
|
||||
}
|
||||
|
||||
void Cpu_session_component::move(const Affinity::Location destination)
|
||||
{
|
||||
_location = destination;
|
||||
}
|
||||
|
||||
Dataspace_capability Cpu_session_component::trace_control()
|
||||
{
|
||||
|
||||
@@ -172,6 +172,7 @@ class Genode::Cpu_session_component : public Session_object<Cpu_session>,
|
||||
void migrate_thread(Thread_capability, Affinity::Location) override;
|
||||
void exception_sigh(Signal_context_capability) override;
|
||||
Affinity::Space affinity_space() const override;
|
||||
void move(const Affinity::Location) override;
|
||||
Dataspace_capability trace_control() override;
|
||||
int ref_account(Cpu_session_capability c) override;
|
||||
int transfer_quota(Cpu_session_capability, size_t) override;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <topo_session_component.h>
|
||||
|
||||
#include <base/log.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Topo_root : public Root_component<Topo_session_component>
|
||||
@@ -35,8 +37,10 @@ namespace Genode {
|
||||
if (ram_quota < Trace::Control_area::SIZE)
|
||||
throw Insufficient_ram_quota();
|
||||
|
||||
if (!affinity.valid())
|
||||
if (!affinity.valid()) {
|
||||
log("Location ", affinity.location(), " not within space ", affinity.space());
|
||||
throw Service_denied();
|
||||
}
|
||||
|
||||
return new (md_alloc())
|
||||
Topo_session_component(*this->ep(),
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Genode {
|
||||
class Genode::Topo_session_component : public Session_object<Topo_session>
|
||||
{
|
||||
private:
|
||||
Genode::Affinity &_affinity;
|
||||
Genode::Affinity _affinity;
|
||||
Sliced_heap _md_alloc;
|
||||
|
||||
Topology::Numa_region _node_affinities[Genode::Platform::MAX_SUPPORTED_CPUS][Genode::Platform::MAX_SUPPORTED_CPUS];
|
||||
@@ -44,9 +44,10 @@ class Genode::Topo_session_component : public Session_object<Topo_session>
|
||||
Diag const &diag,
|
||||
Ram_allocator &ram_alloc,
|
||||
Region_map &local_rm,
|
||||
Affinity &affinity
|
||||
Affinity affinity
|
||||
);
|
||||
|
||||
void construct();
|
||||
|
||||
/**
|
||||
* @brief Topology session interface
|
||||
@@ -66,4 +67,10 @@ class Genode::Topo_session_component : public Session_object<Topo_session>
|
||||
{
|
||||
return _node_count;
|
||||
}
|
||||
|
||||
void reconstruct(Affinity affinity) override
|
||||
{
|
||||
_affinity = affinity;
|
||||
construct();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,19 +25,24 @@ Topo_session_component::Topo_session_component(Rpc_entrypoint &session_ep,
|
||||
Diag const &diag,
|
||||
Ram_allocator &ram_alloc,
|
||||
Region_map &local_rm,
|
||||
Affinity &affinity)
|
||||
Affinity affinity)
|
||||
: Session_object(session_ep, resources, label, diag),
|
||||
_affinity(affinity),
|
||||
_md_alloc(ram_alloc, local_rm),
|
||||
_node_count(0)
|
||||
{
|
||||
Affinity::Location location = affinity.location();
|
||||
construct();
|
||||
}
|
||||
|
||||
void Topo_session_component::construct()
|
||||
{
|
||||
Affinity::Location location = _affinity.location();
|
||||
const unsigned height = location.height();
|
||||
unsigned width = location.width();
|
||||
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);
|
||||
Genode::log("[", label(), "] Creating new topology model of size ", width, "x", height);
|
||||
|
||||
for (unsigned x = 0; x < width; x++)
|
||||
{
|
||||
@@ -53,14 +58,14 @@ 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);
|
||||
log("[", label(), "] CPU (", x, "x", y, ") is native CPU ", cpu_id, " on node ", native_id);
|
||||
|
||||
if (node_created[native_id].core_count() == 0)
|
||||
{
|
||||
_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, ")");
|
||||
log("[", label(), "] Found new native NUMA region ", native_id, " for CPU (", x, "x", y, ")");
|
||||
_node_count++;
|
||||
curr_node_id++;
|
||||
}
|
||||
@@ -71,4 +76,5 @@ Topo_session_component::Topo_session_component(Rpc_entrypoint &session_ep,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user