[PATCH 3/3] MdeModulePkg/SmmCore: Add perf-logging for time-consuming procedures


Ni, Ray
 

Following procedures are perf-logged:
* SmmReadyToBootHandler
* SmmReadyToLockHandler
* SmmEndOfDxeHandler
* SmmEntryPoint
(It's the main routine run in BSP when SMI happens.)
* SmiManage

Cc: Jian J Wang <jian.j.wang@...>
Cc: Liming Gao <gaoliming@...>
Cc: Jiaxin Wu <jiaxin.wu@...>
---
MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 14 +++++++++++++-
MdeModulePkg/Core/PiSmmCore/Smi.c | 6 ++++++
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/Pi=
SmmCore/PiSmmCore.c
index 875c7c0258..a15afa8dd6 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -1,7 +1,7 @@
/** @file=0D
SMM Core Main Entry Point=0D
=0D
- Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -304,6 +304,7 @@ SmmReadyToBootHandler (
{=0D
EFI_STATUS Status;=0D
EFI_HANDLE SmmHandle;=0D
+ PERF_CALLBACK_BEGIN (&gEfiEventReadyToBootGuid);=0D
=0D
//=0D
// Install SMM Ready To Boot protocol.=0D
@@ -318,6 +319,7 @@ SmmReadyToBootHandler (
=0D
SmiHandlerUnRegister (DispatchHandle);=0D
=0D
+ PERF_CALLBACK_END (&gEfiEventReadyToBootGuid);=0D
return Status;=0D
}=0D
=0D
@@ -352,6 +354,8 @@ SmmReadyToLockHandler (
EFI_HANDLE SmmHandle;=0D
VOID *Interface;=0D
=0D
+ PERF_CALLBACK_BEGIN (&gEfiDxeSmmReadyToLockProtocolGuid);=0D
+=0D
//=0D
// Unregister SMI Handlers that are no required after the SMM driver dis=
patch is stopped=0D
//=0D
@@ -408,6 +412,7 @@ SmmReadyToLockHandler (
=0D
SmramProfileReadyToLock ();=0D
=0D
+ PERF_CALLBACK_END (&gEfiDxeSmmReadyToLockProtocolGuid);=0D
return Status;=0D
}=0D
=0D
@@ -442,6 +447,8 @@ SmmEndOfDxeHandler (
=0D
DEBUG ((DEBUG_INFO, "SmmEndOfDxeHandler\n"));=0D
=0D
+ PERF_CALLBACK_BEGIN (&gEfiEndOfDxeEventGroupGuid);=0D
+=0D
//=0D
// Install SMM EndOfDxe protocol=0D
//=0D
@@ -479,6 +486,7 @@ SmmEndOfDxeHandler (
}=0D
}=0D
=0D
+ PERF_CALLBACK_END (&gEfiEndOfDxeEventGroupGuid);=0D
return EFI_SUCCESS;=0D
}=0D
=0D
@@ -669,6 +677,8 @@ SmmEntryPoint (
VOID *CommunicationBuffer;=0D
UINTN BufferSize;=0D
=0D
+ PERF_FUNCTION_BEGIN ();=0D
+=0D
//=0D
// Update SMST with contents of the SmmEntryContext structure=0D
//=0D
@@ -769,6 +779,8 @@ SmmEntryPoint (
//=0D
gSmmCorePrivate->InSmm =3D FALSE;=0D
}=0D
+=0D
+ PERF_FUNCTION_END ();=0D
}=0D
=0D
/**=0D
diff --git a/MdeModulePkg/Core/PiSmmCore/Smi.c b/MdeModulePkg/Core/PiSmmCor=
e/Smi.c
index 6d13969979..2985f989c3 100644
--- a/MdeModulePkg/Core/PiSmmCore/Smi.c
+++ b/MdeModulePkg/Core/PiSmmCore/Smi.c
@@ -109,6 +109,8 @@ SmiManage (
BOOLEAN SuccessReturn;=0D
EFI_STATUS Status;=0D
=0D
+ PERF_FUNCTION_BEGIN ();=0D
+=0D
Status =3D EFI_NOT_FOUND;=0D
SuccessReturn =3D FALSE;=0D
if (HandlerType =3D=3D NULL) {=0D
@@ -125,6 +127,7 @@ SmiManage (
//=0D
// There is no handler registered for this interrupt source=0D
//=0D
+ PERF_FUNCTION_END ();=0D
return Status;=0D
}=0D
}=0D
@@ -148,6 +151,7 @@ SmiManage (
// no additional handlers will be processed and EFI_INTERRUPT_PEND=
ING will be returned.=0D
//=0D
if (HandlerType !=3D NULL) {=0D
+ PERF_FUNCTION_END ();=0D
return EFI_INTERRUPT_PENDING;=0D
}=0D
=0D
@@ -160,6 +164,7 @@ SmiManage (
// additional handlers will be processed.=0D
//=0D
if (HandlerType !=3D NULL) {=0D
+ PERF_FUNCTION_END ();=0D
return EFI_SUCCESS;=0D
}=0D
=0D
@@ -194,6 +199,7 @@ SmiManage (
Status =3D EFI_SUCCESS;=0D
}=0D
=0D
+ PERF_FUNCTION_END ();=0D
return Status;=0D
}=0D
=0D
--=20
2.39.1.windows.1

Join devel@edk2.groups.io to automatically receive all group messages.