From nobody Thu Apr 18 02:06:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56243+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56243+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1585105971; cv=none; d=zohomail.com; s=zohoarc; b=j7xFzkjWOEAtogG5OR2m77R6+ZKCGv4AN+GDFsMFM4QwXiaqPIJI0pPQPumWoNDZU+RduChv6oCkMc1AgYJ1ob5rb2LILV0+IM/4AH0/iqlNbb2I+t6gU7NPAFG0Pyg8drWqfP8nJkrE+BloD7voXX+PYSdfu1mq4rb4euFdbu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585105971; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=zLnY5vLy1yid/1etWvXs2bElj4G83YZq6GO3cqoGcEQ=; b=fgnDCXrwyDERtVFwXqvtxdsWK0JWj2QVln2bccPfvD4PVLsAUV3wzSUhw/VQ7ugCxR52dhPcG74lqPD25CcGIyZCn5tPxABdzOL+s8aByxtsORpKjQFTAxcGX+e+lnD4c/UBHA2CL3R6JlSuUNcG+Q4pfU84suDQiNXV9t6mc8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56243+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585105971297442.2223129798365; Tue, 24 Mar 2020 20:12:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Z9hVYY1788612xUOJOaGVEDH; Tue, 24 Mar 2020 20:12:50 -0700 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.4589.1585105970233062686 for ; Tue, 24 Mar 2020 20:12:50 -0700 IronPort-SDR: R3pRj1ghhgl99/r0DjOiJxTIUHRUYUBt4prR/3xKtrsGrCAXsaM5P3BiLCdQ/oI+ZsEJxm5Ie1 TenXom0t+YxQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2020 20:12:49 -0700 IronPort-SDR: SGXJY9SNVNr3cgbKTA3nySY+Rq56V69lbNrmB6JpwgyT7oJ2vNlQURyWA2DJzkUlNoJZOnrI7G 8V0JV5tU+rsg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,302,1580803200"; d="scan'208";a="246990853" X-Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.4]) by orsmga003.jf.intel.com with ESMTP; 24 Mar 2020 20:12:46 -0700 From: "Wu, Hao A" To: devel@edk2.groups.io Cc: Hao A Wu , Eric Dong , Ray Ni , Laszlo Ersek , Michael D Kinney , Star Zeng , "Brian J . Johnson" Subject: [edk2-devel] [PATCH v3] UefiCpuPkg/MpInitLib DXE: Add PCD to control AP status check interval Date: Wed, 25 Mar 2020 11:12:44 +0800 Message-Id: <20200325031244.8092-1-hao.a.wu@intel.com> Precedence: Bulk List-Unsubscribe: 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,hao.a.wu@intel.com X-Gm-Message-State: buQ5EIFGznlNXYMNiwo2alWPx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585105970; bh=uq3DCyPQd3RH4tUoZ67nrxPLbt4JGrWFmCrVYIxZDYs=; h=Cc:Date:From:Reply-To:Subject:To; b=e5D3uqvYVbYE2V+RCR4/IFitrVZl7KANeZ5sDUHdWBuVvBS7ivDcc3tU9o/yCyaAqmU FeeuC3kUmNQo+DmtmT/jmxuw3DrcEe5MRlSZP8h8HweixUbTjm4NNkp/XGZRcd2t9+aFn GBO6+6qRNYRkU6SGSVMZ1KTrsUe3EJqz3ZU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2627 The commit will introduce a static PCD to specify the periodic interval for checking the AP status when MP services StartupAllAPs() and StartupThisAP() are being executed in a non-blocking manner. Or in other words, specifies the interval for callback function CheckApsStatus(). The purpose is to provide the platform owners with the ability to choose the proper interval value to trigger CheckApsStatus() according to: A) The number of processors in the system; B) How MP services (StartupAllAPs & StartupThisAP) being used. Setting the PCD to a small value means the AP status check callback will be trigerred more frequently, it can benefit the performance for the case when the BSP uses WaitForEvent() or uses CheckEvent() in a loop to wait for AP(s) to complete the task, especially when the task can be finished considerably fast on AP(s). An example is within function CpuFeaturesInitialize() under UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c, where BSP will perform the same task with APs and requires all the processors to finish the task before BSP proceeds to its next task. Setting the PCD to a big value, on the other hand, can reduce the impact on BSP by the time being consumed in CheckApsStatus(), especially when the number of processors is huge so that the time consumed in CheckApsStatus() is not negligible. The type of the PCD is UINT32, which means the maximum possible interval value can be set to: 4,294,967,295 microseconds =3D 4,295 seconds =3D 71.58 minutes =3D 1.19 hou= rs which should be sufficient for usage. For least impact, the default value of the new PCD will be the same with the current interval value. It will be set to 100,000 microseconds, which is 100 milliseconds. Unitest done: A) OS boot successfully; B) Use debug message to confirm the 'TriggerTime' parameter for the 'SetTimer' service is the same before & after this patch. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Michael D Kinney Cc: Star Zeng Cc: Brian J. Johnson Signed-off-by: Hao A Wu --- Notes: V3 A) Use microseconds, instead of milliseconds as the interval unit; B) Use UINT32, instead of UINT64, for the PCD type; C) Address the bug that incorrect 'TriggerTime' parameter was passed into the 'SetTimer' service call in V2 patch V2 Introduce a PCD to specify the AP status check interval. UefiCpuPkg/UefiCpuPkg.dec | 6 ++++++ UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 20 ++++++++++---------- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 7 +++++-- UefiCpuPkg/UefiCpuPkg.uni | 5 ++++- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index e91dc68cbe..762badf5d2 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -230,6 +230,12 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] # @Prompt This PCD is the nominal frequency of the core crystal clock in= Hz as is CPUID Leaf 0x15:ECX gUefiCpuPkgTokenSpaceGuid.PcdCpuCoreCrystalClockFrequency|24000000|UINT6= 4|0x32132113 =20 + ## Specifies the periodic interval value in microseconds for the status = check + # of APs for StartupAllAPs() and StartupThisAP() executed in non-blocki= ng + # mode in DXE phase. + # @Prompt Periodic interval value in microseconds for AP status check in= DXE. + gUefiCpuPkgTokenSpaceGuid.PcdCpuApStatusCheckIntervalInMicroSeconds|1000= 00|UINT32|0x0000001E + [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] ## Specifies max supported number of Logical Processors. # @Prompt Configure max supported number of Logical Processors diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Lib= rary/MpInitLib/DxeMpInitLib.inf index 45aaa179ff..a51a9ec1d2 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf @@ -61,13 +61,13 @@ [Guids] gEdkiiMicrocodePatchHobGuid ## SOMETIMES_CONSUMES ## = HOB =20 [Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONS= UMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CONS= UMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOME= TIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONS= UMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONS= UMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CONS= UMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode ## CONS= UMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## SOME= TIMES_CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONS= UMES - + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## = CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## = CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## = SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## = CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## = CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## = CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode ## = CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## = SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApStatusCheckIntervalInMicroSeconds ## = CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## = CONSUMES diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/M= pInitLib/DxeMpLib.c index a987c32109..ee33e5ce8f 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -15,7 +15,6 @@ =20 #include =20 -#define AP_CHECK_INTERVAL (EFI_TIMER_PERIOD_MILLISECONDS (100)) #define AP_SAFE_STACK_SIZE 128 =20 CPU_MP_DATA *mCpuMpData =3D NULL; @@ -327,6 +326,7 @@ InitMpGlobalData ( EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc; UINTN StackBase; CPU_INFO_IN_HOB *CpuInfoInHob; + UINT64 TriggerTime; =20 SaveCpuMpData (CpuMpData); =20 @@ -448,10 +448,13 @@ InitMpGlobalData ( // // Set timer to check all APs status. // + TriggerTime =3D EFI_TIMER_PERIOD_MICROSECONDS ( + PcdGet32 (PcdCpuApStatusCheckIntervalInMicroSeconds) + ); Status =3D gBS->SetTimer ( mCheckAllApsEvent, TimerPeriodic, - AP_CHECK_INTERVAL + TriggerTime ); ASSERT_EFI_ERROR (Status); =20 diff --git a/UefiCpuPkg/UefiCpuPkg.uni b/UefiCpuPkg/UefiCpuPkg.uni index c0d6ed5136..1780dfdc12 100644 --- a/UefiCpuPkg/UefiCpuPkg.uni +++ b/UefiCpuPkg/UefiCpuPkg.uni @@ -3,7 +3,7 @@ // // This Package provides UEFI compatible CPU modules and libraries. // -// Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+// Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.
// // SPDX-License-Identifier: BSD-2-Clause-Patent // @@ -275,3 +275,6 @@ #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmMpTokenCountPerChunk_PROMPT= #language en-US "Specify the count of pre allocated SMM MP tokens per chu= nk.\n" =20 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmMpTokenCountPerChunk_HELP = #language en-US "This value used to specify the count of pre allocated SM= M MP tokens per chunk.\n" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApStatusCheckIntervalInMicroSe= conds_PROMPT #language en-US "Periodic interval value in microseconds for = AP status check in DXE.\n" +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApStatusCheckIntervalInMicroSe= conds_HELP #language en-US "Periodic interval value in microseconds for = the status check of APs for StartupAllAPs() and StartupThisAP() executed in= non-blocking mode in DXE phase.\n" --=20 2.12.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56243): https://edk2.groups.io/g/devel/message/56243 Mute This Topic: https://groups.io/mt/72534018/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-