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 <ruiyu...@intel.com> > Cc: Jeff Fan <vanjeff_...@hotmail.com> > Cc: Laszlo Ersek <ler...@redhat.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <eric.d...@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; > } > >
Nice and clean. Reviewed-by: Laszlo Ersek <ler...@redhat.com> 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