Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-gnome
Path: blob/main/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
17494 views
1
Without this patch any waits for periods shorter than a single tick return
2
immediately leading to a lot of unnecessary spinning. For example, I observe that
3
my guest's idle loop does a lot of sleeps with periods slightly shorter than 1 ms
4
(1/hz), e.g. 900us. All that waiting turns into pure spinning and VirtualBox eats
5
100% of a core.
6
The patch improves the situation significantly. Also, it (approximately) follows
7
what tvtohz does.
8
9
Submitted by: Andriy Gapon <avg@FreeBSD.org>
10
--- src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h.orig 2021-01-07 15:42:09 UTC
11
+++ src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h
12
@@ -84,6 +84,8 @@ DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0
13
uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000));
14
if (cTicks >= INT_MAX)
15
return RTSEMWAIT_FLAGS_INDEFINITE;
16
+ else if (cTicks == 0 && uTimeout > 0)
17
+ pWait->iTimeout = 1;
18
else
19
pWait->iTimeout = (int)cTicks;
20
#endif
21
22