vbox: increase cpu_session quota for pthreads

Fixes #1591
This commit is contained in:
Alexander Boettcher 2015-06-16 14:53:12 +02:00 committed by Christian Helmuth
parent a3d287f23d
commit be149cc6e4
2 changed files with 45 additions and 20 deletions

View File

@ -61,10 +61,14 @@ void SUPR3QueryHWACCLonGenodeSupport(VM * pVM)
pVM->hm.s.svm.fSupported = hip->has_feature_svm();
pVM->hm.s.vmx.fSupported = hip->has_feature_vmx();
PINF("support svm %u vmx %u", hip->has_feature_svm(), hip->has_feature_vmx());
} catch (...) {
PWRN("No hardware acceleration available - execution will be slow!");
} /* if we get an exception let hardware support off */
if (hip->has_feature_svm() || hip->has_feature_vmx()) {
PINF("Using %s virtualization extension.",
hip->has_feature_svm() ? "SVM" : "VMX");
return;
}
} catch (...) { /* if we get an exception let hardware support off */ }
PWRN("No virtualization hardware acceleration available");
}
@ -116,7 +120,8 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned
return VINF_SUCCESS;
case VMMR0_DO_GVMM_SCHED_POKE:
vcpu_handler->recall();
if (vcpu_handler)
vcpu_handler->recall();
return VINF_SUCCESS;
default:

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2014 Genode Labs GmbH
* Copyright (C) 2014-2015 Genode Labs GmbH
*
* This file is distributed under the terms of the GNU General Public License
* version 2.
@ -29,7 +29,7 @@
/* vbox */
#include <internal/thread.h>
static Genode::Cpu_session * get_cpu_session(RTTHREADTYPE type) {
static Genode::Cpu_connection * cpu_connection(RTTHREADTYPE type) {
using namespace Genode;
static Cpu_connection * con[RTTHREADTYPE_END - 1];
@ -55,16 +55,12 @@ static Genode::Cpu_session * get_cpu_session(RTTHREADTYPE type) {
con[type - 1] = new (env()->heap()) Cpu_connection(data, prio);
/* upgrade memory of cpu session for frequent used thread type */
if (type == RTTHREADTYPE_IO)
Genode::env()->parent()->upgrade(con[type - 1]->cap(), "ram_quota=16384");
return con[type - 1];
}
extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg)
static int create_thread(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg)
{
PRTTHREADINT rtthread = reinterpret_cast<PRTTHREADINT>(arg);
@ -85,22 +81,21 @@ extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
Assert(rtthread->enmType == RTTHREADTYPE_EMULATION);
if (rtthread->enmType == RTTHREADTYPE_EMULATION) {
Genode::Cpu_session * cpu_session = get_cpu_session(RTTHREADTYPE_EMULATION);
/*
Genode::Affinity::Space cpu_space = cpu_session->affinity_space();
Genode::Affinity::Location location = cpu_space.location_of_index(i);
*/
Genode::Cpu_session * cpu_session = cpu_connection(RTTHREADTYPE_EMULATION);
Genode::Affinity::Location location;
if (create_emt_vcpu(thread, stack_size, attr, start_routine, arg,
cpu_session, location))
return 0;
/* no haredware support, create normal pthread thread */
/*
* The virtualization layer had no need to setup the EMT
* specially, so create it as a ordinary pthread.
*/
}
pthread_t thread_obj = new (Genode::env()->heap())
pthread(attr ? *attr : 0, start_routine,
arg, stack_size, rtthread->szName,
get_cpu_session(rtthread->enmType));
cpu_connection(rtthread->enmType));
if (!thread_obj)
return EAGAIN;
@ -112,6 +107,31 @@ extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
return 0;
}
extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg)
{
PRTTHREADINT rtthread = reinterpret_cast<PRTTHREADINT>(arg);
/* retry thread creation once after CPU session upgrade */
for (unsigned i = 0; i < 2; i++) {
using namespace Genode;
try {
return create_thread(thread, attr, start_routine, arg);
} catch (Cpu_session::Out_of_metadata) {
PWRN("Upgrading memory for creation of thread '%s'",
rtthread->szName);
env()->parent()->upgrade(cpu_connection(rtthread->enmType)->cap(),
"ram_quota=4096");
} catch (...) { break; }
}
PERR("Could not create vbox pthread - halt");
Genode::Lock lock(Genode::Lock::LOCKED);
lock.lock();
return EAGAIN;
}
extern "C" int pthread_attr_setdetachstate(pthread_attr_t *, int)
{
return 0;