VirtualBox

Changeset 90972 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Aug 27, 2021 11:00:48 PM (3 years ago)
Author:
vboxsync
Message:

VMM: Correctly update idxBuf so we flush the right buffer when we get to ring-3. Tweaked the EMT/flusher race mitigation hack in vmmR3LogReturnFlush and added a couple of counters for it. bugref:10086

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r90971 r90972  
    32233223             * We always switch buffer if we have more than one.
    32243224             */
     3225#if VMMLOGGER_BUFFER_COUNT == 1
     3226            fFlushedBuffer = true;
     3227#else
    32253228            AssertCompile(VMMLOGGER_BUFFER_COUNT >= 1);
    3226             fFlushedBuffer = VMMLOGGER_BUFFER_COUNT == 1;
     3229            pShared->idxBuf = (idxBuffer + 1) % VMMLOGGER_BUFFER_COUNT;
     3230            fFlushedBuffer = false;
     3231#endif
    32273232        }
    32283233        else
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r90958 r90972  
    476476        STAMR3RegisterF(pVM, &pShared->StatFlushes,     STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,     "", "/VMM/LogFlush/CPU%u/Reg", i);
    477477        STAMR3RegisterF(pVM, &pShared->StatCannotBlock, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,     "", "/VMM/LogFlush/CPU%u/Reg/CannotBlock", i);
     478        STAMR3RegisterF(pVM, &pShared->StatRaces,       STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,     "", "/VMM/LogFlush/CPU%u/Reg/Races", i);
     479        STAMR3RegisterF(pVM, &pShared->StatRacesReal,   STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,     "", "/VMM/LogFlush/CPU%u/Reg/RacesReal", i);
    478480        STAMR3RegisterF(pVM, &pShared->StatWait,        STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL, "", "/VMM/LogFlush/CPU%u/Reg/Wait", i);
    479481        STAMR3RegisterF(pVM, &pShared->cbDropped,       STAMTYPE_U32,     STAMVISIBILITY_USED, STAMUNIT_BYTES,          "", "/VMM/LogFlush/CPU%u/Reg/cbDropped", i);
     
    484486        STAMR3RegisterF(pVM, &pShared->StatFlushes,     STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,     "", "/VMM/LogFlush/CPU%u/Rel", i);
    485487        STAMR3RegisterF(pVM, &pShared->StatCannotBlock, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,     "", "/VMM/LogFlush/CPU%u/Rel/CannotBlock", i);
     488        STAMR3RegisterF(pVM, &pShared->StatRaces,       STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,     "", "/VMM/LogFlush/CPU%u/Rel/Races", i);
     489        STAMR3RegisterF(pVM, &pShared->StatRacesReal,   STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,     "", "/VMM/LogFlush/CPU%u/Rel/RacesReal", i);
    486490        STAMR3RegisterF(pVM, &pShared->StatWait,        STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_TICKS_PER_CALL, "", "/VMM/LogFlush/CPU%u/Rel/Wait", i);
    487491        STAMR3RegisterF(pVM, &pShared->cbDropped,       STAMTYPE_U32,     STAMVISIBILITY_USED, STAMUNIT_BYTES,          "", "/VMM/LogFlush/CPU%u/Rel/cbDropped", i);
     
    942946{
    943947#if VMMLOGGER_BUFFER_COUNT > 1
    944     /* Yield if other log buffers are being flushed already, so we try
    945        avoid totally mixing things up... */
     948    /*
     949     * To avoid totally mixing up the output, make some effort at delaying if
     950     * there are buffers still being worked on by the flusher thread.
     951     */
    946952    if (pShared->cFlushing > 0)
    947         RTThreadYield();
     953    {
     954        STAM_REL_COUNTER_INC(&pShared->StatRaces);
     955        for (uint32_t iTry = 0; iTry < 32 && pShared->cFlushing != 0; iTry++)
     956        {
     957            RTLogBulkWrite(pDstLogger, "", 0); /* A no-op, but it takes the lock and the hope is */
     958            if (pShared->cFlushing != 0)       /* that we end up waiting on the flusher finish up. */
     959                RTThreadYield();
     960        }
     961        if (pShared->cFlushing != 0)
     962        {
     963            RTLogLoggerEx(pDstLogger, RTLOGGRPFLAGS_LEVEL_1, UINT32_MAX, "*MAYBE WRONG ORDER*\n");
     964            if (pShared->cFlushing != 0)
     965                STAM_REL_COUNTER_INC(&pShared->StatRacesReal);
     966        }
     967    }
    948968#endif
    949969    RTLogBulkWrite(pDstLogger, pShared->aBufs[idxBuf].pchBufR3, pShared->aBufs[idxBuf].AuxDesc.offBuf);
  • trunk/src/VBox/VMM/include/VMMInternal.h

    r90970 r90972  
    123123    STAMCOUNTER             StatFlushes;
    124124    STAMCOUNTER             StatCannotBlock;
     125    STAMCOUNTER             StatRaces;
     126    STAMCOUNTER             StatRacesReal;
    125127    STAMPROFILE             StatWait;
    126128} VMMR3CPULOGGER;
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