VirtualBox

Changeset 37214 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
May 25, 2011 2:38:28 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71916
Message:

GMMR0: Added a dedicated for empty chunks.

File:
1 edited

Legend:

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

    r37213 r37214  
    467467
    468468
    469 /** The GMMCHUNK::cFree shift count. */
     469/** The GMMCHUNK::cFree shift count employed by gmmR0SelectFreeSetList. */
    470470#define GMM_CHUNK_FREE_SET_SHIFT    4
     471/** Index of the list containing completely unused chunks.
     472 * The code ASSUMES this is the last list. */
     473#define GMM_CHUNK_FREE_SET_UNUSED_LIST  (GMM_CHUNK_NUM_PAGES >> GMM_CHUNK_FREE_SET_SHIFT)
     474
    471475
    472476
     
    481485     *  something is linked or unlinked from this set. */
    482486    uint64_t            idGeneration;
    483     /** Chunks ordered by increasing number of free pages. */
    484     PGMMCHUNK           apLists[GMM_CHUNK_NUM_PAGES >> GMM_CHUNK_FREE_SET_SHIFT];
     487    /** Chunks ordered by increasing number of free pages.
     488     *  In the final list the chunks are completely unused. */
     489    PGMMCHUNK           apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST + 1];
    485490} GMMCHUNKFREESET;
    486491
     
    12461251            fRedoFromStart = false;
    12471252            iCountDown = 10240;
    1248             pChunk = pGMM->Private.apLists[RT_ELEMENTS(pGMM->Private.apLists) - 1];
     1253            pChunk = pGMM->Private.apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST];
    12491254            while (pChunk)
    12501255            {
    12511256                PGMMCHUNK pNext = pChunk->pFreeNext;
    1252                 if (    pChunk->cFree == GMM_CHUNK_NUM_PAGES
    1253                     && (   !pGMM->fBoundMemoryMode
    1254                          || pChunk->hGVM == pGVM->hSelf))
     1257                Assert(pChunk->cFree == GMM_CHUNK_NUM_PAGES);
     1258                if (   !pGMM->fBoundMemoryMode
     1259                    || pChunk->hGVM == pGVM->hSelf)
    12551260                {
    12561261                    uint64_t const idGenerationOld = pGMM->Private.idGeneration;
     
    18001805 *
    18011806 * @returns Free list index.
    1802  * @param
     1807 * @param   cFree       The number of free pages in the chunk.
    18031808 */
    18041809DECLINLINE(unsigned) gmmR0SelectFreeSetList(unsigned cFree)
    18051810{
    1806     return (cFree - 1) >> GMM_CHUNK_FREE_SET_SHIFT;
     1811    unsigned iList = cFree >> GMM_CHUNK_FREE_SET_SHIFT;
     1812    AssertMsg(iList < RT_SIZEOFMEMB(GMMCHUNKFREESET, apLists) / RT_SIZEOFMEMB(GMMCHUNKFREESET, apLists[0]),
     1813              ("%d (%u)\n", iList, cFree));
     1814    return iList;
    18071815}
    18081816
     
    22962304
    22972305    /* first round, pick from chunks with an affinity to the VM. */
    2298     for (unsigned i = 0; i < RT_ELEMENTS(pSet->apLists) && iPage < cPages; i++)
     2306    for (unsigned i = 0; i < GMM_CHUNK_FREE_SET_UNUSED_LIST && iPage < cPages; i++)
    22992307    {
    23002308        PGMMCHUNK pCurFree = NULL;
     
    23212329        /* second round, pick pages from the 100% empty chunks we just skipped above. */
    23222330        PGMMCHUNK pCurFree = NULL;
    2323         PGMMCHUNK pCur = pSet->apLists[RT_ELEMENTS(pSet->apLists) - 1];
     2331        PGMMCHUNK pCur = pSet->apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST];
    23242332        while (pCur && iPage < cPages)
    23252333        {
    23262334            PGMMCHUNK pNext = pCur->pFreeNext;
    2327 
    2328             if (    pCur->cFree == GMM_CHUNK_NUM_PAGES
    2329                 && (   pCur->hGVM == hGVM
    2330                      || !pGMM->fBoundMemoryMode))
     2335            Assert(pCur->cFree == GMM_CHUNK_NUM_PAGES);
     2336
     2337            if (   pCur->hGVM == hGVM
     2338                || !pGMM->fBoundMemoryMode)
    23312339            {
    23322340                gmmR0UnlinkChunk(pCur);
     
    30473055     * and relink the chunk if necessary.
    30483056     */
    3049     if (gmmR0SelectFreeSetList(pChunk->cFree) != gmmR0SelectFreeSetList(pChunk->cFree + 1))
     3057    unsigned const cFree = pChunk->cFree;
     3058    if (   !cFree
     3059        || gmmR0SelectFreeSetList(cFree) != gmmR0SelectFreeSetList(cFree + 1))
    30503060    {
    30513061        gmmR0UnlinkChunk(pChunk);
     
    30553065    else
    30563066    {
    3057         pChunk->cFree++;
     3067        pChunk->cFree = cFree + 1;
    30583068        pChunk->pSet->cFreePages++;
    30593069    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette