]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuDxe: remove all code to flush TLB for APs
authorJian J Wang <jian.j.wang@intel.com>
Mon, 29 Jan 2018 01:26:31 +0000 (09:26 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Mon, 29 Jan 2018 01:37:41 +0000 (09:37 +0800)
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 <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
UefiCpuPkg/CpuDxe/CpuPageTable.c

index a33ac5519e68cb733f334ceef264e103ce4293eb..e2595b4d892d948c50dfddc7843eaac1ff6b2ac2 100644 (file)
@@ -89,70 +89,6 @@ PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = {
 \r
 PAGE_TABLE_POOL   *mPageTablePool = NULL;\r
 \r
-/**\r
-  Enable write protection function for AP.\r
-\r
-  @param[in,out] Buffer  The pointer to private data buffer.\r
-**/\r
-VOID\r
-EFIAPI\r
-SyncCpuEnableWriteProtection (\r
-  IN OUT VOID *Buffer\r
-  )\r
-{\r
-  AsmWriteCr0 (AsmReadCr0 () | BIT16);\r
-}\r
-\r
-/**\r
-  CpuFlushTlb function for AP.\r
-\r
-  @param[in,out] Buffer  The pointer to private data buffer.\r
-**/\r
-VOID\r
-EFIAPI\r
-SyncCpuFlushTlb (\r
-  IN OUT VOID *Buffer\r
-  )\r
-{\r
-  CpuFlushTlb();\r
-}\r
-\r
-/**\r
-  Sync memory page attributes for AP.\r
-\r
-  @param[in] Procedure            A pointer to the function to be run on enabled APs of\r
-                                  the system.\r
-**/\r
-VOID\r
-SyncMemoryPageAttributesAp (\r
-  IN EFI_AP_PROCEDURE            Procedure\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_MP_SERVICES_PROTOCOL  *MpService;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiMpServiceProtocolGuid,\r
-                  NULL,\r
-                  (VOID **)&MpService\r
-                  );\r
-  //\r
-  // Synchronize the update with all APs\r
-  //\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = MpService->StartupAllAPs (\r
-                          MpService,          // This\r
-                          Procedure,          // Procedure\r
-                          FALSE,              // SingleThread\r
-                          NULL,               // WaitEvent\r
-                          0,                  // TimeoutInMicrosecsond\r
-                          NULL,               // ProcedureArgument\r
-                          NULL                // FailedCpuList\r
-                          );\r
-    ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_STARTED || Status == EFI_NOT_READY);\r
-  }\r
-}\r
-\r
 /**\r
   Return current paging context.\r
 \r
@@ -574,20 +510,6 @@ IsReadOnlyPageWriteProtected (
   return ((AsmReadCr0 () & BIT16) != 0);\r
 }\r
 \r
-/**\r
-  Disable write protection function for AP.\r
-\r
-  @param[in,out] Buffer  The pointer to private data buffer.\r
-**/\r
-VOID\r
-EFIAPI\r
-SyncCpuDisableWriteProtection (\r
-  IN OUT VOID *Buffer\r
-  )\r
-{\r
-  AsmWriteCr0 (AsmReadCr0() & ~BIT16);\r
-}\r
-\r
 /**\r
  Disable Write Protect on pages marked as read-only.\r
 **/\r
@@ -835,10 +757,13 @@ AssignMemoryPageAttributes (
   if (!EFI_ERROR(Status)) {\r
     if ((PagingContext == NULL) && IsModified) {\r
       //\r
-      // Flush TLB as last step\r
+      // Flush TLB as last step.\r
+      //\r
+      // Note: Since APs will always init CR3 register in HLT loop mode or do\r
+      // TLB flush in MWAIT loop mode, there's no need to flush TLB for them\r
+      // here.\r
       //\r
       CpuFlushTlb();\r
-      SyncMemoryPageAttributesAp (SyncCpuFlushTlb);\r
     }\r
   }\r
 \r