VirtualBox

Changeset 77380 in vbox for trunk/src


Ignore:
Timestamp:
Feb 20, 2019 1:40:22 PM (6 years ago)
Author:
vboxsync
Message:

VMM: Further improvments on the IEM timer polling by making it fully configurable. Sideeffect is that EMSTATE_IEM_THEN_REM has now become more accurate and will execute fewer instructions (exactly 1024 rather than up to 1023+4096) before switching to REM.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r77378 r77380  
    1433714337
    1433814338
    14339 VMMDECL(VBOXSTRICTRC) IEMExecLots(PVMCPU pVCpu, uint32_t *pcInstructions)
     14339VMMDECL(VBOXSTRICTRC) IEMExecLots(PVMCPU pVCpu, uint32_t cMaxInstructions, uint32_t cPollRate, uint32_t *pcInstructions)
    1434014340{
    1434114341    uint32_t const cInstructionsAtStart = pVCpu->iem.s.cInstructions;
     14342    AssertMsg(RT_IS_POWER_OF_TWO(cPollRate + 1), ("%#x\n", cPollRate));
    1434214343
    1434314344    /*
     
    1438614387     * Initial decoder init w/ prefetch, then setup setjmp.
    1438714388     */
    14388     unsigned     cTimerPoll = 0;
    1438914389    VBOXSTRICTRC rcStrict = iemInitDecoderAndPrefetchOpcodes(pVCpu, false);
    1439014390    if (rcStrict == VINF_SUCCESS)
     
    1440114401             * The run loop.  We limit ourselves to 4096 instructions right now.
    1440214402             */
    14403             PVM         pVM    = pVCpu->CTX_SUFF(pVM);
    14404             uint32_t    cInstr = 4096;
     14403            PVM pVM = pVCpu->CTX_SUFF(pVM);
    1440514404            for (;;)
    1440614405            {
     
    1444214441                                      && !VM_FF_IS_ANY_SET(pVM, VM_FF_ALL_MASK) ))
    1444314442                        {
    14444                             if (cInstr-- > 0)
     14443                            if (cMaxInstructions-- > 0)
    1444514444                            {
    14446                                 /* Poll timers every 128 call*/
    14447                                 if (   (++cTimerPoll & 0x7f) != 0
     14445                                /* Poll timers every 2048 instructions. */
     14446                                if (   (cMaxInstructions & cPollRate) != 0
    1444814447                                    || !TMTimerPollBool(pVM, pVCpu))
    1444914448                                {
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r77159 r77380  
    12061206            rc = REMR3Run(pVM, pVCpu);
    12071207#else
    1208             rc = VBOXSTRICTRC_TODO(IEMExecLots(pVCpu, NULL /*pcInstructions*/));
     1208            rc = VBOXSTRICTRC_TODO(IEMExecLots(pVCpu, 8192 /*cMaxInstructions*/, 4095 /*cPollRate*/, NULL /*pcInstructions*/));
    12091209#endif
    12101210            STAM_PROFILE_STOP(&pVCpu->em.s.StatREMExec, c);
     
    13741374    {
    13751375        uint32_t     cInstructions;
    1376         VBOXSTRICTRC rcStrict = IEMExecLots(pVCpu, &cInstructions);
     1376        VBOXSTRICTRC rcStrict = IEMExecLots(pVCpu, 1024 - pVCpu->em.s.cIemThenRemInstructions /*cMaxInstructions*/,
     1377                                            UINT32_MAX/2 /*cPollRate*/, &cInstructions);
    13771378        pVCpu->em.s.cIemThenRemInstructions += cInstructions;
    13781379        if (rcStrict != VINF_SUCCESS)
     
    28942895                case EMSTATE_IEM:
    28952896                {
     2897                    uint32_t cInstructions = 0;
    28962898#if 0 /* For testing purposes. */
    28972899                    STAM_PROFILE_START(&pVCpu->em.s.StatHmExec, x1);
     
    29022904                    else if (rc == VERR_EM_CANNOT_EXEC_GUEST)
    29032905#endif
    2904                         rc = VBOXSTRICTRC_TODO(IEMExecLots(pVCpu, NULL /*pcInstructions*/));
     2906                        rc = VBOXSTRICTRC_TODO(IEMExecLots(pVCpu, 4096 /*cMaxInstructions*/, 2047 /*cPollRate*/, &cInstructions));
    29052907                    if (pVM->em.s.fIemExecutesAll)
    29062908                    {
     
    29082910                        Assert(rc != VINF_EM_RESCHEDULE_RAW);
    29092911                        Assert(rc != VINF_EM_RESCHEDULE_HM);
     2912#ifdef VBOX_HIGH_RES_TIMERS_HACK
     2913                        if (cInstructions < 2048)
     2914                            TMTimerPollVoid(pVM, pVCpu);
     2915#endif
    29102916                    }
    29112917                    fFFDone = false;
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