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
This commit is contained in:
Alexander Boettcher 2023-12-01 15:20:13 +01:00 committed by Norman Feske
parent 342e48115e
commit ce66e12699
2 changed files with 2 additions and 2 deletions

View File

@ -336,7 +336,7 @@ class Nic_client
static DECLCALLBACK(int) drvNicNetworkUp_BeginXmit(PPDMINETWORKUP pInterface, bool fOnWorkerThread) static DECLCALLBACK(int) drvNicNetworkUp_BeginXmit(PPDMINETWORKUP pInterface, bool fOnWorkerThread)
{ {
PDRVNIC pThis = PDMINETWORKUP_2_DRVNIC(pInterface); PDRVNIC pThis = PDMINETWORKUP_2_DRVNIC(pInterface);
int rc = RTCritSectTryEnter(&pThis->XmitLock); int rc = RTCritSectEnter(&pThis->XmitLock);
if (RT_FAILURE(rc)) if (RT_FAILURE(rc))
rc = VERR_TRY_AGAIN; rc = VERR_TRY_AGAIN;
return rc; return rc;

View File

@ -351,7 +351,7 @@ class Nic_client
static DECLCALLBACK(int) drvNicNetworkUp_BeginXmit(PPDMINETWORKUP pInterface, bool fOnWorkerThread) static DECLCALLBACK(int) drvNicNetworkUp_BeginXmit(PPDMINETWORKUP pInterface, bool fOnWorkerThread)
{ {
PDRVNIC pThis = PDMINETWORKUP_2_DRVNIC(pInterface); PDRVNIC pThis = PDMINETWORKUP_2_DRVNIC(pInterface);
int rc = RTCritSectTryEnter(&pThis->XmitLock); int rc = RTCritSectEnter(&pThis->XmitLock);
if (RT_FAILURE(rc)) if (RT_FAILURE(rc))
rc = VERR_TRY_AGAIN; rc = VERR_TRY_AGAIN;
return rc; return rc;