Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BugUser0815 committed Jul 1, 2016
1 parent 22d9d54 commit 876a33e
Show file tree
Hide file tree
Showing 23 changed files with 319 additions and 51 deletions.
5 changes: 4 additions & 1 deletion repos/base-foc/src/core/include/cpu_session_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ namespace Genode {
{
return { _session_label, _name,
_platform_thread.execution_time(),
_platform_thread.affinity() };
_platform_thread.affinity(),
_platform_thread.prio() };
}


Expand Down Expand Up @@ -245,6 +246,8 @@ namespace Genode {
int transfer_quota(Cpu_session_capability, size_t);
Quota quota() override;

void set(Ram_session_capability ram_cap);


/***********************************
** Fiasco.OC specific extensions **
Expand Down
4 changes: 3 additions & 1 deletion repos/base-foc/src/core/include/platform_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ namespace Genode {
/**
* Return execution time consumed by the thread
*/
unsigned long long execution_time() const { return 0; }
unsigned long long execution_time() const;


unsigned prio() const;

/*******************************
** Fiasco-specific Accessors **
*******************************/
Expand Down
17 changes: 17 additions & 0 deletions repos/base-foc/src/core/platform_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,23 @@ Weak_ptr<Address_space> Platform_thread::address_space()
}


unsigned long long Platform_thread::execution_time() const
{
unsigned long long time = 0;

if (_utcb) {
l4_thread_stats_time(_thread.local.dst());
time = *(l4_kernel_clock_t*)&l4_utcb_mr()->mr[0];
}

return time;
}

unsigned Platform_thread::prio() const
{
return _prio;
}

Platform_thread::Platform_thread(const char *name, unsigned prio, addr_t)
: _state(DEAD),
_core_thread(false),
Expand Down
46 changes: 40 additions & 6 deletions repos/base/include/base/trace/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ namespace Genode { namespace Trace {
struct Policy_id;
struct Subject_id;
struct Execution_time;
struct Subject_info;
struct CPU_info;
struct RAM_info;
} }


Expand Down Expand Up @@ -81,7 +82,7 @@ struct Genode::Trace::Execution_time
/**
* Subject information
*/
class Genode::Trace::Subject_info
class Genode::Trace::CPU_info
{
public:

Expand All @@ -108,20 +109,23 @@ class Genode::Trace::Subject_info
Policy_id _policy_id;
Execution_time _execution_time;
Affinity::Location _affinity;
unsigned _prio;

public:

Subject_info() : _state(INVALID) { }
CPU_info() : _state(INVALID) { }

Subject_info(Session_label const &session_label,
CPU_info(Session_label const &session_label,
Thread_name const &thread_name,
State state, Policy_id policy_id,
Execution_time execution_time,
Affinity::Location affinity)
Affinity::Location affinity,
unsigned prio
)
:
_session_label(session_label), _thread_name(thread_name),
_state(state), _policy_id(policy_id),
_execution_time(execution_time), _affinity(affinity)
_execution_time(execution_time), _affinity(affinity), _prio(prio)
{ }

Session_label const &session_label() const { return _session_label; }
Expand All @@ -130,6 +134,36 @@ class Genode::Trace::Subject_info
Policy_id policy_id() const { return _policy_id; }
Execution_time execution_time() const { return _execution_time; }
Affinity::Location affinity() const { return _affinity; }
unsigned prio() const { return _prio; }
};

class Genode::Trace::RAM_info
{
private:

Session_label _session_label;
Thread_name _thread_name;
size_t _ram_quota;
size_t _ram_used;

public:

RAM_info() {}

RAM_info(Session_label const &session_label,
Thread_name const &thread_name,
size_t ram_quota,
size_t ram_used
)
:
_session_label(session_label), _thread_name(thread_name),
_ram_quota(ram_quota), _ram_used(ram_used)
{ }

Session_label const &session_label() const { return _session_label; }
Thread_name const &thread_name() const { return _thread_name; }
size_t ram_quota() const { return _ram_quota; }
size_t ram_used() const { return _ram_used; }
};

#endif /* _INCLUDE__BASE__TRACE__TYPES_H_ */
3 changes: 3 additions & 0 deletions repos/base/include/cpu_session/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ struct Genode::Cpu_session_client : Rpc_client<Cpu_session>
Ram_dataspace_capability utcb(Thread_capability thread) override {
return call<Rpc_utcb>(thread); }

void set(Ram_session_capability ram_cap) override {
call<Rpc_set>(ram_cap); }

void kill_thread(Thread_capability thread) override {
call<Rpc_kill_thread>(thread); }

