VirtualBox

Changeset 30590 in vbox


Ignore:
Timestamp:
Jul 2, 2010 6:21:50 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63315
Message:

HWVMXR0.cpp,HWSVMR0.cpp: Realigned and simplified the profiling.

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

Legend:

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

    r30263 r30590  
    956956VMMR0DECL(int) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    957957{
     958    STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatEntry, x);
     959    STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hwaccm.s.StatExit1);
     960    STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hwaccm.s.StatExit2);
     961
    958962    int         rc = VINF_SUCCESS;
    959963    uint64_t    exitCode = (uint64_t)SVM_EXIT_INVALID;
     
    971975#endif
    972976
    973     STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatEntry, x);
    974 
    975977    pVMCB = (SVM_VMCB *)pVCpu->hwaccm.s.svm.pVMCB;
    976978    AssertMsgReturn(pVMCB, ("Invalid pVMCB\n"), VERR_EM_INTERNAL_ERROR);
     
    979981     */
    980982ResumeExecution:
     983    if (!STAM_PROFILE_ADV_IS_RUNNING(&pVCpu->hwaccm.s.StatEntry))
     984        STAM_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatExit2, &pVCpu->hwaccm.s.StatEntry, x);
    981985    Assert(!HWACCMR0SuspendPending());
    982986
     
    10501054                VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_TO_R3);
    10511055                STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatSwitchToR3);
    1052                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    10531056                rc = RT_UNLIKELY(VM_FF_ISPENDING(pVM, VM_FF_PGM_NO_MEMORY)) ? VINF_EM_NO_MEMORY : VINF_EM_RAW_TO_R3;
    10541057                goto end;
     
    10601063            ||  VMCPU_FF_ISPENDING(pVCpu, VMCPU_FF_REQUEST))
    10611064        {
    1062             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    10631065            rc = VINF_EM_PENDING_REQUEST;
    10641066            goto end;
     
    10681070        if (VM_FF_ISPENDING(pVM, VM_FF_PGM_POOL_FLUSH_PENDING))
    10691071        {
    1070             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    10711072            rc = VINF_PGM_POOL_FLUSH_PENDING;
    10721073            goto end;
     
    10991100    rc = SVMR0CheckPendingInterrupt(pVM, pVCpu, pVMCB, pCtx);
    11001101    if (RT_FAILURE(rc))
    1101     {
    1102         STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    11031102        goto end;
    1104     }
    11051103
    11061104    /* TPR caching using CR8 is only available in 64 bits mode or with 32 bits guests when X86_CPUID_AMD_FEATURE_ECX_CR8L is supported. */
     
    11511149
    11521150    /* All done! Let's start VM execution. */
    1153     STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatInGC, x);
    11541151
    11551152    /* Enable nested paging if necessary (disabled each time after #VMEXIT). */
     
    11831180    if (RT_UNLIKELY(rc != VINF_SUCCESS))
    11841181    {
    1185         STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    11861182        VMMR0LogFlushEnable(pVCpu);
    11871183        goto end;
     
    11951191    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC);
    11961192#endif
     1193    STAM_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatEntry, &pVCpu->hwaccm.s.StatInGC, x);
    11971194
    11981195    pCpu = HWACCMR0GetCurrentCpu();
     
    12971294    TMNotifyEndOfExecution(pVCpu);
    12981295    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
     1296    STAM_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatInGC, &pVCpu->hwaccm.s.StatExit1, x);
    12991297    ASMSetFlags(uOldEFlags);
    13001298#ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
    13011299    uOldEFlags = ~(RTCCUINTREG)0;
    13021300#endif
    1303     STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatInGC, x);
    13041301
    13051302    /*
     
    13081305     * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    13091306     */
    1310 
    1311     STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatExit1, x);
    13121307
    13131308    /* Reason for the VM exit */
     
    15821577    }
    15831578
     1579    STAM_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatExit1, &pVCpu->hwaccm.s.StatExit2, x);
     1580
    15841581    /* Deal with the reason of the VM-exit. */
    15851582    switch (exitCode)
     
    16201617
    16211618                SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    1622 
    1623                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    16241619                goto ResumeExecution;
    16251620            }
     
    16421637
    16431638                /* Continue execution. */
    1644                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    16451639                pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0;
    16461640
     
    16571651
    16581652            SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    1659             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    16601653            goto ResumeExecution;
    16611654        }
     
    16851678
    16861679                SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    1687 
    1688                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    16891680                goto ResumeExecution;
    16901681            }
     
    17351726
    17361727                TRPMResetTrap(pVCpu);
    1737                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    17381728                goto ResumeExecution;
    17391729            }
     
    17611751
    17621752                SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    1763 
    1764                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    17651753                goto ResumeExecution;
    17661754            }
     
    17921780
    17931781            SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    1794 
    1795             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    17961782            goto ResumeExecution;
    17971783        }
     
    18381824            Log(("Trap %x at %04x:%RGv esi=%x\n", vector, pCtx->cs, (RTGCPTR)pCtx->rip, pCtx->esi));
    18391825            SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    1840 
    1841             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    18421826            goto ResumeExecution;
    18431827        }
     
    19091893
    19101894            TRPMResetTrap(pVCpu);
    1911 
    1912             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    19131895            goto ResumeExecution;
    19141896        }
     
    19451927        pCtx->rip += 2;     /* Note! hardcoded opcode size! */
    19461928        /* Continue execution.*/
    1947         STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    19481929        goto ResumeExecution;
    19491930
     
    19571938            /* Update EIP and continue execution. */
    19581939            pCtx->rip += 2;             /* Note! hardcoded opcode size! */
    1959             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    19601940            goto ResumeExecution;
    19611941        }
     
    19741954            /* Update EIP and continue execution. */
    19751955            pCtx->rip += 2;             /* Note! hardcoded opcode size! */
    1976             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    19771956            goto ResumeExecution;
    19781957        }
     
    20051984            /* Update EIP and continue execution. */
    20061985            pCtx->rip += 3;             /* Note! hardcoded opcode size! */
    2007             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    20081986            goto ResumeExecution;
    20091987        }
     
    20652043
    20662044            /* Only resume if successful. */
    2067             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    20682045            goto ResumeExecution;
    20692046        }
     
    20872064
    20882065            /* Only resume if successful. */
    2089             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    20902066            goto ResumeExecution;
    20912067        }
     
    21162092            rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, false /* exclude DR6 */);
    21172093            AssertRC(rc);
    2118 
    2119             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    21202094            goto ResumeExecution;
    21212095        }
     
    21282102
    21292103            /* Only resume if successful. */
    2130             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    21312104            goto ResumeExecution;
    21322105        }
     
    21562129            rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, false /* exclude DR6 */);
    21572130            AssertRC(rc);
    2158 
    2159             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    21602131            goto ResumeExecution;
    21612132        }
     
    21672138
    21682139            /* Only resume if successful. */
    2169             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    21702140            goto ResumeExecution;
    21712141        }
     
    23202290
    23212291                            SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    2322 
    2323                             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    23242292                            goto ResumeExecution;
    23252293                        }
    23262294                    }
    23272295                }
    2328 
    2329                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    23302296                goto ResumeExecution;
    23312297            }
     
    24202386        Log(("Forced #UD trap at %RGv\n", (RTGCPTR)pCtx->rip));
    24212387        SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    2422 
    2423         STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    24242388        goto ResumeExecution;
    24252389    }
     
    24482412
    24492413            /* Only resume if successful. */
    2450             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    24512414            goto ResumeExecution;
    24522415        }
     
    24612424
    24622425            /* Only resume if successful. */
    2463             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    24642426            goto ResumeExecution;
    24652427        }
     
    25562518#endif
    25572519
     2520    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2, x);
    25582521    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     2522    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    25592523    return rc;
    25602524}
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r30390 r30590  
    15851585
    15861586        /* When the guest's FPU state is active, then we no longer care about
    1587          * the FPU related bits. 
     1587         * the FPU related bits.
    15881588         */
    15891589        if (CPUMIsGuestFPUStateActive(pVCpu) == false)
     
    22392239VMMR0DECL(int) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    22402240{
     2241    STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatEntry, x);
     2242    STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hwaccm.s.StatExit1);
     2243    STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hwaccm.s.StatExit2);
     2244
    22412245    int         rc = VINF_SUCCESS;
    22422246    RTGCUINTREG val;
     
    22582262    uint64_t    u64LastTime = RTTimeMilliTS();
    22592263#endif
    2260 #ifdef VBOX_WITH_STATISTICS
    2261     bool fStatEntryStarted = true;
    2262     bool fStatExit2Started = false;
    2263 #endif
    22642264
    22652265    Assert(!(pVM->hwaccm.s.vmx.msr.vmx_proc_ctls2.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC2_VIRT_APIC) || (pVCpu->hwaccm.s.vmx.pVAPIC && pVM->hwaccm.s.vmx.pAPIC));
     
    22762276    Log2(("\nE"));
    22772277
    2278     STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatEntry, x);
    2279 
    22802278#ifdef VBOX_STRICT
    22812279    {
     
    23462344     */
    23472345ResumeExecution:
    2348     STAM_STATS({
    2349         if (fStatExit2Started)   { STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2, y); fStatExit2Started = false; }
    2350         if (!fStatEntryStarted) { STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatEntry, x); fStatEntryStarted = true; }
    2351     });
     2346    if (!STAM_REL_PROFILE_ADV_IS_RUNNING(&pVCpu->hwaccm.s.StatEntry))
     2347        STAM_REL_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatExit2, &pVCpu->hwaccm.s.StatEntry, x);
    23522348    AssertMsg(pVCpu->hwaccm.s.idEnteredCpu == RTMpCpuId(),
    23532349              ("Expected %d, I'm %d; cResume=%d exitReason=%RGv exitQualification=%RGv\n",
     
    24282424                VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_TO_R3);
    24292425                STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatSwitchToR3);
    2430                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    24312426                rc = RT_UNLIKELY(VM_FF_ISPENDING(pVM, VM_FF_PGM_NO_MEMORY)) ? VINF_EM_NO_MEMORY : VINF_EM_RAW_TO_R3;
    24322427                goto end;
     
    24382433            ||  VMCPU_FF_ISPENDING(pVCpu, VMCPU_FF_REQUEST))
    24392434        {
    2440             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    24412435            rc = VINF_EM_PENDING_REQUEST;
    24422436            goto end;
     
    24462440        if (VM_FF_ISPENDING(pVM, VM_FF_PGM_POOL_FLUSH_PENDING))
    24472441        {
    2448             STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    24492442            rc = VINF_PGM_POOL_FLUSH_PENDING;
    24502443            goto end;
     
    25992592    pVM->hwaccm.s.vmx.pfnSetupTaggedTLB(pVM, pVCpu);
    26002593
    2601     STAM_STATS({ STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x); fStatEntryStarted = false; });
    2602 
    26032594    /* Manual save and restore:
    26042595     * - General purpose registers except RIP, RSP
     
    26142605
    26152606    /* All done! Let's start VM execution. */
    2616     STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatInGC, z);
     2607    STAM_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatEntry, &pVCpu->hwaccm.s.StatInGC, x);
    26172608    Assert(idCpuCheck == RTMpCpuId());
    26182609
     
    26542645    }
    26552646
     2647    STAM_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatInGC, &pVCpu->hwaccm.s.StatExit1, x);
    26562648    ASMSetFlags(uOldEFlags);
    26572649#ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
     
    26702662     * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    26712663     */
    2672     STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatInGC, z);
    26732664
    26742665    if (RT_UNLIKELY(rc != VINF_SUCCESS))
     
    26792670    }
    26802671
    2681     STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatExit1, v);
    26822672    /* Success. Query the guest state and figure out what has happened. */
    26832673
     
    27572747    }
    27582748
    2759     STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, v);
    2760     STAM_STATS({ STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatExit2, y); fStatExit2Started = true; });
     2749    STAM_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatExit1, &pVCpu->hwaccm.s.StatExit2, x);
    27612750
    27622751    /* Some cases don't need a complete resync of the guest CPU state; handle them here. */
     
    27742763            if (    RTThreadPreemptIsPendingTrusty()
    27752764                &&  !RTThreadPreemptIsPending(NIL_RTTHREAD))
    2776             {
    2777                     STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2Sub3, y3);
    2778                     goto ResumeExecution;
    2779             }
     2765                goto ResumeExecution;
    27802766#endif
    27812767            /* External interrupt; leave to allow it to be dispatched again. */
     
    30323018                    rc = VMXR0InjectEvent(pVM, pVCpu, pCtx, VMX_VMCS_CTRL_ENTRY_IRQ_INFO_FROM_EXIT_INT_INFO(intInfo), cbInstr, errCode);
    30333019                    AssertRC(rc);
     3020                    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2Sub3, y3);
    30343021                    goto ResumeExecution;
    30353022                }
    30363023                if (rc == VINF_SUCCESS)
     3024                {
     3025                    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2Sub3, y3);
    30373026                    goto ResumeExecution;
     3027                }
    30383028                Log(("Debugger BP at %04x:%RGv (rc=%Rrc)\n", pCtx->cs, pCtx->rip, rc));
    30393029                break;
     
    38913881        LogFlow(("VMX_EXIT_TPR\n"));
    38923882        /* RIP is already set to the next instruction and the TPR has been synced back. Just resume. */
    3893         STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2Sub1, y1);
    38943883        goto ResumeExecution;
    38953884
     
    39123901            rc = VBOXSTRICTRC_TODO(IOMMMIOPhysHandler(pVM, (uAccessType == VMX_APIC_ACCESS_TYPE_LINEAR_READ) ? 0 : X86_TRAP_PF_RW, CPUMCTX2CORE(pCtx), GCPhys));
    39133902            if (rc == VINF_SUCCESS)
    3914             {
    3915                 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2Sub1, y1);
    39163903                goto ResumeExecution;   /* rip already updated */
    3917             }
    39183904            break;
    39193905        }
     
    39273913
    39283914    case VMX_EXIT_PREEMPTION_TIMER:     /* 52 VMX-preemption timer expired. The preemption timer counted down to zero. */
    3929         STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2Sub1, y1);
    39303915        goto ResumeExecution;
    39313916
     
    41554140#endif
    41564141
    4157     STAM_STATS({
    4158         if (fStatExit2Started)      STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2, y);
    4159         else if (fStatEntryStarted) STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    4160     });
     4142    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2, x);
     4143    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     4144    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatEntry, x);
    41614145    Log2(("X"));
    41624146    return rc;
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