VirtualBox

Changeset 28974 in vbox


Ignore:
Timestamp:
May 3, 2010 1:09:44 PM (15 years ago)
Author:
vboxsync
Message:

Dump GMM stats on PGMR3PhysAllocateHandyPages failure.

Location:
trunk
Files:
6 edited

Legend:

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

    r28809 r28974  
    399399
    400400/**
    401  * Request buffer for GMMR0QueryVMMMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS.
    402  * @see GMMR0QueryVMMMemoryStatsReq.
     401 * Request buffer for GMMR0QueryHypervisorMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS.
     402 * @see GMMR0QueryHypervisorMemoryStatsReq.
    403403 */
    404404typedef struct GMMMEMSTATSREQ
     
    412412    /** The number of ballooned pages (out). */
    413413    uint64_t            cBalloonedPages;
     414    /** Maximum nr of pages (out). */
     415    uint64_t            cMaxPages;
    414416} GMMMEMSTATSREQ;
    415 /** Pointer to a GMMR0QueryVMMMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS request buffer. */
     417/** Pointer to a GMMR0QueryHypervisorMemoryStatsReq / VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS request buffer. */
    416418typedef GMMMEMSTATSREQ *PGMMMEMSTATSREQ;
    417419
    418 GMMR0DECL(int)  GMMR0QueryVMMMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq);
     420GMMR0DECL(int)  GMMR0QueryHypervisorMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq);
     421GMMR0DECL(int)  GMMR0QueryMemoryStatsReq(PVM pVM, VMCPUID idCpu, PGMMMEMSTATSREQ pReq);
    419422
    420423/**
     
    532535GMMR3DECL(int)  GMMR3MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3);
    533536GMMR3DECL(int)  GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3);
     537GMMR3DECL(int)  GMMR3QueryHypervisorMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages);
     538GMMR3DECL(int)  GMMR3QueryMemoryStats(PVM pVM, uint64_t *pcAllocPages, uint64_t *pcMaxPages, uint64_t *pcBalloonPages);
    534539GMMR3DECL(int)  GMMR3BalloonedPages(PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
    535 GMMR3DECL(int)  GMMR3QueryVMMMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages);
    536540GMMR3DECL(int)  GMMR3RegisterSharedModule(PVM pVM, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule,
    537541                                          unsigned cRegions, VMMDEVSHAREDREGIONDESC *pRegions);
  • trunk/include/VBox/vmm.h

    r28800 r28974  
    296296    /** Call GMMR0FreeLargePage(). */
    297297    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,
    300302    /** Call GMMR0BalloonedPages(). */
    301303    VMMR0_DO_GMM_BALLOONED_PAGES,
  • trunk/src/VBox/VMM/GMM.cpp

    r28800 r28974  
    290290 * @see GMMR0QueryVMMMemoryStatsReq
    291291 */
    292 GMMR3DECL(int)  GMMR3QueryVMMMemoryStats(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)
    293293{
    294294    GMMMEMSTATSREQ Req;
     
    304304
    305305    /* 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);
    307307    if (rc == VINF_SUCCESS)
    308308    {
     
    310310        *pcTotalFreePages    = Req.cFreePages;
    311311        *pcTotalBalloonPages = Req.cBalloonedPages;
     312    }
     313    return rc;
     314}
     315
     316/**
     317 * @see GMMR0QueryMemoryStatsReq
     318 */
     319GMMR3DECL(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;
    312339    }
    313340    return rc;
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r28800 r28974  
    966966
    967967    uint64_t cAllocPages = 0, cFreePages = 0, cBalloonPages = 0;
    968     rc = GMMR3QueryVMMMemoryStats(pVM, &cAllocPages, &cFreePages, &cBalloonPages);
     968    rc = GMMR3QueryHypervisorMemoryStats(pVM, &cAllocPages, &cFreePages, &cBalloonPages);
    969969    AssertRCReturn(rc, rc);
    970970
     
    34753475    else
    34763476    {
     3477        uint64_t cAllocPages, cMaxPages, cBalloonPages;
     3478
    34773479        /*
    34783480         * We should never get here unless there is a genuine shortage of
     
    34903492                pVM->pgm.s.cSharedPages,
    34913493                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
    34923503        if (    rc != VERR_NO_MEMORY
    34933504            &&  rc != VERR_LOCK_FAILED)
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r28806 r28974  
    29912991
    29922992/**
    2993  * Return the total amount of free pages
     2993 * Return memory statistics for the hypervisor
    29942994 *
    29952995 * @returns VBox status code:
     
    29972997 * @param   pReq            The request packet.
    29982998 */
    2999 GMMR0DECL(int) GMMR0QueryVMMMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq)
     2999GMMR0DECL(int) GMMR0QueryHypervisorMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq)
    30003000{
    30013001    /*
     
    30163016    pReq->cFreePages      = (pGMM->cChunks << (GMM_CHUNK_SHIFT- PAGE_SHIFT)) - pGMM->cAllocatedPages;
    30173017    pReq->cBalloonedPages = pGMM->cBalloonedPages;
     3018    pReq->cMaxPages       = pGMM->cMaxPages;
    30183019    GMM_CHECK_SANITY_UPON_LEAVING(pGMM);
    30193020
    30203021    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 */
     3032GMMR0DECL(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;
    30213071}
    30223072
     
    34163466GMMR0DECL(int) GMMR0UnregisterSharedModule(PVM pVM, VMCPUID idCpu, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule)
    34173467{
     3468#ifdef VBOX_WITH_PAGE_SHARING
    34183469    return VERR_NOT_IMPLEMENTED;
     3470#else
     3471    return VERR_NOT_IMPLEMENTED;
     3472#endif
    34193473}
    34203474
     
    34413495
    34423496/**
    3443  * Checks regsitered modules for shared pages
     3497 * Checks registered modules for shared pages
    34443498 *
    34453499 * @returns VBox status code.
     
    34493503GMMR0DECL(int) GMMR0CheckSharedModules(PVM pVM, VMCPUID idCpu)
    34503504{
     3505#ifdef VBOX_WITH_PAGE_SHARING
    34513506    return VERR_NOT_IMPLEMENTED;
    3452 }
     3507#else
     3508    return VERR_NOT_IMPLEMENTED;
     3509#endif
     3510}
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r28800 r28974  
    905905            return GMMR0FreeLargePageReq(pVM, idCpu, (PGMMFREELARGEPAGEREQ)pReqHdr);
    906906
    907         case VMMR0_DO_GMM_QUERY_VMM_MEM_STATS:
     907        case VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS:
    908908            if (u64Arg)
    909909                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);
    911918
    912919        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