foc/sel4: place vcpu thread on same cpu as ep

Issue #3111
This commit is contained in:
Alexander Boettcher 2019-05-03 10:37:13 +02:00 committed by Christian Helmuth
parent 85d98195d5
commit c0a00019c0
3 changed files with 21 additions and 7 deletions

View File

@ -1174,10 +1174,10 @@ struct Vcpu : Genode::Thread
Vcpu(Env &env, Signal_context_capability &cap,
Semaphore &handler_ready,
Vm_session_client::Vcpu_id &id, enum Virt type,
Allocator &alloc)
Allocator &alloc, Affinity::Location location)
:
Thread(env, "vcpu_thread", STACK_SIZE), _signal(cap),
_handler_ready(handler_ready), _alloc(alloc),
Thread(env, "vcpu_thread", STACK_SIZE, location, Weight(), env.cpu()),
_signal(cap), _handler_ready(handler_ready), _alloc(alloc),
_id(id), _vm_type(type)
{ }
@ -1256,10 +1256,13 @@ Vm_session_client::create_vcpu(Allocator &alloc, Env &env,
return id;
}
Thread * ep = reinterpret_cast<Thread *>(&handler._rpc_ep);
Affinity::Location location = ep->affinity();
/* create thread that switches modes between thread/cpu */
Vcpu * vcpu = new (alloc) Registered<Vcpu>(vcpus, env, handler._cap,
handler._done, id, vm_type,
alloc);
alloc, location);
try {
/* now it gets actually valid - vcpu->cap() becomes valid */

View File

@ -742,9 +742,11 @@ struct Vcpu : Genode::Thread
public:
Vcpu(Genode::Env &env, Genode::Signal_context_capability &cap,
Semaphore &handler_ready, unsigned id, Allocator &alloc)
Semaphore &handler_ready, unsigned id, Allocator &alloc,
Affinity::Location &location)
:
Thread(env, "vcpu_thread", STACK_SIZE), _signal(cap),
Thread(env, "vcpu_thread", STACK_SIZE, location, Weight(), env.cpu()),
_signal(cap),
_handler_ready(handler_ready), _alloc(alloc), _id({id})
{ }
@ -795,11 +797,15 @@ Genode::Vm_session_client::Vcpu_id
Genode::Vm_session_client::create_vcpu(Allocator &alloc, Env &env,
Vm_handler_base &handler)
{
Thread * ep = reinterpret_cast<Thread *>(&handler._rpc_ep);
Affinity::Location location = ep->affinity();
/* create thread that switches modes between thread/cpu */
Vcpu * vcpu = new (alloc) Genode::Registered<Vcpu> (vcpus, env,
handler._cap,
handler._done,
vcpu_id, alloc);
vcpu_id, alloc,
location);
try {
/* now it gets actually valid - vcpu->cap() becomes valid */

View File

@ -430,6 +430,11 @@ class Genode::Thread
*/
template <typename EVENT>
static void trace(EVENT const *event) { _logger()->log(event); }
/**
* Thread affinity
*/
Affinity::Location affinity() const { return _affinity; }
};