Changeset 28036 in vbox
- Timestamp:
- Apr 7, 2010 9:47:43 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 59743
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/gmm.h
r28012 r28036 399 399 400 400 /** 401 * Request buffer for GMMR0Query TotalFreePagesReq / VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES.402 * @see GMMR0Query TotalFreePagesReq.403 */ 404 typedef struct GMM FREEQUERYREQ401 * Request buffer for GMMR0QueryVMMMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS. 402 * @see GMMR0QueryVMMMemoryStatsReq. 403 */ 404 typedef struct GMMMEMSTATSREQ 405 405 { 406 406 /** The header. */ 407 407 SUPVMMR0REQHDR Hdr; 408 /** The number of allocated pages (out). */ 409 uint64_t cAllocPages; 408 410 /** The number of free pages (out). */ 409 411 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. */ 416 typedef GMMMEMSTATSREQ *PGMMMEMSTATSREQ; 417 418 GMMR0DECL(int) GMMR0QueryVMMMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq); 415 419 416 420 /** … … 473 477 GMMR3DECL(int) GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3); 474 478 GMMR3DECL(int) GMMR3BalloonedPages(PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages); 475 GMMR3DECL(int) GMMR3Query TotalFreePages(PVM pVM, uint64_t *pcTotalFreePages);479 GMMR3DECL(int) GMMR3QueryVMMMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages); 476 480 /** @} */ 477 481 #endif /* IN_RING3 */ -
trunk/include/VBox/pgm.h
r28012 r28036 467 467 VMMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc); 468 468 VMMR3DECL(int) PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage); 469 VMMR3DECL(int) PGMR3Query FreeMemory(PVM pVM, unsigned *puTotalFreeSize);469 VMMR3DECL(int) PGMR3QueryVMMMemoryStats(PVM pVM, uint64_t *puTotalAllocSize, uint64_t *puTotalFreeSize, uint64_t *puTotalBalloonSize); 470 470 VMMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, 471 471 R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3, -
trunk/include/VBox/vmm.h
r28012 r28036 300 300 /** Call GMMR0FreeLargePage(). */ 301 301 VMMR0_DO_GMM_FREE_LARGE_PAGE, 302 /** Call GMMR0Query TotalFreePagesReq */303 VMMR0_DO_GMM_QUERY_ TOTAL_FREE_PAGES,302 /** Call GMMR0QueryVMMMemoryStatsReq */ 303 VMMR0_DO_GMM_QUERY_VMM_MEM_STATS, 304 304 /** Call GMMR0BalloonedPages(). */ 305 305 VMMR0_DO_GMM_BALLOONED_PAGES, -
trunk/src/VBox/Main/GuestImpl.cpp
r28032 r28036 255 255 STDMETHODIMP Guest::InternalGetStatistics(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle, 256 256 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) 258 259 { 259 260 CheckComArgOutPointerValid(aCpuUser); … … 283 284 if (pVM.isOk()) 284 285 { 285 u nsigned uFreeTotal;286 uint64_t uFreeTotal, uAllocTotal, uBalloonedTotal; 286 287 *aMemFreeTotal = 0; 287 int rc = PGMR3Query FreeMemory(pVM.raw(), &uFreeTotal);288 int rc = PGMR3QueryVMMMemoryStats(pVM.raw(), &uAllocTotal, &uFreeTotal, &uBalloonedTotal); 288 289 AssertRC(rc); 289 290 if (rc == VINF_SUCCESS) 290 *aMemFreeTotal = uFreeTotal; 291 { 292 *aMemAllocTotal = uAllocTotal / _1K; /* bytes -> KB */ 293 *aMemFreeTotal = uFreeTotal / _1K; 294 *aMemBalloonTotal = uBalloonedTotal / _1K; 295 } 291 296 } 292 297 else -
trunk/src/VBox/Main/HostImpl.cpp
r28012 r28036 2411 2411 pm::SubMetric *ramUsageFree = new pm::SubMetric("RAM/Usage/Free", 2412 2412 "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 2413 2420 2414 2421 /* Create and register base metrics */ … … 2422 2429 aCollector->registerBaseMetric (cpuMhz); 2423 2430 pm::BaseMetric *ramUsage = new pm::HostRamUsage(hal, objptr, ramUsageTotal, ramUsageUsed, 2424 ramUsageFree );2431 ramUsageFree, ramVMMUsed, ramVMMFree, ramVMMBallooned); 2425 2432 aCollector->registerBaseMetric (ramUsage); 2426 2433 … … 2480 2487 aCollector->registerMetric(new pm::Metric(ramUsage, ramUsageFree, 2481 2488 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())); 2482 2513 }; 2483 2514 -
trunk/src/VBox/Main/Performance.cpp
r28012 r28036 168 168 && iTick != mLastTick) 169 169 { 170 ULONG ulMem FreeTotal;170 ULONG ulMemAllocTotal, ulMemFreeTotal, ulMemBalloonTotal; 171 171 172 172 mGuest->InternalGetStatistics(&mCpuUser, &mCpuKernel, &mCpuIdle, 173 173 &mMemTotal, &mMemFree, &mMemBalloon, &mMemCache, 174 &mPageTotal, &ulMem FreeTotal);174 &mPageTotal, &ulMemAllocTotal, &ulMemFreeTotal, &ulMemBalloonTotal); 175 175 176 176 if (mHostHAL) 177 mHostHAL->setMem FreeTotal(ulMemFreeTotal);177 mHostHAL->setMemHypervisorStats(ulMemAllocTotal, ulMemFreeTotal, ulMemBalloonTotal); 178 178 179 179 mLastTick = iTick; … … 303 303 mTotal->put(total); 304 304 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); 307 314 } 308 315 … … 426 433 427 434 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)); 433 440 } 434 441 -
trunk/src/VBox/Main/PerformanceImpl.cpp
r28012 r28036 68 68 "RAM/Usage/Free:min", 69 69 "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", 70 82 "Guest/CPU/Load/User", 71 83 "Guest/CPU/Load/User:avg", -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r28032 r28036 8353 8353 <interface 8354 8354 name="IGuest" extends="$unknown" 8355 uuid=" 54ebdc27-89ca-4bf8-a58a-48077679a3af"8355 uuid="8cf03bf9-7478-42de-add8-10b2af75a06d" 8356 8356 wsmap="managed" 8357 8357 > … … 8450 8450 <desc>Total amount of space in the page file</desc> 8451 8451 </param> 8452 <param name="memAllocTotal" type="unsigned long" dir="out"> 8453 <desc>Total amount of memory allocated by the hypervisor</desc> 8454 </param> 8452 8455 <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> 8454 8460 </param> 8455 8461 </method> -
trunk/src/VBox/Main/include/GuestImpl.h
r28032 r28036 90 90 STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle, 91 91 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemCache, 92 ULONG *aPageTotal, ULONG *aMem FreeTotal);92 ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal); 93 93 94 94 // public methods that are not in IDL -
trunk/src/VBox/Main/include/Performance.h
r28012 r28036 139 139 { 140 140 public: 141 CollectorHAL() : mMem FreeTotal(0) {};141 CollectorHAL() : mMemAllocVMM(0), mMemFreeVMM(0), mMemBalloonedVMM(0) {}; 142 142 virtual ~CollectorHAL() { }; 143 143 virtual int preCollect(const CollectorHints& /* hints */, uint64_t /* iTick */) { return VINF_SUCCESS; } … … 163 163 virtual int disable(); 164 164 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; 168 170 return S_OK; 169 171 } 170 172 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; 178 184 }; 179 185 … … 201 207 } 202 208 203 /** Return guest memory information in kb. */209 /** Return guest memory information in MB. */ 204 210 void getGuestMemLoad(ULONG *pulMemTotal, ULONG *pulMemFree, ULONG *pulMemBalloon, ULONG *pulMemCache, ULONG *pulPageTotal) 205 211 { … … 335 341 { 336 342 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; }; 340 346 341 347 void init(ULONG period, ULONG length); … … 350 356 SubMetric *mUsed; 351 357 SubMetric *mAvailable; 358 SubMetric *mAllocVMM; 359 SubMetric *mFreeVMM; 360 SubMetric *mBalloonVMM; 352 361 }; 353 362 -
trunk/src/VBox/VMM/GMM.cpp
r28012 r28036 291 291 292 292 /** 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 */ 295 GMMR3DECL(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); 304 309 if (rc == VINF_SUCCESS) 305 *pcTotalFreePages = Req.cFreePages; 306 310 { 311 *pcTotalAllocPages = Req.cAllocPages; 312 *pcTotalFreePages = Req.cFreePages; 313 *pcTotalBalloonPages = Req.cBalloonedPages; 314 } 307 315 return rc; 308 316 } -
trunk/src/VBox/VMM/PGMPhys.cpp
r28012 r28036 958 958 * @returns VBox status code. 959 959 * @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 */ 964 VMMR3DECL(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; 965 974 966 975 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; 975 982 } 976 983 -
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r28012 r28036 2998 2998 * @param pReq The request packet. 2999 2999 */ 3000 GMMR0DECL(int) GMMR0Query TotalFreePagesReq(PVM pVM, PGMMFREEQUERYREQ pReq)3000 GMMR0DECL(int) GMMR0QueryVMMMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq) 3001 3001 { 3002 3002 /* … … 3005 3005 AssertPtrReturn(pVM, VERR_INVALID_POINTER); 3006 3006 AssertPtrReturn(pReq, VERR_INVALID_POINTER); 3007 AssertMsgReturn(pReq->Hdr.cbReq == sizeof(GMM FREEQUERYREQ),3008 ("%#x < %#x\n", pReq->Hdr.cbReq, sizeof(GMM FREEQUERYREQ)),3007 AssertMsgReturn(pReq->Hdr.cbReq == sizeof(GMMMEMSTATSREQ), 3008 ("%#x < %#x\n", pReq->Hdr.cbReq, sizeof(GMMMEMSTATSREQ)), 3009 3009 VERR_INVALID_PARAMETER); 3010 3010 … … 3014 3014 PGMM pGMM; 3015 3015 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; 3017 3019 GMM_CHECK_SANITY_UPON_LEAVING(pGMM); 3018 3020 -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r28012 r28036 910 910 return GMMR0FreeLargePageReq(pVM, idCpu, (PGMMFREELARGEPAGEREQ)pReqHdr); 911 911 912 case VMMR0_DO_GMM_QUERY_ TOTAL_FREE_PAGES:912 case VMMR0_DO_GMM_QUERY_VMM_MEM_STATS: 913 913 if (u64Arg) 914 914 return VERR_INVALID_PARAMETER; 915 return GMMR0Query TotalFreePagesReq(pVM, (PGMMFREEQUERYREQ)pReqHdr);915 return GMMR0QueryVMMMemoryStatsReq(pVM, (PGMMMEMSTATSREQ)pReqHdr); 916 916 917 917 case VMMR0_DO_GMM_BALLOONED_PAGES:
Note:
See TracChangeset
for help on using the changeset viewer.