VirtualBox

Changeset 28806 in vbox


Ignore:
Timestamp:
Apr 27, 2010 9:58:07 AM (15 years ago)
Author:
vboxsync
Message:

Page sharing updates

Location:
trunk/src/VBox/VMM/VMMR0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r28800 r28806  
    483483    GMMCHUNKFREESET     Shared;
    484484
     485    /** Shared module tree (global). */
     486    PAVLGCPTRNODECORE   pSharedModuleTree;
     487
    485488    /** The maximum number of pages we're allowed to allocate.
    486489     * @gcfgm   64-bit GMM/MaxPages Direct.
     
    33273330                                         unsigned cRegions, VMMDEVSHAREDREGIONDESC *pRegions)
    33283331{
     3332#ifdef VBOX_WITH_PAGE_SHARING
     3333    /*
     3334     * Validate input and get the basics.
     3335     */
     3336    PGMM pGMM;
     3337    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
     3338    PGVM pGVM;
     3339    int rc = GVMMR0ByVMAndEMT(pVM, idCpu, &pGVM);
     3340    if (RT_FAILURE(rc))
     3341        return rc;
     3342
     3343    /*
     3344     * Take the sempahore and do some more validations.
     3345     */
     3346    rc = RTSemFastMutexRequest(pGMM->Mtx);
     3347    AssertRC(rc);
     3348    if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM))
     3349    {
     3350        /* Check if this module was already globally registered. */
     3351        PGMMSHAREDMODULE pRec = (PGMMSHAREDMODULE)RTAvlGCPtrGet(&pGMM->pSharedModuleTree, GCBaseAddr);
     3352        if (!pRec)
     3353        {
     3354            pRec = (PGMMSHAREDMODULE)RTMemAllocZ(RT_OFFSETOF(GMMSHAREDMODULE, aRegions[cRegions]));
     3355            pRec->Core.Key = GCBaseAddr;
     3356            pRec->cbModule = cbModule;
     3357            /* Input limit already safe; no need to check again. */
     3358            strcpy(pRec->szName, pszModuleName);
     3359            strcpy(pRec->szVersion, pszVersion);
     3360
     3361            pRec->cRegions = cRegions;
     3362
     3363            for (unsigned i = 0; i < cRegions; i++)
     3364                pRec->aRegions[i] = pRegions[i];
     3365
     3366            /** @todo references to pages */
     3367        }
     3368        else
     3369        {
     3370        }
     3371
     3372        GMM_CHECK_SANITY_UPON_LEAVING(pGMM);
     3373    }
     3374    else
     3375        rc = VERR_INTERNAL_ERROR_5;
     3376
     3377    RTSemFastMutexRelease(pGMM->Mtx);
     3378    return rc;
     3379#else
    33293380    return VERR_NOT_IMPLEMENTED;
     3381#endif
    33303382}
    33313383
  • trunk/src/VBox/VMM/VMMR0/GMMR0Internal.h

    r28800 r28806  
    2020
    2121#include <VBox/gmm.h>
     22#include <iprt/avl.h>
    2223
    2324/**
     
    3839
    3940/**
     41 * Shared module registration info
     42 */
     43typedef struct GMMSHAREDMODULE
     44{
     45    /* Tree node. */
     46    AVLGCPTRNODECORE            Core;
     47    /** Shared module size. */
     48    uint32_t                    cbModule;
     49    /** Number of included region descriptors */
     50    uint32_t                    cRegions;
     51    /** Module name */
     52    char                        szName[GMM_SHARED_MODULE_MAX_NAME_STRING];
     53    /** Module version */
     54    char                        szVersion[GMM_SHARED_MODULE_MAX_VERSION_STRING];
     55    /** Shared region descriptor(s). */
     56    VMMDEVSHAREDREGIONDESC      aRegions[1];
     57} GMMSHAREDMODULE;
     58/** Pointer to a GMMMODULE. */
     59typedef GMMSHAREDMODULE *PGMMSHAREDMODULE;
     60
     61/**
    4062 * The per-VM GMM data.
    4163 */
     
    4365{
    4466    /** The reservations. */
    45     GMMVMSIZES      Reserved;
     67    GMMVMSIZES          Reserved;
    4668    /** The actual allocations.
    4769     * This includes both private and shared page allocations. */
    48     GMMVMSIZES      Allocated;
     70    GMMVMSIZES          Allocated;
    4971
    5072    /** The current number of private pages. */
    51     uint64_t        cPrivatePages;
     73    uint64_t            cPrivatePages;
    5274    /** The current number of shared pages. */
    53     uint64_t        cSharedPages;
     75    uint64_t            cSharedPages;
    5476    /** The current over-comitment policy. */
    55     GMMOCPOLICY     enmPolicy;
     77    GMMOCPOLICY         enmPolicy;
    5678    /** The VM priority for arbitrating VMs in low and out of memory situation.
    5779     * Like which VMs to start sequeezing first. */
    58     GMMPRIORITY     enmPriority;
     80    GMMPRIORITY         enmPriority;
    5981
    6082    /** The current number of ballooned pages. */
    61     uint64_t        cBalloonedPages;
     83    uint64_t            cBalloonedPages;
    6284    /** The max number of pages that can be ballooned. */
    63     uint64_t        cMaxBalloonedPages;
     85    uint64_t            cMaxBalloonedPages;
    6486    /** The number of pages we've currently requested the guest to give us.
    6587     * This is 0 if no pages currently requested. */
    66     uint64_t        cReqBalloonedPages;
     88    uint64_t            cReqBalloonedPages;
    6789    /** The number of pages the guest has given us in response to the request.
    6890     * This is not reset on request completed and may be used in later decisions. */
    69     uint64_t        cReqActuallyBalloonedPages;
     91    uint64_t            cReqActuallyBalloonedPages;
    7092    /** The number of pages we've currently requested the guest to take back. */
    71     uint64_t        cReqDeflatePages;
     93    uint64_t            cReqDeflatePages;
     94
    7295    /** Whether ballooning is enabled or not. */
    73     bool            fBallooningEnabled;
     96    bool                fBallooningEnabled;
     97
     98    /** Whether shared paging is enabled or not. */
     99    bool                fSharedPagingEnabled;
    74100
    75101    /** Whether the VM is allowed to allocate memory or not.
    76102     * This is used when the reservation update request fails or when the VM has
    77103     * been told to suspend/save/die in an out-of-memory case. */
    78     bool            fMayAllocate;
     104    bool                fMayAllocate;
    79105} GMMPERVM;
    80106/** Pointer to the per-VM GMM data. */
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