summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRay Ni <ray.ni@intel.com>2023-06-07 16:35:46 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-06-21 04:37:17 +0000
commita87f5fdb3d1a23b9ad2475007c58c0969863293f (patch)
treefed2ba0f46403a63c427e96cba93c5b6c36fa608
parent2d3974a35199bfafaf4b56cd908d99e456aed290 (diff)
downloadedk2-a87f5fdb3d1a23b9ad2475007c58c0969863293f.tar.gz
edk2-a87f5fdb3d1a23b9ad2475007c58c0969863293f.tar.bz2
edk2-a87f5fdb3d1a23b9ad2475007c58c0969863293f.zip
UefiCpuPkg/SmmCpu: Add PcdSmmApPerfLogEnable control AP perf-logging
When a platform has lots of CPU cores/threads, perf-logging on every AP produces lots of records. When this multiplies with number of SMIs during post, the records are even more. So, this patch adds a new PCD PcdSmmApPerfLogEnable (default TRUE) to allow platform to turn off perf-logging on APs. Signed-off-by: Ray Ni <ray.ni@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c2
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf1
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c11
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h4
-rw-r--r--UefiCpuPkg/UefiCpuPkg.dec6
5 files changed, 21 insertions, 3 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index bcd90f0671..8364b73242 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -784,7 +784,7 @@ BSPHandler (
// Any SMM MP performance logging after this point will be migrated in next SMI.
//
PERF_CODE (
- MigrateMpPerf (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus);
+ MigrateMpPerf (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus, CpuIndex);
);
//
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
index 4864532c35..d864ae9101 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
@@ -128,6 +128,7 @@
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileRingBuffer ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmFeatureControlMsrLock ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES
+ gUefiCpuPkgTokenSpaceGuid.PcdSmmApPerfLogEnable ## CONSUMES
[Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c
index f6323f9230..6d5d2b2d63 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c
@@ -38,16 +38,25 @@ InitializeMpPerf (
Migrate MP performance data to standardized performance database.
@param NumberofCpus Number of processors in the platform.
+ @param BspIndex The index of the BSP.
**/
VOID
MigrateMpPerf (
- UINTN NumberofCpus
+ UINTN NumberofCpus,
+ UINTN BspIndex
)
{
UINTN CpuIndex;
UINTN MpProcecureId;
for (CpuIndex = 0; CpuIndex < NumberofCpus; CpuIndex++) {
+ if ((CpuIndex != BspIndex) && !FeaturePcdGet (PcdSmmApPerfLogEnable)) {
+ //
+ // Skip migrating AP performance data if AP perf-logging is disabled.
+ //
+ continue;
+ }
+
for (MpProcecureId = 0; MpProcecureId < SMM_MP_PERF_PROCEDURE_ID (SmmMpProcedureMax); MpProcecureId++) {
if (mSmmMpProcedurePerformance[CpuIndex].Begin[MpProcecureId] != 0) {
PERF_START (NULL, gSmmMpPerfProcedureName[MpProcecureId], NULL, mSmmMpProcedurePerformance[CpuIndex].Begin[MpProcecureId]);
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h
index d9f0fb9bf6..591b212c06 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h
@@ -48,10 +48,12 @@ InitializeMpPerf (
Migrate MP performance data to standardized performance database.
@param NumberofCpus Number of processors in the platform.
+ @param BspIndex The index of the BSP.
**/
VOID
MigrateMpPerf (
- UINTN NumberofCpus
+ UINTN NumberofCpus,
+ UINTN BspIndex
);
/**
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index d31c3b127c..5b0ac64e33 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -175,6 +175,12 @@
# @Prompt Support SmmFeatureControl.
gUefiCpuPkgTokenSpaceGuid.PcdSmmFeatureControlEnable|TRUE|BOOLEAN|0x32132110
+ ## Indicates if SMM perf logging in APs will be enabled.<BR><BR>
+ # TRUE - SMM perf logging in APs will be enabled.<BR>
+ # FALSE - SMM perf logging in APs will not be enabled.<BR>
+ # @Prompt Enable SMM perf logging in APs.
+ gUefiCpuPkgTokenSpaceGuid.PcdSmmApPerfLogEnable|TRUE|BOOLEAN|0x32132114
+
[PcdsFixedAtBuild]
## List of exception vectors which need switching stack.
# This PCD will only take into effect if PcdCpuStackGuard is enabled.