Remove per-CPU pool tracking tables
This commit is contained in:
@@ -119,9 +119,6 @@
|
|||||||
/* Number of pool lists per page */
|
/* Number of pool lists per page */
|
||||||
#define MM_POOL_LISTS_PER_PAGE (MM_PAGE_SIZE / MM_POOL_BLOCK_SIZE)
|
#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 */
|
/* C/C++ specific code */
|
||||||
#ifndef __XTOS_ASSEMBLER__
|
#ifndef __XTOS_ASSEMBLER__
|
||||||
|
|||||||
@@ -117,9 +117,6 @@
|
|||||||
/* Number of pool lists per page */
|
/* Number of pool lists per page */
|
||||||
#define MM_POOL_LISTS_PER_PAGE (MM_PAGE_SIZE / MM_POOL_BLOCK_SIZE)
|
#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 */
|
/* C/C++ specific code */
|
||||||
#ifndef __XTOS_ASSEMBLER__
|
#ifndef __XTOS_ASSEMBLER__
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ namespace MM
|
|||||||
STATIC SIZE_T BigAllocationsTrackingTableHash;
|
STATIC SIZE_T BigAllocationsTrackingTableHash;
|
||||||
STATIC KSPIN_LOCK BigAllocationsTrackingTableLock;
|
STATIC KSPIN_LOCK BigAllocationsTrackingTableLock;
|
||||||
STATIC SIZE_T BigAllocationsTrackingTableSize;
|
STATIC SIZE_T BigAllocationsTrackingTableSize;
|
||||||
STATIC PPOOL_TRACKING_TABLE TagTables[MM_POOL_TRACKING_TABLES];
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
STATIC XTAPI XTSTATUS AllocatePages(IN MMPOOL_TYPE PoolType,
|
STATIC XTAPI XTSTATUS AllocatePages(IN MMPOOL_TYPE PoolType,
|
||||||
|
|||||||
@@ -1379,9 +1379,6 @@ MM::Allocator::InitializeAllocationsTracking(VOID)
|
|||||||
/* Zero the entire memory used by the table */
|
/* Zero the entire memory used by the table */
|
||||||
RtlZeroMemory(AllocationsTrackingTable, AllocationsTrackingTableSize * sizeof(POOL_TRACKING_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 */
|
/* Calculate and store the hash mask */
|
||||||
AllocationsTrackingTableMask = AllocationsTrackingTableSize - 2;
|
AllocationsTrackingTableMask = AllocationsTrackingTableSize - 2;
|
||||||
|
|
||||||
@@ -1527,12 +1524,8 @@ MM::Allocator::RegisterAllocationTag(IN ULONG Tag,
|
|||||||
IN SIZE_T Bytes,
|
IN SIZE_T Bytes,
|
||||||
IN MMPOOL_TYPE PoolType)
|
IN MMPOOL_TYPE PoolType)
|
||||||
{
|
{
|
||||||
PPOOL_TRACKING_TABLE CpuTable, TableEntry;
|
PPOOL_TRACKING_TABLE TableEntry;
|
||||||
ULONG Hash, Index, Processor;
|
ULONG Hash, Index;
|
||||||
|
|
||||||
/* Retrieve the local tracking table for the current processor */
|
|
||||||
Processor = KE::Processor::GetCurrentProcessorNumber();
|
|
||||||
CpuTable = TagTables[Processor];
|
|
||||||
|
|
||||||
/* Strip the protected pool bit */
|
/* Strip the protected pool bit */
|
||||||
Tag &= ~MM_POOL_PROTECTED;
|
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 */
|
/* Probe the tracking table until a match or an empty slot is found */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Fetch the tracker entry from the CPU table */
|
/* Fetch the tracker entry from the table */
|
||||||
TableEntry = &CpuTable[Hash];
|
TableEntry = &AllocationsTrackingTable[Hash];
|
||||||
|
|
||||||
/* Check if the current entry tracks the requested pool tag */
|
/* Check if the current entry tracks the requested pool tag */
|
||||||
if(TableEntry->Tag == Tag)
|
if(TableEntry->Tag == Tag)
|
||||||
@@ -1568,23 +1561,11 @@ MM::Allocator::RegisterAllocationTag(IN ULONG Tag,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the CPU table is entirely empty */
|
/* Check if the table is entirely empty */
|
||||||
if(TableEntry->Tag == 0)
|
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 */
|
/* Check if this is not the designated overflow bucket */
|
||||||
if(Hash != (AllocationsTrackingTableSize - 1))
|
if(Hash != (AllocationsTrackingTableSize - 1))
|
||||||
{
|
|
||||||
/* Start a guarded code block */
|
|
||||||
{
|
{
|
||||||
/* Acquire the tracking table lock */
|
/* Acquire the tracking table lock */
|
||||||
KE::SpinLockGuard TrackingTableLock(&AllocationsTrackingTableLock);
|
KE::SpinLockGuard TrackingTableLock(&AllocationsTrackingTableLock);
|
||||||
@@ -1596,7 +1577,6 @@ MM::Allocator::RegisterAllocationTag(IN ULONG Tag,
|
|||||||
AllocationsTrackingTable[Hash].Tag = Tag;
|
AllocationsTrackingTable[Hash].Tag = Tag;
|
||||||
TableEntry->Tag = Tag;
|
TableEntry->Tag = Tag;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Restart the loop */
|
/* Restart the loop */
|
||||||
continue;
|
continue;
|
||||||
@@ -1923,13 +1903,7 @@ MM::Allocator::UnregisterAllocationTag(IN ULONG Tag,
|
|||||||
IN MMPOOL_TYPE PoolType)
|
IN MMPOOL_TYPE PoolType)
|
||||||
{
|
{
|
||||||
ULONG Hash, Index;
|
ULONG Hash, Index;
|
||||||
PPOOL_TRACKING_TABLE CpuTable;
|
|
||||||
PPOOL_TRACKING_TABLE TableEntry;
|
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 */
|
/* Strip the protected pool bit */
|
||||||
Tag &= ~MM_POOL_PROTECTED;
|
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 */
|
/* Probe the tracking table until a match or an empty slot is found */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Fetch the tracker entry from the CPU table */
|
/* Fetch the tracker entry from the table */
|
||||||
TableEntry = &CpuTable[Hash];
|
TableEntry = &AllocationsTrackingTable[Hash];
|
||||||
|
|
||||||
/* Check if the current entry tracks the requested pool tag */
|
/* Check if the current entry tracks the requested pool tag */
|
||||||
if(TableEntry->Tag == Tag)
|
if(TableEntry->Tag == Tag)
|
||||||
@@ -1952,33 +1926,19 @@ MM::Allocator::UnregisterAllocationTag(IN ULONG Tag,
|
|||||||
{
|
{
|
||||||
/* Update the non-paged allocation statistics */
|
/* Update the non-paged allocation statistics */
|
||||||
RTL::Atomic::Increment32(&TableEntry->NonPagedFrees);
|
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
|
else
|
||||||
{
|
{
|
||||||
/* Update the paged allocation statistics */
|
/* Update the paged allocation statistics */
|
||||||
RTL::Atomic::Increment32(&TableEntry->PagedFrees);
|
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 */
|
/* The allocation has been successfully tracked, return */
|
||||||
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 */
|
/* Advance to the next index as hash collision occurred */
|
||||||
Hash = (Hash + 1) & AllocationsTrackingTableMask;
|
Hash = (Hash + 1) & AllocationsTrackingTableMask;
|
||||||
}
|
}
|
||||||
@@ -2010,9 +1970,7 @@ MM::Allocator::UnregisterAllocationTagExpansion(IN ULONG Tag,
|
|||||||
IN SIZE_T Bytes,
|
IN SIZE_T Bytes,
|
||||||
IN MMPOOL_TYPE PoolType)
|
IN MMPOOL_TYPE PoolType)
|
||||||
{
|
{
|
||||||
PPOOL_TRACKING_TABLE CpuTable;
|
|
||||||
ULONG Hash;
|
ULONG Hash;
|
||||||
ULONG Processor;
|
|
||||||
|
|
||||||
/* Start a guarded code block */
|
/* Start a guarded code block */
|
||||||
{
|
{
|
||||||
@@ -2055,22 +2013,18 @@ MM::Allocator::UnregisterAllocationTagExpansion(IN ULONG Tag,
|
|||||||
/* Target the index of the overflow bucket */
|
/* Target the index of the overflow bucket */
|
||||||
Hash = (ULONG)AllocationsTrackingTableSize - 1;
|
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 */
|
/* Update the appropriate statistics based on the pool type */
|
||||||
if((PoolType & MM_POOL_TYPE_MASK) == NonPagedPool)
|
if((PoolType & MM_POOL_TYPE_MASK) == NonPagedPool)
|
||||||
{
|
{
|
||||||
/* Update the non-paged allocation statistics */
|
/* Update the non-paged allocation statistics */
|
||||||
RTL::Atomic::Increment32((PLONG)&CpuTable[Hash].NonPagedFrees);
|
RTL::Atomic::Increment32((PLONG)&AllocationsTrackingTable[Hash].NonPagedFrees);
|
||||||
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&CpuTable[Hash].NonPagedBytes, 0 - Bytes);
|
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&AllocationsTrackingTable[Hash].NonPagedBytes, -(LONG_PTR)Bytes);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Update the paged allocation statistics */
|
/* Update the paged allocation statistics */
|
||||||
RTL::Atomic::Increment32((PLONG)&CpuTable[Hash].PagedFrees);
|
RTL::Atomic::Increment32((PLONG)&AllocationsTrackingTable[Hash].PagedFrees);
|
||||||
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&CpuTable[Hash].PagedBytes, 0 - Bytes);
|
RTL::Atomic::ExchangeAdd64((PLONG_PTR)&AllocationsTrackingTable[Hash].PagedBytes, -(LONG_PTR)Bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,6 @@ KSPIN_LOCK MM::Allocator::BigAllocationsTrackingTableLock;
|
|||||||
/* Maximum capacity of the tracking hash table */
|
/* Maximum capacity of the tracking hash table */
|
||||||
SIZE_T MM::Allocator::BigAllocationsTrackingTableSize;
|
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 */
|
/* Array of free page lists segregated by cache color */
|
||||||
PMMCOLOR_TABLES MM::Colors::FreePages[FreePageList + 1];
|
PMMCOLOR_TABLES MM::Colors::FreePages[FreePageList + 1];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user