Changeset 28974 in vbox
- Timestamp:
- May 3, 2010 1:09:44 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/gmm.h
r28809 r28974 399 399 400 400 /** 401 * Request buffer for GMMR0Query VMMMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS.402 * @see GMMR0Query VMMMemoryStatsReq.401 * Request buffer for GMMR0QueryHypervisorMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS. 402 * @see GMMR0QueryHypervisorMemoryStatsReq. 403 403 */ 404 404 typedef struct GMMMEMSTATSREQ … … 412 412 /** The number of ballooned pages (out). */ 413 413 uint64_t cBalloonedPages; 414 /** Maximum nr of pages (out). */ 415 uint64_t cMaxPages; 414 416 } GMMMEMSTATSREQ; 415 /** Pointer to a GMMR0Query VMMMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS request buffer. */417 /** Pointer to a GMMR0QueryHypervisorMemoryStatsReq / VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS request buffer. */ 416 418 typedef GMMMEMSTATSREQ *PGMMMEMSTATSREQ; 417 419 418 GMMR0DECL(int) GMMR0QueryVMMMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq); 420 GMMR0DECL(int) GMMR0QueryHypervisorMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq); 421 GMMR0DECL(int) GMMR0QueryMemoryStatsReq(PVM pVM, VMCPUID idCpu, PGMMMEMSTATSREQ pReq); 419 422 420 423 /** … … 532 535 GMMR3DECL(int) GMMR3MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3); 533 536 GMMR3DECL(int) GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3); 537 GMMR3DECL(int) GMMR3QueryHypervisorMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages); 538 GMMR3DECL(int) GMMR3QueryMemoryStats(PVM pVM, uint64_t *pcAllocPages, uint64_t *pcMaxPages, uint64_t *pcBalloonPages); 534 539 GMMR3DECL(int) GMMR3BalloonedPages(PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages); 535 GMMR3DECL(int) GMMR3QueryVMMMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages);536 540 GMMR3DECL(int) GMMR3RegisterSharedModule(PVM pVM, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule, 537 541 unsigned cRegions, VMMDEVSHAREDREGIONDESC *pRegions); -
trunk/include/VBox/vmm.h
r28800 r28974 296 296 /** Call GMMR0FreeLargePage(). */ 297 297 VMMR0_DO_GMM_FREE_LARGE_PAGE, 298 /** Call GMMR0QueryVMMMemoryStatsReq(). */ 299 VMMR0_DO_GMM_QUERY_VMM_MEM_STATS, 298 /** Call GMMR0QueryHypervisorMemoryStatsReq(). */ 299 VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS, 300 /** Call GMMR0QueryMemoryStatsReq(). */ 301 VMMR0_DO_GMM_QUERY_MEM_STATS, 300 302 /** Call GMMR0BalloonedPages(). */ 301 303 VMMR0_DO_GMM_BALLOONED_PAGES, -
trunk/src/VBox/VMM/GMM.cpp
r28800 r28974 290 290 * @see GMMR0QueryVMMMemoryStatsReq 291 291 */ 292 GMMR3DECL(int) GMMR3Query VMMMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages)292 GMMR3DECL(int) GMMR3QueryHypervisorMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages) 293 293 { 294 294 GMMMEMSTATSREQ Req; … … 304 304 305 305 /* Must be callable from any thread, so can't use VMMR3CallR0. */ 306 int rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0, VMMR0_DO_GMM_QUERY_ VMM_MEM_STATS, 0, &Req.Hdr);306 int rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0, VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS, 0, &Req.Hdr); 307 307 if (rc == VINF_SUCCESS) 308 308 { … … 310 310 *pcTotalFreePages = Req.cFreePages; 311 311 *pcTotalBalloonPages = Req.cBalloonedPages; 312 } 313 return rc; 314 } 315 316 /** 317 * @see GMMR0QueryMemoryStatsReq 318 */ 319 GMMR3DECL(int) GMMR3QueryMemoryStats(PVM pVM, uint64_t *pcAllocPages, uint64_t *pcMaxPages, uint64_t *pcBalloonPages) 320 { 321 GMMMEMSTATSREQ Req; 322 Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 323 Req.Hdr.cbReq = sizeof(Req); 324 Req.cAllocPages = 0; 325 Req.cFreePages = 0; 326 Req.cBalloonedPages = 0; 327 328 *pcAllocPages = 0; 329 *pcMaxPages = 0; 330 *pcBalloonPages = 0; 331 332 /* Must be callable from any thread, so can't use VMMR3CallR0. */ 333 int rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0, VMMR0_DO_GMM_QUERY_MEM_STATS, 0, &Req.Hdr); 334 if (rc == VINF_SUCCESS) 335 { 336 *pcAllocPages = Req.cAllocPages; 337 *pcMaxPages = Req.cMaxPages; 338 *pcBalloonPages = Req.cBalloonedPages; 312 339 } 313 340 return rc; -
trunk/src/VBox/VMM/PGMPhys.cpp
r28800 r28974 966 966 967 967 uint64_t cAllocPages = 0, cFreePages = 0, cBalloonPages = 0; 968 rc = GMMR3Query VMMMemoryStats(pVM, &cAllocPages, &cFreePages, &cBalloonPages);968 rc = GMMR3QueryHypervisorMemoryStats(pVM, &cAllocPages, &cFreePages, &cBalloonPages); 969 969 AssertRCReturn(rc, rc); 970 970 … … 3475 3475 else 3476 3476 { 3477 uint64_t cAllocPages, cMaxPages, cBalloonPages; 3478 3477 3479 /* 3478 3480 * We should never get here unless there is a genuine shortage of … … 3490 3492 pVM->pgm.s.cSharedPages, 3491 3493 pVM->pgm.s.cZeroPages)); 3494 3495 if (GMMR3QueryMemoryStats(pVM, &cAllocPages, &cMaxPages, &cBalloonPages) == VINF_SUCCESS) 3496 { 3497 LogRel(("GMM: Statistics:\n" 3498 " Allocated pages: %RX64\n" 3499 " Maximum pages: %RX64\n" 3500 " Ballooned pages: %RX64\n", cAllocPages, cMaxPages, cBalloonPages)); 3501 } 3502 3492 3503 if ( rc != VERR_NO_MEMORY 3493 3504 && rc != VERR_LOCK_FAILED) -
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r28806 r28974 2991 2991 2992 2992 /** 2993 * Return the total amount of free pages2993 * Return memory statistics for the hypervisor 2994 2994 * 2995 2995 * @returns VBox status code: … … 2997 2997 * @param pReq The request packet. 2998 2998 */ 2999 GMMR0DECL(int) GMMR0Query VMMMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq)2999 GMMR0DECL(int) GMMR0QueryHypervisorMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq) 3000 3000 { 3001 3001 /* … … 3016 3016 pReq->cFreePages = (pGMM->cChunks << (GMM_CHUNK_SHIFT- PAGE_SHIFT)) - pGMM->cAllocatedPages; 3017 3017 pReq->cBalloonedPages = pGMM->cBalloonedPages; 3018 pReq->cMaxPages = pGMM->cMaxPages; 3018 3019 GMM_CHECK_SANITY_UPON_LEAVING(pGMM); 3019 3020 3020 3021 return VINF_SUCCESS; 3022 } 3023 3024 /** 3025 * Return memory statistics for the VM 3026 * 3027 * @returns VBox status code: 3028 * @param pVM Pointer to the shared VM structure. 3029 * @parma idCpu Cpu id. 3030 * @param pReq The request packet. 3031 */ 3032 GMMR0DECL(int) GMMR0QueryMemoryStatsReq(PVM pVM, VMCPUID idCpu, PGMMMEMSTATSREQ pReq) 3033 { 3034 /* 3035 * Validate input and pass it on. 3036 */ 3037 AssertPtrReturn(pVM, VERR_INVALID_POINTER); 3038 AssertPtrReturn(pReq, VERR_INVALID_POINTER); 3039 AssertMsgReturn(pReq->Hdr.cbReq == sizeof(GMMMEMSTATSREQ), 3040 ("%#x < %#x\n", pReq->Hdr.cbReq, sizeof(GMMMEMSTATSREQ)), 3041 VERR_INVALID_PARAMETER); 3042 3043 /* 3044 * Validate input and get the basics. 3045 */ 3046 PGMM pGMM; 3047 GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR); 3048 PGVM pGVM; 3049 int rc = GVMMR0ByVMAndEMT(pVM, idCpu, &pGVM); 3050 if (RT_FAILURE(rc)) 3051 return rc; 3052 3053 /* 3054 * Take the sempahore and do some more validations. 3055 */ 3056 rc = RTSemFastMutexRequest(pGMM->Mtx); 3057 AssertRC(rc); 3058 if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM)) 3059 { 3060 pReq->cAllocPages = pGVM->gmm.s.Allocated.cBasePages; 3061 pReq->cBalloonedPages = pGVM->gmm.s.cBalloonedPages; 3062 pReq->cMaxPages = pGVM->gmm.s.Reserved.cBasePages; 3063 pReq->cFreePages = pReq->cMaxPages - pReq->cAllocPages; 3064 } 3065 else 3066 rc = VERR_INTERNAL_ERROR_5; 3067 3068 RTSemFastMutexRelease(pGMM->Mtx); 3069 LogFlow(("GMMR3QueryVMMemoryStats: returns %Rrc\n", rc)); 3070 return rc; 3021 3071 } 3022 3072 … … 3416 3466 GMMR0DECL(int) GMMR0UnregisterSharedModule(PVM pVM, VMCPUID idCpu, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule) 3417 3467 { 3468 #ifdef VBOX_WITH_PAGE_SHARING 3418 3469 return VERR_NOT_IMPLEMENTED; 3470 #else 3471 return VERR_NOT_IMPLEMENTED; 3472 #endif 3419 3473 } 3420 3474 … … 3441 3495 3442 3496 /** 3443 * Checks reg sitered modules for shared pages3497 * Checks registered modules for shared pages 3444 3498 * 3445 3499 * @returns VBox status code. … … 3449 3503 GMMR0DECL(int) GMMR0CheckSharedModules(PVM pVM, VMCPUID idCpu) 3450 3504 { 3505 #ifdef VBOX_WITH_PAGE_SHARING 3451 3506 return VERR_NOT_IMPLEMENTED; 3452 } 3507 #else 3508 return VERR_NOT_IMPLEMENTED; 3509 #endif 3510 } -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r28800 r28974 905 905 return GMMR0FreeLargePageReq(pVM, idCpu, (PGMMFREELARGEPAGEREQ)pReqHdr); 906 906 907 case VMMR0_DO_GMM_QUERY_ VMM_MEM_STATS:907 case VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS: 908 908 if (u64Arg) 909 909 return VERR_INVALID_PARAMETER; 910 return GMMR0QueryVMMMemoryStatsReq(pVM, (PGMMMEMSTATSREQ)pReqHdr); 910 return GMMR0QueryHypervisorMemoryStatsReq(pVM, (PGMMMEMSTATSREQ)pReqHdr); 911 912 case VMMR0_DO_GMM_QUERY_MEM_STATS: 913 if (idCpu == NIL_VMCPUID) 914 return VERR_INVALID_CPU_ID; 915 if (u64Arg) 916 return VERR_INVALID_PARAMETER; 917 return GMMR0QueryMemoryStatsReq(pVM, idCpu, (PGMMMEMSTATSREQ)pReqHdr); 911 918 912 919 case VMMR0_DO_GMM_BALLOONED_PAGES:
Note:
See TracChangeset
for help on using the changeset viewer.