VirtualBox

Changeset 28036 in vbox


Ignore:
Timestamp:
Apr 7, 2010 9:47:43 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59743
Message:

More metrics changes

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/gmm.h

    r28012 r28036  
    399399
    400400/**
    401  * Request buffer for GMMR0QueryTotalFreePagesReq / VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES.
    402  * @see GMMR0QueryTotalFreePagesReq.
    403  */
    404 typedef struct GMMFREEQUERYREQ
     401 * Request buffer for GMMR0QueryVMMMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS.
     402 * @see GMMR0QueryVMMMemoryStatsReq.
     403 */
     404typedef struct GMMMEMSTATSREQ
    405405{
    406406    /** The header. */
    407407    SUPVMMR0REQHDR      Hdr;
     408    /** The number of allocated pages (out). */
     409    uint64_t            cAllocPages;
    408410    /** The number of free pages (out). */
    409411    uint64_t            cFreePages;
    410 } GMMFREEQUERYREQ;
    411 /** Pointer to a GMMR0QueryTotalFreePagesReq / VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES request buffer. */
    412 typedef GMMFREEQUERYREQ *PGMMFREEQUERYREQ;
    413 
    414 GMMR0DECL(int)  GMMR0QueryTotalFreePagesReq(PVM pVM, PGMMFREEQUERYREQ pReq);
     412    /** The number of ballooned pages (out). */
     413    uint64_t            cBalloonedPages;
     414} GMMMEMSTATSREQ;
     415/** Pointer to a GMMR0QueryVMMMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS request buffer. */
     416typedef GMMMEMSTATSREQ *PGMMMEMSTATSREQ;
     417
     418GMMR0DECL(int)  GMMR0QueryVMMMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq);
    415419
    416420/**
     
    473477GMMR3DECL(int)  GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3);
    474478GMMR3DECL(int)  GMMR3BalloonedPages(PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
    475 GMMR3DECL(int)  GMMR3QueryTotalFreePages(PVM pVM, uint64_t *pcTotalFreePages);
     479GMMR3DECL(int)  GMMR3QueryVMMMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages);
    476480/** @} */
    477481#endif /* IN_RING3 */
  • trunk/include/VBox/pgm.h

    r28012 r28036  
    467467VMMR3DECL(int)      PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
    468468VMMR3DECL(int)      PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
    469 VMMR3DECL(int)      PGMR3QueryFreeMemory(PVM pVM, unsigned *puTotalFreeSize);
     469VMMR3DECL(int)      PGMR3QueryVMMMemoryStats(PVM pVM, uint64_t *puTotalAllocSize, uint64_t *puTotalFreeSize, uint64_t *puTotalBalloonSize);
    470470VMMR3DECL(int)      PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb,
    471471                                          R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
  • trunk/include/VBox/vmm.h

    r28012 r28036  
    300300    /** Call GMMR0FreeLargePage(). */
    301301    VMMR0_DO_GMM_FREE_LARGE_PAGE,
    302     /** Call GMMR0QueryTotalFreePagesReq */
    303     VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES,
     302    /** Call GMMR0QueryVMMMemoryStatsReq */
     303    VMMR0_DO_GMM_QUERY_VMM_MEM_STATS,
    304304    /** Call GMMR0BalloonedPages(). */
    305305    VMMR0_DO_GMM_BALLOONED_PAGES,
  • trunk/src/VBox/Main/GuestImpl.cpp

    r28032 r28036  
    255255STDMETHODIMP Guest::InternalGetStatistics(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
    256256                                          ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon,
    257                                           ULONG *aMemCache, ULONG *aPageTotal, ULONG *aMemFreeTotal)
     257                                          ULONG *aMemCache, ULONG *aPageTotal,
     258                                          ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal)
    258259{
    259260    CheckComArgOutPointerValid(aCpuUser);
     
    283284    if (pVM.isOk())
    284285    {
    285         unsigned uFreeTotal;
     286        uint64_t uFreeTotal, uAllocTotal, uBalloonedTotal;
    286287        *aMemFreeTotal = 0;
    287         int rc = PGMR3QueryFreeMemory(pVM.raw(), &uFreeTotal);
     288        int rc = PGMR3QueryVMMMemoryStats(pVM.raw(), &uAllocTotal, &uFreeTotal, &uBalloonedTotal);
    288289        AssertRC(rc);
    289290        if (rc == VINF_SUCCESS)
    290             *aMemFreeTotal = uFreeTotal;
     291        {
     292            *aMemAllocTotal   = uAllocTotal / _1K;  /* bytes -> KB */
     293            *aMemFreeTotal    = uFreeTotal / _1K;
     294            *aMemBalloonTotal = uBalloonedTotal / _1K;
     295        }
    291296    }
    292297    else
  • trunk/src/VBox/Main/HostImpl.cpp

    r28012 r28036  
    24112411    pm::SubMetric *ramUsageFree  = new pm::SubMetric("RAM/Usage/Free",
    24122412        "Physical memory currently available to applications.");
     2413    pm::SubMetric *ramVMMUsed = new pm::SubMetric("RAM/VMM/Used",
     2414        "Total physical memory used by the hypervisor.");
     2415    pm::SubMetric *ramVMMFree = new pm::SubMetric("RAM/VMM/Free",
     2416        "Total physical memory free inside the hypervisor.");
     2417    pm::SubMetric *ramVMMBallooned  = new pm::SubMetric("RAM/VMM/Ballooned",
     2418        "Total physical memory ballooned by the hypervisor.");
     2419
    24132420
    24142421    /* Create and register base metrics */
     
    24222429    aCollector->registerBaseMetric (cpuMhz);
    24232430    pm::BaseMetric *ramUsage = new pm::HostRamUsage(hal, objptr, ramUsageTotal, ramUsageUsed,
    2424                                            ramUsageFree);
     2431                                           ramUsageFree, ramVMMUsed, ramVMMFree, ramVMMBallooned);
    24252432    aCollector->registerBaseMetric (ramUsage);
    24262433
     
    24802487    aCollector->registerMetric(new pm::Metric(ramUsage, ramUsageFree,
    24812488                                              new pm::AggregateMax()));
     2489
     2490    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMUsed, 0));
     2491    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMUsed,
     2492                                              new pm::AggregateAvg()));
     2493    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMUsed,
     2494                                              new pm::AggregateMin()));
     2495    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMUsed,
     2496                                              new pm::AggregateMax()));
     2497
     2498    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMFree, 0));
     2499    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMFree,
     2500                                              new pm::AggregateAvg()));
     2501    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMFree,
     2502                                              new pm::AggregateMin()));
     2503    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMFree,
     2504                                              new pm::AggregateMax()));
     2505
     2506    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMBallooned, 0));
     2507    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMBallooned,
     2508                                              new pm::AggregateAvg()));
     2509    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMBallooned,
     2510                                              new pm::AggregateMin()));
     2511    aCollector->registerMetric(new pm::Metric(ramUsage, ramVMMBallooned,
     2512                                              new pm::AggregateMax()));
    24822513};
    24832514
  • trunk/src/VBox/Main/Performance.cpp

    r28012 r28036  
    168168        &&  iTick != mLastTick)
    169169    {
    170         ULONG ulMemFreeTotal;
     170        ULONG ulMemAllocTotal, ulMemFreeTotal, ulMemBalloonTotal;
    171171
    172172        mGuest->InternalGetStatistics(&mCpuUser, &mCpuKernel, &mCpuIdle,
    173173                                      &mMemTotal, &mMemFree, &mMemBalloon, &mMemCache,
    174                                       &mPageTotal, &ulMemFreeTotal);
     174                                      &mPageTotal, &ulMemAllocTotal, &ulMemFreeTotal, &ulMemBalloonTotal);
    175175
    176176        if (mHostHAL)
    177             mHostHAL->setMemFreeTotal(ulMemFreeTotal);
     177            mHostHAL->setMemHypervisorStats(ulMemAllocTotal, ulMemFreeTotal, ulMemBalloonTotal);
    178178
    179179        mLastTick = iTick;
     
    303303        mTotal->put(total);
    304304        mUsed->put(used);
    305         mAvailable->put(available + mHAL->getMemFreeTotal());
    306     }
     305        mAvailable->put(available);
     306
     307    }
     308    ULONG allocVMM, freeVMM, balloonVMM;
     309
     310    mHAL->getMemHypervisorStats(&allocVMM, &freeVMM, &balloonVMM);
     311    mAllocVMM->put(allocVMM);
     312    mFreeVMM->put(freeVMM);
     313    mBalloonVMM->put(balloonVMM);
    307314}
    308315
     
    426433
    427434    mGuestHAL->getGuestMemLoad(&ulMemTotal, &ulMemFree, &ulMemBalloon, &ulMemCache, &ulPageTotal);
    428     mTotal->put(ulMemTotal);
    429     mFree->put(ulMemFree);
    430     mBallooned->put(ulMemBalloon);
    431     mCache->put(ulMemCache);
    432     mPagedTotal->put(ulPageTotal);
     435    mTotal->put(ulMemTotal * (_1M / _1K));      /* MB -> KB */
     436    mFree->put(ulMemFree * (_1M / _1K));
     437    mBallooned->put(ulMemBalloon * (_1M / _1K));
     438    mCache->put(ulMemCache * (_1M / _1K));
     439    mPagedTotal->put(ulPageTotal * (_1M / _1K));
    433440}
    434441
  • trunk/src/VBox/Main/PerformanceImpl.cpp

    r28012 r28036  
    6868    "RAM/Usage/Free:min",
    6969    "RAM/Usage/Free:max",
     70    "RAM/VMM/Used",
     71    "RAM/VMM/Used:avg",
     72    "RAM/VMM/Used:min",
     73    "RAM/VMM/Used:max",
     74    "RAM/VMM/Free",
     75    "RAM/VMM/Free:avg",
     76    "RAM/VMM/Free:min",
     77    "RAM/VMM/Free:max",
     78    "RAM/VMM/Ballooned",
     79    "RAM/VMM/Ballooned:avg",
     80    "RAM/VMM/Ballooned:min",
     81    "RAM/VMM/Ballooned:max",
    7082    "Guest/CPU/Load/User",
    7183    "Guest/CPU/Load/User:avg",
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r28032 r28036  
    83538353  <interface
    83548354     name="IGuest" extends="$unknown"
    8355      uuid="54ebdc27-89ca-4bf8-a58a-48077679a3af"
     8355     uuid="8cf03bf9-7478-42de-add8-10b2af75a06d"
    83568356     wsmap="managed"
    83578357     >
     
    84508450         <desc>Total amount of space in the page file</desc>
    84518451      </param>
     8452      <param name="memAllocTotal" type="unsigned long" dir="out">
     8453         <desc>Total amount of memory allocated by the hypervisor</desc>
     8454      </param>
    84528455      <param name="memFreeTotal" type="unsigned long" dir="out">
    8453          <desc>Total amount of free memory available in VMMR0</desc>
     8456         <desc>Total amount of free memory available in the hypervisor</desc>
     8457      </param>
     8458      <param name="memBalloonTotal" type="unsigned long" dir="out">
     8459         <desc>Total amount of memory ballooned by the hypervisor</desc>
    84548460      </param>
    84558461    </method>
  • trunk/src/VBox/Main/include/GuestImpl.h

    r28032 r28036  
    9090    STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
    9191                                     ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemCache,
    92                                      ULONG *aPageTotal, ULONG *aMemFreeTotal);
     92                                     ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal);
    9393
    9494    // public methods that are not in IDL
  • trunk/src/VBox/Main/include/Performance.h

    r28012 r28036  
    139139    {
    140140    public:
    141                  CollectorHAL() : mMemFreeTotal(0) {};
     141                 CollectorHAL() : mMemAllocVMM(0), mMemFreeVMM(0), mMemBalloonedVMM(0) {};
    142142        virtual ~CollectorHAL() { };
    143143        virtual int preCollect(const CollectorHints& /* hints */, uint64_t /* iTick */) { return VINF_SUCCESS; }
     
    163163        virtual int disable();
    164164
    165         virtual int setMemFreeTotal(ULONG memfree)
    166         {
    167             mMemFreeTotal = memfree;
     165        virtual int setMemHypervisorStats(ULONG memAlloc, ULONG memFree, ULONG memBallooned)
     166        {
     167            mMemAllocVMM     = memAlloc;
     168            mMemFreeVMM      = memFree;
     169            mMemBalloonedVMM = memBallooned;
    168170            return S_OK;
    169171        }
    170172
    171         virtual ULONG getMemFreeTotal()
    172         {
    173             return mMemFreeTotal;
    174         }
    175 
    176     private:
    177         ULONG       mMemFreeTotal;
     173        virtual void getMemHypervisorStats(ULONG *pMemAlloc, ULONG *pMemFree, ULONG *pMemBallooned)
     174        {
     175            *pMemAlloc     = mMemAllocVMM;
     176            *pMemFree      = mMemFreeVMM;
     177            *pMemBallooned = mMemBalloonedVMM;
     178        }
     179
     180    private:
     181        ULONG       mMemAllocVMM;
     182        ULONG       mMemFreeVMM;
     183        ULONG       mMemBalloonedVMM;
    178184    };
    179185
     
    201207        }
    202208
    203         /** Return guest memory information in kb. */
     209        /** Return guest memory information in MB. */
    204210        void getGuestMemLoad(ULONG *pulMemTotal, ULONG *pulMemFree, ULONG *pulMemBalloon, ULONG *pulMemCache, ULONG *pulPageTotal)
    205211        {
     
    335341    {
    336342    public:
    337         HostRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *used, SubMetric *available)
    338         : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mUsed(used), mAvailable(available) {};
    339         ~HostRamUsage() { delete mTotal; delete mUsed; delete mAvailable; };
     343        HostRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *used, SubMetric *available, SubMetric *allocVMM, SubMetric *freeVMM, SubMetric *balloonVMM)
     344        : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mUsed(used), mAvailable(available), mAllocVMM(allocVMM), mFreeVMM(freeVMM), mBalloonVMM(balloonVMM) {};
     345        ~HostRamUsage() { delete mTotal; delete mUsed; delete mAvailable; delete mAllocVMM; delete mFreeVMM; delete mBalloonVMM; };
    340346
    341347        void init(ULONG period, ULONG length);
     
    350356        SubMetric *mUsed;
    351357        SubMetric *mAvailable;
     358        SubMetric *mAllocVMM;
     359        SubMetric *mFreeVMM;
     360        SubMetric *mBalloonVMM;
    352361    };
    353362
  • trunk/src/VBox/VMM/GMM.cpp

    r28012 r28036  
    291291
    292292/**
    293  * @see GMMR0QueryTotalFreePagesReq
    294  */
    295 GMMR3DECL(int)  GMMR3QueryTotalFreePages(PVM pVM, uint64_t *pcTotalFreePages)
    296 {
    297     GMMFREEQUERYREQ Req;
    298     Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
    299     Req.Hdr.cbReq = sizeof(Req);
    300     Req.cFreePages = 0;
    301 
    302     *pcTotalFreePages = 0;
    303     int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES, 0, &Req.Hdr);
     293 * @see GMMR0QueryVMMMemoryStatsReq
     294 */
     295GMMR3DECL(int)  GMMR3QueryVMMMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages)
     296{
     297    GMMMEMSTATSREQ Req;
     298    Req.Hdr.u32Magic     = SUPVMMR0REQHDR_MAGIC;
     299    Req.Hdr.cbReq        = sizeof(Req);
     300    Req.cAllocPages      = 0;
     301    Req.cFreePages       = 0;
     302    Req.cBalloonedPages  = 0;
     303
     304    *pcTotalAllocPages   = 0;
     305    *pcTotalFreePages    = 0;
     306    *pcTotalBalloonPages = 0;
     307
     308    int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_QUERY_VMM_MEM_STATS, 0, &Req.Hdr);
    304309    if (rc == VINF_SUCCESS)
    305         *pcTotalFreePages = Req.cFreePages;
    306 
     310    {
     311        *pcTotalAllocPages   = Req.cAllocPages;
     312        *pcTotalFreePages    = Req.cFreePages;
     313        *pcTotalBalloonPages = Req.cBalloonedPages;
     314    }
    307315    return rc;
    308316}
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r28012 r28036  
    958958 * @returns VBox status code.
    959959 * @param   pVM                 The VM handle.
    960  * @param   puTotalFreeSize     Pointer to total free (allocated but not used yet) memory inside VMMR0 (in megabytes)
    961  */
    962 VMMR3DECL(int) PGMR3QueryFreeMemory(PVM pVM, unsigned *puTotalFreeSize)
    963 {
    964     int rc = VINF_SUCCESS;
     960 * @param   puTotalAllocSize    Pointer to total allocated  memory inside VMMR0 (in bytes)
     961 * @param   puTotalFreeSize     Pointer to total free (allocated but not used yet) memory inside VMMR0 (in bytes)
     962 * @param   puTotalBalloonSize  Pointer to total ballooned memory inside VMMR0 (in bytes)
     963 */
     964VMMR3DECL(int) PGMR3QueryVMMMemoryStats(PVM pVM, uint64_t *puTotalAllocSize, uint64_t *puTotalFreeSize, uint64_t *puTotalBalloonSize)
     965{
     966    int rc;
     967
     968    uint64_t cAllocPages = 0, cFreePages = 0, cBalloonPages = 0;
     969    rc = GMMR3QueryVMMMemoryStats(pVM, &cAllocPages, &cFreePages, &cBalloonPages);
     970    AssertRCReturn(rc, rc);
     971
     972    if (puTotalAllocSize)
     973        *puTotalAllocSize = cAllocPages * _4K;
    965974
    966975    if (puTotalFreeSize)
    967     {
    968         uint64_t cPages = 0;
    969         rc = GMMR3QueryTotalFreePages(pVM, &cPages);
    970         AssertRC(rc);
    971         *puTotalFreeSize = (unsigned) (cPages * _4K / _1M);
    972     }
    973 
    974     return rc;
     976        *puTotalFreeSize = cFreePages * _4K;
     977
     978    if (puTotalBalloonSize)
     979        *puTotalBalloonSize = cBalloonPages * _4K;
     980
     981    return VINF_SUCCESS;
    975982}
    976983
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r28012 r28036  
    29982998 * @param   pReq            The request packet.
    29992999 */
    3000 GMMR0DECL(int) GMMR0QueryTotalFreePagesReq(PVM pVM, PGMMFREEQUERYREQ pReq)
     3000GMMR0DECL(int) GMMR0QueryVMMMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq)
    30013001{
    30023002    /*
     
    30053005    AssertPtrReturn(pVM, VERR_INVALID_POINTER);
    30063006    AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    3007     AssertMsgReturn(pReq->Hdr.cbReq == sizeof(GMMFREEQUERYREQ),
    3008                     ("%#x < %#x\n", pReq->Hdr.cbReq, sizeof(GMMFREEQUERYREQ)),
     3007    AssertMsgReturn(pReq->Hdr.cbReq == sizeof(GMMMEMSTATSREQ),
     3008                    ("%#x < %#x\n", pReq->Hdr.cbReq, sizeof(GMMMEMSTATSREQ)),
    30093009                    VERR_INVALID_PARAMETER);
    30103010
     
    30143014    PGMM pGMM;
    30153015    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    3016     pReq->cFreePages = (pGMM->cChunks << GMM_CHUNK_SHIFT) - pGMM->cAllocatedPages;
     3016    pReq->cAllocPages     = pGMM->cAllocatedPages;
     3017    pReq->cFreePages      = (pGMM->cChunks << GMM_CHUNK_SHIFT) - pGMM->cAllocatedPages;
     3018    pReq->cBalloonedPages = pGMM->cBalloonedPages;
    30173019    GMM_CHECK_SANITY_UPON_LEAVING(pGMM);
    30183020
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r28012 r28036  
    910910            return GMMR0FreeLargePageReq(pVM, idCpu, (PGMMFREELARGEPAGEREQ)pReqHdr);
    911911
    912         case VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES:
     912        case VMMR0_DO_GMM_QUERY_VMM_MEM_STATS:
    913913            if (u64Arg)
    914914                return VERR_INVALID_PARAMETER;
    915             return GMMR0QueryTotalFreePagesReq(pVM, (PGMMFREEQUERYREQ)pReqHdr);
     915            return GMMR0QueryVMMMemoryStatsReq(pVM, (PGMMMEMSTATSREQ)pReqHdr);
    916916
    917917        case VMMR0_DO_GMM_BALLOONED_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