TianoCore EDK2 master
Loading...
Searching...
No Matches
SmmMpPerf.c
Go to the documentation of this file.
1
10#include "PiSmmCpuCommon.h"
11
12#define SMM_MP_PERF_PROCEDURE_NAME(procedure) # procedure
14CHAR8 *gSmmMpPerfProcedureName[] = {
15 SMM_MP_PERF_PROCEDURE_LIST (SMM_MP_PERF_PROCEDURE_NAME)
16};
17//
18// Each element holds the performance data for one processor.
19//
21SMM_PERF_AP_PROCEDURE_PERFORMANCE *mSmmMpProcedurePerformance = NULL;
22
28VOID
30 UINTN NumberofCpus
31 )
32{
33 mSmmMpProcedurePerformance = AllocateZeroPool (NumberofCpus * sizeof (*mSmmMpProcedurePerformance));
34 ASSERT (mSmmMpProcedurePerformance != NULL);
35}
36
43VOID
45 UINTN NumberofCpus,
46 UINTN BspIndex
47 )
48{
49 UINTN CpuIndex;
50 UINTN MpProcecureId;
51
52 for (CpuIndex = 0; CpuIndex < NumberofCpus; CpuIndex++) {
53 if ((CpuIndex != BspIndex) && !FeaturePcdGet (PcdSmmApPerfLogEnable)) {
54 //
55 // Skip migrating AP performance data if AP perf-logging is disabled.
56 //
57 continue;
58 }
59
60 for (MpProcecureId = 0; MpProcecureId < SMM_MP_PERF_PROCEDURE_ID (SmmMpProcedureMax); MpProcecureId++) {
61 if (mSmmMpProcedurePerformance[CpuIndex].Begin[MpProcecureId] != 0) {
62 PERF_START (NULL, gSmmMpPerfProcedureName[MpProcecureId], NULL, mSmmMpProcedurePerformance[CpuIndex].Begin[MpProcecureId]);
63 PERF_END (NULL, gSmmMpPerfProcedureName[MpProcecureId], NULL, mSmmMpProcedurePerformance[CpuIndex].End[MpProcecureId]);
64 }
65 }
66 }
67
68 ZeroMem (mSmmMpProcedurePerformance, NumberofCpus * sizeof (*mSmmMpProcedurePerformance));
69}
70
77VOID
79 IN UINTN CpuIndex,
80 IN UINTN MpProcedureId
81 )
82{
83 mSmmMpProcedurePerformance[CpuIndex].Begin[MpProcedureId] = GetPerformanceCounter ();
84}
85
92VOID
94 IN UINTN CpuIndex,
95 IN UINTN MpProcedureId
96 )
97{
98 mSmmMpProcedurePerformance[CpuIndex].End[MpProcedureId] = GetPerformanceCounter ();
99}
UINT64 UINTN
UINT64 EFIAPI GetPerformanceCounter(VOID)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define GLOBAL_REMOVE_IF_UNREFERENCED
Definition: Base.h:48
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
#define PERF_END(Handle, Token, Module, TimeStamp)
#define PERF_START(Handle, Token, Module, TimeStamp)
VOID MpPerfBegin(IN UINTN CpuIndex, IN UINTN MpProcedureId)
Definition: SmmMpPerf.c:78
VOID MpPerfEnd(IN UINTN CpuIndex, IN UINTN MpProcedureId)
Definition: SmmMpPerf.c:93
VOID MigrateMpPerf(UINTN NumberofCpus, UINTN BspIndex)
Definition: SmmMpPerf.c:44
VOID InitializeMpPerf(UINTN NumberofCpus)
Definition: SmmMpPerf.c:29