From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web10.7304.1686636811551339614 for ; Mon, 12 Jun 2023 23:13:42 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=EOZZjXgP; spf=pass (domain: intel.com, ip: 192.55.52.115, 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=1686636822; x=1718172822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZSb4H7kh0u7P23q/NH9POwqLyZ5G4UBBFZuFCRnuzU8=; b=EOZZjXgPaWnQkNlsHNGgT6ta0ZK1Y4klGcwWRcJ+/U5b4Pus0luYYc29 OclVfy2xuNUbm0GD5uJUKrLRPu79LBucLGhkNS2ud39gc+RTtPJ2Q+myD 4eZpntWSsZqUDP+E8GbJ1J5QWdU0T/QckfkWbHutFfiemldJ1wD3J5P40 Imspoi0IsrPaUezy5Jg8rAgP4GEzrf5yOsSKGSpJ54zYTelrkpztwwzjL gnIRmm7UjF8mRWHKP/2L0mtZSxfscqPPjY4pGYrwU3CKW6nKUwoKoI1GL e/60h9+wqZ0LyqB+sgnBBYjmlpltFK3CAyySYchoSsh7xq/theriUdTq5 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="358238268" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="358238268" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 23:13:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="741306383" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="741306383" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.55.95]) by orsmga008.jf.intel.com with ESMTP; 12 Jun 2023 23:13:40 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Jiaxin Wu , Dandan Bi , Liming Gao , Jian J Wang , Eric Dong Subject: [PATCH V3 5/8] MdeModulePkg/SmmPerformanceLib: Disable perf-logging after ExitBS Date: Tue, 13 Jun 2023 14:13:22 +0800 Message-Id: <20230613061325.1664-6-ray.ni@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 In-Reply-To: <20230613061325.1664-1-ray.ni@intel.com> References: <20230613061325.1664-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 Reviewed-by: Jiaxin Wu Reviewed-by: Eric Dong --- .../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