public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] Remove useless code.
@ 2020-04-10  6:53 Dong, Eric
  2020-04-10  6:54 ` [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove Used parameter Dong, Eric
  2020-04-10  6:54 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove useless code in ResetTokens Dong, Eric
  0 siblings, 2 replies; 5+ messages in thread
From: Dong, Eric @ 2020-04-10  6:53 UTC (permalink / raw)
  To: devel

This patch serial used to remove some useless code. Detail see
each patches.

Eric Dong (2):
  UefiCpuPkg/PiSmmCpuDxeSmm: Remove Used parameter.
  UefiCpuPkg/PiSmmCpuDxeSmm: Remove useless code in ResetTokens.

 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c      | 30 ++++------------------
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h |  1 -
 2 files changed, 5 insertions(+), 26 deletions(-)

-- 
2.23.0.windows.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove Used parameter.
  2020-04-10  6:53 [PATCH 0/2] Remove useless code Dong, Eric
@ 2020-04-10  6:54 ` Dong, Eric
  2020-04-10  7:07   ` [edk2-devel] " Ni, Ray
  2020-04-10  6:54 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove useless code in ResetTokens Dong, Eric
  1 sibling, 1 reply; 5+ messages in thread
From: Dong, Eric @ 2020-04-10  6:54 UTC (permalink / raw)
  To: devel; +Cc: Ray Ni, Star Zeng, Laszlo Ersek

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

After patch "UefiCpuPkg/PiSmmCpuDxeSmm: Improve the
performance of GetFreeToken()" which adds new parameter
FirstFreeToken, it's not need to use Uses parameter.
This patch used to remove this parameter.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c      | 10 +++++-----
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h |  1 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 93cac5e4fa..305bffa9bc 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -441,7 +441,6 @@ ResetTokens (
     ProcToken = PROCEDURE_TOKEN_FROM_LINK (Link);
 
     ProcToken->RunningApCount = 0;
-    ProcToken->Used = FALSE;
 
     //
     // Check the spinlock status and release it if not released yet.
@@ -1049,10 +1048,13 @@ IsTokenInUse (
   }
 
   Link = GetFirstNode (&gSmmCpuPrivate->TokenList);
-  while (!IsNull (&gSmmCpuPrivate->TokenList, Link)) {
+  //
+  // Only search used tokens.
+  //
+  while (Link != gSmmCpuPrivate->FirstFreeToken) {
     ProcToken = PROCEDURE_TOKEN_FROM_LINK (Link);
 
-    if (ProcToken->Used && ProcToken->SpinLock == Token) {
+    if (ProcToken->SpinLock == Token) {
       return TRUE;
     }
 
@@ -1104,7 +1106,6 @@ AllocateTokenBuffer (
 
     ProcTokens[Index].Signature      = PROCEDURE_TOKEN_SIGNATURE;
     ProcTokens[Index].SpinLock       = SpinLock;
-    ProcTokens[Index].Used           = FALSE;
     ProcTokens[Index].RunningApCount = 0;
 
     InsertTailList (&gSmmCpuPrivate->TokenList, &ProcTokens[Index].Link);
@@ -1140,7 +1141,6 @@ GetFreeToken (
   NewToken = PROCEDURE_TOKEN_FROM_LINK (gSmmCpuPrivate->FirstFreeToken);
   gSmmCpuPrivate->FirstFreeToken = GetNextNode (&gSmmCpuPrivate->TokenList, gSmmCpuPrivate->FirstFreeToken);
 
-  NewToken->Used = TRUE;
   NewToken->RunningApCount = RunningApsCount;
   AcquireSpinLock (NewToken->SpinLock);
 
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index c9b3b739f3..7fb3a2d9e4 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -214,7 +214,6 @@ typedef struct {
 
   SPIN_LOCK               *SpinLock;
   volatile UINT32         RunningApCount;
-  BOOLEAN                 Used;
 } PROCEDURE_TOKEN;
 
 #define PROCEDURE_TOKEN_FROM_LINK(a)  CR (a, PROCEDURE_TOKEN, Link, PROCEDURE_TOKEN_SIGNATURE)
-- 
2.23.0.windows.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove useless code in ResetTokens.
  2020-04-10  6:53 [PATCH 0/2] Remove useless code Dong, Eric
  2020-04-10  6:54 ` [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove Used parameter Dong, Eric
@ 2020-04-10  6:54 ` Dong, Eric
  2020-04-10  7:08   ` [edk2-devel] " Ni, Ray
  1 sibling, 1 reply; 5+ messages in thread
From: Dong, Eric @ 2020-04-10  6:54 UTC (permalink / raw)
  To: devel; +Cc: Ray Ni, Star Zeng, Laszlo Ersek

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

After remove Used parameter, below code in ResetTokens can also be
removed:
1. The RunningApCount parameter will be reset in GetFreeToken.
2. The ReleaseSpinLock should be called in ReleaseToken function,
   Code in this function seems like a later fix if ReleaseToken not
   Release it. We should remove code here and fix the real issue if
   existed.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 305bffa9bc..57e788c01b 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -433,26 +433,6 @@ ResetTokens (
   VOID
   )
 {
-  LIST_ENTRY            *Link;
-  PROCEDURE_TOKEN       *ProcToken;
-
-  Link = GetFirstNode (&gSmmCpuPrivate->TokenList);
-  while (!IsNull (&gSmmCpuPrivate->TokenList, Link)) {
-    ProcToken = PROCEDURE_TOKEN_FROM_LINK (Link);
-
-    ProcToken->RunningApCount = 0;
-
-    //
-    // Check the spinlock status and release it if not released yet.
-    //
-    if (!AcquireSpinLockOrFail(ProcToken->SpinLock)) {
-      DEBUG((DEBUG_ERROR, "Risk::SpinLock still not released!"));
-    }
-    ReleaseSpinLock (ProcToken->SpinLock);
-
-    Link = GetNextNode (&gSmmCpuPrivate->TokenList, Link);
-  }
-
   //
   // Reset the FirstFreeToken to the beginning of token list upon exiting SMI.
   //
-- 
2.23.0.windows.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove Used parameter.
  2020-04-10  6:54 ` [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove Used parameter Dong, Eric
@ 2020-04-10  7:07   ` Ni, Ray
  0 siblings, 0 replies; 5+ messages in thread
From: Ni, Ray @ 2020-04-10  7:07 UTC (permalink / raw)
  To: devel@edk2.groups.io, Dong, Eric; +Cc: Zeng, Star, Laszlo Ersek



> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Dong, Eric
> Sent: Friday, April 10, 2020 2:54 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Zeng, Star <star.zeng@intel.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [edk2-devel] [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove Used parameter.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2388
> 
> 
> After patch "UefiCpuPkg/PiSmmCpuDxeSmm: Improve the
> performance of GetFreeToken()" which adds new parameter
> FirstFreeToken, it's not need to use Uses parameter.

Used field in PROCEDURE_TOKEN structure is not needed

> This patch used to remove this parameter.

This patch removes this field.

With above commit message change, Reviewed-by: Ray Ni <ray.ni@intel.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove useless code in ResetTokens.
  2020-04-10  6:54 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove useless code in ResetTokens Dong, Eric
@ 2020-04-10  7:08   ` Ni, Ray
  0 siblings, 0 replies; 5+ messages in thread
From: Ni, Ray @ 2020-04-10  7:08 UTC (permalink / raw)
  To: devel@edk2.groups.io, Dong, Eric; +Cc: Zeng, Star, Laszlo Ersek

Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Dong, Eric
> Sent: Friday, April 10, 2020 2:54 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Zeng, Star <star.zeng@intel.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [edk2-devel] [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove useless code in ResetTokens.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2388
> 
> 
> After remove Used parameter, below code in ResetTokens can also be
> removed:
> 1. The RunningApCount parameter will be reset in GetFreeToken.
> 2. The ReleaseSpinLock should be called in ReleaseToken function,
>    Code in this function seems like a later fix if ReleaseToken not
>    Release it. We should remove code here and fix the real issue if
>    existed.
> 
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 20 --------------------
>  1 file changed, 20 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index 305bffa9bc..57e788c01b 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -433,26 +433,6 @@ ResetTokens (
>    VOID
> 
>    )
> 
>  {
> 
> -  LIST_ENTRY            *Link;
> 
> -  PROCEDURE_TOKEN       *ProcToken;
> 
> -
> 
> -  Link = GetFirstNode (&gSmmCpuPrivate->TokenList);
> 
> -  while (!IsNull (&gSmmCpuPrivate->TokenList, Link)) {
> 
> -    ProcToken = PROCEDURE_TOKEN_FROM_LINK (Link);
> 
> -
> 
> -    ProcToken->RunningApCount = 0;
> 
> -
> 
> -    //
> 
> -    // Check the spinlock status and release it if not released yet.
> 
> -    //
> 
> -    if (!AcquireSpinLockOrFail(ProcToken->SpinLock)) {
> 
> -      DEBUG((DEBUG_ERROR, "Risk::SpinLock still not released!"));
> 
> -    }
> 
> -    ReleaseSpinLock (ProcToken->SpinLock);
> 
> -
> 
> -    Link = GetNextNode (&gSmmCpuPrivate->TokenList, Link);
> 
> -  }
> 
> -
> 
>    //
> 
>    // Reset the FirstFreeToken to the beginning of token list upon exiting SMI.
> 
>    //
> 
> --
> 2.23.0.windows.1
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> 
> View/Reply Online (#57184): https://edk2.groups.io/g/devel/message/57184
> Mute This Topic: https://groups.io/mt/72915832/1712937
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub  [ray.ni@intel.com]
> -=-=-=-=-=-=


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-10  7:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-10  6:53 [PATCH 0/2] Remove useless code Dong, Eric
2020-04-10  6:54 ` [PATCH 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove Used parameter Dong, Eric
2020-04-10  7:07   ` [edk2-devel] " Ni, Ray
2020-04-10  6:54 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove useless code in ResetTokens Dong, Eric
2020-04-10  7:08   ` [edk2-devel] " Ni, Ray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox