From nobody Tue Feb 10 21:41:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+105497+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+105497+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685532895; cv=none; d=zohomail.com; s=zohoarc; b=VYZgj/5ArJGzGje3gJq7PN91GDDyt5lmyVyD/q4RMy1fEOgsQq0KNogHdwKptSp08LnhZQQlREgrjE4TfaGMYecXhoMYXgCNwoDw0HEwF8+hRcwn2hVpLDTJ9N7h9D1g/ZICoOPXQOE9yonQpaJLwuJBN/kpa74MYhHg1m3FNJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685532895; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hVKW4qNiJsoQHheWMJN2z3BG4u1LrooeR2qNSo6jQi0=; b=TOFZD0lsJORgqB3h7Hg0N+vMReWo7KybLxORaAJh7I2e8GB+T4VsdY0/QBgjo36a0k+HNYr3mA7wSaj1ghBs3hgtw/oASE26DlX9NOR7+6hAXoapyhgnKWv096E8ZqJR91I4wE7j3/tvU7g1x0rFgkatLrO1WSe7mRZvI/LQMns= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+105497+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1685532895073370.67612811211086; Wed, 31 May 2023 04:34:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id wIziYY1788612xLbcwpgQ1rM; Wed, 31 May 2023 04:34:54 -0700 X-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 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" X-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" X-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: [edk2-devel] [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> In-Reply-To: <20230531113438.1797-1-ray.ni@intel.com> References: <20230531113438.1797-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: 3XhTpOa5gBaHM3n3BHMYBCbWx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1685532894; bh=mge18eCI3L0O/CErymCQWEynWDoSkrMOOoqfqbmO+1M=; h=Cc:Date:From:Reply-To:Subject:To; b=MbqUsXljGe7KjmbVQFUNkSzkZhXNN9EHWkawQhZuV7IGLlnHudwOiJKa9ygjBaqtD+6 AXsX7LY5v7B96Vf7R7+ZQGnevOs5xHIHjjs1Sj5CArtcnmosVysaHpHPcuA3K4igMd2/3 DNg+E6Vo49yqKKqCusQ+17OBarGjZQ2DlvU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1685532895990100021 Content-Type: text/plain; charset="utf-8" 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 --- .../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. EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement =3D NULL; BOOLEAN mPerformanceMeasurementEnabled; +VOID *mPerformanceLibExitBootServicesRe= gistration; + +/** + This is the Event call back function is triggered in SMM to notify the L= ibrary + the system is entering runtime phase. + + @param[in] Protocol Points to the protocol's unique identifier + @param[in] Interface Points to the interface instance + @param[in] Handle The handle on which the interface was installed + + @retval EFI_SUCCESS SmmAtRuntimeCallBack runs successfully + **/ +EFI_STATUS +EFIAPI +SmmPerformanceLibExitBootServicesCallback ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + // + // Disable performance measurement after ExitBootServices because + // 1. Performance measurement might impact SMI latency at runtime; + // 2. Performance log is copied to non SMRAM at ReadyToBoot so runtime p= erformance + // log is not useful. + // + mPerformanceMeasurementEnabled =3D FALSE; + + return EFI_SUCCESS; +} =20 /** The constructor function initializes the Performance Measurement Enable = flag @@ -40,9 +70,40 @@ SmmPerformanceLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { + EFI_STATUS Status; + mPerformanceMeasurementEnabled =3D (BOOLEAN)((PcdGet8 (PcdPerformanceLi= braryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D= 0); =20 - return EFI_SUCCESS; + Status =3D gSmst->SmmRegisterProtocolNotify ( + &gEdkiiSmmExitBootServicesProtocolGuid, + SmmPerformanceLibExitBootServicesCallback, + &mPerformanceLibExitBootServicesRegistration + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +EFI_STATUS +EFIAPI +SmmPerformanceLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Unregister SmmExitBootServices notification. + // + Status =3D gSmst->SmmRegisterProtocolNotify ( + &gEdkiiSmmExitBootServicesProtocolGuid, + NULL, + &mPerformanceLibExitBootServicesRegistration + ); + ASSERT_EFI_ERROR (Status); + + return Status; } =20 /** 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 =20 CONSTRUCTOR =3D SmmPerformanceLibConstructor + DESTRUCTOR =3D SmmPerformanceLibDestructor =20 # # The following information is for reference only and not required by the = build tools. @@ -46,5 +47,8 @@ [Guids] gEdkiiSmmPerformanceMeasurementProtocolGuid ## SOMETIMES_CONSUM= ES ## UNDEFINED # Locate protocol =20 +[Protocols] + gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES + [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#105497): https://edk2.groups.io/g/devel/message/105497 Mute This Topic: https://groups.io/mt/99240113/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-