From nobody Sat Apr 20 01:50:07 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+56250+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+56250+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1585112851; cv=none; d=zohomail.com; s=zohoarc; b=hwNufGd0kjCBasr1YEttQ0dyAWbFBhJgRKgVhtKA1VG3RWW84hY06fSReECADom2vlk//OF6UHFklgu1p49vZlg2dr1O1DKbh4vOGVMsFmHIqxB5/7DS3xPPCQVA+SGy7mKLAz5CnBv0dEy8p3s8rhcdd+PrDP9Ge4+CYE2i2Lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585112851; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=L2ITaeNtlfoot77sNKjFHZRHpTXHynXpfZ9EjGWSPCE=; b=fQNxaZ42xUuS3QK6kXOq+z5rmD3NYCwfOUiQ3eXge9cWvaIzuD5CBVJpT0tDG2vDa0Z0tpjKK1ZgSs8dbG6B+ODUtKgEQx3XZrZfoya14LuHEPBPt1H7yC7iKTrtSWN5xXHlI5zCVYOPmJM7mrK5KaW0Hu6ju7Tz73FodaN0ODY= 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+56250+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 1585112851173792.6883048336567; Tue, 24 Mar 2020 22:07:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tcxHYY1788612xK20kNOW3tr; Tue, 24 Mar 2020 22:07:30 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web12.5961.1585112849894302225 for ; Tue, 24 Mar 2020 22:07:30 -0700 IronPort-SDR: t4G/4n9UbwArfj17DP7Ddw8OhAxqkikB0Yuj02t0kSAMgpzSRKWX7TaRXmf37FSAq9eeqQDY5G VFdMn+LNyC5g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2020 22:07:29 -0700 IronPort-SDR: 3loVXRe7Rw8XiAg3dXnpiXT5if7AznOIyNtWSyUv8/8ZvvsAEYR8Yg0VuNJTLSP4KwWlKWFtUx dfvCCd9HBnLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,303,1580803200"; d="scan'208";a="270689102" X-Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.4]) by fmsmga004.fm.intel.com with ESMTP; 24 Mar 2020 22:07:26 -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 v4] UefiCpuPkg/MpInitLib DXE: Add PCD to control AP status check interval Date: Wed, 25 Mar 2020 13:07:25 +0800 Message-Id: <20200325050725.9700-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: iCa1rXRdmybOXRrhWnla36tJx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585112850; bh=lW3/A6B+nuFhj6QwaMILs6ysc7QE4P4CiM4bTrOlynY=; h=Cc:Date:From:Reply-To:Subject:To; b=Mm7Fdnic7TBa0CNZYyiJlheL1+nkchrYuUvJVU22pLlqRKJ5MDNYrx1GFTQiy6bw9+i TOGDyHnO4jT6Ghx3nD2b34YOOE7LlRVdL48dKV+2SeIVj5gSW11sdlwpJUgETBzVgk0Bx kvRlSnPqlvip1u+0vsj+pI1WJtDe6QOr8hs= 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 Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni Reviewed-by: Star Zeng --- Notes: V4 Avoiding introducing a local variable in InitMpGlobalData(). 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 | 5 +++-- UefiCpuPkg/UefiCpuPkg.uni | 5 ++++- 4 files changed, 23 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..56b776d3d8 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; @@ -451,7 +450,9 @@ InitMpGlobalData ( Status =3D gBS->SetTimer ( mCheckAllApsEvent, TimerPeriodic, - AP_CHECK_INTERVAL + EFI_TIMER_PERIOD_MICROSECONDS ( + PcdGet32 (PcdCpuApStatusCheckIntervalInMicroSeconds) + ) ); 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 (#56250): https://edk2.groups.io/g/devel/message/56250 Mute This Topic: https://groups.io/mt/72535222/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-