public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wang, Jian J" <jian.j.wang@intel.com>
To: "Ni, Ray" <ray.ni@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wu, Jiaxin" <jiaxin.wu@intel.com>,
	"Bi, Dandan" <dandan.bi@intel.com>,
	"Gao, Liming" <gaoliming@byosoft.com.cn>,
	"Dong, Eric" <eric.dong@intel.com>
Subject: Re: [PATCH V3 5/8] MdeModulePkg/SmmPerformanceLib: Disable perf-logging after ExitBS
Date: Fri, 16 Jun 2023 03:27:35 +0000	[thread overview]
Message-ID: <SN7PR11MB6749E0C8D298D4E9AB7453E4B658A@SN7PR11MB6749.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230613061325.1664-6-ray.ni@intel.com>

Reviewed-by: Jian J Wang <jian.j.wang@intel.com>

Regards,
Jian



> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com>
> Sent: Tuesday, June 13, 2023 2:13 PM
> To: devel@edk2.groups.io
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Gao,
> Liming <gaoliming@byosoft.com.cn>; Wang, Jian J <jian.j.wang@intel.com>;
> Dong, Eric <eric.dong@intel.com>
> Subject: [PATCH V3 5/8] MdeModulePkg/SmmPerformanceLib: Disable perf-
> logging after ExitBS
> 
> 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 <jiaxin.wu@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
> Reviewed-by: Eric Dong <eric.dong@intel.com>
> ---
>  .../SmmPerformanceLib/SmmPerformanceLib.c     | 63 ++++++++++++++++++-
>  .../SmmPerformanceLib/SmmPerformanceLib.inf   |  4 ++
>  2 files changed, 66 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c
> b/MdeModulePkg/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
> interface.
> 
>  EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL
> *mPerformanceMeasurement = NULL;
> 
>  BOOLEAN                                 mPerformanceMeasurementEnabled;
> 
> +VOID                                    *mPerformanceLibExitBootServicesRegistration;
> 
> +
> 
> +/**
> 
> +  This is the Event call back function is triggered in SMM to notify the Library
> 
> +  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
> performance
> 
> +  //    log is not useful.
> 
> +  //
> 
> +  mPerformanceMeasurementEnabled = FALSE;
> 
> +
> 
> +  return EFI_SUCCESS;
> 
> +}
> 
> 
> 
>  /**
> 
>    The constructor function initializes the Performance Measurement Enable flag
> 
> @@ -40,9 +70,40 @@ SmmPerformanceLibConstructor (
>    IN EFI_SYSTEM_TABLE  *SystemTable
> 
>    )
> 
>  {
> 
> +  EFI_STATUS  Status;
> 
> +
> 
>    mPerformanceMeasurementEnabled =  (BOOLEAN)((PcdGet8
> (PcdPerformanceLibraryPropertyMask) &
> PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
> 
> 
> 
> -  return EFI_SUCCESS;
> 
> +  Status = 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 = gSmst->SmmRegisterProtocolNotify (
> 
> +                    &gEdkiiSmmExitBootServicesProtocolGuid,
> 
> +                    NULL,
> 
> +                    &mPerformanceLibExitBootServicesRegistration
> 
> +                    );
> 
> +  ASSERT_EFI_ERROR (Status);
> 
> +
> 
> +  return Status;
> 
>  }
> 
> 
> 
>  /**
> 
> 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                  = PerformanceLib|DXE_SMM_DRIVER
> 
> 
> 
>    CONSTRUCTOR                    = SmmPerformanceLibConstructor
> 
> +  DESTRUCTOR                     = SmmPerformanceLibDestructor
> 
> 
> 
>  #
> 
>  # The following information is for reference only and not required by the build
> tools.
> 
> @@ -46,5 +47,8 @@
>  [Guids]
> 
>    gEdkiiSmmPerformanceMeasurementProtocolGuid          ##
> SOMETIMES_CONSUMES   ## UNDEFINED # Locate protocol
> 
> 
> 
> +[Protocols]
> 
> +  gEdkiiSmmExitBootServicesProtocolGuid                ## CONSUMES
> 
> +
> 
>  [Pcd]
> 
>    gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask    ##
> CONSUMES
> 
> --
> 2.39.1.windows.1


  reply	other threads:[~2023-06-16  3:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13  6:13 [PATCH V3 0/8] Enable SMM perf-logging Ni, Ray
2023-06-13  6:13 ` [PATCH V3 1/8] UefiCpuPkg/CpuSmm: Add perf-logging for time-consuming BSP procedures Ni, Ray
2023-06-13  6:13 ` [PATCH V3 2/8] UefiCpuPkg/CpuSmm: Add perf-logging for MP procedures Ni, Ray
2023-06-13  6:13 ` [PATCH V3 3/8] MdeModulePkg/SmmCore: Add perf-logging for time-consuming procedures Ni, Ray
2023-06-16  3:19   ` Wang, Jian J
2023-06-13  6:13 ` [PATCH V3 4/8] MdeModulePkg/SmmCore: Add perf-logging for SmmDriverDispatchHandler Ni, Ray
2023-06-16  3:19   ` Wang, Jian J
2023-06-13  6:13 ` [PATCH V3 5/8] MdeModulePkg/SmmPerformanceLib: Disable perf-logging after ExitBS Ni, Ray
2023-06-16  3:27   ` Wang, Jian J [this message]
2023-06-13  6:13 ` [PATCH V3 6/8] MdeModulePkg/SmmCorePerformanceLib: Disable perf-logging at runtime Ni, Ray
2023-06-16  3:28   ` Wang, Jian J
2023-06-20  9:34   ` 回复: [edk2-devel] " gaoliming
2023-06-13  6:13 ` [PATCH V3 7/8] UefiCpuPkg/SmmCpu: Add PcdSmmApPerfLogEnable control AP perf-logging Ni, Ray
2023-06-13  6:13 ` [PATCH V3 8/8] MdeModulePkg/SmmCore: Perf-log PlatformHookBefore/AfterSmmDispatch Ni, Ray
2023-06-13  8:44   ` Wu, Jiaxin
2023-06-16  3:29   ` Wang, Jian J

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=SN7PR11MB6749E0C8D298D4E9AB7453E4B658A@SN7PR11MB6749.namprd11.prod.outlook.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