From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id BBA99D80470 for ; Thu, 1 Feb 2024 18:20:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=YfUbQbDH0UyM1iVGbYQRq1TBTIIBvehDrukuOiBilw0=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706811644; v=1; b=qKfUD7EV64U/LfFiInnzJySpzW7108SfUPmWdH6QMnMq4omDV2u/F0aHPyIN2mcmXxpehYoK yZkbY1xP/qYzz5BzztVJegE9+XsmL1JEBy+l1nuKGEI6x44BDXpB2KBHXRNfVeXF3BxALcGSmas +Qo/7Tg5DsvN/fW3I6T9zg+U= X-Received: by 127.0.0.2 with SMTP id 0Nx8YY7687511xfXsWEqwxYL; Thu, 01 Feb 2024 10:20:44 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by mx.groups.io with SMTP id smtpd.web10.2945.1706811643651979420 for ; Thu, 01 Feb 2024 10:20:43 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="10716060" X-IronPort-AV: E=Sophos;i="6.05,235,1701158400"; d="scan'208";a="10716060" X-Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 10:20:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,235,1701158400"; d="scan'208";a="30943960" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 01 Feb 2024 10:20:43 -0800 X-Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 1 Feb 2024 10:20:42 -0800 X-Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 1 Feb 2024 10:20:42 -0800 X-Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Thu, 1 Feb 2024 10:20:42 -0800 X-Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.41) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 1 Feb 2024 10:20:42 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LXxQ1sEiBe6tao+ZcnUifeLmLLIlWg27EDv6oO16nZpppSWX91HYTxpLWZlt5SCM2sM9UNJ1fCs+eod19mGPFDNDdqcojayMqZpTs34h9z6dIp+WqZflIQkl3/UelqXzbv8yMXLnzVHaR+T65+2v1biytg50RTdL5XV9o+6EsuIZNa5Ur8PJCWEVUhZ62jW2bOJfATyLa5g56PqtaWmZ1Ub68fgeX6Qw7avOEDQG+IGExx1bqc35O59r/imGyYbhtuAiSBcvLJ7m6k/LYOAzUajkknuHmUmyBb0b0vnQbq3JM9lAug37MFxkSERmv3JgvHy1L5J1oRDEsEKr11bvtg== 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=xmZ0obdaqRYQS5JpvVP1wRSc9sqy8bID1wB3Fh73HB8=; b=Q/fU9mVAPjfIYj8RFh8J6jUDvqYhkv3Gr1V4CwQI/Szm77crl5XBn7UZosxx9u/Q5ZBqS5Fwz+cWKFIdZtpZBL3wEFrami9Q7fvdpheB5cTIzZ6WCZIHRUGQtOLVfzqzZNZrx4eSG8BEEYg0u+DVeYklZFIcfVLUWRK4gXSKN3w1HrXuk6h2Ihbk3W2iAYPdrW98NDVRbUoU6+PgTc7QnvO0hm7nXaMnulvtfbu2XHLLvGKHmSu/A5CaxRPSELBCVxEQP5CiQv56E8JOuxKlSWcZtAIrJYCmOqlWE04QNdB75CvEF3gR5eklHHqygT8bTZJ3Aq63qzwd48i8SHzXdQ== 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 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com (2603:10b6:303:6d::19) by IA1PR11MB6322.namprd11.prod.outlook.com (2603:10b6:208:38a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.24; Thu, 1 Feb 2024 18:20:39 +0000 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::7e42:1633:d0a6:9c00]) by CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::7e42:1633:d0a6:9c00%6]) with mapi id 15.20.7249.027; Thu, 1 Feb 2024 18:20:38 +0000 From: "Michael D Kinney" To: "devel@edk2.groups.io" , "Wu, Jiaxin" CC: "Ni, Ray" , Laszlo Ersek , "Dong, Eric" , "Zeng, Star" , "Gerd Hoffmann" , "Kumar, Rahul R" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH v1 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex first before lock cmpxchg Thread-Topic: [edk2-devel] [PATCH v1 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex first before lock cmpxchg Thread-Index: AQHaVQC3fn5DKcrNlU+sM5r8UHxzqLD1zHog Date: Thu, 1 Feb 2024 18:20:38 +0000 Message-ID: References: <20240201112001.14416-1-jiaxin.wu@intel.com> <20240201112001.14416-3-jiaxin.wu@intel.com> In-Reply-To: <20240201112001.14416-3-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB4929:EE_|IA1PR11MB6322:EE_ x-ms-office365-filtering-correlation-id: 7d5e1f85-5b03-425b-b32b-08dc23527e0e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: Q+DXtPa3tojm5Mrsy6W8B0zKl+TJXb9kE82nDac4AIDBc1IoSl4mNKJzTKlnLsbkcrcdYd1P6aIYgQvVs33NXG7/EoTrPmKxYpanNBNgUhu1B91TfJrVHbsZlrzxNNuCFSbCQKW6J0e1ScniP9O05AU9ow3cGjS/yBYOl8SPu5m7ClFS3rHHXp+4+x+r0XNJIqJFU1jw6Cjsh90Oy7W7jwBydPNRiVBWQV5B+AFjqvTGsgo1Lp+HzS3+mzJiaM8EmUuiUvV5qPiP7BpfhXYOqwrjXkRhZ7cgGJuNx0rGTh2l07knO68mecAtwOEVxugLIr4olBLNyk/tBnAs8VZUN/tww6Ie+2CPeML+pbuElMF/zRZKSrr9DhIrfUYbsAEKnW4H7aTK9GHk+FXSFJtMPITSHWxWLflPXh4PLjjWgAiEQlFPWGH7eAC6v9oHhTl3b2K82k5J0zRLH9GQsgyPFQBheRqRW04KfCdFqtcFADo41XwwSCJPK4mSTQlxa6WJGnd1DjJHqVFBIyfc+XFSFYJVVTwMRuIuw/eEicRJ9AcJgVsMz9QtVySakfLUWqOFd9N07pRdpdyqGTbT0T/qeArPtKG9uwlL5R0Plxep9ML31+bmdPNPjUWmhTLgDsmuW8QKKrEw0KZUY1X8jglsvs/tglkW5yHxPgrEJaOCtC7INUSn6up97HN3dmwseU6k x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?QYh26KaWDA301Wt6HXNhlWlfkzANcWoTyIIuhj7KqNhUkq/mPK8d4G5TXRed?= =?us-ascii?Q?4awPMlDYoU4gp2C17QMAtTlQ6cg/e1nTPCZeMXip1zrdpGhANPQFUj/3+XDr?= =?us-ascii?Q?820M9pSz7jLUq02fwJjT5t4arV+fIy0I3mz6P/BlUYM8peCN3S3exw6/h7tU?= =?us-ascii?Q?0ie+ZBmhZjn+W/DmW9DMk/RFpRkRXuwdiGFhLaR83N2VkZVTf55C61aOSmYy?= =?us-ascii?Q?jWs54nP8AvxqwwQS3ONvVm7kHgltbIkO37E8iRug00jVKAjcEqnQlPcs4sVF?= =?us-ascii?Q?KJrbYFgGkUu0D222OsQzmioKQlWtOaJrm/vo2PprWAPE7HTIsdBiOdgQfHJM?= =?us-ascii?Q?Qw8AhJay/iE2ARUF/ywDCJB5qf/pesc2IrdD0rD2Dt6uE36DWFUDDmrHpK3L?= =?us-ascii?Q?uyYu4Xu+MeFKK8s/PQIbXwjX6KjdcDJVA2JB5bfuNlJXldYDis8aLgQugqmy?= =?us-ascii?Q?8VQaAth1Cm3EbreyG8absLIHtZPtagCHiReBqxy4DVDQ1xxZKLqtpwsLh4Mu?= =?us-ascii?Q?erLylhpN3Ad2yz8YbXqmKuxlTg7FPV/B4GbGE8t4GAeIn70mZ9bIrhZJavKr?= =?us-ascii?Q?ujInzHnfIH6XOHZ+zAfaiexqDl83LKTjbau7y8VmBn1EMGKACuNZHVp7+c96?= =?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8IlOvDUSRc76OdPE1p/kmnzvnui0KmfAE?= =?us-ascii?Q?632xdkv10vx6V6EzoI1JCVT11lUo22NS+ffzSZ4b?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4929.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d5e1f85-5b03-425b-b32b-08dc23527e0e X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Feb 2024 18:20:38.8319 (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: UUgIeZbv9pTsPY5Izgrum3g5ZSVCB1e5Rvh7Tro5qnqOKZpUxEYRNW8BDbgmrW3gg1uCPo9PRJNtsFxGEcFXXFMV1r18+L5qu1yOGy+2kXs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB6322 X-OriginatorOrg: intel.com Precedence: Bulk 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,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: MAbtHmog8DX8tqh7AKmyiwggx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=qKfUD7EV; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Wu, > Jiaxin > Sent: Thursday, February 1, 2024 3:20 AM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Laszlo Ersek ; Dong, > Eric ; Zeng, Star ; Gerd > Hoffmann ; Kumar, Rahul R > Subject: [edk2-devel] [PATCH v1 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check > BspIndex first before lock cmpxchg >=20 > This patch is to check BspIndex first before lock cmpxchg operation. > It's the optimization to lower the resource contention caused by the > atomic compare exchange operation, so as to improve the SMI > performance for BSP election. >=20 > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Eric Dong > Cc: Zeng Star > Cc: Gerd Hoffmann > Cc: Rahul Kumar > Signed-off-by: Jiaxin Wu > --- > UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > index e988ce0542..479024d294 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > @@ -1652,15 +1652,17 @@ SmiRendezvous ( > } > } else { > // > // Platform hook fails to determine, use default BSP > election method > // > - InterlockedCompareExchange32 ( > - (UINT32 *)&mSmmMpSyncData->BspIndex, > - (UINT32)-1, > - (UINT32)CpuIndex > - ); > + if (mSmmMpSyncData->BspIndex =3D=3D (UINT32)-1) { If the field is UINT32, prefer to use MAX_UINT32 instead of typecase from s= igned to unsigned value. > + InterlockedCompareExchange32 ( > + (UINT32 *)&mSmmMpSyncData->BspIndex, > + (UINT32)-1, If the parameter is UINT32, prefer to use MAX_UINT32 instead of typecase fr= om signed to unsigned value. > + (UINT32)CpuIndex > + ); > + } > } > } > } >=20 > // > -- > 2.16.2.windows.1 >=20 >=20 >=20 >=20 >=20 -=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 (#114952): https://edk2.groups.io/g/devel/message/114952 Mute This Topic: https://groups.io/mt/104094808/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-