Skip to content

Commit

Permalink
UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex first before lock cmpxchg
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Laszlo Ersek <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Kinney Michael D <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>
  • Loading branch information
jiaxinwu authored and mergify[bot] committed Feb 21, 2024
1 parent d698bcf commit 2ca8d55
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
}
}
Expand Down

0 comments on commit 2ca8d55

Please sign in to comment.