MdeModulePkg DxeCore: Check free memory type by CoreUpdateProfile()
It can improve profile performance, especially when PcdMemoryProfileMemoryType configured without EfiBootServicesData. CoreUpdateProfile() can return quickly, but not depend on the further code to find the buffer not recorded and then return. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
@@ -2821,7 +2821,7 @@ BOOLEAN
|
||||
CoreUpdateProfile (
|
||||
IN EFI_PHYSICAL_ADDRESS CallerAddress,
|
||||
IN MEMORY_PROFILE_ACTION Action,
|
||||
IN EFI_MEMORY_TYPE MemoryType, // Valid for AllocatePages/AllocatePool
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
@@ -1105,7 +1105,7 @@ BOOLEAN
|
||||
CoreUpdateProfile (
|
||||
IN PHYSICAL_ADDRESS CallerAddress,
|
||||
IN MEMORY_PROFILE_ACTION Action,
|
||||
IN EFI_MEMORY_TYPE MemoryType, // Valid for AllocatePages/AllocatePool
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool
|
||||
IN VOID *Buffer
|
||||
)
|
||||
@@ -1121,15 +1121,10 @@ CoreUpdateProfile (
|
||||
}
|
||||
|
||||
//
|
||||
// Free operations have no memory type information, so skip the check.
|
||||
// Only record limited MemoryType.
|
||||
//
|
||||
if ((Action == MemoryProfileActionAllocatePages) || (Action == MemoryProfileActionAllocatePool)) {
|
||||
//
|
||||
// Only record limited MemoryType.
|
||||
//
|
||||
if (!CoreNeedRecordProfile (MemoryType)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!CoreNeedRecordProfile (MemoryType)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ContextData = GetMemoryProfileContext ();
|
||||
|
@@ -1444,7 +1444,7 @@ CoreFreePages (
|
||||
|
||||
Status = CoreInternalFreePages (Memory, NumberOfPages, &MemoryType);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePages, (EFI_MEMORY_TYPE) 0, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) Memory);
|
||||
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePages, MemoryType, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) Memory);
|
||||
InstallMemoryAttributesTableOnMemoryAllocation (MemoryType);
|
||||
}
|
||||
return Status;
|
||||
|
@@ -505,7 +505,7 @@ CoreFreePool (
|
||||
|
||||
Status = CoreInternalFreePool (Buffer, &PoolType);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePool, (EFI_MEMORY_TYPE) 0, 0, Buffer);
|
||||
CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePool, PoolType, 0, Buffer);
|
||||
InstallMemoryAttributesTableOnMemoryAllocation (PoolType);
|
||||
}
|
||||
return Status;
|
||||
|
Reference in New Issue
Block a user