From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (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 D6B63202E5483 for ; Thu, 5 Jul 2018 01:10:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1DB5887AAD; Thu, 5 Jul 2018 08:10:54 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-21.rdu2.redhat.com [10.10.120.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4904D111DD02; Thu, 5 Jul 2018 08:10:53 +0000 (UTC) To: "Dong, Eric" , Fan Jeff , "edk2-devel@lists.01.org" Cc: "Ni, Ruiyu" References: <20180704083736.9272-1-eric.dong@intel.com> From: Laszlo Ersek Message-ID: <7e75889d-03dd-29fd-b87a-daf22f32a48b@redhat.com> Date: Thu, 5 Jul 2018 10:10:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Jul 2018 08:10:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Jul 2018 08:10:54 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number performance. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2018 08:10:55 -0000 Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Hi Eric, On 07/05/18 03:26, Dong, Eric wrote: > Jeff, > > Got it. Will update the change log when I commit the changes. please give me a bit more time to check this patch; I'll try to come to it soon. Thanks for your patience! Laszlo > > Thanks, > Eric > From: Fan Jeff [mailto:vanjeff_919@hotmail.com] > Sent: Wednesday, July 4, 2018 5:39 PM > To: Dong, Eric ; edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Laszlo Ersek > Subject: 答复: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number performance. > > > Eric, > > > > Current implementation does not call GetApicid() many times, Please correct you commit message. Your fix is to improve the performance against the current implementation. > > > > This code part is ok to me. > > Reviewed-by: Jeff Fan vanjeff_919@hotmail.com > > > > Thanks! > > Jeff > > > > 发送自 Windows 10 版邮件应用 > > > > ________________________________ > 发件人: Eric Dong > > 发送时间: Wednesday, July 4, 2018 4:37:36 PM > 收件人: edk2-devel@lists.01.org > 抄送: Ruiyu Ni; Jeff Fan; Laszlo Ersek > 主题: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number performance. > > Current function has low performance because it calls GetApicId > many times. > > New logic first try to base on the stack range used by AP to > find the processor number. If this solution failed, then call > GetApicId once and base on this value to search the processor. > > Cc: Ruiyu Ni > > Cc: Jeff Fan > > Cc: Laszlo Ersek > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 25 ++++++++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c > index eb2765910c..abd65bee1a 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -418,7 +418,8 @@ ApInitializeSync ( > } > > /** > - Find the current Processor number by APIC ID. > + First try to find the current Processor number by stack address, > + if it failed, then base on APIC ID. > > @param[in] CpuMpData Pointer to PEI CPU MP Data > @param[out] ProcessorNumber Return the pocessor number found > @@ -435,16 +436,34 @@ GetProcessorNumber ( > UINTN TotalProcessorNumber; > UINTN Index; > CPU_INFO_IN_HOB *CpuInfoInHob; > + UINT32 CurrentApicId; > > + TotalProcessorNumber = CpuMpData->CpuCount; > CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; > > - TotalProcessorNumber = CpuMpData->CpuCount; > + // > + // First try to base on current stack address to find the AP index. > + // &TotalProcessorNumber value located in the stack range. > + // > for (Index = 0; Index < TotalProcessorNumber; Index ++) { > - if (CpuInfoInHob[Index].ApicId == GetApicId ()) { > + if ((CpuInfoInHob[Index].ApTopOfStack > (UINTN) (&TotalProcessorNumber)) && > + (CpuInfoInHob[Index].ApTopOfStack - CpuMpData->CpuApStackSize < (UINTN) (&TotalProcessorNumber))) { > *ProcessorNumber = Index; > return EFI_SUCCESS; > } > } > + > + // > + // If can't base on stack to find the AP index, use the APIC ID. > + // > + CurrentApicId = GetApicId (); > + for (Index = 0; Index < TotalProcessorNumber; Index ++) { > + if (CpuInfoInHob[Index].ApicId == CurrentApicId) { > + *ProcessorNumber = Index; > + return EFI_SUCCESS; > + } > + } > + > return EFI_NOT_FOUND; > } > > -- > 2.15.0.windows.1 >