Set up owner pointers for all pages during pool initialization
All checks were successful
Builds / ExectOS (i686, release) (push) Successful in 28s
Builds / ExectOS (amd64, release) (push) Successful in 26s
Builds / ExectOS (i686, debug) (push) Successful in 38s
Builds / ExectOS (amd64, debug) (push) Successful in 40s

This commit is contained in:
2026-03-04 22:44:45 +01:00
parent 5a9b7c0258
commit 8d2dfa6f62
2 changed files with 14 additions and 4 deletions

View File

@@ -102,6 +102,7 @@ typedef struct _MMFREE_POOL_ENTRY
{ {
LIST_ENTRY List; LIST_ENTRY List;
PFN_COUNT Size; PFN_COUNT Size;
PMMFREE_POOL_ENTRY Owner;
} MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY; } MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
/* Memory layout structure definition */ /* Memory layout structure definition */

View File

@@ -265,8 +265,8 @@ XTAPI
VOID VOID
MM::Allocator::InitializeNonPagedPool(VOID) MM::Allocator::InitializeNonPagedPool(VOID)
{ {
PMMFREE_POOL_ENTRY FreeEntry, SetupEntry;
PMMMEMORY_LAYOUT MemoryLayout; PMMMEMORY_LAYOUT MemoryLayout;
PMMFREE_POOL_ENTRY FreeEntry;
ULONG Index; ULONG Index;
/* Retrieve memory layout */ /* Retrieve memory layout */
@@ -282,8 +282,9 @@ MM::Allocator::InitializeNonPagedPool(VOID)
RTL::LinkedList::InitializeListHead(&NonPagedPoolFreeList[Index]); RTL::LinkedList::InitializeListHead(&NonPagedPoolFreeList[Index]);
} }
/* Take the first free page from the pool */ /* Take the first free entry from the pool and set its size */
FreeEntry = (PMMFREE_POOL_ENTRY)MemoryLayout->NonPagedPoolStart; FreeEntry = (PMMFREE_POOL_ENTRY)MemoryLayout->NonPagedPoolStart;
FreeEntry->Size = MemoryLayout->NonPagedPoolSize;
/* Take number of pages in the pool */ /* Take number of pages in the pool */
Index = (ULONG)(MemoryLayout->NonPagedPoolSize - 1); Index = (ULONG)(MemoryLayout->NonPagedPoolSize - 1);
@@ -293,9 +294,17 @@ MM::Allocator::InitializeNonPagedPool(VOID)
Index = MM_MAX_FREE_PAGE_LIST_HEADS - 1; Index = MM_MAX_FREE_PAGE_LIST_HEADS - 1;
} }
/* Insert the first free page into the free page list and set its size */ /* Insert the first free entry into the free page list */
RTL::LinkedList::InsertHeadList(&NonPagedPoolFreeList[Index], &FreeEntry->List); RTL::LinkedList::InsertHeadList(&NonPagedPoolFreeList[Index], &FreeEntry->List);
FreeEntry->Size = MemoryLayout->NonPagedPoolSize;
/* Create a free entry for each page in the pool */
SetupEntry = FreeEntry;
for(Index = 0; Index < MemoryLayout->NonPagedPoolSize; Index++)
{
/* Initialize the owner for each entry */
SetupEntry->Owner = FreeEntry;
SetupEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)SetupEntry + MM_PAGE_SIZE);
}
} }
/** /**