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 253B29415E3 for ; Wed, 6 Mar 2024 12:11:13 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=CyIps/TcAB/HNIWA0xX7rWaOv5trAzkRBC2+gtYmrPQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe; s=20240206; t=1709727071; v=1; b=qvzrz/aLEgLjMfsvUjS3FlYWZNXrIErX4gRei5QTVlCQO5JYrK0Palt7d6d8vTQyLWNYUHrm U3Il5U0g0+viOQa7i77PEu6pNGLy4zOo5THZYXATFPseCg96Y4IlP2P7Ix+dxSiIvp2QpfGsNxg 6Seuuzpl4rjYllVq87iV1r+ctIHU4POyJ0xmsqDbIyYG9zB/LShgpD4gtoA2iiv6AWapLRl4ZjC sMn7Wg+ST1nlvy+ruthLPO/EJnICIJ8yECoq+71WOKFfXqEP/pPtINmM88Ne5HGlMr/xiNgiG3v wKDy9SBeqme8R9EA3cQM0qLT8wgBTVqiF06Sv2+yAhX0g== X-Received: by 127.0.0.2 with SMTP id TybnYY7687511xiyQw9lPZVU; Wed, 06 Mar 2024 04:11:11 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web10.10348.1709727069087992268 for ; Wed, 06 Mar 2024 04:11:11 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="26803638" X-IronPort-AV: E=Sophos;i="6.06,208,1705392000"; d="scan'208";a="26803638" X-Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 04:11:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,208,1705392000"; d="scan'208";a="9672889" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmviesa010.fm.intel.com with ESMTP; 06 Mar 2024 04:11:08 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Eric Dong , Zeng Star , Gerd Hoffmann , Rahul Kumar Subject: [edk2-devel] [PATCH v1 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove one round of Busy spinlock Date: Wed, 06 Mar 2024 04:11:11 -0800 Message-Id: <20240306121103.356-2-jiaxin.wu@intel.com> In-Reply-To: <20240306121103.356-1-jiaxin.wu@intel.com> References: <20240306121103.356-1-jiaxin.wu@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: n83uBCl1WbvPHr9OpdB33s53x7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="qvzrz/aL"; 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 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 Cc: Laszlo Ersek Cc: Eric Dong Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu --- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-