VirtualBox

Changeset 26689 in vbox for trunk


Ignore:
Timestamp:
Feb 22, 2010 10:11:38 PM (15 years ago)
Author:
vboxsync
Message:

AsyncCompletion: Do not use TM to refresh the bandwidth limit. Expired timers are not executed during suspend leading to a hang because of insufficient bandwidth. Let the I/O managers update them instead

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

Legend:

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

    r26671 r26689  
    464464
    465465/**
    466  * I/O refresh timer callback.
    467  */
    468 static void pdmacFileBwRefresh(PVM pVM, PTMTIMER pTimer, void *pvUser)
    469 {
    470     PPDMACFILEBWMGR pBwMgr = (PPDMACFILEBWMGR)pvUser;
    471 
    472     LogFlowFunc(("pVM=%p pTimer=%p pvUser=%p\n", pVM, pTimer, pvUser));
    473 
    474     /* Reset the counter growing the maximum if allowed and needed */
    475     bool fIncreaseNeeded = ASMAtomicReadBool(&pBwMgr->fVMTransferLimitReached);
    476 
    477     if (   fIncreaseNeeded
    478         && pBwMgr->cbVMTransferPerSecStart < pBwMgr->cbVMTransferPerSecMax)
    479     {
    480        pBwMgr->cbVMTransferPerSecStart = RT_MIN(pBwMgr->cbVMTransferPerSecMax, pBwMgr->cbVMTransferPerSecStart + pBwMgr->cbVMTransferPerSecStep);
    481        LogFlow(("AIOMgr: Increasing maximum bandwidth to %u bytes/sec\n", pBwMgr->cbVMTransferPerSecStart));
    482     }
    483 
    484     /* Update */
    485     ASMAtomicWriteU32(&pBwMgr->cbVMTransferAllowed, pBwMgr->cbVMTransferPerSecStart);
    486     ASMAtomicWriteBool(&pBwMgr->fVMTransferLimitReached, false);
    487 
    488     /* Arm the timer */
    489     TMTimerSetMillies(pTimer, 1000);
    490 }
    491 
    492 /**
    493466 * Destroys a async I/O manager.
    494467 *
     
    549522
    550523        pBwMgr->cbVMTransferAllowed = pBwMgr->cbVMTransferPerSecStart;
    551 
    552         /* Init the refresh timer */
    553         rc = TMR3TimerCreateInternal(pEpClassFile->Core.pVM,
    554                                      TMCLOCK_REAL,
    555                                      pdmacFileBwRefresh,
    556                                      pBwMgr,
    557                                      "AsyncCompletionFile-BW-Refresh",
    558                                      &pBwMgr->pBwRefreshTimer);
    559         if (RT_SUCCESS(rc))
    560             *ppBwMgr = pBwMgr;
    561         else
    562             MMR3HeapFree(pBwMgr);
     524        pBwMgr->tsUpdatedLast       = RTTimeSystemNanoTS();
     525
     526        *ppBwMgr = pBwMgr;
    563527    }
    564528
     
    568532static void pdmacFileBwMgrDestroy(PPDMACFILEBWMGR pBwMgr)
    569533{
    570     TMR3TimerDestroy(pBwMgr->pBwRefreshTimer);
    571534    MMR3HeapFree(pBwMgr);
    572535}
     
    575538{
    576539    pBwMgr->cRefs++;
    577     if (pBwMgr->cRefs == 1)
    578         TMTimerSetMillies(pBwMgr->pBwRefreshTimer, 1000); /* 1sec update interval */
    579540}
    580541
     
    583544    Assert(pBwMgr->cRefs > 0);
    584545    pBwMgr->cRefs--;
    585     if (!pBwMgr->cRefs)
    586         TMTimerStop(pBwMgr->pBwRefreshTimer);
    587546}
    588547
     
    598557    else
    599558    {
    600         /* We are out of ressources */
    601         ASMAtomicAddU32(&pBwMgr->cbVMTransferAllowed, cbTransfer);
    602         ASMAtomicXchgBool(&pBwMgr->fVMTransferLimitReached, true);
     559        /* We are out of ressources  Check if we can update again. */
     560        uint64_t tsNow          = RTTimeSystemNanoTS();
     561        uint64_t tsUpdatedLast  = ASMAtomicUoReadU64(&pBwMgr->tsUpdatedLast);
     562
     563        if (tsNow - tsUpdatedLast >= (1000*1000*1000))
     564        {
     565            if (ASMAtomicCmpXchgU64(&pBwMgr->tsUpdatedLast, tsNow, tsUpdatedLast))
     566            {
     567                if (pBwMgr->cbVMTransferPerSecStart < pBwMgr->cbVMTransferPerSecMax)
     568                {
     569                   pBwMgr->cbVMTransferPerSecStart = RT_MIN(pBwMgr->cbVMTransferPerSecMax, pBwMgr->cbVMTransferPerSecStart + pBwMgr->cbVMTransferPerSecStep);
     570                   LogFlow(("AIOMgr: Increasing maximum bandwidth to %u bytes/sec\n", pBwMgr->cbVMTransferPerSecStart));
     571                }
     572
     573                /* Update */
     574                ASMAtomicWriteU32(&pBwMgr->cbVMTransferAllowed, pBwMgr->cbVMTransferPerSecStart - cbTransfer);
     575                fAllowed = true;
     576                LogFlow(("AIOMgr: Refreshed bandwidth\n"));
     577            }
     578        }
     579        else
     580            ASMAtomicAddU32(&pBwMgr->cbVMTransferAllowed, cbTransfer);
    603581    }
    604582
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileInternal.h

    r26671 r26689  
    204204     * Resetted by the refresh timer. */
    205205    volatile uint32_t cbVMTransferAllowed;
    206     /** Flag whether a request could not processed due to the limit. */
    207     volatile bool     fVMTransferLimitReached;
     206    /** Timestamp of the last update */
     207    volatile uint64_t tsUpdatedLast;
    208208    /** Reference counter - How many endpoints are associated with this manager. */
    209209    uint32_t          cRefs;
    210     /** The refresh timer */
    211     PTMTIMERR3        pBwRefreshTimer;
    212210} PDMACFILEBWMGR;
    213211/** Pointer to a bandwidth control manager */
  • trunk/src/VBox/VMM/PDMAsyncCompletionFileNormal.cpp

    r26672 r26689  
    10261026        pAioMgr->iFreeEntryNext = (pAioMgr->iFreeEntryNext + 1) % pAioMgr->cReqEntries;
    10271027
     1028        /* Free the lock and process pending tasks if neccessary */
     1029        pdmacFileAioMgrNormalRangeLockFree(pAioMgr, pEndpoint, pTask->pRangeLock);
     1030
    10281031        pAioMgr->cRequestsActive--;
    10291032        pEndpoint->AioMgr.cRequestsActive--;
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