Skip to content

Commit

Permalink
MdeModulePkg DxeCore: Check free memory type by CoreUpdateProfile()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Feng Tian <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <[email protected]>
Reviewed-by: Jiewen Yao <[email protected]>
  • Loading branch information
lzeng14 committed Apr 26, 2016
1 parent 6523ae8 commit dea0d6b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion MdeModulePkg/Core/Dxe/DxeMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
13 changes: 4 additions & 9 deletions MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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 ();
Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Core/Dxe/Mem/Page.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Core/Dxe/Mem/Pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dea0d6b

Please sign in to comment.