mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
base: add affinity support to pager construction
Propagating the affinity information is needed to allow for assigning a pager thread that is local to the CPU of the to-be-created thread. issue #814
This commit is contained in:
parent
e171683b8c
commit
4ae1faf14d
@ -136,6 +136,11 @@ namespace Genode {
|
||||
*/
|
||||
void affinity(unsigned cpu);
|
||||
|
||||
/**
|
||||
* Get the executing CPU for this thread
|
||||
*/
|
||||
unsigned affinity();
|
||||
|
||||
/**
|
||||
* Get thread name
|
||||
*/
|
||||
|
@ -29,7 +29,14 @@ using namespace Codezero;
|
||||
|
||||
void Platform_thread::affinity(unsigned int cpu_no)
|
||||
{
|
||||
PDBG("not yet implemented");
|
||||
PDBG("'%s' not yet implemented", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
unsigned Platform_thread::affinity()
|
||||
{
|
||||
PDBG("'%s' not yet implemented", __PRETTY_FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -123,6 +123,11 @@ namespace Genode {
|
||||
*/
|
||||
void affinity(unsigned) { }
|
||||
|
||||
/**
|
||||
* Request the affinity of this thread
|
||||
*/
|
||||
unsigned affinity() { return 0; }
|
||||
|
||||
/**
|
||||
* Return the address space to which the thread is bound
|
||||
*/
|
||||
|
@ -130,7 +130,7 @@ static void _core_pager_loop()
|
||||
}
|
||||
|
||||
|
||||
Platform::Sigma0::Sigma0() : Pager_object(0)
|
||||
Platform::Sigma0::Sigma0() : Pager_object(0, 0)
|
||||
{
|
||||
cap(reinterpret_cap_cast<Cpu_thread>(Native_capability(Fiasco::sigma0_threadid, 0)));
|
||||
}
|
||||
@ -145,7 +145,7 @@ Platform::Sigma0 *Platform::sigma0()
|
||||
|
||||
Platform::Core_pager::Core_pager(Platform_pd *core_pd)
|
||||
:
|
||||
Platform_thread("core.pager"), Pager_object(0)
|
||||
Platform_thread("core.pager"), Pager_object(0, 0)
|
||||
{
|
||||
Platform_thread::pager(sigma0());
|
||||
|
||||
|
@ -138,6 +138,11 @@ namespace Genode {
|
||||
*/
|
||||
void affinity(unsigned cpu);
|
||||
|
||||
/**
|
||||
* Get the executing CPU for this thread
|
||||
*/
|
||||
unsigned affinity();
|
||||
|
||||
/**
|
||||
* Return the address space to which the thread is bound
|
||||
*/
|
||||
|
@ -121,7 +121,7 @@ static void _core_pager_loop()
|
||||
}
|
||||
|
||||
|
||||
Platform::Sigma0::Sigma0(Cap_index* i) : Pager_object(0)
|
||||
Platform::Sigma0::Sigma0(Cap_index* i) : Pager_object(0, 0)
|
||||
{
|
||||
/*
|
||||
* We use the Pager_object here in a slightly different manner,
|
||||
@ -132,7 +132,7 @@ Platform::Sigma0::Sigma0(Cap_index* i) : Pager_object(0)
|
||||
|
||||
|
||||
Platform::Core_pager::Core_pager(Platform_pd *core_pd, Sigma0 *sigma0)
|
||||
: Platform_thread("core.pager"), Pager_object(0)
|
||||
: Platform_thread("core.pager"), Pager_object(0, 0)
|
||||
{
|
||||
Platform_thread::pager(sigma0);
|
||||
|
||||
|
@ -209,6 +209,13 @@ void Platform_thread::affinity(unsigned cpu)
|
||||
}
|
||||
|
||||
|
||||
unsigned Platform_thread::affinity()
|
||||
{
|
||||
PERR("'%s' not yet implemented", __PRETTY_FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::_create_thread()
|
||||
{
|
||||
l4_msgtag_t tag = l4_factory_create_thread(L4_BASE_FACTORY_CAP,
|
||||
|
@ -154,6 +154,16 @@ namespace Genode {
|
||||
void affinity(unsigned cpu) {
|
||||
kernel_log() << __PRETTY_FUNCTION__ << ": not implemented\n"; };
|
||||
|
||||
/**
|
||||
* Get the executing CPU for this thread
|
||||
*/
|
||||
unsigned affinity()
|
||||
{
|
||||
kernel_log() << __PRETTY_FUNCTION__ << ": not implemented\n";
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Return the address space to which the thread is bound
|
||||
*/
|
||||
|
@ -81,7 +81,7 @@ namespace Genode {
|
||||
static Nova::Utcb * _check_handler(Thread_base *&, Pager_object *&);
|
||||
public:
|
||||
|
||||
Pager_object(unsigned long badge);
|
||||
Pager_object(unsigned long badge, unsigned affinity);
|
||||
|
||||
virtual ~Pager_object();
|
||||
|
||||
|
@ -257,7 +257,7 @@ static uint8_t create_portal(addr_t pt, addr_t pd, addr_t ec, Mtd mtd,
|
||||
return res;
|
||||
}
|
||||
|
||||
Pager_object::Pager_object(unsigned long badge)
|
||||
Pager_object::Pager_object(unsigned long badge, unsigned affinity)
|
||||
: Thread_base("pager:", PF_HANDLER_STACK_SIZE), _badge(badge)
|
||||
{
|
||||
class Create_exception_pt_failed { };
|
||||
|
@ -131,6 +131,11 @@ namespace Genode {
|
||||
*/
|
||||
void affinity(unsigned cpu);
|
||||
|
||||
/**
|
||||
* Get the executing CPU for this thread
|
||||
*/
|
||||
unsigned affinity();
|
||||
|
||||
/**
|
||||
* Get thread name
|
||||
*/
|
||||
|
@ -46,6 +46,9 @@ void Platform_thread::affinity(unsigned int cpu_no)
|
||||
}
|
||||
|
||||
|
||||
unsigned Platform_thread::affinity() { return _cpu_no; }
|
||||
|
||||
|
||||
int Platform_thread::start(void *ip, void *sp)
|
||||
{
|
||||
using namespace Nova;
|
||||
@ -323,7 +326,7 @@ Weak_ptr<Address_space> Platform_thread::address_space()
|
||||
Platform_thread::Platform_thread(const char *name, unsigned, int thread_id)
|
||||
:
|
||||
_pd(0), _pager(0), _id_base(cap_selector_allocator()->alloc(1)),
|
||||
_sel_exc_base(Native_thread::INVALID_INDEX), _cpu_no(0),
|
||||
_sel_exc_base(Native_thread::INVALID_INDEX), _cpu_no(0), //XXX find out boot CPU
|
||||
_is_main_thread(false), _is_vcpu(false)
|
||||
{
|
||||
strncpy(_name, name, sizeof(_name));
|
||||
|
@ -142,6 +142,11 @@ namespace Genode {
|
||||
*/
|
||||
void affinity(unsigned cpu);
|
||||
|
||||
/**
|
||||
* Request the affinity of this thread
|
||||
*/
|
||||
unsigned affinity();
|
||||
|
||||
|
||||
/*****************************
|
||||
** OKL4-specific Accessors **
|
||||
|
@ -38,7 +38,14 @@ using namespace Okl4;
|
||||
|
||||
void Platform_thread::affinity(unsigned int cpu_no)
|
||||
{
|
||||
PERR("not yet implemented");
|
||||
PERR("'%s' not yet implemented", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
unsigned Platform_thread::affinity()
|
||||
{
|
||||
PERR("'%s' not yet implemented", __PRETTY_FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,6 +150,8 @@ namespace Genode {
|
||||
Rom_fs *rom_fs() { return &_rom_fs; }
|
||||
|
||||
void wait_for_exit();
|
||||
unsigned num_cpus() const {
|
||||
return L4_NumProcessors(Pistachio::get_kip()); }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,11 @@ namespace Genode {
|
||||
*/
|
||||
void affinity(unsigned cpu);
|
||||
|
||||
/**
|
||||
* Request the affinity of this thread
|
||||
*/
|
||||
unsigned affinity();
|
||||
|
||||
|
||||
/**********************************
|
||||
** Pistachio-specific Accessors **
|
||||
|
@ -199,7 +199,7 @@ static void _core_pager_loop()
|
||||
}
|
||||
|
||||
|
||||
Platform::Sigma0::Sigma0() : Pager_object(0)
|
||||
Platform::Sigma0::Sigma0() : Pager_object(0, 0)
|
||||
{
|
||||
cap(Native_capability(Pistachio::get_sigma0(), 0));
|
||||
}
|
||||
@ -214,7 +214,7 @@ Platform::Sigma0 *Platform::sigma0()
|
||||
|
||||
Platform::Core_pager::Core_pager(Platform_pd *core_pd)
|
||||
:
|
||||
Platform_thread("core.pager"), Pager_object(0)
|
||||
Platform_thread("core.pager"), Pager_object(0, 0)
|
||||
{
|
||||
Platform_thread::pager(sigma0());
|
||||
|
||||
|
@ -51,6 +51,13 @@ void Platform_thread::affinity(unsigned int cpu_no)
|
||||
}
|
||||
|
||||
|
||||
unsigned Platform_thread::affinity()
|
||||
{
|
||||
PERR("'%s' not yet implemented", __PRETTY_FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no)
|
||||
{
|
||||
L4_ThreadId_t thread = _l4_thread_id;
|
||||
|
@ -58,7 +58,7 @@ namespace Genode {
|
||||
*/
|
||||
Thread_state state;
|
||||
|
||||
Pager_object(unsigned long badge) : _badge(badge) { }
|
||||
Pager_object(unsigned long badge, unsigned affinity) : _badge(badge) { }
|
||||
virtual ~Pager_object() { }
|
||||
|
||||
unsigned long badge() const { return _badge; }
|
||||
|
@ -197,12 +197,14 @@ namespace Genode {
|
||||
* \param session RM session to which the client belongs
|
||||
* \param badge pager-object badge used of identifying the client
|
||||
* when a page-fault occurs
|
||||
* \param affinity cpu affinity
|
||||
*/
|
||||
Rm_client(Rm_session_component *session, unsigned long badge,
|
||||
Weak_ptr<Address_space> &address_space)
|
||||
Weak_ptr<Address_space> &address_space,
|
||||
unsigned affinity)
|
||||
:
|
||||
Pager_object(badge), Rm_member(session), Rm_faulter(this),
|
||||
_address_space(address_space) { }
|
||||
Pager_object(badge, affinity), Rm_member(session),
|
||||
Rm_faulter(this), _address_space(address_space) { }
|
||||
|
||||
int pager(Ipc_pager &pager);
|
||||
|
||||
|
@ -605,6 +605,7 @@ void Rm_session_component::detach(Local_addr local_addr)
|
||||
Pager_capability Rm_session_component::add_client(Thread_capability thread)
|
||||
{
|
||||
unsigned long badge;
|
||||
unsigned affinity;
|
||||
Weak_ptr<Address_space> address_space;
|
||||
|
||||
{
|
||||
@ -615,6 +616,8 @@ Pager_capability Rm_session_component::add_client(Thread_capability thread)
|
||||
|
||||
/* determine identification of client when faulting */
|
||||
badge = cpu_thread->platform_thread()->pager_object_badge();
|
||||
/* determine cpu affinity of client thread */
|
||||
affinity = cpu_thread->platform_thread()->affinity();
|
||||
|
||||
address_space = cpu_thread->platform_thread()->address_space();
|
||||
if (!Locked_ptr<Address_space>(address_space).is_valid())
|
||||
@ -625,7 +628,7 @@ Pager_capability Rm_session_component::add_client(Thread_capability thread)
|
||||
Lock::Guard lock_guard(_lock);
|
||||
|
||||
Rm_client *cl;
|
||||
try { cl = new(&_client_slab) Rm_client(this, badge, address_space); }
|
||||
try { cl = new(&_client_slab) Rm_client(this, badge, address_space, affinity); }
|
||||
catch (Allocator::Out_of_memory) { throw Out_of_metadata(); }
|
||||
catch (Cpu_session::Thread_creation_failed) { throw Out_of_metadata(); }
|
||||
catch (Thread_base::Stack_alloc_failed) { throw Out_of_metadata(); }
|
||||
|
Loading…
Reference in New Issue
Block a user