VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.c@ 106901

Last change on this file since 106901 was 101291, checked in by vboxsync, 17 months ago

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
1/** @file
2SMM MP perf-logging implementation
3
4Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
5
6SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#include "PiSmmCpuDxeSmm.h"
11
12#define SMM_MP_PERF_PROCEDURE_NAME(procedure) # procedure
13GLOBAL_REMOVE_IF_UNREFERENCED
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//
20GLOBAL_REMOVE_IF_UNREFERENCED
21SMM_PERF_AP_PROCEDURE_PERFORMANCE *mSmmMpProcedurePerformance = NULL;
22
23/**
24 Initialize the perf-logging feature for APs.
25
26 @param NumberofCpus Number of processors in the platform.
27**/
28VOID
29InitializeMpPerf (
30 UINTN NumberofCpus
31 )
32{
33 mSmmMpProcedurePerformance = AllocateZeroPool (NumberofCpus * sizeof (*mSmmMpProcedurePerformance));
34 ASSERT (mSmmMpProcedurePerformance != NULL);
35}
36
37/**
38 Migrate MP performance data to standardized performance database.
39
40 @param NumberofCpus Number of processors in the platform.
41 @param BspIndex The index of the BSP.
42**/
43VOID
44MigrateMpPerf (
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
71/**
72 Save the performance counter value before running the MP procedure.
73
74 @param CpuIndex The index of the CPU.
75 @param MpProcedureId The ID of the MP procedure.
76**/
77VOID
78MpPerfBegin (
79 IN UINTN CpuIndex,
80 IN UINTN MpProcedureId
81 )
82{
83 mSmmMpProcedurePerformance[CpuIndex].Begin[MpProcedureId] = GetPerformanceCounter ();
84}
85
86/**
87 Save the performance counter value after running the MP procedure.
88
89 @param CpuIndex The index of the CPU.
90 @param MpProcedureId The ID of the MP procedure.
91**/
92VOID
93MpPerfEnd (
94 IN UINTN CpuIndex,
95 IN UINTN MpProcedureId
96 )
97{
98 mSmmMpProcedurePerformance[CpuIndex].End[MpProcedureId] = GetPerformanceCounter ();
99}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette