]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Remove event from protocol database only if registered
authorSamer El-Haj-Mahmoud <samer.el-haj-mahmoud@hpe.com>
Mon, 21 Sep 2015 01:53:34 +0000 (01:53 +0000)
committererictian <erictian@Edk2>
Mon, 21 Sep 2015 01:53:34 +0000 (01:53 +0000)
In a CloseEvent, an UnregisterProtocolNotify is done unconditionally.
There is a penalty associated with searching the protocol database on
every CloseEvent and impacts performance, especially during Network IO.
Unregister needs to be done only if the Event is for a RegisterProtocolNotify.

So extend the ExFlag in IEVENT to a UINT8 and define new flags that can
be set to indicate if the Event is part of a group, or registered on a
protocol notify. Then in CloseEvent, call UnregisterProtocolNotify only
if the register protocol notify flag is set.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@hpe.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18517 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Event/Event.c
MdeModulePkg/Core/Dxe/Event/Event.h
MdeModulePkg/Core/Dxe/Hand/Notify.c

index a8c4c34d83c9f0a98a6ab655b75db48eea9346cd..34b34ac62f7c4c2564adaa301a48b1a16d41cdd6 100644 (file)
@@ -2,6 +2,7 @@
   UEFI Event support functions implemented in this file.\r
 \r
 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -477,7 +478,7 @@ CoreCreateEventInternal (
   IEvent->NotifyContext  = (VOID *)NotifyContext;\r
   if (EventGroup != NULL) {\r
     CopyGuid (&IEvent->EventGroup, EventGroup);\r
-    IEvent->ExFlag = TRUE;\r
+    IEvent->ExFlag |= EVT_EXFLAG_EVENT_GROUP;\r
   }\r
 \r
   *Event = IEvent;\r
@@ -554,7 +555,7 @@ CoreSignalEvent (
     // If signalling type is a notify function, queue it\r
     //\r
     if ((Event->Type & EVT_NOTIFY_SIGNAL) != 0) {\r
-      if (Event->ExFlag) {\r
+      if ((Event->ExFlag & EVT_EXFLAG_EVENT_GROUP) != 0) {\r
         //\r
         // The CreateEventEx() style requires all members of the Event Group\r
         //  to be signaled.\r
@@ -764,7 +765,9 @@ CoreCloseEvent (
   //\r
   // If the event is registered on a protocol notify, then remove it from the protocol database\r
   //\r
-  CoreUnregisterProtocolNotify (Event);\r
+  if ((Event->ExFlag & EVT_EXFLAG_EVENT_PROTOCOL_NOTIFICATION) != 0) {\r
+    CoreUnregisterProtocolNotify (Event);\r
+  }\r
 \r
   Status = CoreFreePool (Event);\r
   ASSERT_EFI_ERROR (Status);\r
index c110f4d072a622b56b6076a51fd96b08d227a840..4c02900b93130e3308d6c8e518d5916733fcfd7e 100644 (file)
@@ -2,6 +2,7 @@
   UEFI Event support functions and structure.\r
 \r
 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -19,6 +20,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define VALID_TPL(a)            ((a) <= TPL_HIGH_LEVEL)\r
 extern  UINTN                   gEventPending;\r
 \r
+///\r
+/// Set if Event is part of an event group\r
+///\r
+#define EVT_EXFLAG_EVENT_GROUP                    0x01\r
+///\r
+/// Set if Event is registered on a protocol notify\r
+///\r
+#define EVT_EXFLAG_EVENT_PROTOCOL_NOTIFICATION    0x02\r
 \r
 //\r
 // EFI_EVENT\r
@@ -50,7 +59,7 @@ typedef struct {
   VOID                    *NotifyContext;\r
   EFI_GUID                EventGroup;\r
   LIST_ENTRY              NotifyLink;\r
-  BOOLEAN                 ExFlag;\r
+  UINT8                   ExFlag;\r
   ///\r
   /// A list of all runtime events\r
   ///\r
index 53780f8e6b1d265d2741142daac7660663c017c1..f0837c403fdd9e9814a8dd2dfedbc212527c3275 100644 (file)
@@ -2,6 +2,7 @@
   Support functions for UEFI protocol notification infrastructure.\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -14,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "DxeMain.h"\r
 #include "Handle.h"\r
-\r
+#include "Event.h"\r
 \r
 /**\r
   Signal event for every protocol in protocol entry.\r
@@ -135,7 +136,7 @@ CoreRegisterProtocolNotify (
     //\r
     ProtNotify = AllocatePool (sizeof(PROTOCOL_NOTIFY));\r
     if (ProtNotify != NULL) {\r
-\r
+      ((IEVENT *)Event)->ExFlag |= EVT_EXFLAG_EVENT_PROTOCOL_NOTIFICATION;\r
       ProtNotify->Signature = PROTOCOL_NOTIFY_SIGNATURE;\r
       ProtNotify->Protocol = ProtEntry;\r
       ProtNotify->Event = Event;\r