For both non blocking and blocking:
Remove unnecessary a pair of AcquireSpinLock and ReleaseSpinLock
for each AP. It's target to improve SmmStartupAllAPs performance.

No functional impact, see below analysis:

During first acquire spinLock, InternalSmmStartupAllAPs will
return EFI_NOT_READY if AcquireSpinLockOrFail return false:

  if (!AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[Index].Busy)) {
    return EFI_NOT_READY;
  }

which means the AcquireSpinLockOrFail () must return TRUE if
InternalSmmStartupAllAPs () can continue the second round of Busy
spinlock. since the Busy has already acquired the spinlock, no need
to release and acquire again.

Cc: Ray Ni <ray...@intel.com>
Cc: Laszlo Ersek <ler...@redhat.com>
Cc: Eric Dong <eric.d...@intel.com>
Cc: Zeng Star <star.z...@intel.com>
Cc: Gerd Hoffmann <kra...@redhat.com>
Cc: Rahul Kumar <rahul1.ku...@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin...@intel.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 081f0c1501..9790b4f888 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -1257,12 +1257,10 @@ InternalSmmStartupAllAPs (
       }
 
       if (!AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[Index].Busy)) {
         return EFI_NOT_READY;
       }
-
-      ReleaseSpinLock (mSmmMpSyncData->CpuData[Index].Busy);
     }
   }
 
   if (CpuCount == 0) {
     return EFI_NOT_STARTED;
@@ -1273,23 +1271,10 @@ InternalSmmStartupAllAPs (
     *Token    = (MM_COMPLETION)ProcToken->SpinLock;
   } else {
     ProcToken = NULL;
   }
 
-  //
-  // Make sure all BUSY should be acquired.
-  //
-  // Because former code already check mSmmMpSyncData->CpuData[***].Busy for 
each AP.
-  // Here code always use AcquireSpinLock instead of AcquireSpinLockOrFail for 
not
-  // block mode.
-  //
-  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
-    if (IsPresentAp (Index)) {
-      AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy);
-    }
-  }
-
   for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
     if (IsPresentAp (Index)) {
       mSmmMpSyncData->CpuData[Index].Procedure = (EFI_AP_PROCEDURE2)Procedure;
       mSmmMpSyncData->CpuData[Index].Parameter = ProcedureArguments;
       if (ProcToken != NULL) {
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116434): https://edk2.groups.io/g/devel/message/116434
Mute This Topic: https://groups.io/mt/104764104/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to