VirtualBox

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


Ignore:
Timestamp:
May 18, 2010 12:15:55 PM (15 years ago)
Author:
vboxsync
Message:

Statistics for shared pages

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/GMM.cpp

    r29613 r29620  
    290290 * @see GMMR0QueryVMMMemoryStatsReq
    291291 */
    292 GMMR3DECL(int)  GMMR3QueryHypervisorMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages)
     292GMMR3DECL(int)  GMMR3QueryHypervisorMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages, uint64_t *puTotalBalloonSize)
    293293{
    294294    GMMMEMSTATSREQ Req;
     
    298298    Req.cFreePages       = 0;
    299299    Req.cBalloonedPages  = 0;
     300    Req.cSharedPages     = 0;
    300301
    301302    *pcTotalAllocPages   = 0;
    302303    *pcTotalFreePages    = 0;
    303304    *pcTotalBalloonPages = 0;
     305    *puTotalBalloonSize  = 0;
    304306
    305307    /* Must be callable from any thread, so can't use VMMR3CallR0. */
     
    310312        *pcTotalFreePages    = Req.cFreePages;
    311313        *pcTotalBalloonPages = Req.cBalloonedPages;
     314        *puTotalBalloonSize  = Req.cSharedPages;
    312315    }
    313316    return rc;
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r29577 r29620  
    967967 * @param   puTotalFreeSize     Pointer to total free (allocated but not used yet) memory inside VMMR0 (in bytes)
    968968 * @param   puTotalBalloonSize  Pointer to total ballooned memory inside VMMR0 (in bytes)
    969  */
    970 VMMR3DECL(int) PGMR3QueryVMMMemoryStats(PVM pVM, uint64_t *puTotalAllocSize, uint64_t *puTotalFreeSize, uint64_t *puTotalBalloonSize)
     969 * @param   puTotalSharedSize   Pointer to total shared memory inside VMMR0 (in bytes)
     970 */
     971VMMR3DECL(int) PGMR3QueryVMMMemoryStats(PVM pVM, uint64_t *puTotalAllocSize, uint64_t *puTotalFreeSize, uint64_t *puTotalBalloonSize, uint64_t *puTotalSharedSize)
    971972{
    972973    int rc;
    973974
    974     uint64_t cAllocPages = 0, cFreePages = 0, cBalloonPages = 0;
    975     rc = GMMR3QueryHypervisorMemoryStats(pVM, &cAllocPages, &cFreePages, &cBalloonPages);
     975    uint64_t cAllocPages = 0, cFreePages = 0, cBalloonPages = 0, cSharedPages = 0;
     976    rc = GMMR3QueryHypervisorMemoryStats(pVM, &cAllocPages, &cFreePages, &cBalloonPages, &cSharedPages);
    976977    AssertRCReturn(rc, rc);
    977978
     
    984985    if (puTotalBalloonSize)
    985986        *puTotalBalloonSize = cBalloonPages * _4K;
     987
     988    if (puTotalSharedSize)
     989        *puTotalSharedSize = cSharedPages * _4K;
     990
     991    return VINF_SUCCESS;
     992}
     993
     994/**
     995 * Query memory stats for the VM
     996 *
     997 * @returns VBox status code.
     998 * @param   pVM                 The VM handle.
     999 * @param   puTotalAllocSize    Pointer to total allocated  memory inside the VM (in bytes)
     1000 * @param   puTotalFreeSize     Pointer to total free (allocated but not used yet) memory inside the VM (in bytes)
     1001 * @param   puTotalBalloonSize  Pointer to total ballooned memory inside the VM (in bytes)
     1002 * @param   puTotalSharedSize   Pointer to total shared memory inside the VM (in bytes)
     1003 */
     1004VMMR3DECL(int) PGMR3QueryMemoryStats(PVM pVM, uint64_t *pulTotalMem, uint64_t *pulPrivateMem, uint64_t *puTotalSharedMem, uint64_t *puTotalZeroMem)
     1005{
     1006    if (pulTotalMem)
     1007        *pulTotalMem = pVM->pgm.s.cAllPages * _4K;
     1008
     1009    if (pulPrivateMem)
     1010        *pulPrivateMem = pVM->pgm.s.cPrivatePages * _4K;
     1011
     1012    if (puTotalSharedMem)
     1013        *puTotalSharedMem = pVM->pgm.s.cReusedSharedPages * _4K;
     1014
     1015    if (puTotalZeroMem)
     1016        *puTotalZeroMem = pVM->pgm.s.cZeroPages * _4K;
    9861017
    9871018    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r29613 r29620  
    505505    /** The number of pages that are shared. A subset of cAllocatedPages. */
    506506    uint64_t            cSharedPages;
     507    /** The number of pages that are actually shared between VMs. */
     508    uint64_t            cDuplicatePages;
    507509    /** The number of pages that are shared that has been left behind by
    508510     * VMs not doing proper cleanups. */
     
    852854            pGMM->cAllocatedPages = 0;
    853855            pGMM->cSharedPages = 0;
     856            pGMM->cDuplicatePages = 0;
    854857            pGMM->cLeftBehindSharedPages = 0;
    855858            pGMM->cChunks = 0;
     
    21272130                            pGVM->gmm.s.Allocated.cBasePages--;
    21282131                            if (!--pPage->Shared.cRefs)
     2132                            {
    21292133                                gmmR0FreeSharedPage(pGMM, paPages[iPage].idSharedPage, pPage);
     2134                            }
     2135                            else
     2136                            {
     2137                                Assert(pGMM->cDuplicatePages);
     2138                                pGMM->cDuplicatePages--;
     2139                            }
    21302140
    21312141                            paPages[iPage].idSharedPage = NIL_GMM_PAGEID;
     
    26672677    Assert(pGMM->cSharedPages > 0);
    26682678    Assert(pGMM->cAllocatedPages > 0);
     2679
     2680    pGMM->cDuplicatePages++;
    26692681
    26702682    pPage->Shared.cRefs++;
     
    30783090    pReq->cBalloonedPages = pGMM->cBalloonedPages;
    30793091    pReq->cMaxPages       = pGMM->cMaxPages;
     3092    pReq->cSharedPages    = pGMM->cDuplicatePages;
    30803093    GMM_CHECK_SANITY_UPON_LEAVING(pGMM);
    30813094
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