From ce66e12699c8235fac2e3c2e3bff48d64d0821ac Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 1 Dec 2023 15:20:13 +0100 Subject: [PATCH] vbox: improve network tx throughput When multiple threads (EMT-0..X + nic_ep) enter the very same critical section, the use of RTCritSectTryEnter may reflect the contention case to the Network Model (E1000). Since no one notifies the model, when the critical section is free again, solely the next packet/event triggered by the guest will resume the former operation. This may lead to long delays until packets are sent actually. Instead of using the RTCritSectTryEnter use RTCritSecEnter to avoid the situation. All of our network code is non blocking, so the network backend will only be contented a short time. Follow up commit to Issue #5045 --- repos/ports/src/virtualbox5/network.cpp | 2 +- repos/ports/src/virtualbox6/network.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/repos/ports/src/virtualbox5/network.cpp b/repos/ports/src/virtualbox5/network.cpp index d3dcf4488a..9f1095a558 100644 --- a/repos/ports/src/virtualbox5/network.cpp +++ b/repos/ports/src/virtualbox5/network.cpp @@ -336,7 +336,7 @@ class Nic_client static DECLCALLBACK(int) drvNicNetworkUp_BeginXmit(PPDMINETWORKUP pInterface, bool fOnWorkerThread) { PDRVNIC pThis = PDMINETWORKUP_2_DRVNIC(pInterface); - int rc = RTCritSectTryEnter(&pThis->XmitLock); + int rc = RTCritSectEnter(&pThis->XmitLock); if (RT_FAILURE(rc)) rc = VERR_TRY_AGAIN; return rc; diff --git a/repos/ports/src/virtualbox6/network.cc b/repos/ports/src/virtualbox6/network.cc index f8f836ac96..6634ea6776 100644 --- a/repos/ports/src/virtualbox6/network.cc +++ b/repos/ports/src/virtualbox6/network.cc @@ -351,7 +351,7 @@ class Nic_client static DECLCALLBACK(int) drvNicNetworkUp_BeginXmit(PPDMINETWORKUP pInterface, bool fOnWorkerThread) { PDRVNIC pThis = PDMINETWORKUP_2_DRVNIC(pInterface); - int rc = RTCritSectTryEnter(&pThis->XmitLock); + int rc = RTCritSectEnter(&pThis->XmitLock); if (RT_FAILURE(rc)) rc = VERR_TRY_AGAIN; return rc;