diff options
author | Jiaxin Wu <jiaxin.wu@intel.com> | 2024-02-06 15:49:55 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-02-21 01:33:51 +0000 |
commit | 2ca8d559744319025592df10ada0f714fc3b8e15 (patch) | |
tree | fd94c4468215f9c667e84f41f5b88f066ca9f2d6 | |
parent | d698bcfe4f3da50418561eaf8d6163136c714f01 (diff) | |
download | edk2-2ca8d559744319025592df10ada0f714fc3b8e15.tar.gz |
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 <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Kinney Michael D <michael.d.kinney@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
-rw-r--r-- | UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c index 71d6b0c6d8..081f0c1501 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -1654,11 +1654,13 @@ SmiRendezvous ( //
// Platform hook fails to determine, use default BSP election method
//
- InterlockedCompareExchange32 (
- (UINT32 *)&mSmmMpSyncData->BspIndex,
- MAX_UINT32,
- (UINT32)CpuIndex
- );
+ if (mSmmMpSyncData->BspIndex == MAX_UINT32) {
+ InterlockedCompareExchange32 (
+ (UINT32 *)&mSmmMpSyncData->BspIndex,
+ MAX_UINT32,
+ (UINT32)CpuIndex
+ );
+ }
}
}
}
|