Simplify lookaside list free path with early returns and direct pool fallback
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 37s
Builds / ExectOS (amd64, debug) (push) Successful in 39s
Builds / ExectOS (i686, release) (push) Successful in 1m17s
Builds / ExectOS (i686, debug) (push) Successful in 1m19s

This commit is contained in:
2026-07-08 09:32:11 +02:00
parent e5cf62cbfb
commit f2922349de

View File

@@ -228,37 +228,41 @@ EX::LookasideList::FreeToPerProcessorList(IN NONPAGED_LOOKASIDE_NUMBER Number,
PKPROCESSOR_CONTROL_BLOCK Prcb; PKPROCESSOR_CONTROL_BLOCK Prcb;
PGENERAL_LOOKASIDE Lookaside; PGENERAL_LOOKASIDE Lookaside;
/* Retrieve the current Processor Control Block */ /* Retrieve the Processor Control Block */
Prcb = KE::Processor::GetCurrentProcessorControlBlock(); Prcb = KE::Processor::GetCurrentProcessorControlBlock();
/* Target the processor's local lookaside list and increment the tracking metric */ /* Acquire the local lookaside list and increment its total free counter */
Lookaside = Prcb->LookasideList[Number].Local; Lookaside = (PGENERAL_LOOKASIDE)Prcb->LookasideList[Number].Local;
Lookaside->TotalFrees += 1; Lookaside->TotalFrees++;
/* Check if the lookaside list has reached its maximum capacity threshold */ /* Check if the local lookaside list has available capacity */
if(RTL::SinglyList::QueryListDepth(&Lookaside->ListHead) >= Lookaside->Depth) if(RTL::SinglyList::QueryListDepth(&Lookaside->ListHead) < Lookaside->Depth)
{ {
/* The local list is full, record a capacity miss */ /* Push the buffer onto the local list and exit */
Lookaside->FreeMisses++; RTL::Atomic::PushEntrySingleList(&Lookaside->ListHead, (PSINGLE_LIST_ENTRY)Entry);
Lookaside->TotalFrees++; return;
/* Switch the target to the shared global lookaside list */
Lookaside = Prcb->LookasideList[Number].Global;
/* Check if the lookaside list has reached its maximum capacity threshold */
if(RTL::SinglyList::QueryListDepth(&Lookaside->ListHead) >= Lookaside->Depth)
{
/* Both caches are saturated, record a miss */
Lookaside->FreeMisses++;
(Lookaside->Free)(Entry);
/* Exit the routine */
return;
}
} }
/* Push the block onto the selected lookaside list */ /* Local list is full, record the miss */
RTL::Atomic::PushEntrySingleList(&Lookaside->ListHead, (PSINGLE_LIST_ENTRY)Entry); Lookaside->FreeMisses++;
/* Acquire the global lookaside list and increment its free counter */
Lookaside = (PGENERAL_LOOKASIDE)Prcb->LookasideList[Number].Global;
Lookaside->TotalFrees++;
/* Check if the global lookaside list has available capacity */
if(RTL::SinglyList::QueryListDepth(&Lookaside->ListHead) < Lookaside->Depth)
{
/* Push the buffer onto the global list and exit */
RTL::Atomic::PushEntrySingleList(&Lookaside->ListHead, (PSINGLE_LIST_ENTRY)Entry);
return;
}
/* Global list is full, record the miss */
Lookaside->FreeMisses++;
/* Free directly to the system pool */
Lookaside->Free(Entry);
} }
/** /**