From nobody Fri Nov 1 12:36:04 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 Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516957412904256.5115665659242; Fri, 26 Jan 2018 01:03:32 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 548A5222A3350; Fri, 26 Jan 2018 00:58:00 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 2C91D222A334B for ; Fri, 26 Jan 2018 00:57:59 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jan 2018 01:03:29 -0800 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.179]) by fmsmga001.fm.intel.com with ESMTP; 26 Jan 2018 01:03:28 -0800 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.31; helo=mga06.intel.com; envelope-from=jian.j.wang@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.46,415,1511856000"; d="scan'208";a="25622251" From: Jian J Wang To: edk2-devel@lists.01.org Date: Fri, 26 Jan 2018 17:03:07 +0800 Message-Id: <20180126090307.6872-3-jian.j.wang@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180126090307.6872-1-jian.j.wang@intel.com> References: <20180126090307.6872-1-jian.j.wang@intel.com> Subject: [edk2] [PATCH 2/2] UefiCpuPkg/CpuDxe: remove all code to flush TLB for APs X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Laszlo Ersek , Jiewen Yao , Eric Dong 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" The reason doing this is that we found that calling StartupAllAps() to flush TLB for all APs in CpuDxe driver after changing page attributes will spend a lot of time to complete. If there are many page attributes update requests, the whole system performance will be slowed down explicitly, including any shell command and UI operation. The solution is removing the flush operation for AP in CpuDxe driver and let AP flush TLB after woken up. Cc: Ruiyu Ni Cc: Jiewen Yao Cc: Eric Dong Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- UefiCpuPkg/CpuDxe/CpuPageTable.c | 85 +++---------------------------------= ---- 1 file changed, 5 insertions(+), 80 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTa= ble.c index a33ac5519e..a5bf0dfe28 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -89,70 +89,6 @@ PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] =3D { =20 PAGE_TABLE_POOL *mPageTablePool =3D NULL; =20 -/** - Enable write protection function for AP. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -SyncCpuEnableWriteProtection ( - IN OUT VOID *Buffer - ) -{ - AsmWriteCr0 (AsmReadCr0 () | BIT16); -} - -/** - CpuFlushTlb function for AP. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -SyncCpuFlushTlb ( - IN OUT VOID *Buffer - ) -{ - CpuFlushTlb(); -} - -/** - Sync memory page attributes for AP. - - @param[in] Procedure A pointer to the function to be run on e= nabled APs of - the system. -**/ -VOID -SyncMemoryPageAttributesAp ( - IN EFI_AP_PROCEDURE Procedure - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpService; - - Status =3D gBS->LocateProtocol ( - &gEfiMpServiceProtocolGuid, - NULL, - (VOID **)&MpService - ); - // - // Synchronize the update with all APs - // - if (!EFI_ERROR (Status)) { - Status =3D MpService->StartupAllAPs ( - MpService, // This - Procedure, // Procedure - FALSE, // SingleThread - NULL, // WaitEvent - 0, // TimeoutInMicrosecsond - NULL, // ProcedureArgument - NULL // FailedCpuList - ); - ASSERT (Status =3D=3D EFI_SUCCESS || Status =3D=3D EFI_NOT_STARTED || = Status =3D=3D EFI_NOT_READY); - } -} - /** Return current paging context. =20 @@ -574,20 +510,6 @@ IsReadOnlyPageWriteProtected ( return ((AsmReadCr0 () & BIT16) !=3D 0); } =20 -/** - Disable write protection function for AP. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -SyncCpuDisableWriteProtection ( - IN OUT VOID *Buffer - ) -{ - AsmWriteCr0 (AsmReadCr0() & ~BIT16); -} - /** Disable Write Protect on pages marked as read-only. **/ @@ -835,10 +757,13 @@ AssignMemoryPageAttributes ( if (!EFI_ERROR(Status)) { if ((PagingContext =3D=3D NULL) && IsModified) { // - // Flush TLB as last step + // Flush TLB as last step. + // + // Note: Don't flush TLB for APs here. It will take a lot of time to + // complete, and then slow down boot performance of the whole system + // if page attributes are requested frequently to update. // CpuFlushTlb(); - SyncMemoryPageAttributesAp (SyncCpuFlushTlb); } } =20 --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel