public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Tian, Feng" <feng.tian@intel.com>
To: "Fan, Jeff" <jeff.fan@intel.com>,
	"edk2-devel@ml01.01.org" <edk2-devel@ml01.01.org>
Cc: "Gao, Liming" <liming.gao@intel.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Tian, Feng" <feng.tian@intel.com>
Subject: Re: [PATCH] UefiCpuPkg/MpInitLib: Do not wakeup AP if only one processor supported
Date: Wed, 9 Nov 2016 07:21:08 +0000	[thread overview]
Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE566E3E6BE@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <20161104081806.19624-1-jeff.fan@intel.com>

Reviewed-by: Feng Tian <feng.tian@Intel.com>

Thanks
Feng

-----Original Message-----
From: Fan, Jeff 
Sent: Friday, November 4, 2016 4:18 PM
To: edk2-devel@ml01.01.org
Cc: Tian, Feng <feng.tian@intel.com>; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [PATCH] UefiCpuPkg/MpInitLib: Do not wakeup AP if only one processor supported

If MaxLogicalProcessorNumber is only 1, we needn't to wake up APs at all and needn't to register callback functions.

It could improve boot performance on single supported system.

https://bugzilla.tianocore.org/show_bug.cgi?id=204

Cc: Feng Tian <feng.tian@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c |  7 ++++++
 UefiCpuPkg/Library/MpInitLib/MpLib.c    | 39 +++++++++++++++++++--------------
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c |  8 +++++++
 3 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index b399f1c..eb36d6f 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -290,6 +290,13 @@ InitMpGlobalData (
 
   SaveCpuMpData (CpuMpData);
 
+  if (CpuMpData->CpuCount == 1) {
+    //
+    // If only BSP exists, return
+    //
+    return;
+  }
+
   //
   // Avoid APs access invalid buff data which allocated by BootServices,
   // so we will allocate reserved data for AP loop code.
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 56b870e..a0edc55 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -1143,6 +1143,7 @@ MpInitLibInitialize (
   } else {
     MaxLogicalProcessorNumber = OldCpuMpData->CpuCount;
   }
+  ASSERT (MaxLogicalProcessorNumber != 0);
 
   AsmGetAddressMap (&AddressMap);
   ApResetVectorSize = AddressMap.RendezvousFunnelSize + sizeof (MP_CPU_EXCHANGE_INFO); @@ -1209,10 +1210,12 @@ MpInitLibInitialize (
   MtrrGetAllMtrrs (&CpuMpData->MtrrTable);
 
   if (OldCpuMpData == NULL) {
-    //
-    // Wakeup all APs and calculate the processor count in system
-    //
-    CollectProcessorCount (CpuMpData);
+    if (MaxLogicalProcessorNumber > 1) {
+      //
+      // Wakeup all APs and calculate the processor count in system
+      //
+      CollectProcessorCount (CpuMpData);
+    }
   } else {
     //
     // APs have been wakeup before, just get the CPU Information @@ -1238,19 +1241,21 @@ MpInitLibInitialize (
         sizeof (CPU_VOLATILE_REGISTERS)
         );
     }
-    //
-    // Wakeup APs to do some AP initialize sync
-    //
-    WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData);
-    //
-    // Wait for all APs finished initialization
-    //
-    while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) {
-      CpuPause ();
-    }
-    CpuMpData->InitFlag = ApInitDone;
-    for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
-      SetApState (&CpuMpData->CpuData[Index], CpuStateIdle);
+    if (MaxLogicalProcessorNumber > 1) {
+      //
+      // Wakeup APs to do some AP initialize sync
+      //
+      WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData);
+      //
+      // Wait for all APs finished initialization
+      //
+      while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) {
+        CpuPause ();
+      }
+      CpuMpData->InitFlag = ApInitDone;
+      for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
+        SetApState (&CpuMpData->CpuData[Index], CpuStateIdle);
+      }
     }
   }
 
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index e242d37..1f2fcb8 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -321,6 +321,14 @@ InitMpGlobalData (
   EFI_STATUS      Status;
 
   SaveCpuMpData (CpuMpData);
+
+  if (CpuMpData->CpuCount == 1) {
+    //
+    // If only BSP exists, return
+    //
+    return;
+  }
+
   //
   // Register an event for EndOfPei
   //
--
2.9.3.windows.2



      parent reply	other threads:[~2016-11-09  7:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04  8:18 [PATCH] UefiCpuPkg/MpInitLib: Do not wakeup AP if only one processor supported Jeff Fan
2016-11-04 16:40 ` Laszlo Ersek
2016-11-07  0:47   ` Fan, Jeff
2016-11-07 13:37     ` Laszlo Ersek
2016-11-08  0:55       ` Fan, Jeff
2016-11-08 13:37         ` Laszlo Ersek
2016-11-09  7:21 ` Tian, Feng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7F1BAD85ADEA444D97065A60D2E97EE566E3E6BE@SHSMSX101.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox