VirtualBox

Changeset 30975 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jul 22, 2010 9:19:17 AM (14 years ago)
Author:
vboxsync
Message:

LsiLogic: Fix very rare race with SMP guests resulting in an endless loop in one EMT creating thousands of I/O requests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp

    r30947 r30975  
    957957        case LSILOGIC_REG_REQUEST_QUEUE:
    958958        {
    959             ASMAtomicWriteU32(&pThis->CTX_SUFF(pRequestQueueBase)[pThis->uRequestQueueNextEntryFreeWrite], u32);
    960             pThis->uRequestQueueNextEntryFreeWrite++;
    961             pThis->uRequestQueueNextEntryFreeWrite %= pThis->cRequestQueueEntries;
     959            uint32_t uNextWrite = ASMAtomicReadU32(&pThis->uRequestQueueNextEntryFreeWrite);
     960
     961            ASMAtomicWriteU32(&pThis->CTX_SUFF(pRequestQueueBase)[uNextWrite], u32);
     962
     963            /*
     964             * Don't update the value in place. It can happen that we get preempted
     965             * after the increment but before the modulo.
     966             * Another EMT will read the wrong value when processing the queues
     967             * and hang in an endless loop creating thousands of requests.
     968             */
     969            uNextWrite++;
     970            uNextWrite %= pThis->cRequestQueueEntries;
     971            ASMAtomicWriteU32(&pThis->uRequestQueueNextEntryFreeWrite, uNextWrite);
    962972
    963973            /* Send notification to R3 if there is not one send already. */
     
    34223432    LogFlowFunc(("pDevIns=%#p pItem=%#p\n", pDevIns, pItem));
    34233433
     3434    /* Reset notification event. */
     3435    ASMAtomicXchgBool(&pLsiLogic->fNotificationSend, false);
     3436
    34243437    /* Only process request which arrived before we received the notification. */
    34253438    uint32_t uRequestQueueNextEntryWrite = ASMAtomicReadU32(&pLsiLogic->uRequestQueueNextEntryFreeWrite);
    3426 
    3427     /* Reset notification event. */
    3428     ASMAtomicXchgBool(&pLsiLogic->fNotificationSend, false);
    34293439
    34303440    /* Go through the messages now and process them. */
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