VirtualBox

Changeset 104281 in vbox


Ignore:
Timestamp:
Apr 10, 2024 5:21:10 PM (10 months ago)
Author:
vboxsync
Message:

VMM/IEM: Gather statistics on the exit behavior of native TBs, bugref:10653

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

Legend:

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

    r104211 r104281  
    36833683
    36843684#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
    3685 # ifdef LOG_ENABLED
     3685# if defined(LOG_ENABLED) || defined(IEMNATIVE_WITH_TB_DEBUG_INFO)
    36863686/** Host CPU SIMD register names. */
    36873687DECL_HIDDEN_CONST(const char * const) g_apszIemNativeHstSimdRegNames[] =
     
    62096209        iemNativeLabelDefine(pReNative, idxLabel, off);
    62106210
     6211#ifdef VBOX_WITH_STATISTICS
     6212        uint8_t const idxStatsTmp1 = iemNativeRegAllocTmp(pReNative, &off);
     6213        uint8_t const idxStatsTmp2 = iemNativeRegAllocTmp(pReNative, &off);
     6214        off = iemNativeEmitIncStamCounterInVCpu(pReNative, off, idxStatsTmp1, idxStatsTmp2,
     6215                                                RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitReturnWithFlags));
     6216        iemNativeRegFreeTmp(pReNative, idxStatsTmp1);
     6217        iemNativeRegFreeTmp(pReNative, idxStatsTmp2);
     6218#endif
     6219
    62116220        off = iemNativeEmitLoadGprImm64(pReNative, off, IEMNATIVE_CALL_RET_GREG, VINF_IEM_REEXEC_FINISH_WITH_FLAGS);
    62126221
     
    62276236    {
    62286237        iemNativeLabelDefine(pReNative, idxLabel, off);
     6238
     6239#ifdef VBOX_WITH_STATISTICS
     6240        uint8_t const idxStatsTmp1 = iemNativeRegAllocTmp(pReNative, &off);
     6241        uint8_t const idxStatsTmp2 = iemNativeRegAllocTmp(pReNative, &off);
     6242        off = iemNativeEmitIncStamCounterInVCpu(pReNative, off, idxStatsTmp1, idxStatsTmp2,
     6243                                                RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitReturnBreak));
     6244        iemNativeRegFreeTmp(pReNative, idxStatsTmp1);
     6245        iemNativeRegFreeTmp(pReNative, idxStatsTmp2);
     6246#endif
    62296247
    62306248        off = iemNativeEmitLoadGprImm64(pReNative, off, IEMNATIVE_CALL_RET_GREG, VINF_IEM_REEXEC_BREAK);
     
    92149232            STAM_REL_COUNTER_INC(&pVCpu->iem.s.StatNativeFullyRecompiledTbs);
    92159233
     9234#ifdef VBOX_WITH_STATISTICS
     9235        uint8_t const idxStatsTmp1 = iemNativeRegAllocTmp(pReNative, &off);
     9236        uint8_t const idxStatsTmp2 = iemNativeRegAllocTmp(pReNative, &off);
     9237        off = iemNativeEmitIncStamCounterInVCpu(pReNative, off, idxStatsTmp1, idxStatsTmp2,
     9238                                                RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbFinished));
     9239        iemNativeRegFreeTmp(pReNative, idxStatsTmp1);
     9240        iemNativeRegFreeTmp(pReNative, idxStatsTmp2);
     9241#endif
     9242
    92169243        /*
    92179244         * Emit the epilog code.
     
    92399266        {
    92409267            IEMNATIVELABELTYPE              enmLabel;
     9268            uint32_t                        offVCpuStats;
    92419269            PFNIEMNATIVESIMPLETAILLABELCALL pfnCallback;
    92429270        } const g_aSimpleTailLabels[] =
    92439271        {
    9244             {   kIemNativeLabelType_Invalid,                NULL },
    9245             {   kIemNativeLabelType_RaiseDe,                iemNativeHlpExecRaiseDe },
    9246             {   kIemNativeLabelType_RaiseUd,                iemNativeHlpExecRaiseUd },
    9247             {   kIemNativeLabelType_RaiseSseRelated,        iemNativeHlpExecRaiseSseRelated },
    9248             {   kIemNativeLabelType_RaiseAvxRelated,        iemNativeHlpExecRaiseAvxRelated },
    9249             {   kIemNativeLabelType_RaiseSseAvxFpRelated,   iemNativeHlpExecRaiseSseAvxFpRelated },
    9250             {   kIemNativeLabelType_RaiseNm,                iemNativeHlpExecRaiseNm },
    9251             {   kIemNativeLabelType_RaiseGp0,               iemNativeHlpExecRaiseGp0 },
    9252             {   kIemNativeLabelType_RaiseMf,                iemNativeHlpExecRaiseMf },
    9253             {   kIemNativeLabelType_RaiseXf,                iemNativeHlpExecRaiseXf },
    9254             {   kIemNativeLabelType_ObsoleteTb,             iemNativeHlpObsoleteTb },
    9255             {   kIemNativeLabelType_NeedCsLimChecking,      iemNativeHlpNeedCsLimChecking },
    9256             {   kIemNativeLabelType_CheckBranchMiss,        iemNativeHlpCheckBranchMiss },
     9272            {   kIemNativeLabelType_Invalid,                0, NULL },
     9273            {   kIemNativeLabelType_RaiseDe,                RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseDe),               iemNativeHlpExecRaiseDe },
     9274            {   kIemNativeLabelType_RaiseUd,                RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseUd),               iemNativeHlpExecRaiseUd },
     9275            {   kIemNativeLabelType_RaiseSseRelated,        RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseSseRelated),       iemNativeHlpExecRaiseSseRelated },
     9276            {   kIemNativeLabelType_RaiseAvxRelated,        RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseAvxRelated),       iemNativeHlpExecRaiseAvxRelated },
     9277            {   kIemNativeLabelType_RaiseSseAvxFpRelated,   RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseSseAvxFpRelated),  iemNativeHlpExecRaiseSseAvxFpRelated },
     9278            {   kIemNativeLabelType_RaiseNm,                RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseNm),               iemNativeHlpExecRaiseNm },
     9279            {   kIemNativeLabelType_RaiseGp0,               RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseGp0),              iemNativeHlpExecRaiseGp0 },
     9280            {   kIemNativeLabelType_RaiseMf,                RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseMf),               iemNativeHlpExecRaiseMf },
     9281            {   kIemNativeLabelType_RaiseXf,                RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitRaiseXf),               iemNativeHlpExecRaiseXf },
     9282            {   kIemNativeLabelType_ObsoleteTb,             RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitObsoleteTb),            iemNativeHlpObsoleteTb },
     9283            {   kIemNativeLabelType_NeedCsLimChecking,      RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitNeedCsLimChecking),     iemNativeHlpNeedCsLimChecking },
     9284            {   kIemNativeLabelType_CheckBranchMiss,        RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbExitCheckBranchMiss),       iemNativeHlpCheckBranchMiss },
    92579285        };
    92589286        AssertCompile(RT_ELEMENTS(g_aSimpleTailLabels) == (unsigned)kIemNativeLabelType_LastSimple + 1U);
     
    92619289        if (fTailLabels)
    92629290        {
     9291#ifdef VBOX_WITH_STATISTICS
     9292            uint8_t const idxStatsTmp1 = iemNativeRegAllocTmp(pReNative, &off);
     9293            uint8_t const idxStatsTmp2 = iemNativeRegAllocTmp(pReNative, &off);
     9294#endif
     9295
    92639296            do
    92649297            {
     
    92739306                    iemNativeLabelDefine(pReNative, idxLabel, off);
    92749307
     9308#ifdef VBOX_WITH_STATISTICS
     9309                    off = iemNativeEmitIncStamCounterInVCpu(pReNative, off, idxStatsTmp1, idxStatsTmp2,
     9310                                                            g_aSimpleTailLabels[enmLabel].offVCpuStats);
     9311#endif
     9312
    92759313                    /* int pfnCallback(PVMCPUCC pVCpu) */
    92769314                    off = iemNativeEmitLoadGprFromGpr(pReNative, off, IEMNATIVE_CALL_ARG0_GREG, IEMNATIVE_REG_FIXED_PVMCPU);
     
    92829320
    92839321            } while (fTailLabels);
     9322
     9323#ifdef VBOX_WITH_STATISTICS
     9324            iemNativeRegFreeTmp(pReNative, idxStatsTmp1);
     9325            iemNativeRegFreeTmp(pReNative, idxStatsTmp2);
     9326#endif
    92849327        }
    92859328    }
  • trunk/src/VBox/VMM/VMMR3/IEMR3.cpp

    r104271 r104281  
    601601                               "Delayed RIP updating percentage",
    602602                               "/IEM/CPU%u/re/NativePcUpdateDelayed_StatusDelayedPct", idCpu);
     603
     604        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbFinished, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     605                        "Number of times the TB finishes execution completely", "/IEM/CPU%u/re/NativeTbFinished", idCpu);
     606        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitReturnBreak, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     607                        "Number of times the TB finished through the ReturnBreak label", "/IEM/CPU%u/re/NativeTbExitReturnBreak", idCpu);
     608        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitReturnWithFlags, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     609                        "Number of times the TB finished through the ReturnWithFlags label", "/IEM/CPU%u/re/NativeTbExitReturnWithFlags", idCpu);
     610        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitObsoleteTb, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     611                        "Number of times the TB finished through the ObsoleteTb label", "/IEM/CPU%u/re/NativeTbExitObsoleteTb", idCpu);
     612        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitNeedCsLimChecking, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     613                        "Number of times the TB finished through the NeedCsLimChecking label", "/IEM/CPU%u/re/NativeTbExitNeedCsLimChecking", idCpu);
     614        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitCheckBranchMiss, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     615                        "Number of times the TB finished through the CheckBranchMiss label", "/IEM/CPU%u/re/NativeTbExitCheckBranchMiss", idCpu);
     616        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseDe, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     617                        "Number of times the TB finished raising a #DE exception", "/IEM/CPU%u/re/NativeTbExitRaiseDe", idCpu);
     618        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseUd, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     619                        "Number of times the TB finished raising a #UD exception", "/IEM/CPU%u/re/NativeTbExitRaiseUd", idCpu);
     620        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseSseRelated, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     621                        "Number of times the TB finished raising a SSE related exception", "/IEM/CPU%u/re/NativeTbExitRaiseSseRelated", idCpu);
     622        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseAvxRelated, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     623                        "Number of times the TB finished raising a AVX related exception", "/IEM/CPU%u/re/NativeTbExitRaiseAvxRelated", idCpu);
     624        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseSseAvxFpRelated, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     625                        "Number of times the TB finished raising a SSE/AVX floating point related exception", "/IEM/CPU%u/re/NativeTbExitRaiseSseAvxFpRelated", idCpu);
     626        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseNm, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     627                        "Number of times the TB finished raising a #NM exception", "/IEM/CPU%u/re/NativeTbExitRaiseNm", idCpu);
     628        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseGp0, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     629                        "Number of times the TB finished raising a #GP(0) exception", "/IEM/CPU%u/re/NativeTbExitRaiseGp0", idCpu);
     630        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseMf, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     631                        "Number of times the TB finished raising a #MF exception", "/IEM/CPU%u/re/NativeTbExitRaiseMf", idCpu);
     632        STAMR3RegisterF(pVM, &pVCpu->iem.s.StatNativeTbExitRaiseXf, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     633                        "Number of times the TB finished raising a #XF exception", "/IEM/CPU%u/re/NativeTbExitRaiseXf", idCpu);
    603634
    604635#  endif /* VBOX_WITH_STATISTICS */
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r104274 r104281  
    19881988#endif
    19891989
    1990     uint64_t                au64Padding[2];
     1990    /** Native recompiler: The TB finished executing completely without jumping to a an exit label. */
     1991    STAMCOUNTER             StatNativeTbFinished;
     1992    /** Native recompiler: The TB finished executing jumping to the ReturnBreak label. */
     1993    STAMCOUNTER             StatNativeTbExitReturnBreak;
     1994    /** Native recompiler: The TB finished executing jumping to the ReturnWithFlags label. */
     1995    STAMCOUNTER             StatNativeTbExitReturnWithFlags;
     1996    /** Native recompiler: The TB finished executing jumping to the RaiseDe label. */
     1997    STAMCOUNTER             StatNativeTbExitRaiseDe;
     1998    /** Native recompiler: The TB finished executing jumping to the RaiseUd label. */
     1999    STAMCOUNTER             StatNativeTbExitRaiseUd;
     2000    /** Native recompiler: The TB finished executing jumping to the RaiseSseRelated label. */
     2001    STAMCOUNTER             StatNativeTbExitRaiseSseRelated;
     2002    /** Native recompiler: The TB finished executing jumping to the RaiseAvxRelated label. */
     2003    STAMCOUNTER             StatNativeTbExitRaiseAvxRelated;
     2004    /** Native recompiler: The TB finished executing jumping to the RaiseSseAvxFpRelated label. */
     2005    STAMCOUNTER             StatNativeTbExitRaiseSseAvxFpRelated;
     2006    /** Native recompiler: The TB finished executing jumping to the RaiseNm label. */
     2007    STAMCOUNTER             StatNativeTbExitRaiseNm;
     2008    /** Native recompiler: The TB finished executing jumping to the RaiseGp0 label. */
     2009    STAMCOUNTER             StatNativeTbExitRaiseGp0;
     2010    /** Native recompiler: The TB finished executing jumping to the RaiseMf label. */
     2011    STAMCOUNTER             StatNativeTbExitRaiseMf;
     2012    /** Native recompiler: The TB finished executing jumping to the RaiseXf label. */
     2013    STAMCOUNTER             StatNativeTbExitRaiseXf;
     2014    /** Native recompiler: The TB finished executing jumping to the ObsoleteTb label. */
     2015    STAMCOUNTER             StatNativeTbExitObsoleteTb;
     2016    /** Native recompiler: The TB finished executing jumping to the NeedCsLimChecking label. */
     2017    STAMCOUNTER             StatNativeTbExitNeedCsLimChecking;
     2018    /** Native recompiler: The TB finished executing jumping to the CheckBranchMiss label. */
     2019    STAMCOUNTER             StatNativeTbExitCheckBranchMiss;
     2020
     2021    uint64_t                au64Padding[3];
    19912022    /** @} */
    19922023
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