mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-12 07:52:44 +00:00
core: evaluate CPU session affinity argument
This commit is contained in:
parent
5ec07614e8
commit
35723d813d
@ -103,6 +103,8 @@ namespace Genode {
|
|||||||
unsigned _priority; /* priority of threads
|
unsigned _priority; /* priority of threads
|
||||||
created with this
|
created with this
|
||||||
session */
|
session */
|
||||||
|
Affinity::Location _location; /* CPU affinity of this
|
||||||
|
session */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception handler that will be invoked unless overridden by a
|
* Exception handler that will be invoked unless overridden by a
|
||||||
@ -127,7 +129,8 @@ namespace Genode {
|
|||||||
*/
|
*/
|
||||||
Cpu_session_component(Rpc_entrypoint *thread_ep,
|
Cpu_session_component(Rpc_entrypoint *thread_ep,
|
||||||
Pager_entrypoint *pager_ep,
|
Pager_entrypoint *pager_ep,
|
||||||
Allocator *md_alloc, const char *args);
|
Allocator *md_alloc, const char *args,
|
||||||
|
Affinity const &affinity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
|
@ -31,10 +31,11 @@ namespace Genode {
|
|||||||
* \param priority designated priority of all threads created
|
* \param priority designated priority of all threads created
|
||||||
* with this CPU session
|
* with this CPU session
|
||||||
*/
|
*/
|
||||||
Cpu_connection(const char *label = "", long priority = DEFAULT_PRIORITY)
|
Cpu_connection(const char *label = "", long priority = DEFAULT_PRIORITY,
|
||||||
|
Affinity const &affinity = Affinity())
|
||||||
:
|
:
|
||||||
Connection<Cpu_session>(
|
Connection<Cpu_session>(
|
||||||
session("priority=0x%lx, ram_quota=128K, label=\"%s\"",
|
session(affinity, "priority=0x%lx, ram_quota=128K, label=\"%s\"",
|
||||||
priority, label)),
|
priority, label)),
|
||||||
Cpu_session_client(cap()) { }
|
Cpu_session_client(cap()) { }
|
||||||
};
|
};
|
||||||
|
@ -97,6 +97,8 @@ namespace Genode {
|
|||||||
unsigned _priority; /* priority of threads
|
unsigned _priority; /* priority of threads
|
||||||
created with this
|
created with this
|
||||||
session */
|
session */
|
||||||
|
Affinity::Location _location; /* CPU affinity of this
|
||||||
|
session */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception handler that will be invoked unless overridden by a
|
* Exception handler that will be invoked unless overridden by a
|
||||||
@ -121,7 +123,8 @@ namespace Genode {
|
|||||||
*/
|
*/
|
||||||
Cpu_session_component(Rpc_entrypoint *thread_ep,
|
Cpu_session_component(Rpc_entrypoint *thread_ep,
|
||||||
Pager_entrypoint *pager_ep,
|
Pager_entrypoint *pager_ep,
|
||||||
Allocator *md_alloc, const char *args);
|
Allocator *md_alloc, const char *args,
|
||||||
|
Affinity const &affinity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
|
@ -103,6 +103,8 @@ namespace Genode {
|
|||||||
unsigned _priority; /* priority of threads
|
unsigned _priority; /* priority of threads
|
||||||
created with this
|
created with this
|
||||||
session */
|
session */
|
||||||
|
Affinity::Location _location; /* CPU affinity of this
|
||||||
|
session */
|
||||||
/**
|
/**
|
||||||
* Exception handler that will be invoked unless overridden by a
|
* Exception handler that will be invoked unless overridden by a
|
||||||
* call of 'Cpu_session::exception_handler'.
|
* call of 'Cpu_session::exception_handler'.
|
||||||
@ -126,7 +128,8 @@ namespace Genode {
|
|||||||
*/
|
*/
|
||||||
Cpu_session_component(Rpc_entrypoint *thread_ep,
|
Cpu_session_component(Rpc_entrypoint *thread_ep,
|
||||||
Pager_entrypoint *pager_ep,
|
Pager_entrypoint *pager_ep,
|
||||||
Allocator *md_alloc, const char *args);
|
Allocator *md_alloc, const char *args,
|
||||||
|
Affinity const &affinity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
|
@ -182,7 +182,11 @@ Cpu_session_component::exception_handler(Thread_capability thread_cap,
|
|||||||
|
|
||||||
Affinity::Space Cpu_session_component::affinity_space() const
|
Affinity::Space Cpu_session_component::affinity_space() const
|
||||||
{
|
{
|
||||||
return platform()->affinity_space();
|
/*
|
||||||
|
* Return affinity subspace as constrained by the CPU session
|
||||||
|
* affinity.
|
||||||
|
*/
|
||||||
|
return Affinity::Space(_location.width(), _location.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -192,17 +196,35 @@ void Cpu_session_component::affinity(Thread_capability thread_cap,
|
|||||||
Object_pool<Cpu_thread_component>::Guard thread(_thread_ep->lookup_and_lock(thread_cap));
|
Object_pool<Cpu_thread_component>::Guard thread(_thread_ep->lookup_and_lock(thread_cap));
|
||||||
if (!thread) return;
|
if (!thread) return;
|
||||||
|
|
||||||
thread->platform_thread()->affinity(location);
|
/* convert session-local location to physical location */
|
||||||
|
int const x1 = location.xpos() + _location.xpos(),
|
||||||
|
y1 = location.ypos() + _location.ypos(),
|
||||||
|
x2 = location.xpos() + location.width(),
|
||||||
|
y2 = location.ypos() + location.height();
|
||||||
|
|
||||||
|
int const clipped_x1 = max(_location.xpos(), x1),
|
||||||
|
clipped_y1 = max(_location.ypos(), y1),
|
||||||
|
clipped_x2 = max(_location.xpos() + (int)_location.width() - 1, x2),
|
||||||
|
clipped_y2 = max(_location.ypos() + (int)_location.height() - 1, y2);
|
||||||
|
|
||||||
|
thread->platform_thread()->affinity(Affinity::Location(clipped_x1, clipped_y1,
|
||||||
|
clipped_x2 - clipped_x1 + 1,
|
||||||
|
clipped_y2 - clipped_y1 + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cpu_session_component::Cpu_session_component(Rpc_entrypoint *thread_ep,
|
Cpu_session_component::Cpu_session_component(Rpc_entrypoint *thread_ep,
|
||||||
Pager_entrypoint *pager_ep,
|
Pager_entrypoint *pager_ep,
|
||||||
Allocator *md_alloc,
|
Allocator *md_alloc,
|
||||||
const char *args)
|
char const *args,
|
||||||
: _thread_ep(thread_ep), _pager_ep(pager_ep),
|
Affinity const &affinity)
|
||||||
|
:
|
||||||
|
_thread_ep(thread_ep), _pager_ep(pager_ep),
|
||||||
_md_alloc(md_alloc, Arg_string::find_arg(args, "ram_quota").long_value(0)),
|
_md_alloc(md_alloc, Arg_string::find_arg(args, "ram_quota").long_value(0)),
|
||||||
_thread_alloc(&_md_alloc), _priority(0)
|
_thread_alloc(&_md_alloc), _priority(0),
|
||||||
|
|
||||||
|
/* map affinity to a location within the physical affinity space */
|
||||||
|
_location(affinity.scale_to(platform()->affinity_space()))
|
||||||
{
|
{
|
||||||
Arg a = Arg_string::find_arg(args, "priority");
|
Arg a = Arg_string::find_arg(args, "priority");
|
||||||
if (a.valid()) {
|
if (a.valid()) {
|
||||||
|
@ -32,9 +32,11 @@ namespace Genode {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Cpu_session_component *_create_session(const char *args) {
|
Cpu_session_component *_create_session(char const *args,
|
||||||
|
Affinity const &affinity) {
|
||||||
return new (md_alloc())
|
return new (md_alloc())
|
||||||
Cpu_session_component(_thread_ep, _pager_ep, _md_alloc, args); }
|
Cpu_session_component(_thread_ep, _pager_ep, _md_alloc,
|
||||||
|
args, affinity); }
|
||||||
|
|
||||||
void _upgrade_session(Cpu_session_component *cpu, const char *args)
|
void _upgrade_session(Cpu_session_component *cpu, const char *args)
|
||||||
{
|
{
|
||||||
|
@ -96,6 +96,8 @@ namespace Genode {
|
|||||||
unsigned _priority; /* priority of threads
|
unsigned _priority; /* priority of threads
|
||||||
created with this
|
created with this
|
||||||
session */
|
session */
|
||||||
|
Affinity::Location _location; /* CPU affinity of this
|
||||||
|
session */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception handler that will be invoked unless overridden by a
|
* Exception handler that will be invoked unless overridden by a
|
||||||
@ -120,7 +122,8 @@ namespace Genode {
|
|||||||
*/
|
*/
|
||||||
Cpu_session_component(Rpc_entrypoint *thread_ep,
|
Cpu_session_component(Rpc_entrypoint *thread_ep,
|
||||||
Pager_entrypoint *pager_ep,
|
Pager_entrypoint *pager_ep,
|
||||||
Allocator *md_alloc, const char *args);
|
Allocator *md_alloc, const char *args,
|
||||||
|
Affinity const &);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
|
Loading…
Reference in New Issue
Block a user