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 3D1BF74003C for ; Fri, 2 Feb 2024 06:33:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=DFPC3Dy+6HIuD1YcVSZ0c9tgt6lbjycvJD/jhTpslQY=; 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=1706855608; v=1; b=HUReU4ZLnFym67Q+vjsVFqjd5/oa3Dc5qPnbs/BaScmG1Lx4gzmSgVbt/blPUY9e50LXMVMu A8GhIqypHl4goWNjGYYJjKPCax3vCXAAQnHwoUZFZoG9Y/xOW9GzHoksHWqK9x/gh+Q70VlV3xn b5e2RjjhoQcXsLGIY9afQa7I= X-Received: by 127.0.0.2 with SMTP id CCwDYY7687511xt2IsHaT4Mq; Thu, 01 Feb 2024 22:33:28 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by mx.groups.io with SMTP id smtpd.web10.17658.1706855608104890731 for ; Thu, 01 Feb 2024 22:33:28 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="8109" X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="8109" X-Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 22:33:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="323639" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orviesa008.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 01 Feb 2024 22:33:28 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 22:33:26 -0800 X-Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 22:33:26 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.100) 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 22:33:26 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SeKpecvxePg923Hv61Sym5aJbs4EbXaoYp975+klovLBNXbdI6bTwpXx4s8aD7HI2vY8oCr3Vd6hsW1ur/qr+GJqeT1jZyY7Y8x1OukTEtLn/Zfjq6xk8frEW6qgkn+WzDZNEHDrIq/7CV69xuGPYK33sH9x4KM2iicA7YsRRpEylRK6TwHfxDvoChBQVKnyOA7aQFWnMXElwe7Z3E1OscjgxxEhhve6nSuTq5wwL5YfE2bsmVOMpLs7r407BZO2BwU1QaNOK1wXazsHWS/3Odil8jDfzcD6thrXCKGcDq/qQvXNzjd3K3UsxMvcZMC/K0PUDZphV5JktClFkmNHQQ== 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=rYw4e7YYqwNjk0nGEG2vsvINWY9xvrQgtZMmcPB9kRg=; b=jifMtRcbsmj7i+VvLquo0cMZtP8KA+y1+VQod7awBSevmliHbIh5/fLPedxm9E/5ufY4E4d9fnGNNSaMvtXCbFlAdKWbVM2j77e2H8d6Oyd/fbhb/HLwCSSn6ciYwIgMhxSXJ1kBp5uTnyGReQ8p68XrslFs0yLvVG9t8grB9tRtW/upP1xKrbNSrzYzJtMYwyqKfY+TBJlzXUgx+flk0LbayHZLQbgQAqasMQ0ZxQXbv8V+SAFPdTv6D5hTFf3icigFe63SKo7rKeupGSKTjFKNCHPa83vAu+FXiQpawSBBMk2Lb629Cz9XRzJO9DBWNnfywGuhwmVFB9iVaGZIpw== 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 MN0PR11MB6158.namprd11.prod.outlook.com (2603:10b6:208:3ca::18) by BL1PR11MB5383.namprd11.prod.outlook.com (2603:10b6:208:318::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.29; Fri, 2 Feb 2024 06:33:24 +0000 X-Received: from MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::42f0:90db:da46:71a5]) by MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::42f0:90db:da46:71a5%4]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 06:33:24 +0000 From: "Wu, Jiaxin" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: "Ni, Ray" , Laszlo Ersek , "Dong, Eric" , "Zeng, Star" , "Gerd Hoffmann" , "Kumar, Rahul R" 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: AQHaVTtb+e6phtFjjUuC6fqhM4Z047D2mNIg Date: Fri, 2 Feb 2024 06:33:24 +0000 Message-ID: References: <20240201112001.14416-1-jiaxin.wu@intel.com> <20240201112001.14416-3-jiaxin.wu@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN0PR11MB6158:EE_|BL1PR11MB5383:EE_ x-ms-office365-filtering-correlation-id: e1f6db66-4087-436d-9b71-08dc23b8db78 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: ruO8FIqIKXy2/nb8x8SBfDeSJy+TS2v7yO5iAUhsj4tIxY4nlg9nSOE9OZv3ycEiNTlORLT9TkbLjh7Oz/pLyNb4Jf5kC6RXP1P6+b0+bizZMML24J4+loEhSNvGnuVT/9UECuW5z3pIh9MIPtwmzivx/l2he+JUsghV0KvYwPkVy27LAfFvG7FgpZHjZYHrCSdr6T762frB6Du1fIihD7nU+jPy0qbhGe5nsvkqKoWrDsJsusyJMFoc25IwnWuO+xWEojew9rTtLVTh8YNtUU2Heb4jBUGhr2tfIN/BM1lm09RV+uifR1KW0jK6/j4eZe9dgWsQ50D6Ez+RX09a21FxmbYkjMqSHdD3H46gL3/Ce+Nsb9GdyJwrXTMv+f960xaL9Lajo657jeULMNiL+bcYz3/p/HWHvREu4KXQ91A+QSrKOqkJu3zvfuquAc8zZGWmJFJoeU+6/0NMG+icgxviGwx/f/hC/hKJv3gzGKnFOnKDF+6VgplhROQGBBLTqotRIG3elw04sMSjnDpMp2mABHywNVZ1cgIXTQTuXUS9ncTAE231cA0cnqpgJfzYSr7eViK0ZE+sco3NQgcVIh8acwv/YarTGQZf/OPV5ynheVlAHNfst1cyMncJFB+ITZgFNvcgmAHzxqMSduRIj8Rp74UI2DlYYpd+Al0lFt3E6jx5ibcXD2m09nCNCgJT x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?aPj1IUisEgtHuzXEx/QLZV5ufobe80+hsXW1dL0c9cjN0uVTFf6KeHITPhAx?= =?us-ascii?Q?N/K4Or0+ZmuyV+ixIMwL0BHg2CO2mcEBBYJuaaR7FzWAk+82U3NogfmwignX?= =?us-ascii?Q?IiApPtxMzmfXEEmD1X52/HDvsgFIbOrD0Fdq/VZnfKS4vuhHzw7XnFTKfxPv?= =?us-ascii?Q?i99WIRznFtrt97dRbstTjY0t9r65/PAEQVIHJoPqIAwaXJ9rtu+fgJzzWGbU?= =?us-ascii?Q?GGScGuugusIdelps9ifIzzMKcPTWWQm/TuDB5ZuA2ciKrOFzuOPiS215m+g6?= =?us-ascii?Q?FqeIeUS4Kc1HGkHEPXnP9Ic8/Eteq98l5hWph+DJh1dHZk+JoAYtxYYUat3d?= =?us-ascii?Q?jZrq724yz2g0Xsyz/OCiyT3f2lq9drV8yNl+m9RhU5NDVFaDXybErbj2vOq1?= =?us-ascii?Q?D4FGr9/JJzFy1R4LKIFdyHIHLHVSuFcsm12Xm7OAYDBRYQKXRruL5Wi2CPSY?= =?us-ascii?Q?KrVEEgJFNkT7wSrzHkMnTaRatBfoxh56LHJWRbZxo/2KnVqMBcFsT9uVBwD8?= =?us-ascii?Q?RWbqwGdZ2MjcuotDAcypRDITrLcEsxUEp7rPOO+ve7Jx9dVHiet4e4Ms9gkm?= =?us-ascii?Q?caPlUBF+/+S2e6+cuU4y7QfYa6CJ4RW3kvR/YbMzFnj9K856Xe7gz5PtTUm9?= =?us-ascii?Q?d25iS/MueHudCpGuicLCoBoML1N43oaQYSo4DK0lWM8nxTK584IeqEtiK01h?= =?us-ascii?Q?3zprplVa/hXasOYtRoNo/131hkhj/6LaKJSiVJTmjIN3m0UGK7LcmLQAQQfg?= =?us-ascii?Q?88rDmOeCV+pP+yhcufMHoFrZ9SJzdRcaFvafxRZYXahX4ovzdGfqSUfIlF+/?= =?us-ascii?Q?JEL9YzrXE8hLej3VnXt3Wjz++f9cCmCoE0d2nAm5OQpSFoo3jhxle5XJo6Vi?= =?us-ascii?Q?cbpVKhO4YK8id+k6amAfxspke998fh9+yHAiRCVpnvS1uKrqcJocvraYTuty?= =?us-ascii?Q?OGhB3bsLTr6E6l0ltvYZ4m0hpYeNH691Gd4N0CgjeyaWGANl7X7E0dYJKeLo?= =?us-ascii?Q?BfCS4HlISZNjl5lopM+whAYJSWF+mv6HfXP4a8EsN7/KoyiNZgPt/NYUSPak?= =?us-ascii?Q?MyQMt3BO113sbc7iHyVUetg0RBnr1zCereJqn/yohOZZOdEHn/iPrN4vwOyU?= =?us-ascii?Q?GxTU7rlu9jDkLPlEyJmelYaCw2JgotpGA/RLdeQIcmExibm7ePdcsddypCjR?= =?us-ascii?Q?r+O89K1L6a0k76NRLo65q+zQWr3xE7UQcSSFOpWiR3yNXwd8hKmggPBxFFXI?= =?us-ascii?Q?oeoF8vx7DWUao/D+DzH3wOIjZCX0o4N9i1hu2/KQsiwWpNQuZHxCfHGbYz8f?= =?us-ascii?Q?wyQSzVEsOuENaUJAkJZ/bnatVmx2ARzkGkRy+EgIK5HZ6ar0V9HWAR4Ggj3r?= =?us-ascii?Q?XvFXETjxstv1pm+pVpryXT0OMVl2dnj37XelyzU8u2njCJFnlVmB7IXTIbY+?= =?us-ascii?Q?SggDLZpN9aaixsWoXwW5YvRg99yGdE4zS6Zl16Gme+KIwXKbYgBHVrJi40zT?= =?us-ascii?Q?5aOdh8BJ8cOm410gR2pXYZ7wLScL8RIWMuaWnZ0gjusumdvD8XdBbQlbaZ41?= =?us-ascii?Q?oUGu/KTGSwyzNK4F2iiaauPN4JCPp+nkrUTGqRGD?= 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: e1f6db66-4087-436d-9b71-08dc23b8db78 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2024 06:33:24.2727 (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: eLr32lQTcqusi82a68S3rBJNEF0tHNtRiAaq9dRWbQysHpVsbpQcc8pOoKTVeOebOhMl28i1yv4dScLfN/FzmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB5383 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,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 6uZT8Q3j5AoDcLcGFgIH2TLQx7686176AA= 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=HUReU4ZL; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Yes, thanks Mike, I will update the patch. > -----Original Message----- > From: Kinney, Michael D > Sent: Friday, February 2, 2024 2:21 AM > To: devel@edk2.groups.io; Wu, Jiaxin > Cc: Ni, Ray ; Laszlo Ersek ; Dong, E= ric > ; 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 >=20 >=20 >=20 > > -----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 > > > > 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. > > > > 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(-) > > > > 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) { >=20 > If the field is UINT32, prefer to use MAX_UINT32 instead of typecase from > signed to unsigned value. >=20 > > + InterlockedCompareExchange32 ( > > + (UINT32 *)&mSmmMpSyncData->BspIndex, > > + (UINT32)-1, >=20 > If the parameter is UINT32, prefer to use MAX_UINT32 instead of typecase > from signed to unsigned value. >=20 > > + (UINT32)CpuIndex > > + ); > > + } > > } > > } > > } > > > > // > > -- > > 2.16.2.windows.1 > > > > > > > >=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 (#115023): https://edk2.groups.io/g/devel/message/115023 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-