Re: [edk2] [Patch v2] UefiCpuPkg/MpInitLib: Optimize get processor number performance.

2018-07-19 Thread Laszlo Ersek
On 07/18/18 07:19, Eric Dong wrote:
> 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 
> Cc: Jeff Fan 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong 
> ---
>  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;
>  }
>  
> 

Nice and clean.

Reviewed-by: Laszlo Ersek 

Sorry about the delay in my getting to this patch.
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch v2] UefiCpuPkg/MpInitLib: Optimize get processor number performance.

2018-07-18 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: Dong, Eric
> Sent: Wednesday, July 18, 2018 1:19 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Jeff Fan ;
> Laszlo Ersek 
> 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 
> Cc: Jeff Fan 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong 
> ---
>  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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v2] UefiCpuPkg/MpInitLib: Optimize get processor number performance.

2018-07-17 Thread Eric Dong
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 
Cc: Jeff Fan 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel