VirtualBox

Changeset 26542 in vbox


Ignore:
Timestamp:
Feb 15, 2010 1:54:20 PM (15 years ago)
Author:
vboxsync
Message:

Preparations for large page use

File:
1 edited

Legend:

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

    r26413 r26542  
    366366/** Pointer to a GMM allocation chunk mapping. */
    367367typedef struct GMMCHUNKMAP *PGMMCHUNKMAP;
     368
     369typedef enum GMMCHUNKTYPE
     370{
     371    GMMCHUNKTYPE_INVALID        = 0,
     372    GMMCHUNKTYPE_NON_CONTINUOUS = 1,      /* 4 kb pages */
     373    GMMCHUNKTYPE_CONTINUOUS     = 2,      /* one 2 MB continuous physical range. */
     374    GMMCHUNKTYPE_32BIT_HACK     = 0x7fffffff
     375} GMMCHUNKTYPE;
    368376
    369377
     
    403411    /** The number of shared pages. */
    404412    uint16_t            cShared;
    405 #if HC_ARCH_BITS == 64
    406     /** Reserved for later. */
    407     uint16_t            au16Reserved[2];
    408 #endif
     413    /** Chunk type */
     414    GMMCHUNKTYPE        enmType;
    409415    /** The pages. */
    410416    GMMPAGE             aPages[GMM_CHUNK_SIZE >> PAGE_SHIFT];
     
    15271533 *
    15281534 * @returns VBox status code.
    1529  * @param   pGMM        Pointer to the GMM instance.
    1530  * @param   pSet        Pointer to the set.
    1531  * @param   MemObj      The memory object for the chunk.
    1532  * @param   hGVM        The affinity of the chunk. NIL_GVM_HANDLE for no
    1533  *                      affinity.
    1534  */
    1535 static int gmmR0RegisterChunk(PGMM pGMM, PGMMCHUNKFREESET pSet, RTR0MEMOBJ MemObj, uint16_t hGVM)
     1535 * @param   pGMM            Pointer to the GMM instance.
     1536 * @param   pSet            Pointer to the set.
     1537 * @param   MemObj          The memory object for the chunk.
     1538 * @param   hGVM            The affinity of the chunk. NIL_GVM_HANDLE for no
     1539 *                          affinity.
     1540 * @param   enmChunkType    Chunk type (continuous or non-continuous)
     1541 */
     1542static int gmmR0RegisterChunk(PGMM pGMM, PGMMCHUNKFREESET pSet, RTR0MEMOBJ MemObj, uint16_t hGVM, GMMCHUNKTYPE enmChunkType)
    15361543{
    15371544    Assert(hGVM != NIL_GVM_HANDLE || pGMM->fBoundMemoryMode);
     
    15481555        pChunk->hGVM = hGVM;
    15491556        pChunk->iFreeHead = 0;
     1557        pChunk->enmType = enmChunkType;
    15501558        for (unsigned iPage = 0; iPage < RT_ELEMENTS(pChunk->aPages) - 1; iPage++)
    15511559        {
     
    15991607 *
    16001608 * @returns VBox status code.
    1601  * @param   pGMM        Pointer to the GMM instance.
    1602  * @param   pSet        Pointer to the set.
    1603  * @param   hGVM        The affinity of the new chunk.
     1609 * @param   pGMM            Pointer to the GMM instance.
     1610 * @param   pSet            Pointer to the set.
     1611 * @param   hGVM            The affinity of the new chunk.
     1612 * @param   enmChunkType    Chunk type (continuous or non-continuous)
    16041613 *
    16051614 * @remarks Called without owning the mutex.
    16061615 */
    1607 static int gmmR0AllocateOneChunk(PGMM pGMM, PGMMCHUNKFREESET pSet, uint16_t hGVM)
     1616static int gmmR0AllocateOneChunk(PGMM pGMM, PGMMCHUNKFREESET pSet, uint16_t hGVM, GMMCHUNKTYPE enmChunkType)
    16081617{
    16091618    /*
     
    16111620     */
    16121621    RTR0MEMOBJ MemObj;
    1613     int rc = RTR0MemObjAllocPhysNC(&MemObj, GMM_CHUNK_SIZE, NIL_RTHCPHYS);
     1622    int        rc;
     1623
     1624    AssertCompile(GMM_CHUNK_SIZE == _2M);
     1625    AssertReturn(enmChunkType == GMMCHUNKTYPE_NON_CONTINUOUS || enmChunkType == GMMCHUNKTYPE_CONTINUOUS, VERR_INVALID_PARAMETER);
     1626
     1627    if (enmChunkType == GMMCHUNKTYPE_NON_CONTINUOUS)
     1628        rc = RTR0MemObjAllocPhysNC(&MemObj, GMM_CHUNK_SIZE, NIL_RTHCPHYS);
     1629    else
     1630        rc = RTR0MemObjAllocPhysEx(&MemObj, GMM_CHUNK_SIZE, NIL_RTHCPHYS, GMM_CHUNK_SIZE);
     1631
    16141632    if (RT_SUCCESS(rc))
    16151633    {
    1616         rc = gmmR0RegisterChunk(pGMM, pSet, MemObj, hGVM);
     1634        rc = gmmR0RegisterChunk(pGMM, pSet, MemObj, hGVM, enmChunkType);
    16171635        if (RT_FAILURE(rc))
    16181636            RTR0MemObjFree(MemObj, false /* fFreeMappings */);
     
    16701688        {
    16711689            RTSemFastMutexRelease(pGMM->Mtx);
    1672             int rc = gmmR0AllocateOneChunk(pGMM, pSet, pGVM->hSelf);
     1690            int rc = gmmR0AllocateOneChunk(pGMM, pSet, pGVM->hSelf, GMMCHUNKTYPE_NON_CONTINUOUS);
    16731691            int rc2 = RTSemFastMutexRequest(pGMM->Mtx);
    16741692            AssertRCReturn(rc2, rc2);
     
    17071725            /* Allocate more. */
    17081726            RTSemFastMutexRelease(pGMM->Mtx);
    1709             int rc = gmmR0AllocateOneChunk(pGMM, pSet, hGVM);
     1727            int rc = gmmR0AllocateOneChunk(pGMM, pSet, hGVM, GMMCHUNKTYPE_NON_CONTINUOUS);
    17101728            int rc2 = RTSemFastMutexRequest(pGMM->Mtx);
    17111729            AssertRCReturn(rc2, rc2);
     
    31183136         * Add a new chunk with our hGVM.
    31193137         */
    3120         rc = gmmR0RegisterChunk(pGMM, &pGMM->Private, MemObj, pGVM->hSelf);
     3138        rc = gmmR0RegisterChunk(pGMM, &pGMM->Private, MemObj, pGVM->hSelf, GMMCHUNKTYPE_NON_CONTINUOUS);
    31213139        if (RT_FAILURE(rc))
    31223140            RTR0MemObjFree(MemObj, false /* fFreeMappings */);
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