Changeset 37195 in vbox for trunk/src/VBox
- Timestamp:
- May 24, 2011 2:00:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r37193 r37195 468 468 /** The GMMCHUNK::cFree shift count. */ 469 469 #define GMM_CHUNK_FREE_SET_SHIFT 4 470 /** The GMMCHUNK::cFree mask for use when considering relinking a chunk. */471 #define GMM_CHUNK_FREE_SET_MASK 15472 /** The number of lists in set. */473 #define GMM_CHUNK_FREE_SET_LISTS (GMM_CHUNK_NUM_PAGES >> GMM_CHUNK_FREE_SET_SHIFT)474 470 475 471 … … 485 481 uint64_t idGeneration; 486 482 /** Chunks ordered by increasing number of free pages. */ 487 PGMMCHUNK apLists[GMM_CHUNK_ FREE_SET_LISTS];483 PGMMCHUNK apLists[GMM_CHUNK_NUM_PAGES >> GMM_CHUNK_FREE_SET_SHIFT]; 488 484 } GMMCHUNKFREESET; 489 485 … … 1706 1702 1707 1703 /** 1704 * Selects the appropriate free list given the number of free pages. 1705 * 1706 * @returns Free list index. 1707 * @param 1708 */ 1709 DECLINLINE(unsigned) gmmR0SelectFreeSetList(unsigned cFree) 1710 { 1711 return (cFree - 1) >> GMM_CHUNK_FREE_SET_SHIFT; 1712 } 1713 1714 1715 /** 1708 1716 * Unlinks the chunk from the free list it's currently on (if any). 1709 1717 * … … 1723 1731 pPrev->pFreeNext = pNext; 1724 1732 else 1725 pSet->apLists[ (pChunk->cFree - 1) >> GMM_CHUNK_FREE_SET_SHIFT] = pNext;1733 pSet->apLists[gmmR0SelectFreeSetList(pChunk->cFree)] = pNext; 1726 1734 if (pNext) 1727 1735 pNext->pFreePrev = pPrev; … … 1758 1766 pChunk->pSet = pSet; 1759 1767 pChunk->pFreePrev = NULL; 1760 unsigned iList = (pChunk->cFree - 1) >> GMM_CHUNK_FREE_SET_SHIFT;1768 unsigned const iList = gmmR0SelectFreeSetList(pChunk->cFree); 1761 1769 pChunk->pFreeNext = pSet->apLists[iList]; 1762 1770 if (pChunk->pFreeNext) … … 1987 1995 && pOtherSet->cFreePages >= GMM_CHUNK_NUM_PAGES) 1988 1996 { 1989 PGMMCHUNK pChunk = pOtherSet->apLists[ GMM_CHUNK_FREE_SET_LISTS- 1];1997 PGMMCHUNK pChunk = pOtherSet->apLists[RT_ELEMENTS(pOtherSet->apLists) - 1]; 1990 1998 while (pChunk && pChunk->cFree != GMM_CHUNK_NUM_PAGES) 1991 1999 pChunk = pChunk->pFreeNext; … … 2910 2918 * and relink the chunk if necessary. 2911 2919 */ 2912 if ( (pChunk->cFree & GMM_CHUNK_FREE_SET_MASK) == 0)2920 if (gmmR0SelectFreeSetList(pChunk->cFree) != gmmR0SelectFreeSetList(pChunk->cFree + 1)) 2913 2921 { 2914 2922 gmmR0UnlinkChunk(pChunk); … … 2920 2928 pChunk->cFree++; 2921 2929 pChunk->pSet->cFreePages++; 2922 2923 /* 2924 * If the chunk becomes empty, consider giving memory back to the host OS. 2925 * 2926 * The current strategy is to try give it back if there are other chunks 2927 * in this free list, meaning if there are at least 240 free pages in this 2928 * category. Note that since there are probably mappings of the chunk, 2929 * it won't be freed up instantly, which probably screws up this logic 2930 * a bit... 2931 */ 2932 if (RT_UNLIKELY( pChunk->cFree == GMM_CHUNK_NUM_PAGES 2933 && pChunk->pFreeNext 2934 && pChunk->pFreePrev /** @todo this is probably misfiring, see reset... */ 2935 && !pGMM->fLegacyAllocationMode)) 2936 gmmR0FreeChunk(pGMM, NULL, pChunk); 2937 } 2930 } 2931 2932 /* 2933 * If the chunk becomes empty, consider giving memory back to the host OS. 2934 * 2935 * The current strategy is to try give it back if there are other chunks 2936 * in this free list, meaning if there are at least 240 free pages in this 2937 * category. Note that since there are probably mappings of the chunk, 2938 * it won't be freed up instantly, which probably screws up this logic 2939 * a bit... 2940 */ 2941 if (RT_UNLIKELY( pChunk->cFree == GMM_CHUNK_NUM_PAGES 2942 && pChunk->pFreeNext 2943 && pChunk->pFreePrev /** @todo this is probably misfiring, see reset... */ 2944 && !pGMM->fLegacyAllocationMode)) 2945 gmmR0FreeChunk(pGMM, NULL, pChunk); 2946 2938 2947 } 2939 2948
Note:
See TracChangeset
for help on using the changeset viewer.