VirtualBox

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


Ignore:
Timestamp:
May 15, 2012 1:43:43 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77982
Message:

VMM/VMMR0: Remove superfluous fFlushTLB flag in HMGLOBLCPUINFO. Fixes some TLB flush statistics.

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

Legend:

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

    r40227 r41312  
    865865
    866866    pCpu->idCpu         = idCpu;
    867 
    868     /* Make sure we start with a clean TLB. */
    869     pCpu->fFlushTLB     = true;
    870 
    871867    pCpu->uCurrentASID  = 0;    /* we'll aways increment this the first time (host uses ASID 0) */
    872868    pCpu->cTLBFlushes   = 0;
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r41309 r41312  
    10141014
    10151015    pVCpu->hwaccm.s.idLastCpu = pCpu->idCpu;
    1016     pCpu->fFlushTLB = false;
    10171016    pVMCB->ctrl.TLBCtrl.n.u8TLBFlush = SVM_TLB_FLUSH_NOTHING;
    10181017
     
    11021101    if (pVMCB->ctrl.TLBCtrl.n.u8TLBFlush == SVM_TLB_FLUSH_NOTHING)
    11031102        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatNoFlushTLBWorldSwitch);
     1103    else if (   pVMCB->ctrl.TLBCtrl.n.u8TLBFlush == SVM_TLB_FLUSH_SINGLE_CONTEXT
     1104             || pVMCB->ctrl.TLBCtrl.n.u8TLBFlush == SVM_TLB_FLUSH_SINGLE_CONTEXT_RETAIN_GLOBALS)
     1105    {
     1106        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatFlushASID);
     1107    }
    11041108    else
    11051109        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatFlushTLBWorldSwitch);
     
    13321336            LogFlow(("Force TLB flush due to changed TLB flush count (%x vs %x)\n", pVCpu->hwaccm.s.cTLBFlushes, pCpu->cTLBFlushes));
    13331337    }
    1334     if (pCpu->fFlushTLB)
    1335         LogFlow(("Force TLB flush: first time cpu %d is used -> flush\n", pCpu->idCpu));
     1338    else if (VMCPU_FF_ISSET(pVCpu, VMCPU_FF_TLB_FLUSH))
     1339        LogFlow(("Manual TLB flush\n"));
    13361340#endif
    13371341
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r41281 r41312  
    233233#endif
    234234
    235     /* Allocate VMCBs for all guest CPUs. */
     235    /* Allocate VMCSs for all guest CPUs. */
    236236    for (VMCPUID i = 0; i < pVM->cCpus; i++)
    237237    {
     
    22052205
    22062206    pVCpu->hwaccm.s.idLastCpu = pCpu->idCpu;
    2207     pCpu->fFlushTLB           = false;
    2208 
    2209 #ifdef VBOX_WITH_STATISTICS
    2210     if (pVCpu->hwaccm.s.fForceTLBFlush)
    2211         STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatFlushTLBWorldSwitch);
    2212     else
    2213         STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatNoFlushTLBWorldSwitch);
    2214 #endif
    22152207
    22162208    if (pVCpu->hwaccm.s.fForceTLBFlush)
     
    22282220            pVCpu->hwaccm.s.uCurrentASID = pCpu->uCurrentASID;
    22292221            if (pCpu->fFlushASIDBeforeUse)
     2222            {
    22302223                hmR0VmxFlushVPID(pVM, pVCpu, pVM->hwaccm.s.vmx.enmFlushVPID, 0 /* GCPtr */);
     2224#ifdef VBOX_WITH_STATISTICS
     2225                STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatFlushASID);
     2226#endif
     2227            }
    22312228        }
    22322229        else
     
    22362233            else
    22372234                hmR0VmxFlushEPT(pVM, pVCpu, pVM->hwaccm.s.vmx.enmFlushEPT);
     2235
     2236#ifdef VBOX_WITH_STATISTICS
     2237            /*
     2238             * This is not terribly accurate (i.e. we don't have a StatFlushEPT counter so we currently count these
     2239             * as ASID flushes too, better than including them under StatFlushTLBWorldSwitch.
     2240             */
     2241            STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatFlushASID);
     2242#endif
    22382243        }
    22392244
     
    22642269                hmR0VmxFlushEPT(pVM, pVCpu, pVM->hwaccm.s.vmx.enmFlushEPT);
    22652270        }
     2271        else
     2272        {
     2273#ifdef VBOX_WITH_STATISTICS
     2274            STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatNoFlushTLBWorldSwitch);
     2275#endif
     2276        }
    22662277    }
    22672278    pVCpu->hwaccm.s.TlbShootdown.cPages = 0;
    22682279    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_TLB_SHOOTDOWN);
    22692280
    2270     Assert(pCpu->fFlushTLB == false);
    22712281    AssertMsg(pVCpu->hwaccm.s.cTLBFlushes == pCpu->cTLBFlushes,
    22722282              ("Flush count mismatch for cpu %d (%x vs %x)\n", pCpu->idCpu, pVCpu->hwaccm.s.cTLBFlushes, pCpu->cTLBFlushes));
     
    23072317        pVCpu->hwaccm.s.fForceTLBFlush = true;
    23082318    }
    2309     /* Disabled because this has triggered every time I have suspended my
    2310      * laptop with a VM running for the past three months or more.  */
    2311     // else
    2312     //     Assert(!pCpu->fFlushTLB);
    23132319
    23142320    /* Check for tlb shootdown flushes. */
     
    23172323
    23182324    pVCpu->hwaccm.s.idLastCpu = pCpu->idCpu;
    2319     pCpu->fFlushTLB           = false;
    23202325
    23212326    if (pVCpu->hwaccm.s.fForceTLBFlush)
    2322     {
    23232327        hmR0VmxFlushEPT(pVM, pVCpu, pVM->hwaccm.s.vmx.enmFlushEPT);
    2324     }
    23252328    else
    23262329    {
     
    23742377        pVCpu->hwaccm.s.fForceTLBFlush = true;
    23752378    }
    2376     else
    2377         Assert(!pCpu->fFlushTLB);
    23782379
    23792380    pVCpu->hwaccm.s.idLastCpu = pCpu->idCpu;
     
    23872388    {
    23882389        ++pCpu->uCurrentASID;
    2389         if (    pCpu->uCurrentASID >= pVM->hwaccm.s.uMaxASID
    2390             ||  pCpu->fFlushTLB)
    2391         {
    2392             pCpu->fFlushTLB                  = false;
     2390        if (pCpu->uCurrentASID >= pVM->hwaccm.s.uMaxASID)
     2391        {
    23932392            pCpu->uCurrentASID               = 1;       /* start at 1; host uses 0 */
    23942393            pCpu->cTLBFlushes++;
     
    24062405    else
    24072406    {
    2408         Assert(!pCpu->fFlushTLB);
    24092407        Assert(pVCpu->hwaccm.s.uCurrentASID && pCpu->uCurrentASID);
    24102408
     
    27572755                LogFlow(("Force TLB flush due to changed TLB flush count (%x vs %x)\n", pVCpu->hwaccm.s.cTLBFlushes, pCpu->cTLBFlushes));
    27582756        }
    2759         if (pCpu->fFlushTLB)
    2760             LogFlow(("Force TLB flush: first time cpu %d is used -> flush\n", pCpu->idCpu));
    2761         else if (pVCpu->hwaccm.s.fForceTLBFlush)
     2757        else if (VMCPU_FF_ISSET(pVCpu, VMCPU_FF_TLB_FLUSH))
    27622758            LogFlow(("Manual TLB flush\n"));
    27632759    }
  • trunk/src/VBox/VMM/include/HWACCMInternal.h

    r41205 r41312  
    168168    /** Whether to flush each new ASID/VPID before use. */
    169169    bool                fFlushASIDBeforeUse;
    170 
    171     /** Set the first time a cpu is used to make sure we start with a clean TLB. */
    172     bool                fFlushTLB;
    173170
    174171    /** Configured for VT-x or AMD-V. */
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