Changeset 37214 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- May 25, 2011 2:38:28 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 71916
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r37213 r37214 467 467 468 468 469 /** The GMMCHUNK::cFree shift count . */469 /** The GMMCHUNK::cFree shift count employed by gmmR0SelectFreeSetList. */ 470 470 #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 471 475 472 476 … … 481 485 * something is linked or unlinked from this set. */ 482 486 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]; 485 490 } GMMCHUNKFREESET; 486 491 … … 1246 1251 fRedoFromStart = false; 1247 1252 iCountDown = 10240; 1248 pChunk = pGMM->Private.apLists[ RT_ELEMENTS(pGMM->Private.apLists) - 1];1253 pChunk = pGMM->Private.apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST]; 1249 1254 while (pChunk) 1250 1255 { 1251 1256 PGMMCHUNK pNext = pChunk->pFreeNext; 1252 if ( pChunk->cFree == GMM_CHUNK_NUM_PAGES1253 &&( !pGMM->fBoundMemoryMode1254 || pChunk->hGVM == pGVM->hSelf))1257 Assert(pChunk->cFree == GMM_CHUNK_NUM_PAGES); 1258 if ( !pGMM->fBoundMemoryMode 1259 || pChunk->hGVM == pGVM->hSelf) 1255 1260 { 1256 1261 uint64_t const idGenerationOld = pGMM->Private.idGeneration; … … 1800 1805 * 1801 1806 * @returns Free list index. 1802 * @param 1807 * @param cFree The number of free pages in the chunk. 1803 1808 */ 1804 1809 DECLINLINE(unsigned) gmmR0SelectFreeSetList(unsigned cFree) 1805 1810 { 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; 1807 1815 } 1808 1816 … … 2296 2304 2297 2305 /* 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++) 2299 2307 { 2300 2308 PGMMCHUNK pCurFree = NULL; … … 2321 2329 /* second round, pick pages from the 100% empty chunks we just skipped above. */ 2322 2330 PGMMCHUNK pCurFree = NULL; 2323 PGMMCHUNK pCur = pSet->apLists[ RT_ELEMENTS(pSet->apLists) - 1];2331 PGMMCHUNK pCur = pSet->apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST]; 2324 2332 while (pCur && iPage < cPages) 2325 2333 { 2326 2334 PGMMCHUNK pNext = pCur->pFreeNext; 2327 2328 if ( pCur->cFree == GMM_CHUNK_NUM_PAGES 2329 &&( pCur->hGVM == hGVM2330 || !pGMM->fBoundMemoryMode))2335 Assert(pCur->cFree == GMM_CHUNK_NUM_PAGES); 2336 2337 if ( pCur->hGVM == hGVM 2338 || !pGMM->fBoundMemoryMode) 2331 2339 { 2332 2340 gmmR0UnlinkChunk(pCur); … … 3047 3055 * and relink the chunk if necessary. 3048 3056 */ 3049 if (gmmR0SelectFreeSetList(pChunk->cFree) != gmmR0SelectFreeSetList(pChunk->cFree + 1)) 3057 unsigned const cFree = pChunk->cFree; 3058 if ( !cFree 3059 || gmmR0SelectFreeSetList(cFree) != gmmR0SelectFreeSetList(cFree + 1)) 3050 3060 { 3051 3061 gmmR0UnlinkChunk(pChunk); … … 3055 3065 else 3056 3066 { 3057 pChunk->cFree ++;3067 pChunk->cFree = cFree + 1; 3058 3068 pChunk->pSet->cFreePages++; 3059 3069 }
Note:
See TracChangeset
for help on using the changeset viewer.