sel4: support tracing of exec. time of core thread

Issue #2646
This commit is contained in:
Alexander Boettcher 2017-09-12 11:25:03 +02:00 committed by Norman Feske
parent 2bd873e2b4
commit 9269d09e18
2 changed files with 46 additions and 10 deletions

View File

@ -553,8 +553,6 @@ Platform::Platform()
*/ */
Info trace_source_info() const override Info trace_source_info() const override
{ {
Genode::String<8> name("idle", affinity.xpos());
Genode::Thread * me = Genode::Thread::myself(); Genode::Thread * me = Genode::Thread::myself();
addr_t const ipc_buffer = reinterpret_cast<addr_t>(me->utcb()); addr_t const ipc_buffer = reinterpret_cast<addr_t>(me->utcb());
seL4_IPCBuffer * ipcbuffer = reinterpret_cast<seL4_IPCBuffer *>(ipc_buffer); seL4_IPCBuffer * ipcbuffer = reinterpret_cast<seL4_IPCBuffer *>(ipc_buffer);
@ -563,29 +561,28 @@ Platform::Platform()
seL4_BenchmarkGetThreadUtilisation(tcb_sel.value()); seL4_BenchmarkGetThreadUtilisation(tcb_sel.value());
uint64_t execution_time = buf[BENCHMARK_IDLE_TCBCPU_UTILISATION]; uint64_t execution_time = buf[BENCHMARK_IDLE_TCBCPU_UTILISATION];
return { Session_label("kernel"), Trace::Thread_name(name), return { Session_label("kernel"), Trace::Thread_name("idle"),
Trace::Execution_time(execution_time), affinity }; Trace::Execution_time(execution_time), affinity };
} }
Idle_trace_source(Platform &platform, Range_allocator &phys_alloc, Idle_trace_source(Trace::Source_registry &registry,
Platform &platform, Range_allocator &phys_alloc,
Affinity::Location affinity) Affinity::Location affinity)
: :
Trace::Control(), Trace::Control(),
Trace::Source(*this, *this), affinity(affinity) Trace::Source(*this, *this), affinity(affinity)
{ {
Thread_info::init_tcb(platform, phys_alloc, 0, affinity.xpos()); Thread_info::init_tcb(platform, phys_alloc, 0, affinity.xpos());
registry.insert(this);
} }
Trace::Source &source() { return *this; }
}; };
Idle_trace_source *source = new (core_mem_alloc()) new (core_mem_alloc())
Idle_trace_source(*this, *_core_mem_alloc.phys_alloc(), Idle_trace_source(Trace::sources(), *this,
*_core_mem_alloc.phys_alloc(),
Affinity::Location(cpu_id, 0, Affinity::Location(cpu_id, 0,
affinity_space().width(), affinity_space().width(),
affinity_space().height())); affinity_space().height()));
Trace::sources().insert(&source->source());
} }
/* I/O port allocator (only meaningful for x86) */ /* I/O port allocator (only meaningful for x86) */

View File

@ -23,6 +23,10 @@
#include <platform.h> #include <platform.h>
#include <platform_thread.h> #include <platform_thread.h>
#include <thread_sel4.h> #include <thread_sel4.h>
#include <trace/source_registry.h>
/* seL4 includes */
#include <sel4/benchmark_utilisation_types.h>
using namespace Genode; using namespace Genode;
@ -101,6 +105,41 @@ void Thread::start()
{ {
start_sel4_thread(Cap_sel(native_thread().tcb_sel), (addr_t)&_thread_start, start_sel4_thread(Cap_sel(native_thread().tcb_sel), (addr_t)&_thread_start,
(addr_t)stack_top(), _affinity.xpos()); (addr_t)stack_top(), _affinity.xpos());
struct Core_trace_source : public Trace::Source::Info_accessor,
private Trace::Control,
private Trace::Source
{
Thread &_thread;
/**
* Trace::Source::Info_accessor interface
*/
Info trace_source_info() const override
{
Thread * const me = Thread::myself();
seL4_IPCBuffer * const ipcbuffer = reinterpret_cast<seL4_IPCBuffer *>(me->utcb());
uint64_t const * const buf = reinterpret_cast<uint64_t *>(ipcbuffer->msg);
seL4_BenchmarkGetThreadUtilisation(_thread.native_thread().tcb_sel);
uint64_t const thread_time = buf[BENCHMARK_TCB_UTILISATION];
return { Session_label("core"), _thread.name(),
Trace::Execution_time(thread_time), _thread._affinity };
}
Core_trace_source(Trace::Source_registry &registry, Thread &t)
:
Trace::Control(),
Trace::Source(*this, *this), _thread(t)
{
registry.insert(this);
}
};
new (*platform()->core_mem_alloc())
Core_trace_source(Trace::sources(), *this);
} }