VirtualBox

Changeset 48262 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Sep 4, 2013 12:01:35 PM (11 years ago)
Author:
vboxsync
Message:

VMM/HM: Preempt stats and minor optimizations to VT-x when thread-context hooks are used.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r48256 r48262  
    16271627
    16281628            VMMRZCallRing3Enable(pVCpu);                         /* Restore longjmp state. */
     1629            STAM_COUNTER_INC(&pVCpu->hm.s.StatPreemptPreempting);
    16291630            break;
    16301631        }
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r48256 r48262  
    70067006        case RTTHREADCTXEVENT_PREEMPTING:
    70077007        {
    7008             /** @todo Stats. */
    70097008            Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    70107009            Assert(VMMR0ThreadCtxHooksAreRegistered(pVCpu));
     
    70317030            /* Restore longjmp state. */
    70327031            VMMRZCallRing3Enable(pVCpu);
     7032            STAM_COUNTER_INC(&pVCpu->hm.s.StatPreemptPreempting);
    70337033            break;
    70347034        }
     
    70367036        case RTTHREADCTXEVENT_RESUMED:
    70377037        {
    7038             /** @todo Stats. */
    70397038            Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    70407039            Assert(VMMR0ThreadCtxHooksAreRegistered(pVCpu));
     
    70607059            }
    70617060            pVCpu->hm.s.fLeaveDone = false;
     7061
     7062            /* Restore longjmp state. */
    70627063            VMMRZCallRing3Enable(pVCpu);
    70637064            break;
     
    71197120    LogFlowFunc(("pVM=%p pVCpu=%p\n", pVM, pVCpu));
    71207121
    7121     /* When thread-context hooks are available, this is done later (when preemption/interrupts are disabled). */
    7122     if (!VMMR0ThreadCtxHooksAreRegistered(pVCpu))
    7123     {
    7124         Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    7125         return hmR0VmxSaveHostState(pVM, pVCpu);
    7126     }
    7127     return VINF_SUCCESS;
     7122    /* Save the host state here while entering HM context. When thread-context hooks are used, we might get preempted
     7123       and have to resave the host state but most of the time we won't be, so do it here before we disable interrupts. */
     7124    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     7125    return hmR0VmxSaveHostState(pVM, pVCpu);
    71287126}
    71297127
     
    74667464
    74677465    /*
    7468      * Load the host state bits as we may've been preempted (only happens when
    7469      * thread-context hooks are used).
    7470      */
    7471     if (pVCpu->hm.s.fContextUseFlags & HM_CHANGED_HOST_CONTEXT)
    7472     {
    7473         Assert(VMMR0ThreadCtxHooksAreRegistered(pVCpu));
    7474         int rc = hmR0VmxSaveHostState(pVM, pVCpu);
    7475         AssertRC(rc);
    7476     }
    7477     Assert(!(pVCpu->hm.s.fContextUseFlags & HM_CHANGED_HOST_CONTEXT));
    7478 
    7479     /*
    74807466     * If we are injecting events to a real-on-v86 mode guest, we may have to update
    74817467     * RIP and some other registers, i.e. hmR0VmxInjectPendingEvent()->hmR0VmxInjectEventVmcs().
     
    74897475    }
    74907476
    7491     /* Load the state shared between host and guest (FPU, debug). */
     7477    /*
     7478     * Load the host state bits as we may've been preempted (only happens when
     7479     * thread-context hooks are used).
     7480     */
     7481    if (pVCpu->hm.s.fContextUseFlags & HM_CHANGED_HOST_CONTEXT)
     7482    {
     7483        Assert(VMMR0ThreadCtxHooksAreRegistered(pVCpu));
     7484        int rc = hmR0VmxSaveHostState(pVM, pVCpu);
     7485        AssertRC(rc);
     7486        STAM_COUNTER_INC(&pVCpu->hm.s.StatPreemptSaveHostState);
     7487    }
     7488    Assert(!(pVCpu->hm.s.fContextUseFlags & HM_CHANGED_HOST_CONTEXT));
     7489
     7490    /*
     7491     * Load the state shared between host and guest (FPU, debug).
     7492     */
    74927493    if (pVCpu->hm.s.fContextUseFlags & HM_CHANGED_HOST_GUEST_SHARED_STATE)
    74937494        hmR0VmxLoadSharedState(pVM, pVCpu, pMixedCtx);
     
    75017502
    75027503    PHMGLOBALCPUINFO pCpu = HMR0GetCurrentCpu();
    7503     RTCPUID idCurrentCpu = pCpu->idCpu;
     7504    RTCPUID  idCurrentCpu = pCpu->idCpu;
    75047505    if (   pVmxTransient->fUpdateTscOffsettingAndPreemptTimer
    75057506        || idCurrentCpu != pVCpu->hm.s.idLastCpu)
     
    75117512    ASMAtomicWriteBool(&pVCpu->hm.s.fCheckedTLBFlush, true);    /* Used for TLB-shootdowns, set this across the world switch. */
    75127513    hmR0VmxFlushTaggedTlb(pVCpu, pCpu);                         /* Invalidate the appropriate guest entries from the TLB. */
    7513 
    75147514    Assert(idCurrentCpu == pVCpu->hm.s.idLastCpu);
    75157515    pVCpu->hm.s.vmx.LastError.idCurrentCpu = idCurrentCpu;      /* Update the error reporting info. with the current host CPU. */
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