]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg DxeCore: Add lock to pretect memory profile AllocInfo list
authorStar Zeng <star.zeng@intel.com>
Wed, 29 Jun 2016 04:51:55 +0000 (12:51 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 1 Jul 2016 01:39:55 +0000 (09:39 +0800)
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c

index 1ba8488a0e041761c67e3fa5e25cc74684106c01..14c4959f9fe220857cf7640be6e0ab0fc18ef275 100644 (file)
@@ -63,6 +63,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA mMemoryProfileContext
 };\r
 GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA *mMemoryProfileContextPtr = NULL;\r
 \r
+EFI_LOCK mMemoryProfileLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);\r
 BOOLEAN mMemoryProfileGettingStatus = FALSE;\r
 BOOLEAN mMemoryProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE;\r
 EFI_DEVICE_PATH_PROTOCOL *mMemoryProfileDriverPath;\r
@@ -217,6 +218,28 @@ EDKII_MEMORY_PROFILE_PROTOCOL mProfileProtocol = {
   ProfileProtocolRecord,\r
 };\r
 \r
+/**\r
+  Acquire lock on mMemoryProfileLock.\r
+**/\r
+VOID\r
+CoreAcquireMemoryProfileLock (\r
+  VOID\r
+  )\r
+{\r
+  CoreAcquireLock (&mMemoryProfileLock);\r
+}\r
+\r
+/**\r
+  Release lock on mMemoryProfileLock.\r
+**/\r
+VOID\r
+CoreReleaseMemoryProfileLock (\r
+  VOID\r
+  )\r
+{\r
+  CoreReleaseLock (&mMemoryProfileLock);\r
+}\r
+\r
 /**\r
   Return memory profile context.\r
 \r
@@ -1383,6 +1406,7 @@ CoreUpdateProfile (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
+  CoreAcquireMemoryProfileLock ();\r
   switch (BasicAction) {\r
     case MemoryProfileActionAllocatePages:\r
       Status = CoreUpdateProfileAllocate (CallerAddress, Action, MemoryType, Size, Buffer, ActionString);\r
@@ -1401,6 +1425,8 @@ CoreUpdateProfile (
       Status = EFI_UNSUPPORTED;\r
       break;\r
   }\r
+  CoreReleaseMemoryProfileLock ();\r
+\r
   return Status;\r
 }\r
 \r