vm_session: evaluate priority (nova)

Issue #3111
This commit is contained in:
Alexander Boettcher 2019-01-14 08:35:10 +01:00 committed by Christian Helmuth
parent d2229ab381
commit 526554741f
3 changed files with 21 additions and 15 deletions

View File

@ -40,6 +40,22 @@ namespace Genode {
return size_log2 > MAX_MAP_LOG2 ? (size_t)MAX_MAP_LOG2 : size_log2;
}
inline unsigned scale_priority(unsigned const prio, char const * name)
{
using Nova::Qpd;
unsigned priority = Cpu_session::scale_priority(Qpd::DEFAULT_PRIORITY,
prio);
if (priority == 0) {
warning("priority of thread '", name, "' below minimum - boost to 1");
priority = 1;
}
if (priority > Nova::Qpd::DEFAULT_PRIORITY) {
warning("priority of thread '", name, "' above maximum - limit to ",
(unsigned)Qpd::DEFAULT_PRIORITY);
priority = Qpd::DEFAULT_PRIORITY;
}
return priority;
}
}
#endif /* _CORE__INCLUDE__UTIL_H_ */

View File

@ -343,19 +343,9 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned prio,
_pd(0), _pager(0), _id_base(cap_map().insert(2)),
_sel_exc_base(Native_thread::INVALID_INDEX), _location(affinity),
_features(0),
_priority(Cpu_session::scale_priority(Nova::Qpd::DEFAULT_PRIORITY, prio)),
_priority(scale_priority(prio, name)),
_name(name)
{
if (_priority == 0) {
warning("priority of thread '", _name, "' below minimum - boost to 1");
_priority = 1;
}
if (_priority > Nova::Qpd::DEFAULT_PRIORITY) {
warning("priority of thread '", _name, "' above maximum - limit to ",
(unsigned)Nova::Qpd::DEFAULT_PRIORITY);
_priority = Nova::Qpd::DEFAULT_PRIORITY;
}
}
{ }
Platform_thread::~Platform_thread()

View File

@ -23,6 +23,7 @@
#include <vm_session_component.h>
#include <platform.h>
#include <pager.h>
#include <util.h>
#include <nova/cap_map.h>
@ -222,7 +223,6 @@ void Vm_session_component::_run(Vcpu_id const vcpu_id)
if (!vcpu.init())
return;
addr_t const _priority = 1; /* XXX */
uint8_t res = _with_kernel_quota_upgrade(_pd_sel, [&] {
return Nova::create_sc(vcpu.sc_sel(), _pd_sel, vcpu.ec_sel(),
Nova::Qpd(Nova::Qpd::DEFAULT_QUANTUM, _priority));
@ -277,14 +277,14 @@ Vm_session_component::Vm_session_component(Rpc_entrypoint &ep,
Diag,
Ram_allocator &ram,
Region_map &local_rm,
unsigned)
unsigned const priority)
:
Ram_quota_guard(resources.ram_quota),
Cap_quota_guard(resources.cap_quota),
_ep(ep),
_constrained_md_ram_alloc(ram, _ram_quota_guard(), _cap_quota_guard()),
_sliced_heap(_constrained_md_ram_alloc, local_rm),
_priority(1 /*scale_priority(priority, "VM session")*/)
_priority(scale_priority(priority, "VM sesssion"))
{
_cap_quota_guard().withdraw(Cap_quota{1});