Differential D28871 Diff 85283 emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
Changeset View
Changeset View
Standalone View
Standalone View
emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
Without this patch any waits for periods shorter than a single tick return | Without this patch any waits for periods shorter than a single tick return | ||||
immediately leading to a lot of unnecessary spinning. For example, I observe that | immediately leading to a lot of unnecessary spinning. For example, I observe that | ||||
my guest's idle loop does a lot of sleeps with periods slightly shorter than 1 ms | my guest's idle loop does a lot of sleeps with periods slightly shorter than 1 ms | ||||
(1/hz), e.g. 900us. All that waiting turns into pure spinning and VirtualBox eats | (1/hz), e.g. 900us. All that waiting turns into pure spinning and VirtualBox eats | ||||
100% of a core. | 100% of a core. | ||||
The patch improves the situation significantly. Also, it (approximately) follows | The patch improves the situation significantly. Also, it (approximately) follows | ||||
what tvtohz does. | what tvtohz does. | ||||
Submitted by: Andriy Gapon <avg@FreeBSD.org> | Submitted by: Andriy Gapon <avg@FreeBSD.org> | ||||
--- src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h.orig 2020-05-13 19:44:32 UTC | --- src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h.orig 2021-01-07 15:42:09 UTC | ||||
+++ src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h | +++ src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h | ||||
@@ -82,6 +82,8 @@ DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0 | @@ -84,6 +84,8 @@ DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0 | ||||
uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000)); | uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000)); | ||||
if (cTicks >= INT_MAX) | if (cTicks >= INT_MAX) | ||||
return RTSEMWAIT_FLAGS_INDEFINITE; | return RTSEMWAIT_FLAGS_INDEFINITE; | ||||
+ else if (cTicks == 0 && uTimeout > 0) | + else if (cTicks == 0 && uTimeout > 0) | ||||
+ pWait->iTimeout = 1; | + pWait->iTimeout = 1; | ||||
else | else | ||||
pWait->iTimeout = (int)cTicks; | pWait->iTimeout = (int)cTicks; | ||||
#endif | #endif |