VirtualBox

Changeset 81417 in vbox


Ignore:
Timestamp:
Oct 21, 2019 3:22:15 PM (5 years ago)
Author:
vboxsync
Message:

DevE1000: Eliminating hCanRxTask (previously pCanRxQueue) by replacing hEventMoreRxDescAvail with a SUPSEMEVENT than can be signalled from ring-0. This probably changes the EMT run pattern quite abit, since we used to force a lot of trips back to ring-3 to service the queue there for no good reason. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevE1000.cpp

    r81414 r81417  
    10481048    /** Transmit task. */
    10491049    PDMTASKHANDLE           hTxTask;
    1050     /** Rx wakeup signaller. */
    1051     PDMTASKHANDLE           hCanRxTask;
    10521050
    10531051    /** Critical section - what is it protecting? */
     
    11101108    bool volatile fMaybeOutOfSpace;
    11111109    /** EMT: Gets signalled when more RX descriptors become available. */
    1112     RTSEMEVENT hEventMoreRxDescAvail;
     1110    SUPSEMEVENT hEventMoreRxDescAvail;
    11131111#ifdef E1K_WITH_RXD_CACHE
    11141112    /** RX: Fetched RX descriptors. */
     
    12091207    STAMPROFILE                         StatTransmitSendR3;
    12101208    STAMPROFILE                         StatRxOverflow;
    1211     STAMCOUNTER                         StatRxOverflowWakeup;
     1209    STAMCOUNTER                         StatRxOverflowWakeupRZ;
     1210    STAMCOUNTER                         StatRxOverflowWakeupR3;
    12121211    STAMCOUNTER                         StatTxDescCtxNormal;
    12131212    STAMCOUNTER                         StatTxDescCtxTSE;
     
    16711670#endif /* E1K_WITH_TX_CS */
    16721671
     1672
     1673/**
     1674 * Wakeup the RX thread.
     1675 */
     1676static void e1kWakeupReceive(PPDMDEVINS pDevIns, PE1KSTATE pThis)
     1677{
     1678    if (   pThis->fMaybeOutOfSpace
     1679        && pThis->hEventMoreRxDescAvail != NIL_SUPSEMEVENT)
     1680    {
     1681        STAM_COUNTER_INC(&pThis->CTX_SUFF_Z(StatRxOverflowWakeup));
     1682        E1kLog(("%s Waking up Out-of-RX-space semaphore\n",  pThis->szPrf));
     1683        int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEventMoreRxDescAvail);
     1684        AssertRC(rc);
     1685    }
     1686}
     1687
    16731688#ifdef IN_RING3
    1674 
    1675 /**
    1676  * Wakeup the RX thread.
    1677  */
    1678 static void e1kWakeupReceive(PPDMDEVINS pDevIns)
    1679 {
    1680     PE1KSTATE pThis = PDMINS_2_DATA(pDevIns, PE1KSTATE);
    1681     if (    pThis->fMaybeOutOfSpace
    1682         &&  pThis->hEventMoreRxDescAvail != NIL_RTSEMEVENT)
    1683     {
    1684         STAM_COUNTER_INC(&pThis->StatRxOverflowWakeup);
    1685         E1kLog(("%s Waking up Out-of-RX-space semaphore\n",  pThis->szPrf));
    1686         RTSemEventSignal(pThis->hEventMoreRxDescAvail);
    1687     }
    1688 }
    16891689
    16901690/**
     
    33393339        if (RT_SUCCESS(rc))
    33403340        {
    3341 /** @todo bird: Use SUPSem* for this so we can signal it in ring-0 as well
    3342  *        without requiring any context switches.  We should also check the
    3343  *        wait condition before bothering to queue the item as we're currently
    3344  *        queuing thousands of items per second here in a normal transmit
    3345  *        scenario.  Expect performance changes when fixing this! */
    3346 #ifdef IN_RING3
    33473341            /* Signal that we have more receive descriptors available. */
    3348             e1kWakeupReceive(pDevIns);
    3349 #else
    3350             PDMDevHlpTaskTrigger(pDevIns, pThis->hCanRxTask);
    3351 #endif
     3342            e1kWakeupReceive(pDevIns, pThis);
    33523343        }
    33533344    }
     
    56195610{
    56205611    RT_NOREF(pvUser);
    5621     e1kWakeupReceive(pDevIns);
     5612    e1kWakeupReceive(pDevIns, PDMINS_2_DATA(pDevIns, PE1KSTATE));
    56225613}
    56235614
     
    64986489        E1kLogRel(("E1000: e1kR3NetworkDown_WaitReceiveAvail: waiting cMillies=%u...\n", cMillies));
    64996490        E1kLog(("%s: e1kR3NetworkDown_WaitReceiveAvail: waiting cMillies=%u...\n", pThis->szPrf, cMillies));
    6500         RTSemEventWait(pThis->hEventMoreRxDescAvail, cMillies);
     6491        PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->hEventMoreRxDescAvail, cMillies);
    65016492    }
    65026493    STAM_PROFILE_STOP(&pThis->StatRxOverflow, a);
     
    75487539{
    75497540    /* Poke thread waiting for buffer space. */
    7550     e1kWakeupReceive(pDevIns);
     7541    e1kWakeupReceive(pDevIns, PDMINS_2_DATA(pDevIns, PE1KSTATE));
    75517542}
    75527543
     
    75807571{
    75817572    /* Poke thread waiting for buffer space. */
    7582     e1kWakeupReceive(pDevIns);
     7573    e1kWakeupReceive(pDevIns, PDMINS_2_DATA(pDevIns, PE1KSTATE));
    75837574}
    75847575
     
    76257616    if (PDMCritSectIsInitialized(&pThis->cs))
    76267617    {
    7627         if (pThis->hEventMoreRxDescAvail != NIL_RTSEMEVENT)
    7628         {
    7629             RTSemEventSignal(pThis->hEventMoreRxDescAvail);
    7630             RTSemEventDestroy(pThis->hEventMoreRxDescAvail);
    7631             pThis->hEventMoreRxDescAvail = NIL_RTSEMEVENT;
     7618        if (pThis->hEventMoreRxDescAvail != NIL_SUPSEMEVENT)
     7619        {
     7620            PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEventMoreRxDescAvail);
     7621            RTThreadYield();
     7622            PDMDevHlpSUPSemEventClose(pDevIns, pThis->hEventMoreRxDescAvail);
     7623            pThis->hEventMoreRxDescAvail = NIL_SUPSEMEVENT;
    76327624        }
    76337625#ifdef E1K_WITH_TX_CS
     
    77307722    RTStrPrintf(pThis->szPrf, sizeof(pThis->szPrf), "E1000#%d", iInstance);
    77317723    E1kLog(("%s Constructing new instance sizeof(E1KRXDESC)=%d\n", pThis->szPrf, sizeof(E1KRXDESC)));
    7732     pThis->hEventMoreRxDescAvail = NIL_RTSEMEVENT;
     7724    pThis->hEventMoreRxDescAvail = NIL_SUPSEMEVENT;
    77337725    pThis->u16TxPktLen  = 0;
    77347726    pThis->fIPcsum      = false;
     
    79267918    AssertRCReturn(rc, rc);
    79277919
    7928     /* Create the RX notifier signaller. */
    7929     rc = PDMDevHlpTaskCreate(pDevIns, PDMTASK_F_RZ, "E1000-Rcv", e1kCanRxTaskCallback, NULL, &pThis->hCanRxTask);
    7930     AssertRCReturn(rc, rc);
    7931 
    79327920#ifdef E1K_TX_DELAY
    79337921    /* Create Transmit Delay Timer */
     
    80148002        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the network LUN"));
    80158003
    8016     rc = RTSemEventCreate(&pThis->hEventMoreRxDescAvail);
     8004    rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pThis->hEventMoreRxDescAvail);
    80178005    AssertRCReturn(rc, rc);
    80188006
     
    80488036    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatReceiveStore,       STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling receive storing",          "/Devices/E1k%d/Receive/Store", iInstance);
    80498037    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRxOverflow,         STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE, "Profiling RX overflows",        "/Devices/E1k%d/RxOverflow", iInstance);
    8050     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRxOverflowWakeup,   STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,     "Nr of RX overflow wakeups",          "/Devices/E1k%d/RxOverflowWakeup", iInstance);
     8038    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRxOverflowWakeupRZ, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,     "Nr of RX overflow wakeups in RZ",    "/Devices/E1k%d/RxOverflowWakeupRZ", iInstance);
     8039    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRxOverflowWakeupR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,     "Nr of RX overflow wakeups in R3",    "/Devices/E1k%d/RxOverflowWakeupR3", iInstance);
    80518040    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitRZ,         STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling transmits in RZ",          "/Devices/E1k%d/Transmit/TotalRZ", iInstance);
    80528041    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitR3,         STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling transmits in R3",          "/Devices/E1k%d/Transmit/TotalR3", iInstance);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette