From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.15157.1686321820834058167 for ; Fri, 09 Jun 2023 07:43:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=kr2dt4ak; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: jiaxin.wu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686321820; x=1717857820; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=XzFL79i7044ObPGhwl+z1K21cUS7F+OT0DoL8Y7B5nQ=; b=kr2dt4ak779dLEtJR9hFYAHGY68bJXofufENybob0WPY/4e6ucfQI0iU xF9J3SJeVkKL47w6M1BqZ/+Ge215htwmLzI7jW9q200Hl9H0TesOsDzCB 8OMxrd1mMzaHM1Xf3U/EJ54Mc98a5NADvVAJ59GAyI7qK2Xk7jBwvB3BA L3DIjTZ4sgP/m84tIB+b60uJGjojckAIRp6HwR/2O7eKbjYk5jWYNxdeK b5HEtNfYv3lQ/zRDJBtddZgUTmAdulkLjvCvhYYeH2z5YGglg6d1Ac4Ah UMhEJCZShgzcC8S2TS2Rv0r/1SS+n6qdx2vVIvmx2apHbeZyxsqPcBH1c A==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="360968072" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="360968072" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 07:43:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="713539257" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="713539257" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga007.fm.intel.com with ESMTP; 09 Jun 2023 07:43:39 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 9 Jun 2023 07:43:39 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 9 Jun 2023 07:43:39 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Fri, 9 Jun 2023 07:43:39 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.177) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Fri, 9 Jun 2023 07:43:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QAGn+sjJUh52vX2XGyd4/Peb3Ph2kHXhXkVqc6zK6UALmpNMke4i5mmlHplrI7hiJhWQt8oCIKnl3wQzBnbkktRkO7dOeMoZTPSELQLrcTGY5bZtw+B0c+7qEGLHHO3PL2MXtfZ9zk3Y6ys2rNrqw6laJ+Ox65qJ/2J6tmXzQuVe0G+JtPK74O6VpYkoYKgUzE/mjYr4FKAJ8K2b+s/uxZSbIg5U84wN2J8cLrShW3NIzF+OJq+tK7kv966NsH/LUwLwXQs/nrmIQCvSwKtrccfHFhM8Y660ELOmp4/b3dWrA/5Anp85bJ+/Aihk+ekDlGk6oGTE2KF2AxlpZhj9Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2grU8pjQoUIryvyQZn+Sv1FGY1+BmboX5GzlEtHKav0=; b=ft4qiClRB5KXkp0nedBdSkDyL+UzDeZv2ILmi8cjTlEK0qcmisyNSM4gdVnh7U8RBHYaAGX8kWzb6B9M7rEh/N2PLfr2nWRDsZLTxePx9comgXy9piJNTIauZAF13lqK8XXPV+6iJ+kDPaJ/xpYfvV+9qDLQbF0cDj010gpmemD2iJ9xSQ8PrzfYvwCIC87VNVpaDJDD0/06nRQPK4U8zMdnF8WtbENROTZxDGnfBwbbxb0VxqcPL7xPNKLA9mEaSBXQSBlSWZgI0biQSUds/FabmItZKen96ZItAHEfngQlpQH4UmdAOLsC6Z+vv8kEjgQIYyQehnBbdneENYdySg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MN0PR11MB6158.namprd11.prod.outlook.com (2603:10b6:208:3ca::18) by PH7PR11MB6426.namprd11.prod.outlook.com (2603:10b6:510:1f6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 14:43:33 +0000 Received: from MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::a50f:27de:660a:544d]) by MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::a50f:27de:660a:544d%4]) with mapi id 15.20.6455.037; Fri, 9 Jun 2023 14:43:33 +0000 From: "Wu, Jiaxin" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Bi, Dandan" , "Gao, Liming" , "Wang, Jian J" Subject: Re: [PATCH V2 6/6] MdeModulePkg/SmmCorePerformanceLib: Disable perf-logging at runtime Thread-Topic: [PATCH V2 6/6] MdeModulePkg/SmmCorePerformanceLib: Disable perf-logging at runtime Thread-Index: AQHZk7PzZpmi0bYGKESpK+cZU7rK16+CmhTQ Date: Fri, 9 Jun 2023 14:43:32 +0000 Message-ID: References: <20230531113438.1797-1-ray.ni@intel.com> <20230531113438.1797-7-ray.ni@intel.com> In-Reply-To: <20230531113438.1797-7-ray.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN0PR11MB6158:EE_|PH7PR11MB6426:EE_ x-ms-office365-filtering-correlation-id: 31933b56-9231-4460-1a11-08db68f7e625 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Bet/GxcRVdiWOVEEEVgKGpNCYTqjYT3vSoat9F4z94X8jUPSiH9ZoOaR/6Mi0AHQ5z0ya1AFyH4KXQkTmHDOevqCxHCFFDzXrDlybHc5o8hfKk7nvr7I/9YNIaBBvaVyi6tp1HDodiKJ5x04xSzfNijS6oIzIoKLwKQrfuUqEx+TNrB3pv1g1HVbGdXndurRbRZe2vOcOzGBIJ+n5jZIG/jZtGid3TmRzMk7W6eqbDFRt8FjnY4DRUPZ2PJ3JM/t9IMBs+bQffGKBFi7ZfCxygsead/SqDoK9TmqS9otVY41p3gpjl4PHBGqhpw1stVDdpc1iR4cPmeNFafeljn1sWSFy75CuoglbJUQ0iwjVtJAM3PsLtNROBC9fzRL3MV3IP1zd6hZfu0cltKbKivQN2PBvqw+GFozxtjBBLILncuThXlrDGrhJE9AUx37lh5IoSCGn9U8O6+WrTQJjMktngpf99K2FwoX3TyvY2jYFaBwLSAPnne4uusjZKQeyWvmkVlNUw7cyT5cC7oZYZzrUqULBLcN9p2ETNDsfhK2xHTYW2I1KmlyciSE8UsiPcR/KUjWYHovtyVwqmLIwuJacjfWxWqaqVD5t9hHFmTsK81/WvI/+RVtRqQp5AtEoIZ/ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN0PR11MB6158.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(39860400002)(396003)(136003)(346002)(366004)(451199021)(4326008)(8676002)(8936002)(66946007)(66556008)(66476007)(76116006)(7696005)(86362001)(478600001)(41300700001)(66446008)(316002)(64756008)(52536014)(83380400001)(5660300002)(19627235002)(54906003)(110136005)(55016003)(33656002)(71200400001)(2906002)(82960400001)(186003)(53546011)(38070700005)(122000001)(38100700002)(9686003)(107886003)(26005)(6506007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?+5kBGwDNV5Qv586GhQ7jvxPy+1sLwR5mwQxQRRYm0c0zhhdeHH935JQpdg92?= =?us-ascii?Q?LRDMjfskhDsocujnwGw+OgH3riJhSi7gV5JOxeq5hzyh193mcGWb2KPfc1yr?= =?us-ascii?Q?btwB1ks3EIPkvypzye6EOK9PY/YNbWjWVgmZdFwLlB/THpcoAeEZS3m63HxF?= =?us-ascii?Q?sTvyReq/+toWKdrwwoo8gPmMipuooG43S3IdIkd/6tcVgvNgNjxBDjgNLYpQ?= =?us-ascii?Q?hFFL3FUI7SfRUtSnKQrtMOSr2J8KhvfcmcjOJ5ZCnocFfFqipgiaPEOBWQaU?= =?us-ascii?Q?H7V/+lxfPuz/TySPhGL3+f2rchSzH2MCh+qdKAhS0g6DIkVpcqdsq4RoFw4f?= =?us-ascii?Q?opx3aRbVpiBkWqlJz8zz6UgZqoc6qee5DmNjDFKw8geVJ/J1wy/tasAsLOgZ?= =?us-ascii?Q?bMPsteV7E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/q8ttWeLVti?= =?us-ascii?Q?/F8lS5vyFiGe2pfPQZL31e86Wcc5W5jLzMAJDdhRqCbOH7hwQ0Z8or6cTVRJ?= =?us-ascii?Q?t7tdRJWLS8JS1fYZQAXksD0eNExUtcIJPZ+JKlgxhcRCx2DS1DCnpqCDTfNX?= =?us-ascii?Q?Ypnu0t+4a33/ReblALuVNY1MF1BxpnQ//Jch+dB8MghruTcjj9I6u8nzF2v3?= =?us-ascii?Q?dBa/tSX+GconuxLuuabVNnh2weSEYk+GKU7WVh+ur0X9faPDgxYhndQoMU9A?= =?us-ascii?Q?atzQcicamixmVVWlKKo07rDHL9/K9+xpnaSFAKDG?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN0PR11MB6158.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31933b56-9231-4460-1a11-08db68f7e625 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jun 2023 14:43:33.0108 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ZQ5kpxN9zXaeE/QZGzDqcfAphER7aTMH48XR/Gb6wAXkeUSrH1hwh8SVkt97XzTs1glyUbhoE8raAeQymzecRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6426 Return-Path: jiaxin.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiaxin Wu > -----Original Message----- > From: Ni, Ray > Sent: Wednesday, May 31, 2023 7:35 PM > To: devel@edk2.groups.io > Cc: Wu, Jiaxin ; Bi, Dandan ; > Gao, Liming ; Wang, Jian J > > Subject: [PATCH V2 6/6] MdeModulePkg/SmmCorePerformanceLib: Disable > perf-logging at runtime >=20 > 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 SmmCorePerformanceLib is updated to disable perf-logging > after ExitBS. >=20 > Cc: Jiaxin Wu > Cc: Dandan Bi > Cc: Liming Gao > Cc: Jian J Wang > --- > .../SmmCorePerformanceLib.c | 48 ++++++++++++++++++- > .../SmmCorePerformanceLib.inf | 3 +- > 2 files changed, 48 insertions(+), 3 deletions(-) >=20 > diff --git > a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformance > Lib.c > b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformance > Lib.c > index 3efe56e056..c566a298dd 100644 > --- > a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformance > Lib.c > +++ > b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformance > Lib.c > @@ -16,7 +16,7 @@ >=20 >=20 > SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive > untrusted input and do basic validation. >=20 >=20 >=20 > -Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
>=20 > +Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 >=20 >=20 > **/ >=20 > @@ -48,6 +48,7 @@ SPIN_LOCK mSmmFpdtLock; > PERFORMANCE_PROPERTY mPerformanceProperty; >=20 > UINT32 mCachedLength =3D 0; >=20 > UINT32 mBootRecordSize =3D 0; >=20 > +BOOLEAN mPerformanceMeasurementEnabled; >=20 >=20 >=20 > // >=20 > // Interfaces for SMM PerformanceMeasurement Protocol. >=20 > @@ -929,6 +930,36 @@ FpdtSmiHandler ( > return EFI_SUCCESS; >=20 > } >=20 >=20 >=20 > +/** >=20 > + This is the Event call back function is triggered in SMM to notify the= Library >=20 > + the system is entering runtime phase. >=20 > + >=20 > + @param[in] Protocol Points to the protocol's unique identifier >=20 > + @param[in] Interface Points to the interface instance >=20 > + @param[in] Handle The handle on which the interface was installed >=20 > + >=20 > + @retval EFI_SUCCESS SmmAtRuntimeCallBack runs successfully >=20 > + **/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +SmmCorePerformanceLibExitBootServicesCallback ( >=20 > + IN CONST EFI_GUID *Protocol, >=20 > + IN VOID *Interface, >=20 > + IN EFI_HANDLE Handle >=20 > + ) >=20 > +{ >=20 > + // >=20 > + // Disable performance measurement after ExitBootServices because >=20 > + // 1. Performance measurement might impact SMI latency at runtime; >=20 > + // 2. Performance log is copied to non SMRAM at ReadyToBoot so runtime > performance >=20 > + // log is not useful. >=20 > + // >=20 > + mPerformanceMeasurementEnabled =3D FALSE; >=20 > + >=20 > + return EFI_SUCCESS; >=20 > +} >=20 > + >=20 > + >=20 > /** >=20 > SmmBase2 protocol notify callback function, when SMST and SMM memory > service get initialized >=20 > this function is callbacked to initialize the Smm Performance Lib >=20 > @@ -948,6 +979,7 @@ InitializeSmmCorePerformanceLib ( > EFI_HANDLE SmiHandle; >=20 > EFI_STATUS Status; >=20 > PERFORMANCE_PROPERTY *PerformanceProperty; >=20 > + VOID *Registration; >=20 >=20 >=20 > // >=20 > // Initialize spin lock >=20 > @@ -987,6 +1019,16 @@ InitializeSmmCorePerformanceLib ( > Status =3D gBS->InstallConfigurationTable (&gPerformanceProtocolGuid= , > &mPerformanceProperty); >=20 > ASSERT_EFI_ERROR (Status); >=20 > } >=20 > + >=20 > + // >=20 > + // Register callback function for ExitBootServices event. >=20 > + // >=20 > + Status =3D gSmst->SmmRegisterProtocolNotify ( >=20 > + &gEdkiiSmmExitBootServicesProtocolGuid, >=20 > + SmmCorePerformanceLibExitBootServicesCallback, >=20 > + &Registration >=20 > + ); >=20 > + ASSERT_EFI_ERROR (Status); >=20 > } >=20 >=20 >=20 > /** >=20 > @@ -1011,6 +1053,8 @@ SmmCorePerformanceLibConstructor ( > EFI_EVENT Event; >=20 > VOID *Registration; >=20 >=20 >=20 > + mPerformanceMeasurementEnabled =3D (BOOLEAN)((PcdGet8 > (PcdPerformanceLibraryPropertyMask) & > PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D 0); >=20 > + >=20 > if (!PerformanceMeasurementEnabled ()) { >=20 > // >=20 > // Do not initialize performance infrastructure if not required. >=20 > @@ -1383,7 +1427,7 @@ PerformanceMeasurementEnabled ( > VOID >=20 > ) >=20 > { >=20 > - return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & > PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D 0); >=20 > + return mPerformanceMeasurementEnabled; >=20 > } >=20 >=20 >=20 > /** >=20 > diff --git > a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformance > Lib.inf > b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformance > Lib.inf > index 9eecc4b58c..9a7e14e80c 100644 > --- > a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformance > Lib.inf > +++ > b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformance > Lib.inf > @@ -8,7 +8,7 @@ > # This library is mainly used by SMM Core to start performance logging = to > ensure that >=20 > # SMM Performance and PerformanceEx Protocol are installed at the very > beginning of SMM phase. >=20 > # >=20 > -# Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved. >=20 > +# Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved. >=20 > # SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > # >=20 > ## >=20 > @@ -58,6 +58,7 @@ >=20 >=20 > [Protocols] >=20 > gEfiSmmBase2ProtocolGuid ## CONSUMES >=20 > + gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES >=20 >=20 >=20 > [Guids] >=20 > ## PRODUCES ## SystemTable >=20 > -- > 2.39.1.windows.1