From nobody Sun Apr 28 19:15:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1531891185511398.75228783381203; Tue, 17 Jul 2018 22:19:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2166E209831CD; Tue, 17 Jul 2018 22:19:45 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 BBF25211F887E for ; Tue, 17 Jul 2018 22:19:43 -0700 (PDT) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 22:19:43 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.9.24]) by orsmga006.jf.intel.com with ESMTP; 17 Jul 2018 22:19:42 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,368,1526367600"; d="scan'208";a="58546627" From: Eric Dong To: edk2-devel@lists.01.org Date: Wed, 18 Jul 2018 13:19:29 +0800 Message-Id: <20180718051929.18172-1-eric.dong@intel.com> X-Mailer: git-send-email 2.15.0.windows.1 Subject: [edk2] [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: , Cc: Ruiyu Ni , Laszlo Ersek MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Laszlo Ersek Reviewed-by: Ruiyu Ni --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/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 --=20 2.15.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel