From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Dmitry Antipov <dmanti@microsoft.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <liming.gao@intel.com>,
Star Zeng <star.zeng@intel.com>
Subject: [patch 2/3] MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi
Date: Mon, 30 Jul 2018 14:59:04 +0800 [thread overview]
Message-ID: <20180730065905.9152-3-dandan.bi@intel.com> (raw)
In-Reply-To: <20180730065905.9152-1-dandan.bi@intel.com>
Enhance the PeiPerformanceLib to produce the Performance
Measurement PPI.
Cc: Dmitry Antipov <dmanti@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../Library/PeiPerformanceLib/PeiPerformanceLib.c | 81 ++++++++++++++++++++++
.../PeiPerformanceLib/PeiPerformanceLib.inf | 1 +
2 files changed, 82 insertions(+)
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
index 808a63501e..528bf12303 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
@@ -30,14 +30,52 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/HobLib.h>
#include <Library/BaseLib.h>
#include <Library/TimerLib.h>
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/PeiServicesLib.h>
#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
#define PEI_MAX_RECORD_SIZE (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD) + STRING_SIZE)
+/**
+ Create performance record with event description and a timestamp.
+
+ @param CallerIdentifier - Image handle or pointer to caller ID GUID.
+ @param Guid - Pointer to a GUID.
+ @param String - Pointer to a string describing the measurement.
+ @param TimeStamp - 64-bit time stamp.
+ @param Address - Pointer to a location in memory relevant to the measurement.
+ @param Identifier - Performance identifier describing the type of measurement.
+ @param Attribute - The attribute of the measurement. According to attribute can create a start
+ record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,
+ or a general record for other Perf macros.
+
+ @retval EFI_SUCCESS - Successfully created performance record.
+ @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records.
+ @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+ pointer or invalid PerfId.
+**/
+EFI_STATUS
+EFIAPI
+CreatePerformanceMeasurementPpi (
+ IN CONST VOID *CallerIdentifier,
+ IN CONST VOID *Guid, OPTIONAL
+ IN CONST CHAR8 *String, OPTIONAL
+ IN UINT64 TimeStamp,
+ IN UINT64 Address, OPTIONAL
+ IN UINT32 Identifier,
+ IN PERF_MEASUREMENT_ATTRIBUTE Attribute
+ );
+
+EDKII_PERFORMANCE_MEASUREMENT_PPI mPerformancePpi = {CreatePerformanceMeasurementPpi};
+
+EFI_PEI_PPI_DESCRIPTOR mPerformancePpiDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEdkiiPerformanceMeasurementPpiGuid,
+ &mPerformancePpi
+};
/**
Return the pointer to the FPDT record in the allocated memory.
@param RecordSize The size of FPDT record.
@@ -56,10 +94,12 @@ GetFpdtRecordPtr (
{
UINT16 PeiPerformanceLogEntries;
UINTN PeiPerformanceSize;
UINT8 *PeiFirmwarePerformance;
EFI_HOB_GUID_TYPE *GuidHob;
+ EFI_HOB_GUID_TYPE *FirstGuidHob;
+ EFI_STATUS Status;
//
// Get the number of PeiPerformanceLogEntries form PCD.
//
PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?
@@ -68,10 +108,11 @@ GetFpdtRecordPtr (
//
// Create GUID HOB Data.
//
GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid);
+ FirstGuidHob = GuidHob;
PeiFirmwarePerformance = NULL;
while (GuidHob != NULL) {
//
// PEI Performance HOB was found, then return the existing one.
//
@@ -89,10 +130,16 @@ GetFpdtRecordPtr (
//
GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));
}
if (GuidHob == NULL) {
+ if (FirstGuidHob == NULL) {
+ Status = PeiServicesInstallPpi(&mPerformancePpiDesc);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "PeiCorePerformanceLib - %a - InstallPpi returned %r!\n", __FUNCTION__, Status));
+ }
+ }
//
// PEI Performance HOB was not found, then build one.
//
PeiPerformanceSize = sizeof (FPDT_PEI_EXT_PERF_HEADER) +
PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntries;
@@ -513,10 +560,44 @@ InsertFpdtRecord (
PeiPerformanceLogHeader->SizeOfAllEntries += FpdtRecordPtr.RecordHeader->Length;
return EFI_SUCCESS;
}
+/**
+ Create performance record with event description and a timestamp.
+
+ @param CallerIdentifier - Image handle or pointer to caller ID GUID.
+ @param Guid - Pointer to a GUID.
+ @param String - Pointer to a string describing the measurement.
+ @param TimeStamp - 64-bit time stamp.
+ @param Address - Pointer to a location in memory relevant to the measurement.
+ @param Identifier - Performance identifier describing the type of measurement.
+ @param Attribute - The attribute of the measurement. According to attribute can create a start
+ record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,
+ or a general record for other Perf macros.
+
+ @retval EFI_SUCCESS - Successfully created performance record.
+ @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records.
+ @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+ pointer or invalid PerfId.
+**/
+EFI_STATUS
+EFIAPI
+CreatePerformanceMeasurementPpi (
+ IN CONST VOID *CallerIdentifier,
+ IN CONST VOID *Guid, OPTIONAL
+ IN CONST CHAR8 *String, OPTIONAL
+ IN UINT64 TimeStamp,
+ IN UINT64 Address, OPTIONAL
+ IN UINT32 Identifier,
+ IN PERF_MEASUREMENT_ATTRIBUTE Attribute
+ )
+{
+ return InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute);
+
+}
+
/**
Creates a record for the beginning of a performance measurement.
If TimeStamp is zero, then this function reads the current time stamp
and adds that time stamp value to the record as the start time.
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
index cad3a120a2..9b40af0738 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
@@ -52,10 +52,11 @@
[Guids]
## PRODUCES ## HOB
## CONSUMES ## HOB
gEdkiiFpdtExtendedFirmwarePerformanceGuid
+ gEdkiiPerformanceMeasurementPpiGuid
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries16 ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES
--
2.14.3.windows.1
next prev parent reply other threads:[~2018-07-30 7:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 6:59 [patch 0/3] Add PeiPerformancePpiLib Dandan Bi
2018-07-30 6:59 ` [patch 1/3] MdeModulePkg: Add the definition of performance measurement PPI Dandan Bi
2018-07-30 6:59 ` Dandan Bi [this message]
2018-07-30 6:59 ` [patch 3/3] MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib Dandan Bi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180730065905.9152-3-dandan.bi@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox