View | Details | Raw Unified | Return to bug 280495 | Differences between
and this patch

Collapse All | Expand All

(-)b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h (-9 / +27 lines)
Lines 1-13 Link Here
1
Without this patch any waits for periods shorter than a single tick return
1
Without the first part of this patch, any waits for periods shorter than a
2
immediately leading to a lot of unnecessary spinning. For example, I observe that
2
single tick return immediately leading to a lot of unnecessary spinning. For
3
my guest's idle loop does a lot of sleeps with periods slightly shorter than 1 ms
3
example, I observe that my guest's idle loop does a lot of sleeps with periods
4
(1/hz), e.g. 900us.  All that waiting turns into pure spinning and VirtualBox eats
4
slightly shorter than 1 ms (1/hz), e.g. 900us.  All that waiting turns into pure
5
100% of a core.
5
spinning and VirtualBox eats 100% of a core.
6
The patch improves the situation significantly. Also, it (approximately) follows
6
7
what tvtohz does.
7
The clamping improves the situation significantly. Also, it (approximately)
8
follows what tvtohz does.  The rest of the patch just chases an upstream
9
KPI change.
8
10
9
Submitted by:	Andriy Gapon <avg@FreeBSD.org>
11
Submitted by:	Andriy Gapon <avg@FreeBSD.org>
10
--- src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h.orig	2020-05-13 19:44:32 UTC
12
--- src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h.orig	2020-07-09 16:57:38 UTC
11
+++ src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h
13
+++ src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h
12
@@ -82,6 +82,8 @@ DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0
14
@@ -82,6 +82,8 @@ DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0
13
     uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000));
15
     uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000));
Lines 18-20 Submitted by: Andriy Gapon <avg@FreeBSD.org> Link Here
18
     else
20
     else
19
         pWait->iTimeout     = (int)cTicks;
21
         pWait->iTimeout     = (int)cTicks;
20
 #endif
22
 #endif
21
- 
23
@@ -298,10 +300,16 @@ DECLINLINE(void) rtR0SemBsdSignal(void *pvWaitChan)
24
 DECLINLINE(void) rtR0SemBsdSignal(void *pvWaitChan)
25
 {
26
     sleepq_lock(pvWaitChan);
27
+#if __FreeBSD_version < 1500022
28
     int fWakeupSwapProc = sleepq_signal(pvWaitChan, SLEEPQ_CONDVAR, 0, 0);
29
+#else
30
+    sleepq_signal(pvWaitChan, SLEEPQ_CONDVAR, 0, 0);
31
+#endif
32
     sleepq_release(pvWaitChan);
33
+#if __FreeBSD_version < 1500022
34
     if (fWakeupSwapProc)
35
         kick_proc0();
36
+#endif
37
 }
38
 
39
 /**

Return to bug 280495