Expand Down
6 changes: 5 additions & 1 deletion repos/base/include/cpu_session/cpu_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ struct Genode::Cpu_session : Session
static size_t quota_lim_downscale(size_t const value, size_t const limit) {
return ((T)value * limit) >> Cpu_session::QUOTA_LIMIT_LOG2; }

virtual void set(Ram_session_capability ram_cap) = 0;

/*********************
** RPC declaration **
*********************/
Expand Down Expand Up @@ -331,6 +333,7 @@ struct Genode::Cpu_session : Session
GENODE_RPC(Rpc_ref_account, int, ref_account, Cpu_session_capability);
GENODE_RPC(Rpc_transfer_quota, int, transfer_quota, Cpu_session_capability, size_t);
GENODE_RPC(Rpc_quota, Quota, quota);
GENODE_RPC(Rpc_set, void, set, Ram_session_capability);

/*
* 'GENODE_RPC_INTERFACE' declaration done manually
Expand Down Expand Up @@ -361,8 +364,9 @@ struct Genode::Cpu_session : Session
Meta::Type_tuple<Rpc_ref_account,
Meta::Type_tuple<Rpc_transfer_quota,
Meta::Type_tuple<Rpc_quota,
Meta::Type_tuple<Rpc_set,
Meta::Empty>
> > > > > > > > > > > > > > > > > > > > Rpc_functions;
> > > > > > > > > > > > > > > > > > > > > Rpc_functions;
};

struct Genode::Cpu_session::Quota
Expand Down
2 changes: 2 additions & 0 deletions repos/base/include/ram_session/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct Genode::Ram_session_client : Rpc_client<Ram_session>
size_t quota() override { return call<Rpc_quota>(); }

size_t used() override { return call<Rpc_used>(); }

void set_label(char *label) override { call<Rpc_set_label>(label); }
};

#endif /* _INCLUDE__RAM_SESSION__CLIENT_H_ */
5 changes: 4 additions & 1 deletion repos/base/include/ram_session/ram_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ struct Genode::Ram_session : Session
return q > u ? q - u : 0;
}

virtual void set_label(char *label) = 0;


/*********************
** RPC declaration **
Expand All @@ -133,9 +135,10 @@ struct Genode::Ram_session : Session
GENODE_RPC(Rpc_transfer_quota, int, transfer_quota, Ram_session_capability, size_t);
GENODE_RPC(Rpc_quota, size_t, quota);
GENODE_RPC(Rpc_used, size_t, used);
GENODE_RPC(Rpc_set_label, void, set_label, char*);

GENODE_RPC_INTERFACE(Rpc_alloc, Rpc_free, Rpc_ref_account,
Rpc_transfer_quota, Rpc_quota, Rpc_used);
Rpc_transfer_quota, Rpc_quota, Rpc_used, Rpc_set_label);
};

#endif /* _INCLUDE__RAM_SESSION__RAM_SESSION_H_ */
7 changes: 5 additions & 2 deletions repos/base/include/trace_session/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ struct Genode::Trace::Session_client : Genode::Rpc_client<Genode::Trace::Session
void resume(Subject_id subject) override {
call<Rpc_resume>(subject); }

Subject_info subject_info(Subject_id subject) override {
return call<Rpc_subject_info>(subject); }
CPU_info cpu_info(Subject_id subject) override {
return call<Rpc_cpu_info>(subject); }

RAM_info ram_info(Subject_id subject) override {
return call<Rpc_ram_info>(subject); }

Dataspace_capability buffer(Subject_id subject) override {
return call<Rpc_buffer>(subject); }
Expand Down
13 changes: 9 additions & 4 deletions repos/base/include/trace_session/trace_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ struct Genode::Trace::Session : Genode::Session
*
* \throw Nonexistent_subject
*/
virtual Subject_info subject_info(Subject_id) = 0;
virtual CPU_info cpu_info(Subject_id) = 0;

virtual RAM_info ram_info(Subject_id) = 0;

/**
* Obtain trace buffer of given subject
Expand Down Expand Up @@ -133,7 +135,9 @@ struct Genode::Trace::Session : Genode::Session
Subject_id);
GENODE_RPC_THROW(Rpc_subjects, size_t, subjects,
GENODE_TYPE_LIST(Out_of_metadata));
GENODE_RPC_THROW(Rpc_subject_info, Subject_info, subject_info,
GENODE_RPC_THROW(Rpc_cpu_info, CPU_info, cpu_info,
GENODE_TYPE_LIST(Nonexistent_subject), Subject_id);
GENODE_RPC_THROW(Rpc_ram_info, RAM_info, ram_info,
GENODE_TYPE_LIST(Nonexistent_subject), Subject_id);
GENODE_RPC_THROW(Rpc_buffer, Dataspace_capability, buffer,
GENODE_TYPE_LIST(Nonexistent_subject, Subject_not_traced),
Expand All @@ -150,11 +154,12 @@ struct Genode::Trace::Session : Genode::Session
Meta::Type_tuple<Rpc_pause,
Meta::Type_tuple<Rpc_resume,
Meta::Type_tuple<Rpc_subjects,
Meta::Type_tuple<Rpc_subject_info,
Meta::Type_tuple<Rpc_cpu_info,
Meta::Type_tuple<Rpc_ram_info,
Meta::Type_tuple<Rpc_buffer,
Meta::Type_tuple<Rpc_free,
Meta::Empty>
> > > > > > > > > > > Rpc_functions;
> > > > > > > > > > > > Rpc_functions;
};

#endif /* _INCLUDE__TRACE_SESSION__TRACE_SESSION_H_ */
2 changes: 2 additions & 0 deletions repos/base/src/core/context_area.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class Context_area_ram_session : public Ram_session
size_t quota() { return 0; }

