From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.groups.io with SMTP id smtpd.web10.20837.1585164281115326651 for ; Wed, 25 Mar 2020 12:24:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E6kK6PLI; spf=pass (domain: redhat.com, ip: 216.205.24.74, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585164280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BsjVNjKIstWyPGxjtdI8dHry2SK8/QKIPHnRkGMh/+8=; b=E6kK6PLIAX/v+ykCgoAjKD+cQV2WLwvBj21aWU5QD1ShfwtjxsEzkXaTVxVeNcDR+4iGaE aWyijK2RYrdGqjfHyNeHEL0PmKGs/GPDvMaQiJhIdY3k7DIpxF8IeSbQe5QMmemgoJlc/j TNZL9SQTJZ4K86K1wakfm6PVO0k6zkY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383--KS1iw6OO4-smTqr5xC0nA-1; Wed, 25 Mar 2020 15:24:34 -0400 X-MC-Unique: -KS1iw6OO4-smTqr5xC0nA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 059F919251A0; Wed, 25 Mar 2020 19:24:33 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-153.ams2.redhat.com [10.36.113.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DC9B1001938; Wed, 25 Mar 2020 19:24:31 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v4] UefiCpuPkg/MpInitLib DXE: Add PCD to control AP status check interval To: devel@edk2.groups.io, hao.a.wu@intel.com Cc: Eric Dong , Ray Ni , Michael D Kinney , Star Zeng , "Brian J . Johnson" References: <20200325050725.9700-1-hao.a.wu@intel.com> From: "Laszlo Ersek" Message-ID: <5d7fb00a-29f8-4904-44df-308e05b8c774@redhat.com> Date: Wed, 25 Mar 2020 20:24:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200325050725.9700-1-hao.a.wu@intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 03/25/20 06:07, Wu, Hao A wrote: > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2627 > > 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 = 4,295 seconds = 71.58 minutes = 1.19 hours > 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: > 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|UINT64|0x32132113 > > + ## Specifies the periodic interval value in microseconds for the status check > + # of APs for StartupAllAPs() and StartupThisAP() executed in non-blocking > + # mode in DXE phase. > + # @Prompt Periodic interval value in microseconds for AP status check in DXE. > + gUefiCpuPkgTokenSpaceGuid.PcdCpuApStatusCheckIntervalInMicroSeconds|100000|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/Library/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 > > [Pcd] > - 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 > - gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES > - > + 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/MpInitLib/DxeMpLib.c > index a987c32109..56b776d3d8 100644 > --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > @@ -15,7 +15,6 @@ > > #include > > -#define AP_CHECK_INTERVAL (EFI_TIMER_PERIOD_MILLISECONDS (100)) > #define AP_SAFE_STACK_SIZE 128 > > CPU_MP_DATA *mCpuMpData = NULL; > @@ -451,7 +450,9 @@ InitMpGlobalData ( > Status = gBS->SetTimer ( > mCheckAllApsEvent, > TimerPeriodic, > - AP_CHECK_INTERVAL > + EFI_TIMER_PERIOD_MICROSECONDS ( > + PcdGet32 (PcdCpuApStatusCheckIntervalInMicroSeconds) > + ) > ); > ASSERT_EFI_ERROR (Status); > > 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 chunk.\n" > > #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmMpTokenCountPerChunk_HELP #language en-US "This value used to specify the count of pre allocated SMM MP tokens per chunk.\n" > + > +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApStatusCheckIntervalInMicroSeconds_PROMPT #language en-US "Periodic interval value in microseconds for AP status check in DXE.\n" > +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApStatusCheckIntervalInMicroSeconds_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" > For this patch: Reviewed-by: Laszlo Ersek I'm happy if this patch is pushed, as-is. Independently, I have found that MpInitLib, despite using several PCDs, does not list the PcdLib class in the [LibraryClasses] section, and never #include's either. (The [LibraryClasses] observation applies to both INF files, that is, PEI and DXE alike.) Things happen to work in practice because both the #include and the lib class dependency must be inherited from other headers / lib instances. But it would be prudent to spell out the PcdLib dependency, especially because some of the subject PCDs are used with the dynamic access method, in practice (for example by OvmfPkg) -- meaning that the actual PCD library APIs are exercised. Hao, can you post a followup patch for that, or do you prefer that we only enter a BZ ticket at the moment? Thanks! Laszlo