mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 22:47:50 +00:00
base: set default cpu affinity
Set cpu_session default affinity space already during construction of the thread, so that main thread is placed in the cpu affinity space as defined by the parent. Otherwise the main thread is placed potentially outside the affinity space, typically on the first/boot CPU. Fixes #1107
This commit is contained in:
parent
73f71322f0
commit
5169de72c4
@ -68,12 +68,11 @@ namespace Genode {
|
|||||||
*
|
*
|
||||||
* \param ip instruction pointer to start at
|
* \param ip instruction pointer to start at
|
||||||
* \param sp stack pointer to use
|
* \param sp stack pointer to use
|
||||||
* \param cpu_no target cpu
|
|
||||||
*
|
*
|
||||||
* \retval 0 successful
|
* \retval 0 successful
|
||||||
* \retval -1 thread could not be started
|
* \retval -1 thread could not be started
|
||||||
*/
|
*/
|
||||||
int start(void *ip, void *sp, unsigned int cpu_no = 0);
|
int start(void *ip, void *sp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause this thread
|
* Pause this thread
|
||||||
|
@ -50,8 +50,9 @@ void Platform_thread::affinity(Affinity::Location location)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (L4_Set_ProcessorNo(_l4_thread_id, cpu_no) == 0)
|
if (_l4_thread_id != L4_nilthread)
|
||||||
PERR("Error setting processor number.");
|
if (L4_Set_ProcessorNo(_l4_thread_id, cpu_no) == 0)
|
||||||
|
PERR("Error setting processor number.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ Affinity::Location Platform_thread::affinity()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no)
|
int Platform_thread::start(void *ip, void *sp)
|
||||||
{
|
{
|
||||||
L4_ThreadId_t thread = _l4_thread_id;
|
L4_ThreadId_t thread = _l4_thread_id;
|
||||||
L4_ThreadId_t pager = _pager ? _pager->cap().dst() : L4_nilthread;
|
L4_ThreadId_t pager = _pager ? _pager->cap().dst() : L4_nilthread;
|
||||||
@ -108,7 +109,7 @@ int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get the thread running on the right cpu */
|
/* get the thread running on the right cpu */
|
||||||
affinity(Affinity::Location(cpu_no, 0));
|
affinity(_location);
|
||||||
|
|
||||||
/* assign priority */
|
/* assign priority */
|
||||||
if (!L4_Set_Priority(thread,
|
if (!L4_Set_Priority(thread,
|
||||||
|
@ -53,6 +53,9 @@ Thread_capability Cpu_session_component::create_thread(Name const &name,
|
|||||||
_default_exception_handler,
|
_default_exception_handler,
|
||||||
trace_control_index,
|
trace_control_index,
|
||||||
*trace_control);
|
*trace_control);
|
||||||
|
|
||||||
|
/* set default affinity defined by CPU session */
|
||||||
|
thread->platform_thread()->affinity(_location);
|
||||||
} catch (Allocator::Out_of_memory) {
|
} catch (Allocator::Out_of_memory) {
|
||||||
throw Out_of_metadata();
|
throw Out_of_metadata();
|
||||||
}
|
}
|
||||||
@ -122,13 +125,6 @@ int Cpu_session_component::start(Thread_capability thread_cap,
|
|||||||
*/
|
*/
|
||||||
thread->update_exception_sigh();
|
thread->update_exception_sigh();
|
||||||
|
|
||||||
/*
|
|
||||||
* If no affinity location was set for this specific thread before,
|
|
||||||
* we set the one which was defined for the whole CPU session.
|
|
||||||
*/
|
|
||||||
if (!thread->platform_thread()->affinity().valid())
|
|
||||||
thread->platform_thread()->affinity(_location);
|
|
||||||
|
|
||||||
return thread->platform_thread()->start((void *)ip, (void *)sp);
|
return thread->platform_thread()->start((void *)ip, (void *)sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user