public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] UefiCpuPkg/SmmCpu: Add PcdSmmApPerfLogEnable control AP perf-logging
@ 2023-06-07  8:37 Ni, Ray
  2023-06-09  3:23 ` Dong, Eric
  0 siblings, 1 reply; 2+ messages in thread
From: Ni, Ray @ 2023-06-07  8:37 UTC (permalink / raw)
  To: devel; +Cc: Eric Dong, Rahul Kumar, Gerd Hoffmann

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.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c        |  2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf |  1 +
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c        | 11 ++++++++++-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h        |  4 +++-
 UefiCpuPkg/UefiCpuPkg.dec                    |  6 ++++++
 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 c13556af46..92c67f31bf 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c
@@ -39,16 +39,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 b148a99e86..5ad1734cc8 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h
@@ -44,10 +44,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.
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] UefiCpuPkg/SmmCpu: Add PcdSmmApPerfLogEnable control AP perf-logging
  2023-06-07  8:37 [PATCH] UefiCpuPkg/SmmCpu: Add PcdSmmApPerfLogEnable control AP perf-logging Ni, Ray
@ 2023-06-09  3:23 ` Dong, Eric
  0 siblings, 0 replies; 2+ messages in thread
From: Dong, Eric @ 2023-06-09  3:23 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io; +Cc: Kumar, Rahul R, Gerd Hoffmann

Looks good to me.

Thanks,
Eric

-----Original Message-----
From: Ni, Ray <ray.ni@intel.com> 
Sent: Wednesday, June 7, 2023 4:38 PM
To: devel@edk2.groups.io
Cc: Dong, Eric <eric.dong@intel.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH] 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.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c        |  2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf |  1 +
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c        | 11 ++++++++++-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h        |  4 +++-
 UefiCpuPkg/UefiCpuPkg.dec                    |  6 ++++++
 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 c13556af46..92c67f31bf 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c
@@ -39,16 +39,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 b148a99e86..5ad1734cc8 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h
@@ -44,10 +44,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.

-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-09  3:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07  8:37 [PATCH] UefiCpuPkg/SmmCpu: Add PcdSmmApPerfLogEnable control AP perf-logging Ni, Ray
2023-06-09  3:23 ` Dong, Eric

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox