VirtualBox

Changeset 36970 in vbox


Ignore:
Timestamp:
May 5, 2011 10:05:34 AM (14 years ago)
Author:
vboxsync
Message:

GMM: Adjusted the mapping array allocation 'strategy' to conserve memory. Cleanups.

File:
1 edited

Legend:

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

    r36944 r36970  
    362362{
    363363    /** The mapping object. */
    364     RTR0MEMOBJ      MapObj;
     364    RTR0MEMOBJ          MapObj;
    365365    /** The VM owning the mapping. */
    366     PGVM            pGVM;
     366    PGVM                pGVM;
    367367} GMMCHUNKMAP;
    368368/** Pointer to a GMM allocation chunk mapping. */
     
    426426{
    427427    /** The chunk id. */
    428     uint32_t        idChunk;
     428    uint32_t            idChunk;
    429429    /** Pointer to the chunk. */
    430     PGMMCHUNK       pChunk;
     430    PGMMCHUNK           pChunk;
    431431} GMMCHUNKTLBE;
    432432/** Pointer to an allocation chunk TLB entry. */
     
    464464{
    465465    /** The number of free pages in the set. */
    466     uint64_t        cFreePages;
     466    uint64_t            cFreePages;
    467467    /** Chunks ordered by increasing number of free pages. */
    468     PGMMCHUNK       apLists[GMM_CHUNK_FREE_SET_LISTS];
     468    PGMMCHUNK           apLists[GMM_CHUNK_FREE_SET_LISTS];
    469469} GMMCHUNKFREESET;
    470470
     
    10691069    {
    10701070        if (pChunk->paMappings[i].pGVM != pGVM)
    1071             SUPR0Printf("gmmR0CleanupVMDestroyChunk: %p/%#x: mapping #%x: pGVM=%p exepcted %p\n", pChunk,
     1071            SUPR0Printf("gmmR0CleanupVMDestroyChunk: %p/%#x: mapping #%x: pGVM=%p expected %p\n", pChunk,
    10721072                        pChunk->Core.Key, i, pChunk->paMappings[i].pGVM, pGVM);
    10731073        int rc = RTR0MemObjFree(pChunk->paMappings[i].MapObj, false /* fFreeMappings (NA) */);
     
    25292529    {
    25302530        /** @todo R0 -> VM request */
    2531         /* The chunk can be owned by more than one VM if fBoundMemoryMode is false! */
     2531        /* The chunk can be mapped by more than one VM if fBoundMemoryMode is false! */
    25322532        Log(("gmmR0FreeChunk: chunk still has %d mappings; don't free!\n", pChunk->cMappings));
    25332533    }
     
    32783278    if (RT_SUCCESS(rc))
    32793279    {
    3280         /* reallocate the array? */
    3281         if ((pChunk->cMappings & 1 /*7*/) == 0)
    3282         {
    3283             void *pvMappings = RTMemRealloc(pChunk->paMappings, (pChunk->cMappings + 2 /*8*/) * sizeof(pChunk->paMappings[0]));
     3280        /* reallocate the array? assumes few users per chunk (usually one). */
     3281        if (   pChunk->cMappings <= 3
     3282            || (pChunk->cMappings & 3) == 0)
     3283        {
     3284            unsigned cNewSize = pChunk->cMappings <= 3
     3285                              ? pChunk->cMappings + 1
     3286                              : pChunk->cMappings + 4;
     3287            Assert(cNewSize < 4 || RT_ALIGN_32(cNewSize, 4) == cNewSize);
     3288            void *pvMappings = RTMemRealloc(pChunk->paMappings, cNewSize * sizeof(pChunk->paMappings[0]));
    32843289            if (RT_UNLIKELY(!pvMappings))
    32853290            {
     
    32933298        /* insert new entry */
    32943299        pChunk->paMappings[pChunk->cMappings].MapObj = MapObj;
    3295         pChunk->paMappings[pChunk->cMappings].pGVM = pGVM;
     3300        pChunk->paMappings[pChunk->cMappings].pGVM   = pGVM;
    32963301        pChunk->cMappings++;
    32973302
     
    33013306    return rc;
    33023307}
     3308
    33033309
    33043310/**
     
    33273333    return false;
    33283334}
     3335
    33293336
    33303337/**
     
    38493856}
    38503857
    3851 
    38523858#ifdef VBOX_WITH_PAGE_SHARING
     3859
    38533860/**
    38543861 * Checks specified shared module range for changes
     
    40574064    return 0;
    40584065}
    4059 #endif
     4066
     4067#endif /* VBOX_WITH_PAGE_SHARING */
    40604068
    40614069/**
     
    41034111
    41044112#ifdef VBOX_WITH_PAGE_SHARING
     4113
    41054114typedef struct
    41064115{
     
    41294138    return 0;
    41304139}
    4131 #endif
    4132 
     4140
     4141#endif /* VBOX_WITH_PAGE_SHARING */
    41334142#ifdef DEBUG_sandervl
     4143
    41344144/**
    41354145 * Setup for a GMMR0CheckSharedModules call (to allow log flush jumps back to ring 3)
     
    41764186    return VINF_SUCCESS;
    41774187}
    4178 #endif
     4188
     4189#endif /* DEBUG_sandervl */
    41794190
    41804191/**
     
    42354246
    42364247#if defined(VBOX_STRICT) && HC_ARCH_BITS == 64
     4248
    42374249typedef struct
    42384250{
     
    42914303}
    42924304
     4305
    42934306/**
    42944307 * Find a duplicate of the specified page in other active VMs
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