From nobody Sun May 5 08:50:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1512660606960378.3963590668626; Thu, 7 Dec 2017 07:30:06 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2D868221EA0AD; Thu, 7 Dec 2017 07:25:32 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 518C6221EA0A5 for ; Thu, 7 Dec 2017 07:25:30 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2017 07:30:03 -0800 Received: from lgao4-mobl1.ccr.corp.intel.com ([10.254.210.154]) by fmsmga001.fm.intel.com with ESMTP; 07 Dec 2017 07:30:02 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,373,1508828400"; d="scan'208";a="11421329" From: Liming Gao To: edk2-devel@lists.01.org Date: Thu, 7 Dec 2017 23:29:53 +0800 Message-Id: <20171207152953.10840-1-liming.gao@intel.com> X-Mailer: git-send-email 2.11.0.windows.1 Subject: [edk2] [RFC] Update EDKII Performance infrastructure based on ACPI FPDT table X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gao, Liming" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Gao, Liming" Current EDKII performance implementation bases on performance protocol to l= og and dump performance entry. There is no way to get the performance data in = OS. ACPI FPDT table allows to insert the firmware extension record. If so, the detail boot performance data can be stored as FPDT record in ACPI FPDT=20 table. It supports to dump performance data in UEFI Shell and OS both. This proposal is to update EDKII performance infrastructure to log and dump=20 the performance entry as FPDT record in ACPI FPDT table. This RFC defines 5=20 edk2 FPDT records. Three of them are used for current Perf entry. Other two=20 will be used with new Perf APIs. Now, this proposal focus on the performance internal implementation, but doesn't impact PerformanceLib interfaces and DP application output. So, there is no change required to any consumer code and platform DSC/FDF. New Perf APIs will be introduced later. The detail changes are list here. 0. Introduce PCD PcdEdkiiFpdtStringRecordEnableOnly to generate two style e= dk2 extended FPDT records. 1. When PCD PcdEdkiiFpdtStringRecordEnableOnly is set to FALSE, the differe= nt records will be used to store the different performance entry. EDKII pro= vides two pair PERF APIs. PERF_START()/PERF_END() and PERF_START_EX()/PERF_END= _EX(). Every PERF_START or PERF_END will be saved into one record. Every record= has ProgressId to identify the perf entry. It has Guid to store the module G= UID. Some records have String for Token/Module name. PERF_START_EX()/PERF_END= _EX() has ProgressId parameter. They will be converted based on their Progress= Id. PERF_START()/PERF_END() have no ProgressId parameter. Its token name will be converted to ProgressId. Below is the detail mapping between perf token name and records. "StartImage:" --> GUID_EVENT_RECORD with ProgressId 0x01~0x02 "PEIM" --> GUID_EVENT_RECORD with ProgressId 0x01~0x02 "LoadImage:" --> GUID_QWORD_EVENT_RECORD with ProgressId 0x03~0x04, its Qword is the loaded image count. "DB:Start:" START --> GUID_QWORD_EVENT_RECORD with ProgressId 0x05, its Qword is the controller handle. "DB:Start:" END --> GUID_QWORD_STRING_EVENT_RECORD with ProgressId 0x0= 6, its Qword is the controller handle, its String is = the device path of the controller handle. "DB:Support:" --> GUID_QWORD_EVENT_RECORD with ProgressId 0x07~0x08, its Qword is the controller handle. "DB:Stop:" --> GUID_QWORD_EVENT_RECORD with ProgressId 0x09~0x0A, its Qword is the controller handle. "SEC", "PEI" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x50~0= x51 (cross module), its String is the token name. "DXE", "BDS" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x50~0= x51 (cross module), its String is the token name. Non-null token --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x40~0= x41 (in module), its String is the token name. Non-null module --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x40~0= x41 (in module), its String is the module name. Non-null Handle --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x40~0= x41 (in module), its String is the module name from Ha= ndle Others are ignored. 2. When PCD PcdEdkiiFpdtStringRecordEnableOnly is set to TRUE, DYNAMIC_STRING_EVENT_RECORD will be used to store all performance entry. Every record has ProgressId to identify the perf entry. Its Guid stores the module or caller GUID. Its String stores Token/Module name. PERF_START_EX()/PERF_END_EX() has ProgressId parameter. They will be converted based on their ProgressId. PERF_START()/PERF_END() have no ProgressId parameter. Its token name will be converted to ProgressId. Below is the detail mapping. "StartImage:" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x01~0x02 "PEIM" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x01~0x02 "LoadImage:" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x03~0x04 "DB:Start:" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x05~0x06 "DB:Support:" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x07~0x08 "DB:Stop:" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x09~0x0A "SEC", "PEI" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x50~0x51 (cross module), its String is the token name. "DXE", "BDS" --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x50~0x51 (cross module), its String is the token name. Non-null token --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x40~0x41 (in module), its String is the token name. Non-null module --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x40~0x41 (in module), its String is the module name. Non-null Handle --> DYNAMIC_STRING_EVENT_RECORD with ProgressId 0x40~0x41 (in module), its String is the module name from Hand= le Others are ignored. 3. Update MdeModulePkg three libraries PeiPerformanceLib,DxeCorePerformance= Lib and SmmCorePerformanceLib to store the performance entry in edkii extend= ed records, and report them to FPDT table driver. FPDT table driver has supported to accept the extended records and integrate those records into FPDT Firmware Basic Boot Performance (FBBP) Table. 4. Update MdeModulePkg FPDT table PEIM to collect edk2 string event records on S3 boot,and save them into FPDT FBBP Table. If so, OS utility can par= se FPDT FBBP table to get S3 boot performance data. 5. Update PerformancePkg Dp_App to parse ACPI FPDT table and get FBBP Table, then retrieve edkii string event records, convert them into the performa= nce entry log and dump them as current output format. 6. Clean up BDS and S3Resume2 module to drop PERF_CODE logic. Boot and S3 b= oot performance entries have been saved inito FPDT FBBP table. PERF_CODE log= ic is not used any longer. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao --- .../Include/Guid/ExtendedFirmwarePerformance.h | 258 +++++++++++++++++= ++++ MdeModulePkg/MdeModulePkg.dec | 9 + 2 files changed, 267 insertions(+) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h b/MdeM= odulePkg/Include/Guid/ExtendedFirmwarePerformance.h new file mode 100644 index 0000000000..34cd9bb539 --- /dev/null +++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h @@ -0,0 +1,258 @@ +/** @file + This file defines edk2 extended firmware performance records. + These records will be added into ACPI FPDT Firmware Basic Boot Performan= ce Table. + +Copyright (c) 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made availabl= e under=20 +the terms and conditions of the BSD License that accompanies this distribu= tion. =20 +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. = =20 + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. + +**/ + +#ifndef __EXTENDED_FIRMWARE_PERFORMANCE_H__ +#define __EXTENDED_FIRMWARE_PERFORMANCE_H__ + +#include + +// +// Known performance tokens +// +#define SEC_TOK "SEC" ///< SEC Phase +#define DXE_TOK "DXE" ///< DXE Phase +#define PEI_TOK "PEI" ///< PEI Phase +#define BDS_TOK "BDS" ///< BDS Phase +#define DRIVERBINDING_START_TOK "DB:Start:" ///< Driver Bind= ing Start() function call +#define DRIVERBINDING_SUPPORT_TOK "DB:Support:" ///< Driver Bind= ing Support() function call +#define DRIVERBINDING_STOP_TOK "DB:Stop:" ///< Driver Bind= ing Stop() function call +#define LOAD_IMAGE_TOK "LoadImage:" ///< Load a disp= atched module +#define START_IMAGE_TOK "StartImage:" ///< Dispatched = Modules Entry Point execution +#define PEIM_TOK "PEIM" ///< PEIM Module= s Entry Point execution + +// +// Public Progress Identifiers for Event Records to map the above known to= ken +// +#define MODULE_START_ID 0x01 +#define MODULE_END_ID 0x02 +#define MODULE_LOADIMAGE_START_ID 0x03 +#define MODULE_LOADIMAGE_END_ID 0x04 +#define MODULE_DB_START_ID 0x05 +#define MODULE_DB_END_ID 0x06 +#define MODULE_DB_SUPPORT_START_ID 0x07 +#define MODULE_DB_SUPPORT_END_ID 0x08 +#define MODULE_DB_STOP_BEGIN_ID 0x09 +#define MODULE_DB_STOP_END_ID 0x0A + +#define PERF_EVENTSIGNAL_BEGIN_ID 0x10 +#define PERF_EVENTSIGNAL_END_ID 0x11 +#define PERF_CALLBACK_BEGIN_ID 0x20 +#define PERF_CALLBACK_END_ID 0x21 +#define PERF_FUNCTION_BEGIN_ID 0x30 +#define PERF_FUNCTION_END_ID 0x31 +#define PERF_INMODULE_BEGIN_ID 0x40 +#define PERF_INMODULE_END_ID 0x41 +#define PERF_CROSSMODULE_BEGIN_ID 0x50 +#define PERF_CROSSMODULE_END_ID 0x51 + +// +// Misc defines +// +#define RECORD_REVISION_1 (0x01) + +// +// Length field in EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER is a UINT8,= thus: +// +#define MAX_PERF_RECORD_SIZE (0xFF) + +// +// FPDT Record Types +// +#define GUID_EVENT_TYPE 0x1010 +#define DYNAMIC_STRING_EVENT_TYPE 0x1011 +#define DUAL_GUID_STRING_EVENT_TYPE 0x1012 +#define GUID_QWORD_EVENT_TYPE 0x1013 +#define GUID_QWORD_STRING_EVENT_TYPE 0x1014 + +// +// EDKII extended Fpdt record structures +// +#define EDKII_STRING_EVENT_RECORD_NAME_LENGTH 24 + +#pragma pack(1) +// +// FPDT Boot Performance Guid Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-ze= ro value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock so= urce. + /// If only one timestamp clock source is used, this field is Reserved a= nd populated as 0. + /// + UINT32 ApicID; + /// + /// 64-bit value (nanosecond) describing elapsed time since the most rec= ent deassertion of processor reset. + /// + UINT64 Timestamp; + /// + /// If ProgressID < 0x10, GUID of the referenced module; otherwise, GUID= of the module logging the event. + /// + EFI_GUID Guid; +} GUID_EVENT_RECORD; + +// +// FPDT Boot Performance Dynamic String Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-ze= ro value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock so= urce. + /// If only one timestamp clock source is used, this field is Reserved a= nd populated as 0. + /// + UINT32 ApicID; + /// + /// 64-bit value (nanosecond) describing elapsed time since the most rec= ent deassertion of processor reset. + /// + UINT64 Timestamp; + /// + /// If ProgressID < 0x10, GUID of the referenced module; otherwise, GUID= of the module logging the event. + /// + EFI_GUID Guid; + /// + /// ASCII string describing the module. Padding supplied at the end if n= ecessary with null characters (0x00). + /// It may be module name, function name, or token name. + /// + CHAR8 String[0]; +} DYNAMIC_STRING_EVENT_RECORD; + +// +// FPDT Boot Performance Dual GUID String Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-ze= ro value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock so= urce. + /// If only one timestamp clock source is used, this field is Reserved a= nd populated as 0. + /// + UINT32 ApicID; + /// + /// 64-bit value (nanosecond) describing elapsed time since the most rec= ent deassertion of processor reset. + /// + UINT64 Timestamp; + /// + /// GUID of the module logging the event. + /// + EFI_GUID Guid1; + /// + /// Event or Ppi or Protocol GUID for Callback. + /// + EFI_GUID Guid2; + /// + /// ASCII string describing the module. Padding supplied at the end if n= ecessary with null characters (0x00). + /// It is the function name. + /// + CHAR8 String[0]; +} DUAL_GUID_STRING_EVENT_RECORD; + +// +// FPDT Boot Performance GUID Qword Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-ze= ro value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock so= urce. + /// If only one timestamp clock source is used, this field is Reserved a= nd populated as 0. + /// + UINT32 ApicID; + /// + /// 64-bit value (nanosecond) describing elapsed time since the most rec= ent deassertion of processor reset. + /// + UINT64 Timestamp; + /// + /// Qword of misc data, meaning depends on the ProgressId + /// + UINT64 Qword; +} GUID_QWORD_EVENT_RECORD; + +// +// FPDT Boot Performance GUID Qword String Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-ze= ro value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock so= urce. + /// If only one timestamp clock source is used, this field is Reserved a= nd populated as 0. + /// + UINT32 ApicID; + /// + /// 64-bit value (nanosecond) describing elapsed time since the most rec= ent deassertion of processor reset. + /// + UINT64 Timestamp; + /// + /// Qword of misc data, meaning depends on the ProgressId + /// + UINT64 Qword; + /// + /// ASCII string describing the module. Padding supplied at the end if n= ecessary with null characters (0x00). + /// + CHAR8 String[0]; +} GUID_QWORD_STRING_EVENT_RECORD; +#pragma pack() + +// +// Union of all pointers to FPDT records +// +typedef union { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *RecordHeader; + GUID_EVENT_RECORD *GuidEvent; + DYNAMIC_STRING_EVENT_RECORD *DynamicStringEvent; + DUAL_GUID_STRING_EVENT_RECORD *DualGuidStringEvent; + GUID_QWORD_EVENT_RECORD *GuidQwordEvent; + GUID_QWORD_STRING_EVENT_RECORD *GuidQwordStringEvent; +} FPDT_RECORD_PTR; + +/// +/// Hob: +/// GUID - gEdkiiExtendedFirmwarePerformanceGuid +/// Data - PEI_PERFORMANCE_LOG_HEADER + one or more FPDT records +/// +extern EFI_GUID gEdkiiExtendedFirmwarePerformanceGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 856d67aceb..bcf02de60d 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -391,6 +391,9 @@ =20 ## Include/Guid/PlatformHasAcpi.h gEdkiiPlatformHasAcpiGuid =3D { 0xf0966b41, 0xc23f, 0x41b9, { 0x96, 0x04= , 0x0f, 0xf7, 0xe1, 0x11, 0x96, 0x5a } } + =20 + ## Include/Guid/ExtendedFirmwarePerformance.h + gEdkiiExtendedFirmwarePerformanceGuid =3D { 0x3b387bfd, 0x7abc, 0x4cf2, = { 0xa0, 0xca, 0xb6, 0xa1, 0x6c, 0x1b, 0x1b, 0x25 } } =20 [Ppis] ## Include/Ppi/AtaController.h @@ -1383,6 +1386,12 @@ # @Prompt CapsuleMax value in capsule report variable. gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0xFFFF|UINT16|0x00000107 =20 + ## Control which FPDT record format will be used to store the performanc= e entry. + # On TRUE, the string FPDT record will be used to store every performanc= e entry.=20 + # On FALSE, the different FPDT record will be used to store the differen= t performance entries. + # @Prompt String FPDT Record Enable Only + gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiFpdtStringRecordEnableOnly|FALSE|= BOOLEAN|0x00000109 + [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] ## This PCD defines the Console output row. The default value is 25 acco= rding to UEFI spec. # This PCD could be set to 0 then console output would be at max column= and max row. --=20 2.11.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel