Remove per-CPU pool tracking tables
All checks were successful
Builds / ExectOS (i686, release) (push) Successful in 30s
Builds / ExectOS (amd64, release) (push) Successful in 33s
Builds / ExectOS (amd64, debug) (push) Successful in 48s
Builds / ExectOS (i686, debug) (push) Successful in 46s

This commit is contained in:
2026-05-22 23:45:32 +02:00
parent 6f3b5b5e51
commit 71870cd178
5 changed files with 21 additions and 77 deletions

View File

@@ -119,9 +119,6 @@
/* Number of pool lists per page */
#define MM_POOL_LISTS_PER_PAGE (MM_PAGE_SIZE / MM_POOL_BLOCK_SIZE)
/* Number of pool tracking tables */
#define MM_POOL_TRACKING_TABLES 64
/* C/C++ specific code */
#ifndef __XTOS_ASSEMBLER__

View File

@@ -117,9 +117,6 @@
/* Number of pool lists per page */
#define MM_POOL_LISTS_PER_PAGE (MM_PAGE_SIZE / MM_POOL_BLOCK_SIZE)
/* Number of pool tracking tables */
#define MM_POOL_TRACKING_TABLES 32
/* C/C++ specific code */
#ifndef __XTOS_ASSEMBLER__

View File

@@ -30,7 +30,6 @@ namespace MM
STATIC SIZE_T BigAllocationsTrackingTableHash;
STATIC KSPIN_LOCK BigAllocationsTrackingTableLock;
STATIC SIZE_T BigAllocationsTrackingTableSize;
STATIC PPOOL_TRACKING_TABLE TagTables[MM_POOL_TRACKING_TABLES];
public:
STATIC XTAPI XTSTATUS AllocatePages(IN MMPOOL_TYPE PoolType,

View File

@@ -1379,9 +1379,6 @@ MM::Allocator::InitializeAllocationsTracking(VOID)
/* Zero the entire memory used by the table */
RtlZeroMemory(AllocationsTrackingTable, AllocationsTrackingTableSize * sizeof(POOL_TRACKING_TABLE));
/* Assign the global tracking table as the local table for the bootstrap processor */
TagTables[0] = AllocationsTrackingTable;
/* Calculate and store the hash mask */
AllocationsTrackingTableMask = AllocationsTrackingTableSize - 2;
@@ -1527,12 +1524,8 @@ MM::Allocator::RegisterAllocationTag(IN ULONG Tag,
IN SIZE_T Bytes,
IN MMPOOL_TYPE PoolType)
{
PPOOL_TRACKING_TABLE CpuTable, TableEntry;
ULONG Hash, Index, Processor;
/* Retrieve the local tracking table for the current processor */
Processor = KE::Processor::GetCurrentProcessorNumber();
CpuTable = TagTables[Processor];
PPOOL_TRACKING_TABLE TableEntry;
ULONG Hash, Index;
/* Strip the protected pool bit */
Tag &= ~MM_POOL_PROTECTED;
@@ -1544,8 +1537,8 @@ MM::Allocator::RegisterAllocationTag(IN ULONG Tag,
/* Probe the tracking table until a match or an empty slot is found */
do
{
/* Fetch the tracker entry from the CPU table */
TableEntry = &CpuTable[Hash];
/* Fetch the tracker entry from the table */
TableEntry = &AllocationsTrackingTable[Hash];
/* Check if the current entry tracks the requested pool tag */
if(TableEntry->Tag == Tag)
@@ -1568,23 +1561,11 @@ MM::Allocator::RegisterAllocationTag(IN ULONG Tag,
return;
}
/* Check if the CPU table is entirely empty */
/* Check if the table is entirely empty */
if(TableEntry->Tag == 0)
{
/* Check if another processor has claimed this slot in the global table */
if(AllocationsTrackingTable[Hash].Tag != 0)
{
/* Synchronize the local table with the global table */
TableEntry->Tag = AllocationsTrackingTable[Hash].Tag;
/* Restart the loop to evaluation */
continue;
}
/* Check if this is not the designated overflow bucket */
if(Hash != (AllocationsTrackingTableSize - 1))
{
/* Start a guarded code block */
{
/* Acquire the tracking table lock */
KE::SpinLockGuard TrackingTableLock(&AllocationsTrackingTableLock);
@@ -1596,7 +1577,6 @@ MM::Allocator::RegisterAllocationTag(IN ULONG Tag,
AllocationsTrackingTable[Hash].Tag = Tag;
TableEntry->Tag = Tag;
}
}
/* Restart the loop */
continue;
@@ -1923,13 +1903,7 @@ MM::Allocator::UnregisterAllocationTag(IN ULONG Tag,
IN MMPOOL_TYPE PoolType)
{
ULONG Hash, Index;
PPOOL_TRACKING_TABLE CpuTable;
PPOOL_TRACKING_TABLE TableEntry;
ULONG Processor;
/* Retrieve the local tracking table for the current processor */
Processor = KE::Processor::GetCurrentProcessorNumber();
CpuTable = TagTables[Processor];
/* Strip the protected pool bit */
Tag &= ~MM_POOL_PROTECTED;
@@ -1941,8 +1915,8 @@ MM::Allocator::UnregisterAllocationTag(IN ULONG Tag,
/* Probe the tracking table until a match or an empty slot is found */
do
{
/* Fetch the tracker entry from the CPU table */
TableEntry = &CpuTable[Hash];
/* Fetch the tracker entry from the table */
TableEntry = &AllocationsTrackingTable[Hash];
/* Check if the current entry tracks the requested pool tag */
if(TableEntry->Tag == Tag)
@@ -1952,33 +1926,19 @@ MM::Allocator::UnregisterAllocationTag(IN ULONG Tag,
{
/* Update the non-paged allocation statistics */
RTL::Atomic::Increment32(&TableEntry->NonPagedFrees);
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&TableEntry->NonPagedBytes, 0 - Bytes);
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&TableEntry->NonPagedBytes, -(LONG_PTR)Bytes);
}
else
{
/* Update the paged allocation statistics */
RTL::Atomic::Increment32(&TableEntry->PagedFrees);
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&TableEntry->PagedBytes, 0 - Bytes);
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&TableEntry->PagedBytes, -(LONG_PTR)Bytes);
}
/* The allocation has been successfully tracked, return */
return;
}
/* Check if the CPU table is entirely empty */
if(TableEntry->Tag == 0)
{
/* Check if another processor has claimed this slot in the global table */
if(AllocationsTrackingTable[Hash].Tag != 0)
{
/* Synchronize the local table with the global table */
TableEntry->Tag = AllocationsTrackingTable[Hash].Tag;
/* Restart the loop to evaluation */
continue;
}
}
/* Advance to the next index as hash collision occurred */
Hash = (Hash + 1) & AllocationsTrackingTableMask;
}
@@ -2010,9 +1970,7 @@ MM::Allocator::UnregisterAllocationTagExpansion(IN ULONG Tag,
IN SIZE_T Bytes,
IN MMPOOL_TYPE PoolType)
{
PPOOL_TRACKING_TABLE CpuTable;
ULONG Hash;
ULONG Processor;
/* Start a guarded code block */
{
@@ -2055,22 +2013,18 @@ MM::Allocator::UnregisterAllocationTagExpansion(IN ULONG Tag,
/* Target the index of the overflow bucket */
Hash = (ULONG)AllocationsTrackingTableSize - 1;
/* Retrieve the local tracking table for the current processor */
Processor = KE::Processor::GetCurrentProcessorNumber();
CpuTable = TagTables[Processor];
/* Update the appropriate statistics based on the pool type */
if((PoolType & MM_POOL_TYPE_MASK) == NonPagedPool)
{
/* Update the non-paged allocation statistics */
RTL::Atomic::Increment32((PLONG)&CpuTable[Hash].NonPagedFrees);
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&CpuTable[Hash].NonPagedBytes, 0 - Bytes);
RTL::Atomic::Increment32((PLONG)&AllocationsTrackingTable[Hash].NonPagedFrees);
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&AllocationsTrackingTable[Hash].NonPagedBytes, -(LONG_PTR)Bytes);
}
else
{
/* Update the paged allocation statistics */
RTL::Atomic::Increment32((PLONG)&CpuTable[Hash].PagedFrees);
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&CpuTable[Hash].PagedBytes, 0 - Bytes);
RTL::Atomic::Increment32((PLONG)&AllocationsTrackingTable[Hash].PagedFrees);
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&AllocationsTrackingTable[Hash].PagedBytes, -(LONG_PTR)Bytes);
}
}

View File

@@ -42,9 +42,6 @@ KSPIN_LOCK MM::Allocator::BigAllocationsTrackingTableLock;
/* Maximum capacity of the tracking hash table */
SIZE_T MM::Allocator::BigAllocationsTrackingTableSize;
/* Array of CPU-local tracking tables */
PPOOL_TRACKING_TABLE MM::Allocator::TagTables[MM_POOL_TRACKING_TABLES];
/* Array of free page lists segregated by cache color */
PMMCOLOR_TABLES MM::Colors::FreePages[FreePageList + 1];