VirtualBox

Changeset 32953 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Oct 6, 2010 3:53:27 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66452
Message:

Finer grained cpu capping

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

Legend:

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

    r32952 r32953  
    5555#include <VBox/patm.h>
    5656#include "EMInternal.h"
     57#include "include/internal/em.h"
    5758#include <VBox/vm.h>
    5859#include <VBox/cpumdis.h>
     
    960961         * Execute REM.
    961962         */
    962         STAM_PROFILE_START(&pVCpu->em.s.StatREMExec, c);
    963         rc = REMR3Run(pVM, pVCpu);
    964         STAM_PROFILE_STOP(&pVCpu->em.s.StatREMExec, c);
    965 
     963        if (RT_LIKELY(EMR3IsExecutionAllowed(pVM, pVCpu)))
     964        {
     965            STAM_PROFILE_START(&pVCpu->em.s.StatREMExec, c);
     966            rc = REMR3Run(pVM, pVCpu);
     967            STAM_PROFILE_STOP(&pVCpu->em.s.StatREMExec, c);
     968        }
     969        else
     970        {
     971            /* Give up this time slice; virtual time continues */
     972            STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatCapped, u);
     973            RTThreadSleep(2);
     974            STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatCapped, u);
     975        }
    966976
    967977        /*
     
    16751685 *
    16761686 */
    1677 bool emR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu)
     1687VMMR3DECL(bool) EMR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu)
    16781688{
    16791689    uint64_t u64UserTime, u64KernelTime;
     
    20012011                 */
    20022012                case EMSTATE_RAW:
    2003                     if (emR3IsExecutionAllowed(pVM, pVCpu))
    2004                     {
    2005                         rc = emR3RawExecute(pVM, pVCpu, &fFFDone);
    2006                     }
    2007                     else
    2008                     {
    2009                         /* Give up this time slice; virtual time continues */
    2010                         STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatCapped, u);
    2011                         RTThreadSleep(10);
    2012                         STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatCapped, u);
    2013                         rc = VINF_SUCCESS;
    2014                     }
     2013                    rc = emR3RawExecute(pVM, pVCpu, &fFFDone);
    20152014                    break;
    20162015
     
    20192018                 */
    20202019                case EMSTATE_HWACC:
    2021                     if (emR3IsExecutionAllowed(pVM, pVCpu))
    2022                     {
    2023                         rc = emR3HwAccExecute(pVM, pVCpu, &fFFDone);
    2024                     }
    2025                     else
    2026                     {
    2027                         /* Give up this time slice; virtual time continues */
    2028                         STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatCapped, u);
    2029                         RTThreadSleep(10);
    2030                         STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatCapped, u);
    2031                         rc = VINF_SUCCESS;
    2032                     }
     2020                    rc = emR3HwAccExecute(pVM, pVCpu, &fFFDone);
    20332021                    break;
    20342022
     
    20372025                 */
    20382026                case EMSTATE_REM:
    2039                     if (emR3IsExecutionAllowed(pVM, pVCpu))
    2040                     {
    2041                         rc = emR3RemExecute(pVM, pVCpu, &fFFDone);
    2042                         Log2(("EMR3ExecuteVM: emR3RemExecute -> %Rrc\n", rc));
    2043                     }
    2044                     else
    2045                     {
    2046                         /* Give up this time slice; virtual time continues */
    2047                         STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatCapped, u);
    2048                         RTThreadSleep(10);
    2049                         STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatCapped, u);
    2050                         rc = VINF_SUCCESS;
    2051                     }
     2027                    rc = emR3RemExecute(pVM, pVCpu, &fFFDone);
     2028                    Log2(("EMR3ExecuteVM: emR3RemExecute -> %Rrc\n", rc));
    20522029                    break;
    20532030
  • trunk/src/VBox/VMM/EMHwaccm.cpp

    r29329 r32953  
    5353#include <VBox/hwaccm.h>
    5454#include "EMInternal.h"
     55#include "include/internal/em.h"
    5556#include <VBox/vm.h>
    5657#include <VBox/cpumdis.h>
     
    544545         */
    545546        STAM_PROFILE_ADV_STOP(&pVCpu->em.s.StatHwAccEntry, a);
    546         STAM_PROFILE_START(&pVCpu->em.s.StatHwAccExec, x);
    547         rc = VMMR3HwAccRunGC(pVM, pVCpu);
    548         STAM_PROFILE_STOP(&pVCpu->em.s.StatHwAccExec, x);
     547
     548        if (RT_LIKELY(EMR3IsExecutionAllowed(pVM, pVCpu)))
     549        {
     550            STAM_PROFILE_START(&pVCpu->em.s.StatHwAccExec, x);
     551            rc = VMMR3HwAccRunGC(pVM, pVCpu);
     552            STAM_PROFILE_STOP(&pVCpu->em.s.StatHwAccExec, x);
     553        }
     554        else
     555        {
     556            /* Give up this time slice; virtual time continues */
     557            STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatCapped, u);
     558            RTThreadSleep(2);
     559            STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatCapped, u);
     560        }
     561       
    549562
    550563        /*
  • trunk/src/VBox/VMM/EMRaw.cpp

    r31636 r32953  
    5454#include <VBox/patm.h>
    5555#include "EMInternal.h"
     56#include "include/internal/em.h"
    5657#include <VBox/vm.h>
    5758#include <VBox/cpumdis.h>
     
    15281529         */
    15291530        STAM_PROFILE_ADV_STOP(&pVCpu->em.s.StatRAWEntry, b);
    1530         STAM_PROFILE_START(&pVCpu->em.s.StatRAWExec, c);
    1531         rc = VMMR3RawRunGC(pVM, pVCpu);
    1532         STAM_PROFILE_STOP(&pVCpu->em.s.StatRAWExec, c);
     1531        if (RT_LIKELY(EMR3IsExecutionAllowed(pVM, pVCpu)))
     1532        {
     1533            STAM_PROFILE_START(&pVCpu->em.s.StatRAWExec, c);
     1534            rc = VMMR3RawRunGC(pVM, pVCpu);
     1535            STAM_PROFILE_STOP(&pVCpu->em.s.StatRAWExec, c);
     1536        }
     1537        else
     1538        {
     1539            /* Give up this time slice; virtual time continues */
     1540            STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatCapped, u);
     1541            RTThreadSleep(2);
     1542            STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatCapped, u);
     1543        }
    15331544        STAM_PROFILE_ADV_START(&pVCpu->em.s.StatRAWTail, d);
    15341545
  • trunk/src/VBox/VMM/include/internal/em.h

    r32912 r32953  
    2424VMMR3DECL(int)  EMR3NotifySuspend(PVM pVM);
    2525
     26VMMR3DECL(bool) EMR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu);
     27
    2628#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette