Allocate contiguous memory for local lookaside lists
All checks were successful
Builds / ExectOS (i686, debug) (push) Successful in 33s
Builds / ExectOS (amd64, debug) (push) Successful in 35s
Builds / ExectOS (amd64, release) (push) Successful in 1m6s
Builds / ExectOS (i686, release) (push) Successful in 1m4s

This commit is contained in:
2026-07-07 14:42:49 +02:00
parent e3081c0cf5
commit 10aaac59e4
2 changed files with 76 additions and 16 deletions

View File

@@ -326,35 +326,63 @@ XTAPI
VOID VOID
EX::LookasideList::InitializePointers(VOID) EX::LookasideList::InitializePointers(VOID)
{ {
PGENERAL_LOOKASIDE LookasideEntry; PGENERAL_LOOKASIDE LookasideList;
PKPROCESSOR_CONTROL_BLOCK Prcb; PKPROCESSOR_CONTROL_BLOCK Prcb;
ULONG Index; ULONG Index, Offset;
XTSTATUS Status;
/* Retrieve the processor control block */ /* Retrieve the processor control block */
Prcb = KE::Processor::GetCurrentProcessorControlBlock(); Prcb = KE::Processor::GetCurrentProcessorControlBlock();
/* Allocate a contiguous memory block for lookaside lists */
Status = MM::Allocator::AllocatePool(NonPagedPool, sizeof(GENERAL_LOOKASIDE) * POOL_LOOKASIDE_LISTS * 2,
(PVOID*)&LookasideList, TAG_MM_MEMORY_POOL);
/* Initialize both non-paged and paged lookaside lists for all pool indexes */ /* Initialize both non-paged and paged lookaside lists for all pool indexes */
for(Index = 0; Index < POOL_LOOKASIDE_LISTS; Index++) for(Index = 0; Index < POOL_LOOKASIDE_LISTS; Index++)
{ {
/* Get the non-paged lookaside list entry */ /* Wire the global pointer for the non-paged lookaside list */
LookasideEntry = &NonPagedPoolLookasideLists[Index]; Prcb->NonPagedLookasideList[Index].Global = &NonPagedPoolLookasideLists[Index];
/* Initialize the singly linked list header for the non-paged entry */ /* Check if the contiguous allocation was successful */
RTL::SinglyList::InitializeListHead(&LookasideEntry->ListHead); if(Status == STATUS_SUCCESS && LookasideList)
{
/* Map the pointer to the first half of the contiguous block */
Prcb->NonPagedLookasideList[Index].Local = &LookasideList[Index];
/* Assign the initialized non-paged entry to the PRCB */ /* Initialize the local non-paged list */
Prcb->NonPagedLookasideList[Index].Global = LookasideEntry; EX::LookasideList::InitializeLookasideList(&LookasideList[Index], NonPagedPool,
Prcb->NonPagedLookasideList[Index].Local = LookasideEntry; (Index + 1) * 8, TAG_MM_MEMORY_POOL,
256, &PoolLookasideListHead);
}
else
{
/* Allocation failed, use shared global list */
Prcb->NonPagedLookasideList[Index].Local = &NonPagedPoolLookasideLists[Index];
}
/* Get the paged lookaside list entry */ /* Wire the global pointer for the paged lookaside list */
LookasideEntry = &PagedPoolLookasideLists[Index]; Prcb->PagedLookasideList[Index].Global = &PagedPoolLookasideLists[Index];
/* Initialize the singly linked list header for the paged entry */ /* Check if the contiguous allocation was successful */
RTL::SinglyList::InitializeListHead(&LookasideEntry->ListHead); if(Status == STATUS_SUCCESS && LookasideList)
{
/* Calculate the offset into the second half of the contiguous memory block */
Offset = POOL_LOOKASIDE_LISTS + Index;
/* Assign the initialized paged entry to the PRCB */ /* Map the pointer to the second half of the contiguous block */
Prcb->PagedLookasideList[Index].Global = LookasideEntry; Prcb->PagedLookasideList[Index].Local = &LookasideList[Offset];
Prcb->PagedLookasideList[Index].Local = LookasideEntry;
/* Initialize the local paged list */
EX::LookasideList::InitializeLookasideList(&LookasideList[Offset], PagedPool,
(Index + 1) * 8, TAG_MM_MEMORY_POOL,
256, &PoolLookasideListHead);
}
else
{
/* Allocation failed, use shared global list */
Prcb->PagedLookasideList[Index].Local = &PagedPoolLookasideLists[Index];
}
} }
} }
@@ -393,3 +421,33 @@ EX::LookasideList::InitializeSystemLookasideLists(VOID)
TAG_MM_MEMORY_POOL, 256, &PoolLookasideListHead); TAG_MM_MEMORY_POOL, 256, &PoolLookasideListHead);
} }
} }
/**
* Retrieves the head of the pool lookaside list tracker.
*
* @return This routine returns a pointer to the global pool lookaside list head.
*
* @since XT 1.0
*/
XTAPI
PLIST_ENTRY
EX::LookasideList::GetPoolLookasideListHead(VOID)
{
/* Return the head of the pool lookaside list */
return &PoolLookasideListHead;
}
/**
* Retrieves the head of the system-wide lookaside list tracker.
*
* @return This routine returns a pointer to the global system lookaside list head.
*
* @since XT 1.0
*/
XTAPI
PLIST_ENTRY
EX::LookasideList::GetSystemLookasideListHead(VOID)
{
/* Return the head of the pool lookaside list */
return &SystemLookasideListHead;
}

View File

@@ -45,6 +45,8 @@ namespace EX
IN PLIST_ENTRY ListHead); IN PLIST_ENTRY ListHead);
STATIC XTAPI VOID InitializePointers(VOID); STATIC XTAPI VOID InitializePointers(VOID);
STATIC XTAPI VOID InitializeSystemLookasideLists(VOID); STATIC XTAPI VOID InitializeSystemLookasideLists(VOID);
STATIC XTAPI PLIST_ENTRY GetPoolLookasideListHead(VOID);
STATIC XTAPI PLIST_ENTRY GetSystemLookasideListHead(VOID);
}; };
} }