Capability quota accounting and trading
This patch mirrors the accounting and trading scheme that Genode employs
for physical memory to the accounting of capability allocations.
Capability quotas must now be explicitly assigned to subsystems by
specifying a 'caps=<amount>' attribute to init's start nodes.
Analogously to RAM quotas, cap quotas can be traded between clients and
servers as part of the session protocol. The capability budget of each
component is maintained by the component's corresponding PD session at
core.
At the current stage, the accounting is applied to RPC capabilities,
signal-context capabilities, and dataspace capabilities. Capabilities
that are dynamically allocated via core's CPU and TRACE service are not
yet covered. Also, the capabilities allocated by resource multiplexers
outside of core (like nitpicker) must be accounted by the respective
servers, which is not covered yet.
If a component runs out of capabilities, core's PD service prints a
warning to the log. To observe the consumption of capabilities per
component in detail, the PD service is equipped with a diagnostic
mode, which can be enabled via the 'diag' attribute in the target
node of init's routing rules. E.g., the following route enables the
diagnostic mode for the PD session of the "timer" component:
<default-route>
<service name="PD" unscoped_label="timer">
<parent diag="yes"/>
</service>
...
</default-route>
For subsystems based on a sub-init instance, init can be configured
to report the capability-quota information of its subsystems by
adding the attribute 'child_caps="yes"' to init's '<report>'
config node. Init's own capability quota can be reported by adding
the attribute 'init_caps="yes"'.
Fixes #2398
This commit is contained in:
committed by
Christian Helmuth
parent
773e08976d
commit
1f4f119b1e
@@ -59,6 +59,7 @@ class Launchpad_child : public Genode::Child_policy,
|
||||
Genode::Ram_session_capability _ref_ram_cap;
|
||||
Genode::Ram_session_client _ref_ram { _ref_ram_cap };
|
||||
|
||||
Genode::Cap_quota const _cap_quota;
|
||||
Genode::Ram_quota const _ram_quota;
|
||||
|
||||
Parent_services &_parent_services;
|
||||
@@ -97,6 +98,7 @@ class Launchpad_child : public Genode::Child_policy,
|
||||
Genode::Allocator &alloc,
|
||||
Genode::Session_label const &label,
|
||||
Binary_name const &elf_name,
|
||||
Genode::Cap_quota cap_quota,
|
||||
Genode::Ram_quota ram_quota,
|
||||
Parent_services &parent_services,
|
||||
Child_services &child_services,
|
||||
@@ -105,6 +107,7 @@ class Launchpad_child : public Genode::Child_policy,
|
||||
_name(label), _elf_name(elf_name),
|
||||
_env(env), _alloc(alloc),
|
||||
_ref_ram_cap(env.ram_session_cap()),
|
||||
_cap_quota(Genode::Child::effective_quota(cap_quota)),
|
||||
_ram_quota(Genode::Child::effective_quota(ram_quota)),
|
||||
_parent_services(parent_services),
|
||||
_child_services(child_services),
|
||||
@@ -133,9 +136,19 @@ class Launchpad_child : public Genode::Child_policy,
|
||||
|
||||
Binary_name binary_name() const override { return _elf_name; }
|
||||
|
||||
Genode::Pd_session &ref_pd() override { return _env.pd(); }
|
||||
Genode::Pd_session_capability ref_pd_cap() const override { return _env.pd_session_cap(); }
|
||||
|
||||
Genode::Ram_session &ref_ram() override { return _ref_ram; }
|
||||
Genode::Ram_session_capability ref_ram_cap() const override { return _ref_ram_cap; }
|
||||
|
||||
void init(Genode::Pd_session &session,
|
||||
Genode::Pd_session_capability cap) override
|
||||
{
|
||||
session.ref_account(_env.pd_session_cap());
|
||||
_env.pd().transfer_quota(cap, _cap_quota);
|
||||
}
|
||||
|
||||
void init(Genode::Ram_session &session,
|
||||
Genode::Ram_session_capability cap) override
|
||||
{
|
||||
@@ -200,7 +213,8 @@ class Launchpad_child : public Genode::Child_policy,
|
||||
Child_service(_child_services, service_name,
|
||||
_session_requester.id_space(),
|
||||
_child.session_factory(), *this,
|
||||
_child.ram_session_cap());
|
||||
_child.ram_session_cap(),
|
||||
_child.pd_session_cap());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -233,6 +247,7 @@ class Launchpad
|
||||
|
||||
public:
|
||||
|
||||
typedef Genode::Cap_quota Cap_quota;
|
||||
typedef Genode::Ram_quota Ram_quota;
|
||||
|
||||
Launchpad(Genode::Env &env, unsigned long initial_quota);
|
||||
@@ -254,7 +269,7 @@ class Launchpad
|
||||
virtual void quota(unsigned long quota) { }
|
||||
|
||||
virtual void add_launcher(Launchpad_child::Name const &binary_name,
|
||||
unsigned long default_quota,
|
||||
Cap_quota caps, unsigned long default_quota,
|
||||
Genode::Dataspace_capability config_ds) { }
|
||||
|
||||
virtual void add_child(Launchpad_child::Name const &,
|
||||
@@ -266,7 +281,7 @@ class Launchpad
|
||||
Genode::Allocator &) { }
|
||||
|
||||
Launchpad_child *start_child(Launchpad_child::Name const &binary_name,
|
||||
Ram_quota quota,
|
||||
Cap_quota cap_quota, Ram_quota ram_quota,
|
||||
Genode::Dataspace_capability config_ds);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user