Populate pool tracking table with common allocation tags
This commit is contained in:
@@ -64,6 +64,7 @@ namespace MM
|
|||||||
OUT PPFN_NUMBER PagesFreed);
|
OUT PPFN_NUMBER PagesFreed);
|
||||||
STATIC XTAPI XTSTATUS FreePagedPoolPages(IN PVOID VirtualAddress,
|
STATIC XTAPI XTSTATUS FreePagedPoolPages(IN PVOID VirtualAddress,
|
||||||
OUT PPFN_NUMBER PagesFreed);
|
OUT PPFN_NUMBER PagesFreed);
|
||||||
|
STATIC XTAPI VOID PopulateAllocationTags(VOID);
|
||||||
STATIC XTAPI VOID RegisterAllocationTag(IN ULONG Tag,
|
STATIC XTAPI VOID RegisterAllocationTag(IN ULONG Tag,
|
||||||
IN SIZE_T Bytes,
|
IN SIZE_T Bytes,
|
||||||
IN MMPOOL_TYPE PoolType);
|
IN MMPOOL_TYPE PoolType);
|
||||||
|
|||||||
@@ -1382,6 +1382,9 @@ MM::Allocator::InitializeAllocationsTracking(VOID)
|
|||||||
/* Calculate and store the hash mask */
|
/* Calculate and store the hash mask */
|
||||||
AllocationsTrackingTableMask = AllocationsTrackingTableSize - 2;
|
AllocationsTrackingTableMask = AllocationsTrackingTableSize - 2;
|
||||||
|
|
||||||
|
/* Populate the pool tracking table with the most frequently used allocation tags */
|
||||||
|
PopulateAllocationTags();
|
||||||
|
|
||||||
/* Initialize the spinlock used to synchronize concurrent modifications to the tracking table */
|
/* Initialize the spinlock used to synchronize concurrent modifications to the tracking table */
|
||||||
KE::SpinLock::InitializeSpinLock(&AllocationsTrackingTableLock);
|
KE::SpinLock::InitializeSpinLock(&AllocationsTrackingTableLock);
|
||||||
}
|
}
|
||||||
@@ -1502,6 +1505,64 @@ MM::Allocator::InitializeBigAllocationsTracking(VOID)
|
|||||||
NonPagedPool);
|
NonPagedPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the pool tracking table with the most frequently used allocation tags.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
MM::Allocator::PopulateAllocationTags(VOID)
|
||||||
|
{
|
||||||
|
ULONG Hash, HashIndex, Index;
|
||||||
|
|
||||||
|
CULONG HotTags[] =
|
||||||
|
{
|
||||||
|
SIGNATURE32('B', 'i', 'g', 'A'), /* Big Allocations */
|
||||||
|
SIGNATURE32('M', 'M', 'g', 'r'), /* Memory Manager Internal */
|
||||||
|
SIGNATURE32('N', 'o', 'n', 'e'), /* Untagged allocations */
|
||||||
|
SIGNATURE32('O', 'v', 'f', 'l'), /* Global table expansion overflow fallback */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Seed all tags */
|
||||||
|
for(Index = 0; Index < ARRAY_SIZE(HotTags); Index++)
|
||||||
|
{
|
||||||
|
/* Compute the initial hash index */
|
||||||
|
Hash = ComputeHash(HotTags[Index], AllocationsTrackingTableMask);
|
||||||
|
HashIndex = Hash;
|
||||||
|
|
||||||
|
/* Probe the tracking table until an empty slot is found */
|
||||||
|
while(TRUE)
|
||||||
|
{
|
||||||
|
/* Check if the tag is already present in the table */
|
||||||
|
if(AllocationsTrackingTable[Hash].Tag == HotTags[Index])
|
||||||
|
{
|
||||||
|
/* The tag has already been registered, skip it */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the slot is empty */
|
||||||
|
if((AllocationsTrackingTable[Hash].Tag == 0) && (Hash != (AllocationsTrackingTableSize - 1)))
|
||||||
|
{
|
||||||
|
/* Claim the slot and break the loop */
|
||||||
|
AllocationsTrackingTable[Hash].Tag = HotTags[Index];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Advance to the next index on collision */
|
||||||
|
Hash = (Hash + 1) & AllocationsTrackingTableMask;
|
||||||
|
|
||||||
|
/* Check if the hash index has wrapped around */
|
||||||
|
if(Hash == HashIndex)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a pool memory allocation in the tracking table.
|
* Registers a pool memory allocation in the tracking table.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user