core: add kernel-specific UTCB quota bookkeeping

Fix #859
This commit is contained in:
Stefan Kalkowski 2020-01-31 15:50:34 +01:00 committed by Christian Helmuth
parent 4f217b19a9
commit 79fba6c2ac
6 changed files with 22 additions and 27 deletions

View File

@ -18,6 +18,9 @@
#include <cpu_session_component.h>
#include <kernel/configuration.h>
/* base-internal includes */
#include <base/internal/native_utcb.h>
using namespace Genode;
@ -33,3 +36,7 @@ Cpu_session::Quota Cpu_session_component::quota()
size_t const u = quota_lim_downscale<sizet_arithm_t>(_quota, spu);
return { spu, u };
}
size_t Cpu_session_component::_utcb_quota_size() {
return sizeof(Native_utcb); }

View File

@ -9,7 +9,7 @@ SRC_CC = stack_area.cc \
core_rpc_cap_alloc.cc \
core_region_map.cc \
cpu_session_component.cc \
cpu_session_platform.cc \
cpu_session_support.cc \
cpu_thread_component.cc \
capability_space.cc \
dataspace_component.cc \

View File

@ -1,26 +0,0 @@
/*
* \brief Platform-specific parts of the core CPU session interface
* \author Martin Stein
* \date 2012-04-17
*/
/*
* Copyright (C) 2009-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <cpu_session_component.h>
using namespace Genode;
Dataspace_capability Cpu_thread_component::utcb()
{
return Dataspace_capability();
}
Cpu_session::Quota Cpu_session_component::quota() { return Quota(); }

View File

@ -34,6 +34,10 @@ Thread_capability Cpu_session_component::create_thread(Capability<Pd_session> pd
{
Trace::Thread_name thread_name(name.string());
if (!_md_alloc.withdraw(_utcb_quota_size())) {
throw Out_of_ram();
}
Cpu_thread_component *thread = 0;
if (weight.value == 0) {
@ -121,6 +125,8 @@ void Cpu_session_component::_unsynchronized_kill_thread(Thread_capability thread
Lock::Guard lock_guard(_thread_alloc_lock);
destroy(&_thread_alloc, thread);
}
_md_alloc.upgrade(_utcb_quota_size());
}

View File

@ -28,3 +28,6 @@ Dataspace_capability Cpu_thread_component::utcb()
Cpu_session::Quota Cpu_session_component::quota() { return Quota(); }
size_t Cpu_session_component::_utcb_quota_size() { return 0; }

View File

@ -128,6 +128,11 @@ class Genode::Cpu_session_component : public Rpc_object<Cpu_session>,
*/
Affinity::Location _thread_affinity(Affinity::Location) const;
/**
* Return the UTCB quota size that needs to be accounted per thread
*/
size_t _utcb_quota_size();
/*
* Noncopyable
*/