From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 BC8CD2098C8B3 for ; Wed, 18 Jul 2018 21:41:42 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 21:41:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,373,1526367600"; d="scan'208";a="241464093" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga005.jf.intel.com with ESMTP; 18 Jul 2018 21:40:21 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 18 Jul 2018 21:40:20 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 18 Jul 2018 21:40:20 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.81]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.173]) with mapi id 14.03.0319.002; Thu, 19 Jul 2018 12:40:18 +0800 From: "Ni, Ruiyu" To: "Dong, Eric" , "edk2-devel@lists.01.org" CC: Jeff Fan , Laszlo Ersek Thread-Topic: [Patch v2] UefiCpuPkg/MpInitLib: Optimize get processor number performance. Thread-Index: AQHUHlb0qy33RhEvz0mfbwYDC2LTPKSV+JxQ Date: Thu, 19 Jul 2018 04:40:18 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BD7F21D@SHSMSX104.ccr.corp.intel.com> References: <20180718051929.18172-1-eric.dong@intel.com> In-Reply-To: <20180718051929.18172-1-eric.dong@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch v2] UefiCpuPkg/MpInitLib: Optimize get processor number performance. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2018 04:41:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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. >=20 > Current function has low performance because it calls GetApicId many time= s. >=20 > New logic call GetApicId once and base on this value to search the proces= sor. >=20 > 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. >=20 > 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(-) >=20 > 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; >=20 > CpuInfoInHob =3D (CPU_INFO_IN_HOB *) (UINTN) CpuMpData- > >CpuInfoInHob; >=20 > TotalProcessorNumber =3D CpuMpData->CpuCount; > + CurrentApicId =3D GetApicId (); > for (Index =3D 0; Index < TotalProcessorNumber; Index ++) { > - if (CpuInfoInHob[Index].ApicId =3D=3D GetApicId ()) { > + if (CpuInfoInHob[Index].ApicId =3D=3D CurrentApicId) { > *ProcessorNumber =3D Index; > return EFI_SUCCESS; > } > } > + > return EFI_NOT_FOUND; > } >=20 > -- > 2.15.0.windows.1