mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-14 16:26:30 +00:00
cpu_sampler: propagate Create_thread_error
The accounting of caps for the UTCB allocation on base-hw puts pressure on the out-of-ram/caps handling of Create_thread_result in the CPU sampler. This patch implements the formerly missing error handling. Issue #5408
This commit is contained in:
parent
b0052a71be
commit
414afba682
@ -30,22 +30,30 @@ Cpu_sampler::Cpu_session_component::create_thread(Pd_session_capability pd,
|
||||
{
|
||||
Cpu_thread_component *cpu_thread = new (_md_alloc)
|
||||
Cpu_thread_component(*this, _env,
|
||||
_md_alloc,
|
||||
pd,
|
||||
name,
|
||||
affinity,
|
||||
weight,
|
||||
utcb,
|
||||
name.string(),
|
||||
_next_thread_id);
|
||||
_md_alloc,
|
||||
pd,
|
||||
name,
|
||||
affinity,
|
||||
weight,
|
||||
utcb,
|
||||
name.string(),
|
||||
_next_thread_id);
|
||||
|
||||
_thread_list.insert(new (_md_alloc) Thread_element(cpu_thread));
|
||||
return cpu_thread->result().convert<Create_thread_result>(
|
||||
[&] (Thread_capability) {
|
||||
_thread_list.insert(new (_md_alloc) Thread_element(cpu_thread));
|
||||
|
||||
_thread_list_change_handler.thread_list_changed();
|
||||
_thread_list_change_handler.thread_list_changed();
|
||||
|
||||
_next_thread_id++;
|
||||
_next_thread_id++;
|
||||
|
||||
return cpu_thread->cap();
|
||||
return cpu_thread->cap();
|
||||
},
|
||||
[&] (Create_thread_error e) {
|
||||
destroy(_md_alloc, cpu_thread);
|
||||
return e;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,15 +36,14 @@ Cpu_sampler::Cpu_thread_component::Cpu_thread_component(
|
||||
_cpu_session_component(cpu_session_component), _env(env), _md_alloc(md_alloc),
|
||||
_parent_cpu_thread(
|
||||
_cpu_session_component.parent_cpu_session()
|
||||
.create_thread(pd, name, affinity, weight, utcb)
|
||||
.convert<Thread_capability>(
|
||||
[&] (Thread_capability cap) { return cap; },
|
||||
[&] (auto) {
|
||||
error("failed to create CPU thread");
|
||||
return Thread_capability(); })),
|
||||
.create_thread(pd, name, affinity, weight, utcb)),
|
||||
_label(_cpu_session_component.session_label().string(), " -> ", thread_name),
|
||||
_log_session_label("samples -> ", _label, ".", thread_id)
|
||||
{
|
||||
_parent_cpu_thread.with_result(
|
||||
[&] (Thread_capability cap) { _parent_cpu_client.construct(cap); },
|
||||
[&] (Cpu_session::Create_thread_error) { });
|
||||
|
||||
_cpu_session_component.thread_ep().manage(this);
|
||||
}
|
||||
|
||||
@ -72,13 +71,13 @@ void Cpu_sampler::Cpu_thread_component::take_sample()
|
||||
unsigned loop_cnt = 0;
|
||||
for (; loop_cnt < MAX_LOOP_CNT; loop_cnt++) {
|
||||
|
||||
_parent_cpu_thread.pause();
|
||||
_parent_cpu_client->pause();
|
||||
|
||||
Thread_state const thread_state = _parent_cpu_thread.state();
|
||||
Thread_state const thread_state = _parent_cpu_client->state();
|
||||
if (thread_state.state == Thread_state::State::VALID)
|
||||
_sample_buf[_sample_buf_index++] = thread_state.cpu.ip;
|
||||
|
||||
_parent_cpu_thread.resume();
|
||||
_parent_cpu_client->resume();
|
||||
|
||||
if (_sample_buf_index == SAMPLE_BUF_SIZE)
|
||||
flush();
|
||||
@ -122,75 +121,75 @@ void Cpu_sampler::Cpu_thread_component::flush()
|
||||
Dataspace_capability
|
||||
Cpu_sampler::Cpu_thread_component::utcb()
|
||||
{
|
||||
return _parent_cpu_thread.utcb();
|
||||
return _parent_cpu_client->utcb();
|
||||
}
|
||||
|
||||
|
||||
void Cpu_sampler::Cpu_thread_component::start(addr_t ip, addr_t sp)
|
||||
{
|
||||
_parent_cpu_thread.start(ip, sp);
|
||||
_parent_cpu_client->start(ip, sp);
|
||||
_started = true;
|
||||
}
|
||||
|
||||
|
||||
void Cpu_sampler::Cpu_thread_component::pause()
|
||||
{
|
||||
_parent_cpu_thread.pause();
|
||||
_parent_cpu_client->pause();
|
||||
}
|
||||
|
||||
|
||||
void Cpu_sampler::Cpu_thread_component::resume()
|
||||
{
|
||||
_parent_cpu_thread.resume();
|
||||
_parent_cpu_client->resume();
|
||||
}
|
||||
|
||||
|
||||
void Cpu_sampler::Cpu_thread_component::single_step(bool enable)
|
||||
{
|
||||
_parent_cpu_thread.single_step(enable);
|
||||
_parent_cpu_client->single_step(enable);
|
||||
}
|
||||
|
||||
|
||||
Thread_state Cpu_sampler::Cpu_thread_component::state()
|
||||
{
|
||||
return _parent_cpu_thread.state();
|
||||
return _parent_cpu_client->state();
|
||||
}
|
||||
|
||||
|
||||
void Cpu_sampler::Cpu_thread_component::state(Thread_state const &state)
|
||||
{
|
||||
_parent_cpu_thread.state(state);
|
||||
_parent_cpu_client->state(state);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Cpu_sampler::Cpu_thread_component::exception_sigh(Signal_context_capability sigh_cap)
|
||||
{
|
||||
_parent_cpu_thread.exception_sigh(sigh_cap);
|
||||
_parent_cpu_client->exception_sigh(sigh_cap);
|
||||
}
|
||||
|
||||
|
||||
void Cpu_sampler::Cpu_thread_component::affinity(Affinity::Location location)
|
||||
{
|
||||
_parent_cpu_thread.affinity(location);
|
||||
_parent_cpu_client->affinity(location);
|
||||
}
|
||||
|
||||
|
||||
unsigned Cpu_sampler::Cpu_thread_component::trace_control_index()
|
||||
{
|
||||
return _parent_cpu_thread.trace_control_index();
|
||||
return _parent_cpu_client->trace_control_index();
|
||||
}
|
||||
|
||||
|
||||
Dataspace_capability
|
||||
Cpu_sampler::Cpu_thread_component::trace_buffer()
|
||||
{
|
||||
return _parent_cpu_thread.trace_buffer();
|
||||
return _parent_cpu_client->trace_buffer();
|
||||
}
|
||||
|
||||
|
||||
Dataspace_capability
|
||||
Cpu_sampler::Cpu_thread_component::trace_policy()
|
||||
{
|
||||
return _parent_cpu_thread.trace_policy();
|
||||
return _parent_cpu_client->trace_policy();
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ class Cpu_sampler::Cpu_thread_component : public Rpc_object<Cpu_thread>
|
||||
|
||||
Allocator &_md_alloc;
|
||||
|
||||
Cpu_thread_client _parent_cpu_thread;
|
||||
Cpu_session::Create_thread_result _parent_cpu_thread;
|
||||
Constructible<Cpu_thread_client> _parent_cpu_client;
|
||||
|
||||
bool _started = false;
|
||||
|
||||
@ -68,7 +69,9 @@ class Cpu_sampler::Cpu_thread_component : public Rpc_object<Cpu_thread>
|
||||
Cpu_session_component const *cpu_session_component() const
|
||||
{ return &_cpu_session_component; }
|
||||
|
||||
Thread_capability parent_thread() { return _parent_cpu_thread.rpc_cap(); }
|
||||
Cpu_session::Create_thread_result result() { return _parent_cpu_thread; }
|
||||
|
||||
Thread_capability parent_thread() { return _parent_cpu_client->rpc_cap(); }
|
||||
Session_label &label() { return _label; }
|
||||
|
||||
void take_sample();
|
||||
|
Loading…
x
Reference in New Issue
Block a user