Changeset 32912 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Oct 5, 2010 1:04:39 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 66395
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/EM.cpp
r32173 r32912 64 64 #include <iprt/string.h> 65 65 #include <iprt/stream.h> 66 #include <iprt/thread.h> 66 67 67 68 … … 144 145 pVCpu->em.s.pPatmGCState = PATMR3QueryGCStateHC(pVM); 145 146 AssertMsg(pVCpu->em.s.pPatmGCState, ("PATMR3QueryGCStateHC failed!\n")); 147 148 /* Force reset of the time slice. */ 149 pVCpu->em.s.u64TimeSliceStart = 0; 146 150 147 151 # define EM_REG_COUNTER(a, b, c) \ … … 388 392 EM_REG_COUNTER(&pVCpu->em.s.StatForcedActions, "/PROF/CPU%d/EM/ForcedActions", "Profiling forced action execution."); 389 393 EM_REG_COUNTER(&pVCpu->em.s.StatHalted, "/PROF/CPU%d/EM/Halted", "Profiling halted state (VMR3WaitHalted)."); 394 EM_REG_COUNTER(&pVCpu->em.s.StatCapped, "/PROF/CPU%d/EM/Capped", "Profiling capped state (sleep)."); 390 395 EM_REG_COUNTER(&pVCpu->em.s.StatREMTotal, "/PROF/CPU%d/EM/REMTotal", "Profiling emR3RemExecute (excluding FFs)."); 391 396 EM_REG_COUNTER(&pVCpu->em.s.StatRAWTotal, "/PROF/CPU%d/EM/RAWTotal", "Profiling emR3RawExecute (excluding FFs)."); … … 1659 1664 Assert(rcIrq == VINF_SUCCESS || rcIrq == rc); 1660 1665 return rc; 1666 } 1667 1668 1669 /** 1670 * Check if the preset execution time cap restricts guest execution scheduling. 1671 * 1672 * @returns true if allowed, false otherwise 1673 * @param pVM The VM to operate on. 1674 * @param pVCpu The VMCPU to operate on. 1675 * 1676 */ 1677 bool emR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu) 1678 { 1679 uint64_t u64UserTime, u64KernelTime; 1680 1681 if ( pVM->uCpuExecutionCap != 100 1682 && RT_SUCCESS(RTThreadGetExecutionTimeMilli(RTThreadSelf(), &u64KernelTime, &u64UserTime))) 1683 { 1684 uint64_t u64TimeNow = RTTimeMilliTS(); 1685 if (pVCpu->em.s.u64TimeSliceStart + EM_TIME_SLICE < u64TimeNow) 1686 { 1687 /* New time slice. */ 1688 pVCpu->em.s.u64TimeSliceStart = u64TimeNow; 1689 pVCpu->em.s.u64TimeSliceStartExec = u64KernelTime + u64UserTime; 1690 pVCpu->em.s.u64TimeSliceExec = 0; 1691 } 1692 pVCpu->em.s.u64TimeSliceExec = u64KernelTime + u64UserTime - pVCpu->em.s.u64TimeSliceStartExec; 1693 1694 if (pVCpu->em.s.u64TimeSliceExec >= (EM_TIME_SLICE * 100) / pVM->uCpuExecutionCap) 1695 return false; 1696 } 1697 return true; 1661 1698 } 1662 1699 … … 1963 2000 */ 1964 2001 case EMSTATE_RAW: 1965 rc = emR3RawExecute(pVM, pVCpu, &fFFDone); 2002 if (emR3IsExecutionAllowed(pVM, pVCpu)) 2003 { 2004 rc = emR3RawExecute(pVM, pVCpu, &fFFDone); 2005 } 2006 else 2007 { 2008 /* Give up this time slice; virtual time continues */ 2009 STAM_REL_PROFILE_START(&pVCpu->em.s.StatCapped, u); 2010 RTThreadSleep(2); 2011 STAM_REL_PROFILE_STOP(&pVCpu->em.s.StatCapped, u); 2012 rc = VINF_SUCCESS; 2013 } 1966 2014 break; 1967 2015 … … 1970 2018 */ 1971 2019 case EMSTATE_HWACC: 1972 rc = emR3HwAccExecute(pVM, pVCpu, &fFFDone); 2020 if (emR3IsExecutionAllowed(pVM, pVCpu)) 2021 { 2022 rc = emR3HwAccExecute(pVM, pVCpu, &fFFDone); 2023 } 2024 else 2025 { 2026 /* Give up this time slice; virtual time continues */ 2027 STAM_REL_PROFILE_START(&pVCpu->em.s.StatCapped, u); 2028 RTThreadSleep(2); 2029 STAM_REL_PROFILE_STOP(&pVCpu->em.s.StatCapped, u); 2030 rc = VINF_SUCCESS; 2031 } 1973 2032 break; 1974 2033 … … 1977 2036 */ 1978 2037 case EMSTATE_REM: 1979 rc = emR3RemExecute(pVM, pVCpu, &fFFDone); 1980 Log2(("EMR3ExecuteVM: emR3RemExecute -> %Rrc\n", rc)); 2038 if (emR3IsExecutionAllowed(pVM, pVCpu)) 2039 { 2040 rc = emR3RemExecute(pVM, pVCpu, &fFFDone); 2041 Log2(("EMR3ExecuteVM: emR3RemExecute -> %Rrc\n", rc)); 2042 } 2043 else 2044 { 2045 /* Give up this time slice; virtual time continues */ 2046 STAM_REL_PROFILE_START(&pVCpu->em.s.StatCapped, u); 2047 RTThreadSleep(2); 2048 STAM_REL_PROFILE_STOP(&pVCpu->em.s.StatCapped, u); 2049 rc = VINF_SUCCESS; 2050 } 1981 2051 break; 1982 2052 -
trunk/src/VBox/VMM/EMInternal.h
r28800 r32912 54 54 #define EMMWAIT_FLAG_MONITOR_ACTIVE RT_BIT(2) 55 55 56 /** EM time slice in ms; used for capping execution time. */ 57 #define EM_TIME_SLICE 1000 56 58 57 59 /** … … 352 354 #endif 353 355 356 /** Start of the current time slice in ms. */ 357 uint64_t u64TimeSliceStart; 358 /** Start of the current time slice in thread execution time (ms). */ 359 uint64_t u64TimeSliceStartExec; 360 /** Current time slice value. */ 361 uint64_t u64TimeSliceExec; 362 uint64_t u64Alignment; 363 354 364 /* MWait halt state. */ 355 365 struct … … 391 401 STAMPROFILE StatForcedActions; 392 402 STAMPROFILE StatHalted; 403 STAMPROFILE StatCapped; 393 404 STAMPROFILEADV StatHwAccEntry; 394 405 STAMPROFILE StatHwAccExec; -
trunk/src/VBox/VMM/include/internal/em.h
r32171 r32912 21 21 #include <VBox/em.h> 22 22 23 VMMR3DECL(int) EMR3NotifyResume(PVM pVM);24 VMMR3DECL(int) EMR3NotifySuspend(PVM pVM);23 VMMR3DECL(int) EMR3NotifyResume(PVM pVM); 24 VMMR3DECL(int) EMR3NotifySuspend(PVM pVM); 25 25 26 26 #endif
Note:
See TracChangeset
for help on using the changeset viewer.