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 20029740052 for ; Fri, 3 Nov 2023 15:30:25 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=wKqOPKnDYQIbSkHHFSFuGh3ekg1du6ukooz/5COH1xA=; 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=20140610; t=1699025424; v=1; b=IXNat6hEH53u22JILOAjxAcC9mX1dL81qEL5jNzFXcFAGWXpx0ZlSXdmZ382vIF3YknadyGQ F0/6UJ0v0AlzHqG43b8IBHCRpVS8Vsla57CZqY+JZcyR0lUtSCzn0qpj9eKj3/Pb6oDs+5t3l8S /uH60lkVSrJdqE4fizXzHyHM= X-Received: by 127.0.0.2 with SMTP id EUvJYY7687511xlzE0haI73v; Fri, 03 Nov 2023 08:30:24 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mx.groups.io with SMTP id smtpd.web10.56401.1699025420211463760 for ; Fri, 03 Nov 2023 08:30:24 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10883"; a="1898882" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="1898882" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 08:30:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10883"; a="790793145" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="790793145" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orsmga008.jf.intel.com with ESMTP; 03 Nov 2023 08:30:21 -0700 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Zeng Star , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH v1 2/7] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce times of BSP and AP Sync for SMM Exit Date: Fri, 3 Nov 2023 23:30:07 +0800 Message-Id: <20231103153012.3704-3-jiaxin.wu@intel.com> In-Reply-To: <20231103153012.3704-1-jiaxin.wu@intel.com> References: <20231103153012.3704-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: l4IchOuCa3sxk7DtNiQl2P0Ex7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=IXNat6hE; 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 After review, there are unnecessary steps for BSP and AP sync for SMM exit. This patch is to reduce one round BSP and AP sync so as to improve SMI performance: BSP: WaitForAllAPs <-- AP: ReleaseBsp BSP: ReleaseAllAPs --> AP: WaitForBsp Change-Id: Ic33f42f3daa7ff1847e524d0c3d9cd4fcdefa61b Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Rahul Kumar Cc: Gerd Hoffmann Signed-off-by: Jiaxin Wu --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 44 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c index e96c7f51d6..5a42a5dd12 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -665,11 +665,13 @@ BSPHandler ( // *mSmmMpSyncData->AllCpusInSync = TRUE; ApCount = LockdownSemaphore (mSmmMpSyncData->Counter) - 1; // - // Wait for all APs to get ready for programming MTRRs + // Wait for all APs: + // 1. Make sure all Aps have set the Present. + // 2. Get ready for programming MTRRs. // WaitForAllAPs (ApCount); if (SmmCpuFeaturesNeedConfigureMtrrs ()) { // @@ -768,16 +770,16 @@ BSPHandler ( // Notify all APs to exit // *mSmmMpSyncData->InsideSmm = FALSE; ReleaseAllAPs (); - // - // Wait for all APs to complete their pending tasks - // - WaitForAllAPs (ApCount); - if (SmmCpuFeaturesNeedConfigureMtrrs ()) { + // + // Wait for all APs to complete their pending tasks + // + WaitForAllAPs (ApCount); + // // Signal APs to restore MTRRs // ReleaseAllAPs (); @@ -789,23 +791,23 @@ BSPHandler ( // // Wait for all APs to complete MTRR programming // WaitForAllAPs (ApCount); + + // + // Signal APs to Reset states/semaphore for this processor + // + ReleaseAllAPs (); } // // Stop source level debug in BSP handler, the code below will not be // debugged. // InitializeDebugAgent (DEBUG_AGENT_INIT_EXIT_SMI, NULL, NULL); - // - // Signal APs to Reset states/semaphore for this processor - // - ReleaseAllAPs (); - // // Perform pending operations for hot-plug // SmmCpuUpdate (); @@ -941,10 +943,12 @@ APHandler ( *(mSmmMpSyncData->CpuData[CpuIndex].Present) = TRUE; if ((SyncMode == SmmCpuSyncModeTradition) || SmmCpuFeaturesNeedConfigureMtrrs ()) { // // Notify BSP of arrival at this point + // 1. Set the Present. + // 2. Get ready for programming MTRRs. // ReleaseBsp (mSmmMpSyncData->CpuData[BspIndex].Run); } if (SmmCpuFeaturesNeedConfigureMtrrs ()) { @@ -1033,21 +1037,21 @@ APHandler ( // // Restore OS MTRRs // SmmCpuFeaturesReenableSmrr (); MtrrSetAllMtrrs (&Mtrrs); - } - // - // Notify BSP the readiness of this AP to Reset states/semaphore for this processor - // - ReleaseBsp (mSmmMpSyncData->CpuData[BspIndex].Run); + // + // Notify BSP the readiness of this AP to Reset states/semaphore for this processor + // + ReleaseBsp (mSmmMpSyncData->CpuData[BspIndex].Run); - // - // Wait for the signal from BSP to Reset states/semaphore for this processor - // - WaitForBsp (mSmmMpSyncData->CpuData[CpuIndex].Run); + // + // Wait for the signal from BSP to Reset states/semaphore for this processor + // + WaitForBsp (mSmmMpSyncData->CpuData[CpuIndex].Run); + } // // Reset states/semaphore for this processor // *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE; -- 2.16.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110638): https://edk2.groups.io/g/devel/message/110638 Mute This Topic: https://groups.io/mt/102366299/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-