VirtualBox

Changeset 91702 in vbox


Ignore:
Timestamp:
Oct 12, 2021 9:15:19 PM (3 years ago)
Author:
vboxsync
Message:

VMM/NEM: More stats. Played with using WHvMapGpaRange again, but much too slow to use on a per-page basis. bugref:10118

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/vm.h

    r91580 r91702  
    13461346        struct NEM  s;
    13471347#endif
    1348         uint8_t     padding[128];       /* multiple of 64 */
     1348        uint8_t     padding[256];       /* multiple of 64 */
    13491349    } nem;
    13501350
     
    14541454
    14551455    /** Padding for aligning the structure size on a page boundrary. */
    1456     uint8_t         abAlignment2[2136 - sizeof(PVMCPUR3) * VMM_MAX_CPU_COUNT];
     1456    uint8_t         abAlignment2[2008 - sizeof(PVMCPUR3) * VMM_MAX_CPU_COUNT];
    14571457
    14581458    /* ---- end small stuff ---- */
  • trunk/include/VBox/vmm/vm.mac

    r91345 r91702  
    149149    .em                     resb 256
    150150    alignb 64
    151     .nem                    resb 128
     151    .nem                    resb 256
    152152    alignb 64
    153153    .tm                     resb 10112
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r91692 r91702  
    16071607        Log5(("NEM GPA unmap all: %RGp (cMappedPages=%u)\n", GCPhys, pVM->nem.s.cMappedPages - 1));
    16081608        *pu2NemState = NEM_WIN_PAGE_STATE_UNMAPPED;
     1609        STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    16091610    }
    16101611    else
     
    16181619# endif
    16191620        *pu2NemState = NEM_WIN_PAGE_STATE_NOT_SET;
     1621        STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    16201622    }
    16211623    if (pVM->nem.s.cMappedPages > 0)
     
    17371739                if (RT_SUCCESS(rc))
    17381740                {
     1741                    STAM_REL_COUNTER_INC(&pVM->nem.s.StatRemapPage);
    17391742                    pInfo->u2NemState = NEM_WIN_PAGE_STATE_WRITABLE;
    17401743                    pState->fDidSomething = true;
     
    17431746                          GCPhys, g_apszPageStates[u2State], pVM->nem.s.cMappedPages));
    17441747                }
     1748                else
     1749                    STAM_REL_COUNTER_INC(&pVM->nem.s.StatRemapPageFailed);
    17451750            }
    17461751            else
     
    17941799        pState->fCanResume    = true;
    17951800        pInfo->u2NemState = NEM_WIN_PAGE_STATE_UNMAPPED;
     1801        STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    17961802        uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    17971803        Log5(("NEM GPA unmapped/exit: %RGp (was %s, cMappedPages=%u)\n", GCPhys, g_apszPageStates[u2State], cMappedPages));
    17981804        return VINF_SUCCESS;
    17991805    }
     1806    STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    18001807# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    18011808    LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhys, rc));
     
    18081815    PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemHCWinUnmapOnePageCallback, NULL);
    18091816    Log(("nemHCWinHandleMemoryAccessPageCheckerCallback: Unmapped all (cMappedPages=%u)\n", pVM->nem.s.cMappedPages));
     1817    STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapAllPages);
    18101818
    18111819    pState->fDidSomething = true;
     
    42064214         */
    42074215        uint32_t const cMappedPages = pVM->nem.s.cMappedPages;
    4208         if (cMappedPages >= 4000)
     4216        if (cMappedPages < pVM->nem.s.cMaxMappedPages)
     4217        { /* likely*/ }
     4218        else
    42094219        {
    42104220            PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemHCWinUnmapOnePageCallback, NULL);
    42114221            Log(("nemHCWinRunGC: Unmapped all; cMappedPages=%u -> %u\n", cMappedPages, pVM->nem.s.cMappedPages));
     4222            STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapAllPages);
    42124223        }
    42134224# endif
     
    45344545# endif
    45354546        {
     4547            STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    45364548            uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    45374549            Log5(("NEM GPA unmapped/A20: %RGp (was %s, cMappedPages=%u)\n", GCPhys, g_apszPageStates[pInfo->u2NemState], cMappedPages));
     
    45404552        else
    45414553        {
     4554            STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    45424555# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    45434556            LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
     
    46364649            {
    46374650                *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
     4651                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    46384652                uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    46394653                Log5(("NEM GPA unmapped/set: %RGp (was %s, cMappedPages=%u)\n", GCPhysDst, g_apszPageStates[u2OldState], cMappedPages));
    46404654            }
    46414655            else
     4656            {
     4657                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    46424658                AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
     4659            }
    46434660        }
    46444661        else
     
    46554672            {
    46564673                *pu2State = NEM_WIN_PAGE_STATE_WRITABLE;
     4674                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
    46574675                uint32_t cMappedPages = u2OldState <= NEM_WIN_PAGE_STATE_UNMAPPED
    46584676                                      ? ASMAtomicIncU32(&pVM->nem.s.cMappedPages) : pVM->nem.s.cMappedPages;
     
    46614679            }
    46624680            else
     4681            {
     4682                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
    46634683                AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
     4684            }
    46644685        }
    46654686        else
     
    46754696            {
    46764697                *pu2State = NEM_WIN_PAGE_STATE_READABLE;
     4698                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
    46774699                uint32_t cMappedPages = u2OldState <= NEM_WIN_PAGE_STATE_UNMAPPED
    46784700                                      ? ASMAtomicIncU32(&pVM->nem.s.cMappedPages) : pVM->nem.s.cMappedPages;
     
    46814703            }
    46824704            else
     4705            {
     4706                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
    46834707                AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
     4708            }
    46844709        }
    46854710        else
     
    47104735            {
    47114736                *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
     4737                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    47124738                uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    47134739                if (u2NewState == NEM_WIN_PAGE_STATE_UNMAPPED)
     
    47204746            else
    47214747            {
     4748                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    47224749                LogRel(("nemHCNativeSetPhysPage/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
    47234750                return rc;
     
    47284755            {
    47294756                *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
     4757                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    47304758                uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    47314759                if (u2NewState == NEM_WIN_PAGE_STATE_UNMAPPED)
     
    47384766            else
    47394767            {
     4768                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    47404769                LogRel(("nemHCNativeSetPhysPage/unmap: GCPhysDst=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n",
    47414770                        GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
     
    47594788        {
    47604789            *pu2State = NEM_WIN_PAGE_STATE_WRITABLE;
     4790            STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
    47614791            uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    47624792            Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n",
     
    47644794            return VINF_SUCCESS;
    47654795        }
     4796        STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
    47664797        LogRel(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
    47674798        return rc;
     
    47764807            {
    47774808                *pu2State = NEM_WIN_PAGE_STATE_WRITABLE;
     4809                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
    47784810                uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    47794811                Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n",
     
    47814813                return VINF_SUCCESS;
    47824814            }
     4815            STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
    47834816            LogRel(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n",
    47844817                    GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
     
    47994832        {
    48004833            *pu2State = NEM_WIN_PAGE_STATE_READABLE;
     4834            STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
    48014835            uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    48024836            Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n",
     
    48044838            return VINF_SUCCESS;
    48054839        }
     4840        STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
    48064841        LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
    48074842        return rc;
     
    48164851            {
    48174852                *pu2State = NEM_WIN_PAGE_STATE_READABLE;
     4853                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
    48184854                uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    48194855                Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n",
     
    48214857                return VINF_SUCCESS;
    48224858            }
     4859            STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
    48234860            LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysDst=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n",
    48244861                    GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
     
    48534890    if (RT_SUCCESS(rc))
    48544891    {
     4892        STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    48554893        uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    48564894        Log5(("NEM GPA unmapped/just: %RGp (was %s, cMappedPages=%u)\n", GCPhysDst, g_apszPageStates[*pu2State], cMappedPages));
     
    48584896        return VINF_SUCCESS;
    48594897    }
     4898    STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    48604899    LogRel(("nemHCJustUnmapPageFromHyperV/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
    48614900    return rc;
     4901
    48624902#elif defined(IN_RING3)
    48634903    HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK, X86_PAGE_SIZE);
    48644904    if (SUCCEEDED(hrc))
    48654905    {
     4906        STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    48664907        uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    48674908        *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
     
    48694910        return VINF_SUCCESS;
    48704911    }
     4912    STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    48714913    LogRel(("nemHCJustUnmapPageFromHyperV(%RGp): failed! hrc=%Rhrc (%#x) Last=%#x/%u\n",
    48724914            GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r91692 r91702  
    12871287#endif
    12881288
     1289#ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1290    /** Some guess working here. */
     1291    pVM->nem.s.cMaxMappedPages = 4000;
     1292    if (g_uBuildNo >= 22000)
     1293        pVM->nem.s.cMaxMappedPages = _64K; /* seems it can do lots more even */
     1294#endif
     1295
    12891296    /*
    12901297     * Error state.
     
    13341341
    13351342                        /* Register release statistics */
     1343                        STAMR3Register(pVM, (void *)&pVM->nem.s.cMappedPages, STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1344                                       "/NEM/PagesCurrentlyMapped", STAMUNIT_PAGES, "Number guest pages currently mapped by the VM");
     1345                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatMapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     1346                                       "/NEM/PagesMapCalls", STAMUNIT_PAGES, "Calls to WHvMapGpaRange/HvCallMapGpaPages");
     1347                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatMapPageFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     1348                                       "/NEM/PagesMapFails", STAMUNIT_PAGES, "Calls to WHvMapGpaRange/HvCallMapGpaPages that failed");
     1349                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatUnmapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     1350                                       "/NEM/PagesUnmapCalls", STAMUNIT_PAGES, "Calls to WHvUnmapGpaRange/HvCallUnmapGpaPages");
     1351                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatUnmapPageFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     1352                                       "/NEM/PagesUnmapFails", STAMUNIT_PAGES, "Calls to WHvUnmapGpaRange/HvCallUnmapGpaPages that failed");
     1353#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1354                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatRemapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     1355                                       "/NEM/PagesRemapCalls", STAMUNIT_PAGES, "Calls to HvCallMapGpaPages for changing page protection");
     1356                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatRemapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     1357                                       "/NEM/PagesRemapFails", STAMUNIT_PAGES, "Calls to HvCallMapGpaPages for changing page protection failed");
     1358#else
     1359                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatUnmapAllPages, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     1360                                       "/NEM/PagesUnmapAll", STAMUNIT_PAGES, "Times we had to unmap all the pages");
     1361#endif
     1362
    13361363                        for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
    13371364                        {
     
    20262053#endif
    20272054        {
     2055            STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
    20282056            uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
    20292057            Log5(("NEM GPA unmapped/A20: %RGp (was %s, cMappedPages=%u)\n", GCPhys, g_apszPageStates[pInfo->u2NemState], cMappedPages));
     
    20322060        else
    20332061        {
     2062            STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
    20342063#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    20352064            LogRel(("nemR3WinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
  • trunk/src/VBox/VMM/include/NEMInternal.h

    r91692 r91702  
    192192    /** Number of currently mapped pages. */
    193193    uint32_t volatile           cMappedPages;
     194#  ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     195    /** Max number of pages we dare map at once. */
     196    uint32_t                    cMaxMappedPages;
     197#  endif
     198    STAMCOUNTER                 StatMapPage;
     199    STAMCOUNTER                 StatUnmapPage;
     200#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     201    STAMCOUNTER                 StatRemapPage;
     202    STAMCOUNTER                 StatRemapPageFailed;
     203#  else
     204    STAMCOUNTER                 StatUnmapAllPages;
     205#  endif
     206    STAMCOUNTER                 StatMapPageFailed;
     207    STAMCOUNTER                 StatUnmapPageFailed;
    194208
    195209#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
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