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 C0854941270 for ; Mon, 5 Feb 2024 07:44:01 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KOgkGT5NvYO7irvO+rVXuKn8mK7EiFF/iV8XG/jyCXk=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To: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=1707119040; v=1; b=KiSfv1N56VTghr3ZAyX7zOWbO0RLaSzc1hQe0fG96iR1EqfkpGDCt8k578honqLshrHiDozL GxJkVYFhXwms2cg+xTczi8iQ9ojPFL+I6Ay8bInQW6fD3bW3jLaPzaOoxZw2lqY4yLvYFT1Tv39 zFCRho35+0ueuAVLBx/LVweI= X-Received: by 127.0.0.2 with SMTP id Vg2YYY7687511xIIbKCRWOBe; Sun, 04 Feb 2024 23:44:00 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.58002.1707119039809845954 for ; Sun, 04 Feb 2024 23:43:59 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-s_McVqd0OSa2boelDz3fXg-1; Mon, 05 Feb 2024 02:43:53 -0500 X-MC-Unique: s_McVqd0OSa2boelDz3fXg-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 45A14185A780; Mon, 5 Feb 2024 07:43:53 +0000 (UTC) X-Received: from [10.39.192.216] (unknown [10.39.192.216]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1015C3C2E; Mon, 5 Feb 2024 07:43:51 +0000 (UTC) Message-ID: Date: Mon, 5 Feb 2024 08:43:50 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex first before lock cmpxchg To: "Ni, Ray" , "Wu, Jiaxin" , "devel@edk2.groups.io" Cc: "Dong, Eric" , "Zeng, Star" , Gerd Hoffmann , "Kumar, Rahul R" , "Kinney, Michael D" References: <20240204084744.16464-1-jiaxin.wu@intel.com> <20240204084744.16464-3-jiaxin.wu@intel.com> From: "Laszlo Ersek" In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: jPM3pyRm4KGrcVOBaKRLmDHUx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 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=KiSfv1N5; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.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 On 2/5/24 06:06, Ni, Ray wrote: > Jiaxin, > Can you separate the changes in 2 patches? > 1 is to change (UINT32)-1 to MAX_UINT32, the other is to add the test bef= ore test-and-set. Thanks; I'll defer to Ray on this series. Laszlo >=20 > Thanks, > Ray >> -----Original Message----- >> From: Wu, Jiaxin >> Sent: Sunday, February 4, 2024 4:48 PM >> To: devel@edk2.groups.io >> Cc: Ni, Ray ; Laszlo Ersek ; Dong, >> Eric ; Zeng, Star ; Gerd >> Hoffmann ; Kumar, Rahul R ; >> Kinney, Michael D >> Subject: [PATCH v2 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex >> first before lock cmpxchg >> >> This patch is to check BspIndex first before lock cmpxchg operation. >> If BspIndex has not been set, then do the lock cmpxchg, otherwise, >> the APs don't need to lock cmpxchg the BspIndex value since the BSP >> election has been done. 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 >> Cc: Kinney Michael D >> 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..085aa91286 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 electi= on >> method >> // >> - InterlockedCompareExchange32 ( >> - (UINT32 *)&mSmmMpSyncData->BspIndex, >> - (UINT32)-1, >> - (UINT32)CpuIndex >> - ); >> + if (mSmmMpSyncData->BspIndex =3D=3D MAX_UINT32) { >> + InterlockedCompareExchange32 ( >> + (UINT32 *)&mSmmMpSyncData->BspIndex, >> + MAX_UINT32, >> + (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 (#115099): https://edk2.groups.io/g/devel/message/115099 Mute This Topic: https://groups.io/mt/104153489/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-