Changeset 2965 in vbox
- Timestamp:
- May 31, 2007 5:22:32 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 21673
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMEmt.cpp
r2830 r2965 363 363 364 364 /** 365 * Method 1 - Block whenever possible, and when lagging behind 365 * Method 1 - Block whenever possible, and when lagging behind 366 366 * switch to spinning for 10-30ms with occational blocking until 367 367 * the lag has been eliminated. … … 377 377 bool fBlockOnce = false; 378 378 bool fSpinning = false; 379 if (TMVirtualSyncGetCatchUpPct(pVM) /* non-zero if catching up */) 380 { 381 const uint64_t u64Lag = TMVirtualSyncGetLag(pVM); 382 fSpinning = u64Lag > 25000000 /* 25ms */; 383 if (fSpinning) 384 { 385 if (!pVM->vm.s.Halt.Method12.u64StartSpinTS) 379 uint32_t u32CatchUpPct = TMVirtualSyncGetCatchUpPct(pVM); 380 if (u32CatchUpPct /* non-zero if catching up */) 381 { 382 if (pVM->vm.s.Halt.Method12.u64StartSpinTS) 383 { 384 fSpinning = TMVirtualSyncGetLag(pVM) >= 2*1000000; 385 if (fSpinning) 386 { 387 uint64_t u64Lag = TMVirtualSyncGetLag(pVM); 388 fBlockOnce = u64Now - pVM->vm.s.Halt.Method12.u64LastBlockTS 389 > RT_MAX(5*1000000, RT_MIN(u64Lag / 4, 200*1000000)); 390 } 391 else 392 { 393 RTLogRelPrintf("Stopped spinning (%u ms)\n", (u64Now - pVM->vm.s.Halt.Method12.u64StartSpinTS) / 1000000); 394 pVM->vm.s.Halt.Method12.u64StartSpinTS = 0; 395 } 396 } 397 else 398 { 399 fSpinning = TMVirtualSyncGetLag(pVM) >= 20*1000000; 400 if (fSpinning) 386 401 pVM->vm.s.Halt.Method12.u64StartSpinTS = u64Now; 387 else if (u64Now - pVM->vm.s.Halt.Method12.u64LastBlockTS > 32000000 /* 32ms */) 388 fBlockOnce = true; 389 } 390 else if (pVM->vm.s.Halt.Method12.u64StartSpinTS) 391 pVM->vm.s.Halt.Method12.u64StartSpinTS = 0; 402 } 392 403 } 393 404 else if (pVM->vm.s.Halt.Method12.u64StartSpinTS) 405 { 406 RTLogRelPrintf("Stopped spinning (%u ms)\n", (u64Now - pVM->vm.s.Halt.Method12.u64StartSpinTS) / 1000000); 394 407 pVM->vm.s.Halt.Method12.u64StartSpinTS = 0; 408 } 395 409 396 410 /* … … 403 417 { 404 418 /* 405 * Work the timers and check if we can exit. 419 * Work the timers and check if we can exit. 406 420 */ 407 421 STAM_REL_PROFILE_START(&pVM->vm.s.StatHaltPoll, a); … … 424 438 * Block if we're not spinning and the interval isn't all that small. 425 439 */ 426 if ( ( !fSpinning 440 if ( ( !fSpinning 427 441 || fBlockOnce) 428 442 && u64NanoTS >= 250000) /* 0.250 ms */ … … 434 448 if (cMilliSecs <= pVM->vm.s.Halt.Method12.cNSBlockedTooLongAvg) 435 449 cMilliSecs = 1; 436 else 450 else 437 451 cMilliSecs -= pVM->vm.s.Halt.Method12.cNSBlockedTooLongAvg; 438 //RTLogRelPrintf("u64NanoTS=%RI64 cLoops=%3d sleep %02dms (%7RU64) ", u64NanoTS, cLoops, cMilliSecs, u64NanoTS);452 RTLogRelPrintf("u64NanoTS=%RI64 cLoops=%3d sleep %02dms (%7RU64) ", u64NanoTS, cLoops, cMilliSecs, u64NanoTS); 439 453 STAM_REL_PROFILE_START(&pVM->vm.s.StatHaltBlock, a); 440 454 rc = RTSemEventWait(pVM->vm.s.EventSemWait, cMilliSecs); … … 451 465 } 452 466 453 /* 454 * Calc the statistics. 467 /* 468 * Calc the statistics. 455 469 * Update averages every 16th time, and flush parts of the history every 64th time. 456 470 */ … … 469 483 } 470 484 } 471 //RTLogRelPrintf(" -> %7RU64 ns / %7RI64 ns delta%s\n", Elapsed, Elapsed - u64NanoTS, fBlockOnce ? " (block once)" : "");485 RTLogRelPrintf(" -> %7RU64 ns / %7RI64 ns delta%s\n", Elapsed, Elapsed - u64NanoTS, fBlockOnce ? " (block once)" : ""); 472 486 473 487 /* … … 479 493 } 480 494 } 495 if (fSpinning) RTLogRelPrintf("spun for %RU64 ns %u loops; lag=%RU64 pct=%d\n", RTTimeNanoTS() - u64Now, cLoops, TMVirtualSyncGetLag(pVM), u32CatchUpPct); 481 496 482 497 return rc; … … 546 561 #else 547 562 # error "misconfigured halt" 548 #endif 563 #endif 549 564 550 565 /*
Note:
See TracChangeset
for help on using the changeset viewer.