public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Dong, Eric" <eric.dong@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Jeff Fan <vanjeff_919@hotmail.com>, Laszlo Ersek <lersek@redhat.com>
Subject: Re: [Patch v2] UefiCpuPkg/MpInitLib: Optimize get processor number performance.
Date: Thu, 19 Jul 2018 04:40:18 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BD7F21D@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20180718051929.18172-1-eric.dong@intel.com>

Reviewed-by: Ruiyu Ni <Ruiyu.ni@intel.com>

Thanks/Ray

> -----Original Message-----
> From: Dong, Eric
> Sent: Wednesday, July 18, 2018 1:19 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Jeff Fan <vanjeff_919@hotmail.com>;
> Laszlo Ersek <lersek@redhat.com>
> Subject: [Patch v2] UefiCpuPkg/MpInitLib: Optimize get processor number
> performance.
> 
> Current function has low performance because it calls GetApicId many times.
> 
> New logic call GetApicId once and base on this value to search the processor.
> 
> V2 changes:
> Rollback V1 change which base on stack info to get AP index because this
> solution may return error AP index if stack buffer overflow.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jeff Fan <vanjeff_919@hotmail.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 722db2a01f..0bb0582985 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -435,16 +435,19 @@ GetProcessorNumber (
>    UINTN                   TotalProcessorNumber;
>    UINTN                   Index;
>    CPU_INFO_IN_HOB         *CpuInfoInHob;
> +  UINT32                  CurrentApicId;
> 
>    CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData-
> >CpuInfoInHob;
> 
>    TotalProcessorNumber = CpuMpData->CpuCount;
> +  CurrentApicId = GetApicId ();
>    for (Index = 0; Index < TotalProcessorNumber; Index ++) {
> -    if (CpuInfoInHob[Index].ApicId == GetApicId ()) {
> +    if (CpuInfoInHob[Index].ApicId == CurrentApicId) {
>        *ProcessorNumber = Index;
>        return EFI_SUCCESS;
>      }
>    }
> +
>    return EFI_NOT_FOUND;
>  }
> 
> --
> 2.15.0.windows.1



  reply	other threads:[~2018-07-19  4:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18  5:19 [Patch v2] UefiCpuPkg/MpInitLib: Optimize get processor number performance Eric Dong
2018-07-19  4:40 ` Ni, Ruiyu [this message]
2018-07-19 14:53 ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=734D49CCEBEEF84792F5B80ED585239D5BD7F21D@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox