- Timestamp:
- Feb 22, 2010 10:11:38 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMAsyncCompletionFile.cpp
r26671 r26689 464 464 465 465 /** 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 ( fIncreaseNeeded478 && 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 /**493 466 * Destroys a async I/O manager. 494 467 * … … 549 522 550 523 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; 563 527 } 564 528 … … 568 532 static void pdmacFileBwMgrDestroy(PPDMACFILEBWMGR pBwMgr) 569 533 { 570 TMR3TimerDestroy(pBwMgr->pBwRefreshTimer);571 534 MMR3HeapFree(pBwMgr); 572 535 } … … 575 538 { 576 539 pBwMgr->cRefs++; 577 if (pBwMgr->cRefs == 1)578 TMTimerSetMillies(pBwMgr->pBwRefreshTimer, 1000); /* 1sec update interval */579 540 } 580 541 … … 583 544 Assert(pBwMgr->cRefs > 0); 584 545 pBwMgr->cRefs--; 585 if (!pBwMgr->cRefs)586 TMTimerStop(pBwMgr->pBwRefreshTimer);587 546 } 588 547 … … 598 557 else 599 558 { 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); 603 581 } 604 582 -
trunk/src/VBox/VMM/PDMAsyncCompletionFileInternal.h
r26671 r26689 204 204 * Resetted by the refresh timer. */ 205 205 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; 208 208 /** Reference counter - How many endpoints are associated with this manager. */ 209 209 uint32_t cRefs; 210 /** The refresh timer */211 PTMTIMERR3 pBwRefreshTimer;212 210 } PDMACFILEBWMGR; 213 211 /** Pointer to a bandwidth control manager */ -
trunk/src/VBox/VMM/PDMAsyncCompletionFileNormal.cpp
r26672 r26689 1026 1026 pAioMgr->iFreeEntryNext = (pAioMgr->iFreeEntryNext + 1) % pAioMgr->cReqEntries; 1027 1027 1028 /* Free the lock and process pending tasks if neccessary */ 1029 pdmacFileAioMgrNormalRangeLockFree(pAioMgr, pEndpoint, pTask->pRangeLock); 1030 1028 1031 pAioMgr->cRequestsActive--; 1029 1032 pEndpoint->AioMgr.cRequestsActive--;
Note:
See TracChangeset
for help on using the changeset viewer.