From nobody Wed May 8 19:43:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=hotmail.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1530697167097833.7075428832749; Wed, 4 Jul 2018 02:39:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 114F0210C7AC7; Wed, 4 Jul 2018 02:39:26 -0700 (PDT) Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-oln040092010069.outbound.protection.outlook.com [40.92.10.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 42F38210C125E for ; Wed, 4 Jul 2018 02:39:24 -0700 (PDT) Received: from CO1NAM04FT014.eop-NAM04.prod.protection.outlook.com (10.152.90.53) by CO1NAM04HT180.eop-NAM04.prod.protection.outlook.com (10.152.90.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.906.15; Wed, 4 Jul 2018 09:39:23 +0000 Received: from SN6PR19MB2269.namprd19.prod.outlook.com (10.152.90.59) by CO1NAM04FT014.mail.protection.outlook.com (10.152.90.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.906.15 via Frontend Transport; Wed, 4 Jul 2018 09:39:23 +0000 Received: from SN6PR19MB2269.namprd19.prod.outlook.com ([fe80::5403:ac56:937d:97aa]) by SN6PR19MB2269.namprd19.prod.outlook.com ([fe80::5403:ac56:937d:97aa%4]) with mapi id 15.20.0906.026; Wed, 4 Jul 2018 09:39:23 +0000 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=40.92.10.69; helo=nam04-co1-obe.outbound.protection.outlook.com; envelope-from=vanjeff_919@hotmail.com; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9l2mHhWb3FtmCAKYdkBn3lvRsfGgJUf3XgS0Qc4F7ek=; b=rGiR3AJI3xc0EP0YyLXPivMMFTmQVtxwA0HIr0QBMSyng4d0Xo6c4xz1+Bm7v1uo1cKcTQueEFo0z1h1x1PrYm0GShkPtWOlvlsvX/OiwNWoh7SNmYou4fqg1P+GpSU60Wq/kXlyCed6bkEEWOcNWb2FgNTtudO4nz1cornByJi9ACdpxPczBIIkitfQZray5Z9+8j6y8KYj4hpikrqwUPS0K6ZUOyDVwAd9npP8sN4p+wchI2B+2xvnkVVtYoUhybfOMX3M3Cd3JmMUZKe8sLs5ARIVaUh0IUzuGP8j6S9mPR1z12OkgEflxNAJtSOAcatNPHrOtI4dpp/A32QBBg== From: Fan Jeff To: Eric Dong , "edk2-devel@lists.01.org" Thread-Topic: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number performance. Thread-Index: AQHUE3JGhNH2KVIHZ0O9MeyB4YtgvKR+zVoz Date: Wed, 4 Jul 2018 09:39:23 +0000 Message-ID: References: <20180704083736.9272-1-eric.dong@intel.com> In-Reply-To: <20180704083736.9272-1-eric.dong@intel.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:1ACDD383ADF6B187A4B9CFF5D160D2984CD84554E7C626CCC27250417AB20E39; UpperCasedChecksum:04F0B4001E1BEB6EB7DAB9F43A04912C413894A5B7AC93D5CF2E126D92433DE6; SizeAsReceived:7207; Count:47 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [lnXxoa6QTo5Gt5r/2pQhysIWKrscFzEn] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CO1NAM04HT180; 7:KDyodbwlgAGOiBZNw1fQ2VsTVZLrC81aHSTt3clKCqADijEqTHuhnZJ4NcEr4dIr2iaHzWtgdXENlY1uKvsHrIPfWkWnuokTGKM0EbVlFhERsv43TajLgGa7f8Xt9ePl5oIFds5TRaARXeAHme/wtNLMgpC8wg5r02hkF991r3siDb4LNApviVDpBeCftgdmZSrnZzmZ2mHYzUU6CRKibMFQULIuFhAKxMmnp9ZxcMmM88SXLOYVgjFxOGD6+e5D x-incomingheadercount: 47 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125500)(1701031045); SRVR:CO1NAM04HT180; x-ms-traffictypediagnostic: CO1NAM04HT180: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:CO1NAM04HT180; BCL:0; PCL:0; RULEID:; SRVR:CO1NAM04HT180; x-forefront-prvs: 0723A02764 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(6029001)(199004)(189003)(54906003)(6346003)(5250100002)(2501003)(16234385003)(11346002)(486006)(256004)(74316002)(81156014)(8936002)(9686003)(102836004)(26005)(45080400002)(446003)(83332001)(6306002)(4326008)(25786009)(54896002)(55016002)(236005)(476003)(7696005)(76176011)(6436002)(86362001)(73972006)(606006)(82202002)(5660300001)(99286004)(97736004)(20460500001)(104016004)(87572001)(14454004)(33656002)(2900100001)(68736007)(6506007)(224303003)(105586002)(106356001)(110136005)(15852004)(19627235001); DIR:OUT; SFP:1901; SCL:1; SRVR:CO1NAM04HT180; H:SN6PR19MB2269.namprd19.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:; received-spf: None (protection.outlook.com: hotmail.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=vanjeff_919@hotmail.com; x-microsoft-antispam-message-info: 2CQLk3F1j18c6Ymjvh5e8yzgx4yWEtZ6FE4soPCHa891iDuV5EGOYSZH92Gv31qUDqZX9QNE7xT3bLODHwmHOLQh1w8i8JakPYVX1mmpkEcciVdxcF7repwgus2kzFf6qEWmNlsKJbU5EGYUwazxEAY9YOuCd4mRdfTEdwB4gFaAMvyWHs5lArgxcKZlDyNQmrrHthBeXDQlf1imc/KgCzQLhse1NMqlsSLhLoHbnqI= MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: d4d70346-2c10-4f39-8c00-e767963926d9 X-MS-Exchange-CrossTenant-Network-Message-Id: bb6809b1-4fa9-4225-74e6-08d5e1920676 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: d4d70346-2c10-4f39-8c00-e767963926d9 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jul 2018 09:39:23.1943 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM04HT180 X-Content-Filtered-By: Mailman/MimeDel 2.1.26 Subject: [edk2] =?gb2312?b?tPC4tDogW1BhdGNoXSBVZWZpQ3B1UGtnL01wSW5pdExp?= =?gb2312?b?YjogT3B0aW1pemUgZ2V0IHByb2Nlc3NvciBudW1iZXIgcGVyZm9ybWFuY2Uu?= X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Laszlo Ersek Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Eric, Current implementation does not call GetApicid() many times, Please correc= t you commit message. Your fix is to improve the performance against the cu= rrent implementation. This code part is ok to me. Reviewed-by: Jeff Fan vanjeff_919@hotmail.com Thanks! Jeff =E5=8F=91=E9=80=81=E8=87=AA Windows 10 =E7=89=88=E9=82=AE=E4=BB=B6=E5=BA=94=E7=94=A8 ________________________________ =E5=8F=91=E4=BB=B6=E4=BA=BA: Eric Dong =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: Wednesday, July 4, 2018 4:37:36 PM =E6=94=B6=E4=BB=B6=E4=BA=BA: edk2-devel@lists.01.org =E6=8A=84=E9=80=81: Ruiyu Ni; Jeff Fan; Laszlo Ersek =E4=B8=BB=E9=A2=98: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor nu= mber performance. Current function has low performance because it calls GetApicId many times. New logic first try to base on the stack range used by AP to find the processor number. If this solution failed, then call GetApicId once and base on this value to search the processor. 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 | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index eb2765910c..abd65bee1a 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -418,7 +418,8 @@ ApInitializeSync ( } /** - Find the current Processor number by APIC ID. + First try to find the current Processor number by stack address, + if it failed, then base on APIC ID. @param[in] CpuMpData Pointer to PEI CPU MP Data @param[out] ProcessorNumber Return the pocessor number found @@ -435,16 +436,34 @@ GetProcessorNumber ( UINTN TotalProcessorNumber; UINTN Index; CPU_INFO_IN_HOB *CpuInfoInHob; + UINT32 CurrentApicId; + TotalProcessorNumber =3D CpuMpData->CpuCount; CpuInfoInHob =3D (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - TotalProcessorNumber =3D CpuMpData->CpuCount; + // + // First try to base on current stack address to find the AP index. + // &TotalProcessorNumber value located in the stack range. + // for (Index =3D 0; Index < TotalProcessorNumber; Index ++) { - if (CpuInfoInHob[Index].ApicId =3D=3D GetApicId ()) { + if ((CpuInfoInHob[Index].ApTopOfStack > (UINTN) (&TotalProcessorNumber= )) && + (CpuInfoInHob[Index].ApTopOfStack - CpuMpData->CpuApStackSize < (U= INTN) (&TotalProcessorNumber))) { *ProcessorNumber =3D Index; return EFI_SUCCESS; } } + + // + // If can't base on stack to find the AP index, use the APIC ID. + // + CurrentApicId =3D GetApicId (); + for (Index =3D 0; Index < TotalProcessorNumber; Index ++) { + if (CpuInfoInHob[Index].ApicId =3D=3D CurrentApicId) { + *ProcessorNumber =3D 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