mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[NTOS:MM] Fix placing entries into MmNonPagedPoolFreeListHead
When freeing pages, free page entries with pages num == 3 were incorrectly treated as entries with pages num >= 4 and thus their re-insertion was not triggered. That lead to non paged pool fragmentation (can be triggered by kmtest:ExPools, for example) Also, altered the index acquisition code for MmNonPagedPoolFreeList entries so it looks more clear
This commit is contained in:
parent
a3cadf630a
commit
3f601122bc
1 changed files with 6 additions and 10 deletions
|
@ -680,8 +680,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
|
|||
//
|
||||
// Allocations of less than 4 pages go into their individual buckets
|
||||
//
|
||||
i = SizeInPages - 1;
|
||||
if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
|
||||
i = min(SizeInPages, MI_MAX_FREE_PAGE_LISTS) - 1;
|
||||
|
||||
//
|
||||
// Loop through all the free page lists based on the page index
|
||||
|
@ -738,8 +737,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
|
|||
if (FreeEntry->Size != 0)
|
||||
{
|
||||
/* Check which list to insert this entry into */
|
||||
i = FreeEntry->Size - 1;
|
||||
if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
|
||||
i = min(FreeEntry->Size, MI_MAX_FREE_PAGE_LISTS) - 1;
|
||||
|
||||
/* Insert the entry into the free list head, check for prot. pool */
|
||||
if (MmProtectFreedNonPagedPool)
|
||||
|
@ -1176,11 +1174,11 @@ MiFreePoolPages(IN PVOID StartingVa)
|
|||
}
|
||||
|
||||
//
|
||||
// Check if the entry is small enough to be indexed on a free list
|
||||
// Check if the entry is small enough (1-3 pages) to be indexed on a free list
|
||||
// If it is, we'll want to re-insert it, since we're about to
|
||||
// collapse our pages on top of it, which will change its count
|
||||
//
|
||||
if (FreeEntry->Size < (MI_MAX_FREE_PAGE_LISTS - 1))
|
||||
if (FreeEntry->Size < MI_MAX_FREE_PAGE_LISTS)
|
||||
{
|
||||
/* Remove the item from the list, depending if pool is protected */
|
||||
if (MmProtectFreedNonPagedPool)
|
||||
|
@ -1196,8 +1194,7 @@ MiFreePoolPages(IN PVOID StartingVa)
|
|||
//
|
||||
// And now find the new appropriate list to place it in
|
||||
//
|
||||
i = (ULONG)(FreeEntry->Size - 1);
|
||||
if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
|
||||
i = min(FreeEntry->Size, MI_MAX_FREE_PAGE_LISTS) - 1;
|
||||
|
||||
/* Insert the entry into the free list head, check for prot. pool */
|
||||
if (MmProtectFreedNonPagedPool)
|
||||
|
@ -1228,8 +1225,7 @@ MiFreePoolPages(IN PVOID StartingVa)
|
|||
//
|
||||
// Find the appropriate list we should be on
|
||||
//
|
||||
i = FreeEntry->Size - 1;
|
||||
if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
|
||||
i = min(FreeEntry->Size, MI_MAX_FREE_PAGE_LISTS) - 1;
|
||||
|
||||
/* Insert the entry into the free list head, check for prot. pool */
|
||||
if (MmProtectFreedNonPagedPool)
|
||||
|
|
Loading…
Reference in a new issue