size_t used() { return 0; }

void set_label(char *label) { }
};


Expand Down
11 changes: 10 additions & 1 deletion repos/base/src/core/cpu_session_component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <rm_session_component.h>
#include <platform_generic.h>

#include <ram_session/connection.h>

using namespace Genode;

static constexpr bool verbose = false;
Expand Down Expand Up @@ -332,6 +334,7 @@ void Cpu_session_component::_transfer_quota(Cpu_session_component * const dst,
if (!quota) { return; }
_decr_quota(quota);
dst->_incr_quota(quota);

}


Expand Down Expand Up @@ -361,7 +364,8 @@ int Cpu_session_component::transfer_quota(Cpu_session_capability dst_cap,
/* transfer quota */
_transfer_quota(dst, quota);
return 0;
};
};

return _session_ep->apply(dst_cap, lambda);
}

Expand Down Expand Up @@ -525,6 +529,11 @@ Cpu_session_component::_weight_to_quota(size_t const weight) const {
return (weight * _quota) / _weight; }


void Cpu_session_component::set(Ram_session_capability ram_cap)
{
Genode::Ram_connection::Ram_session_client ram(ram_cap);
}

/****************************
** Trace::Source_registry **
****************************/
Expand Down
21 changes: 17 additions & 4 deletions repos/base/src/core/include/core_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include <cap_session_component.h>
#include <ram_session_component.h>

#include <trace_session/trace_session.h>
#include <trace/source_registry.h>
#include <trace/control_area.h>

namespace Genode {

/**
Expand Down Expand Up @@ -60,9 +64,10 @@ namespace Genode {
Range_allocator *ram_alloc,
Allocator *md_alloc,
const char *args,
Trace::Source_registry &trace_sources,
size_t quota_limit = 0)
:
RAM_SESSION_IMPL(ds_ep, ram_session_ep, ram_alloc, md_alloc, args, quota_limit)
RAM_SESSION_IMPL(ds_ep, ram_session_ep, ram_alloc, md_alloc, args, trace_sources, quota_limit)
{ }


Expand Down Expand Up @@ -104,6 +109,12 @@ namespace Genode {
Lock::Guard lock_guard(_lock);
return RAM_SESSION_IMPL::used();
}

void set_label(char label[])
{
Lock::Guard lock_guard(_lock);
RAM_SESSION_IMPL::set_label(label);
}
};


Expand All @@ -128,16 +139,17 @@ namespace Genode {
/**
* Constructor
*/
Core_env() :
Core_env(Trace::Source_registry trace_sources) :
_cap_session(platform()->core_mem_alloc(), "ram_quota=4K"),
_entrypoint(&_cap_session, ENTRYPOINT_STACK_SIZE, "entrypoint"),
_rm_session(&_entrypoint),
_ram_session(&_entrypoint, &_entrypoint,
platform()->ram_alloc(), platform()->core_mem_alloc(),
"ram_quota=4M", platform()->ram_alloc()->avail()),
"ram_quota=4M", trace_sources, platform()->ram_alloc()->avail()),
_heap(&_ram_session, &_rm_session),
_ram_session_cap(_entrypoint.manage(&_ram_session))
{ }
{
}

/**
* Destructor
Expand Down Expand Up @@ -178,6 +190,7 @@ namespace Genode {
void reinit(Capability<Parent>::Dst, long) { }

void reinit_main_thread(Rm_session_capability &) { }

};


Expand Down
3 changes: 2 additions & 1 deletion repos/base/src/core/include/cpu_root.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ namespace Genode {
Root_component<Cpu_session_component>(session_ep, md_alloc),
_thread_ep(thread_ep), _pager_ep(pager_ep),
_md_alloc(md_alloc), _trace_sources(trace_sources)
{ }
{
}
};
}

Expand Down
Loading

0 comments on commit 876a33e

Please sign in to comment.