From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3A4C781C50 for ; Fri, 4 Nov 2016 09:40:13 -0700 (PDT) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E94A78FCF3; Fri, 4 Nov 2016 16:40:14 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-156.phx2.redhat.com [10.3.116.156]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA4GeC4n029012; Fri, 4 Nov 2016 12:40:13 -0400 To: Jeff Fan , edk2-devel@ml01.01.org References: <20161104081806.19624-1-jeff.fan@intel.com> Cc: Michael Kinney , Feng Tian , Liming Gao From: Laszlo Ersek Message-ID: <9af37565-ad49-6e1a-bf33-07e1254c4217@redhat.com> Date: Fri, 4 Nov 2016 17:40:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161104081806.19624-1-jeff.fan@intel.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 04 Nov 2016 16:40:15 +0000 (UTC) Subject: Re: [PATCH] UefiCpuPkg/MpInitLib: Do not wakeup AP if only one processor supported X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 16:40:13 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 11/04/16 09:18, Jeff Fan wrote: > If MaxLogicalProcessorNumber is only 1, we needn't to wake up APs at all > and needn't to register callback functions. > > It could improve boot performance on single supported system. > > https://bugzilla.tianocore.org/show_bug.cgi?id=204 > > Cc: Feng Tian > Cc: Liming Gao > Cc: Michael Kinney > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jeff Fan > --- > UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 7 ++++++ > UefiCpuPkg/Library/MpInitLib/MpLib.c | 39 +++++++++++++++++++-------------- > UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 8 +++++++ > 3 files changed, 37 insertions(+), 17 deletions(-) The MP services protocol and PPI that depend on this library will remain available to callers, right? Thanks Laszlo > diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > index b399f1c..eb36d6f 100644 > --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > @@ -290,6 +290,13 @@ InitMpGlobalData ( > > SaveCpuMpData (CpuMpData); > > + if (CpuMpData->CpuCount == 1) { > + // > + // If only BSP exists, return > + // > + return; > + } > + > // > // Avoid APs access invalid buff data which allocated by BootServices, > // so we will allocate reserved data for AP loop code. > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c > index 56b870e..a0edc55 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -1143,6 +1143,7 @@ MpInitLibInitialize ( > } else { > MaxLogicalProcessorNumber = OldCpuMpData->CpuCount; > } > + ASSERT (MaxLogicalProcessorNumber != 0); > > AsmGetAddressMap (&AddressMap); > ApResetVectorSize = AddressMap.RendezvousFunnelSize + sizeof (MP_CPU_EXCHANGE_INFO); > @@ -1209,10 +1210,12 @@ MpInitLibInitialize ( > MtrrGetAllMtrrs (&CpuMpData->MtrrTable); > > if (OldCpuMpData == NULL) { > - // > - // Wakeup all APs and calculate the processor count in system > - // > - CollectProcessorCount (CpuMpData); > + if (MaxLogicalProcessorNumber > 1) { > + // > + // Wakeup all APs and calculate the processor count in system > + // > + CollectProcessorCount (CpuMpData); > + } > } else { > // > // APs have been wakeup before, just get the CPU Information > @@ -1238,19 +1241,21 @@ MpInitLibInitialize ( > sizeof (CPU_VOLATILE_REGISTERS) > ); > } > - // > - // Wakeup APs to do some AP initialize sync > - // > - WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData); > - // > - // Wait for all APs finished initialization > - // > - while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { > - CpuPause (); > - } > - CpuMpData->InitFlag = ApInitDone; > - for (Index = 0; Index < CpuMpData->CpuCount; Index++) { > - SetApState (&CpuMpData->CpuData[Index], CpuStateIdle); > + if (MaxLogicalProcessorNumber > 1) { > + // > + // Wakeup APs to do some AP initialize sync > + // > + WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData); > + // > + // Wait for all APs finished initialization > + // > + while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { > + CpuPause (); > + } > + CpuMpData->InitFlag = ApInitDone; > + for (Index = 0; Index < CpuMpData->CpuCount; Index++) { > + SetApState (&CpuMpData->CpuData[Index], CpuStateIdle); > + } > } > } > > diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c > index e242d37..1f2fcb8 100644 > --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c > @@ -321,6 +321,14 @@ InitMpGlobalData ( > EFI_STATUS Status; > > SaveCpuMpData (CpuMpData); > + > + if (CpuMpData->CpuCount == 1) { > + // > + // If only BSP exists, return > + // > + return; > + } > + > // > // Register an event for EndOfPei > // >