UefiCpuPkg/CpuSmm: Add perf-logging for MP procedures

MP procedures are those procedures that run in every CPU thread.
The EDKII perf infra is not MP safe so it doesn't support to be called
from those MP procedures.

The patch adds SMM MP perf-logging support in SmmMpPerf.c.
The following procedures are perf-logged:
* SmmInitHandler
* SmmCpuFeaturesRendezvousEntry
* PlatformValidSmi
* SmmCpuFeaturesRendezvousExit

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>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
This commit is contained in:
Ray Ni
2023-05-26 21:34:36 +08:00
committed by mergify[bot]
parent 0da3df78ff
commit ad6c8540cc
6 changed files with 219 additions and 0 deletions

View File

@@ -778,6 +778,15 @@ BSPHandler (
//
WaitForAllAPs (ApCount);
//
// At this point, all APs should have exited from APHandler().
// Migrate the SMM MP performance logging to standard SMM performance logging.
// Any SMM MP performance logging after this point will be migrated in next SMI.
//
PERF_CODE (
MigrateMpPerf (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus);
);
//
// Reset the tokens buffer.
//
@@ -1769,12 +1778,24 @@ SmiRendezvous (
//
// Perform CPU specific entry hooks
//
PERF_CODE (
MpPerfBegin (CpuIndex, SMM_MP_PERF_PROCEDURE_ID (SmmRendezvousEntry));
);
SmmCpuFeaturesRendezvousEntry (CpuIndex);
PERF_CODE (
MpPerfEnd (CpuIndex, SMM_MP_PERF_PROCEDURE_ID (SmmRendezvousEntry));
);
//
// Determine if this is a valid SMI
//
PERF_CODE (
MpPerfBegin (CpuIndex, SMM_MP_PERF_PROCEDURE_ID (PlatformValidSmi));
);
ValidSmi = PlatformValidSmi ();
PERF_CODE (
MpPerfEnd (CpuIndex, SMM_MP_PERF_PROCEDURE_ID (PlatformValidSmi));
);
//
// Determine if BSP has been already in progress. Note this must be checked after
@@ -1904,7 +1925,20 @@ SmiRendezvous (
}
Exit:
//
// Note: SmmRendezvousExit perf-logging entry is the only one that will be
// migrated to standard perf-logging database in next SMI by BSPHandler().
// Hence, the number of SmmRendezvousEntry entries will be larger than
// the number of SmmRendezvousExit entries. Delta equals to the number
// of CPU threads.
//
PERF_CODE (
MpPerfBegin (CpuIndex, SMM_MP_PERF_PROCEDURE_ID (SmmRendezvousExit));
);
SmmCpuFeaturesRendezvousExit (CpuIndex);
PERF_CODE (
MpPerfEnd (CpuIndex, SMM_MP_PERF_PROCEDURE_ID (SmmRendezvousExit));
);
//
// Restore Cr2