From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.11830.1685532887032383064 for ; Wed, 31 May 2023 04:34:54 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bt26RCL1; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685532894; x=1717068894; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PyMM2WaifTFl2WOnfOxLyWpNEdhJw+rAvKNASh84YY8=; b=bt26RCL14RWPsIQuwbu/3hQWmBrbmAfXWQVN++PYlzJS5sNC+c3KeSQ1 ymaVEBhH1FFvuq38IyfQ1/LvbOLHn1tpZyBedys3qnwyDiRt7nIEQIC6L HDiM4dUihTl9AsSFyRuLlKVdzut8lfPJtnl1YmnmY/F0gIcWRKhxTqLN5 7i1D/EbPqA1LypHxlCeODWXQgj/ytq34G1dJHzyFQrfYW+/Q3si1Sx5/O rfr4qlP00+bNNSolmwDG+/lfLM1evHhoWsABd+bHC0mMqurVsm232X/eG VJVEa/WNCRztcy3dXLiCTd2DV40qKnc3GtwN215JzFaYw7p27gd4dhDDH A==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="334830257" X-IronPort-AV: E=Sophos;i="6.00,207,1681196400"; d="scan'208";a="334830257" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 04:34:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="739921510" X-IronPort-AV: E=Sophos;i="6.00,207,1681196400"; d="scan'208";a="739921510" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.55.95]) by orsmga001.jf.intel.com with ESMTP; 31 May 2023 04:34:52 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Jiaxin Wu , Dandan Bi , Liming Gao , Jian J Wang Subject: [PATCH V2 5/6] MdeModulePkg/SmmPerformanceLib: Disable perf-logging after ExitBS Date: Wed, 31 May 2023 19:34:37 +0800 Message-Id: <20230531113438.1797-6-ray.ni@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 In-Reply-To: <20230531113438.1797-1-ray.ni@intel.com> References: <20230531113438.1797-1-ray.ni@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Because SMM perf-logging is migrated to non-SMRAM at ReadyToBoot by DxeCorePerformanceLib, the perf-logging after ExitBS is useless and impact the SMI latency at runtime. Hence the SmmPerformanceLib is updated to disable perf-logging after ExitBS. Cc: Jiaxin Wu Cc: Dandan Bi Cc: Liming Gao Cc: Jian J Wang --- .../SmmPerformanceLib/SmmPerformanceLib.c | 63 ++++++++++++++++++- .../SmmPerformanceLib/SmmPerformanceLib.inf | 4 ++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c b/M= deModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c index 623f8a978c..b9c33c0f64 100644 --- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c +++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c @@ -23,6 +23,36 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // The cached SMM Performance Protocol and SMM PerformanceEx Protocol inte= rface.=0D EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement =3D NULL;= =0D BOOLEAN mPerformanceMeasurementEnabled;=0D +VOID *mPerformanceLibExitBootServicesRe= gistration;=0D +=0D +/**=0D + This is the Event call back function is triggered in SMM to notify the L= ibrary=0D + the system is entering runtime phase.=0D +=0D + @param[in] Protocol Points to the protocol's unique identifier=0D + @param[in] Interface Points to the interface instance=0D + @param[in] Handle The handle on which the interface was installed=0D +=0D + @retval EFI_SUCCESS SmmAtRuntimeCallBack runs successfully=0D + **/=0D +EFI_STATUS=0D +EFIAPI=0D +SmmPerformanceLibExitBootServicesCallback (=0D + IN CONST EFI_GUID *Protocol,=0D + IN VOID *Interface,=0D + IN EFI_HANDLE Handle=0D + )=0D +{=0D + //=0D + // Disable performance measurement after ExitBootServices because=0D + // 1. Performance measurement might impact SMI latency at runtime;=0D + // 2. Performance log is copied to non SMRAM at ReadyToBoot so runtime p= erformance=0D + // log is not useful.=0D + //=0D + mPerformanceMeasurementEnabled =3D FALSE;=0D +=0D + return EFI_SUCCESS;=0D +}=0D =0D /**=0D The constructor function initializes the Performance Measurement Enable = flag=0D @@ -40,9 +70,40 @@ SmmPerformanceLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable=0D )=0D {=0D + EFI_STATUS Status;=0D +=0D mPerformanceMeasurementEnabled =3D (BOOLEAN)((PcdGet8 (PcdPerformanceLi= braryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D= 0);=0D =0D - return EFI_SUCCESS;=0D + Status =3D gSmst->SmmRegisterProtocolNotify (=0D + &gEdkiiSmmExitBootServicesProtocolGuid,=0D + SmmPerformanceLibExitBootServicesCallback,=0D + &mPerformanceLibExitBootServicesRegistration=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + return Status;=0D +}=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +SmmPerformanceLibDestructor (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + //=0D + // Unregister SmmExitBootServices notification.=0D + //=0D + Status =3D gSmst->SmmRegisterProtocolNotify (=0D + &gEdkiiSmmExitBootServicesProtocolGuid,=0D + NULL,=0D + &mPerformanceLibExitBootServicesRegistration=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + return Status;=0D }=0D =0D /**=0D diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf b= /MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf index d79cd5c8da..002462f5ca 100644 --- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf +++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf @@ -21,6 +21,7 @@ LIBRARY_CLASS =3D PerformanceLib|DXE_SMM_DRIVER=0D =0D CONSTRUCTOR =3D SmmPerformanceLibConstructor=0D + DESTRUCTOR =3D SmmPerformanceLibDestructor=0D =0D #=0D # The following information is for reference only and not required by the = build tools.=0D @@ -46,5 +47,8 @@ [Guids]=0D gEdkiiSmmPerformanceMeasurementProtocolGuid ## SOMETIMES_CONSUM= ES ## UNDEFINED # Locate protocol=0D =0D +[Protocols]=0D + gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES=0D +=0D [Pcd]=0D gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUME= S=0D --=20 2.39.1.windows.1