]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: use index to traverse free pool pages
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 6 Mar 2015 02:55:35 +0000 (02:55 +0000)
committerlgao4 <lgao4@Edk2>
Fri, 6 Mar 2015 02:55:35 +0000 (02:55 +0000)
In preparation of making the pool code capable of serving allocations
from higher-up bins, update the free path to traverse a candidate page
by following the index of POOL_FREE header instead of duplicating the
carving logic that was used at page allocation time. This allows chunks
to be split into smaller ones, where one can be returned to serve the
allocation, and the other stored in a smaller bin for later use.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17013 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Mem/Pool.c

index c7998e80cce695412064cd8971dadd96bb16e45c..0c5cf3d2845130ebe4e2346ed7cabd2b9b9430f3 100644 (file)
@@ -495,7 +495,6 @@ CoreFreePoolI (
   UINTN       NoPages;\r
   UINTN       Size;\r
   CHAR8       *NewPage;\r
-  UINTN       FSize;\r
   UINTN       Offset;\r
   BOOLEAN     AllFree;\r
   UINTN       Granularity;\r
@@ -589,22 +588,16 @@ CoreFreePoolI (
 \r
     if (Free->Signature == POOL_FREE_SIGNATURE) {\r
 \r
-      Index = Free->Index;\r
-\r
       AllFree = TRUE;\r
       Offset = 0;\r
 \r
       while ((Offset < Granularity) && (AllFree)) {\r
-        FSize = LIST_TO_SIZE(Index);\r
-        while (Offset + FSize <= Granularity) {\r
-          Free = (POOL_FREE *) &NewPage[Offset];\r
-          ASSERT(Free != NULL);\r
-          if (Free->Signature != POOL_FREE_SIGNATURE) {\r
-            AllFree = FALSE;\r
-          }\r
-          Offset += FSize;\r
+        Free = (POOL_FREE *) &NewPage[Offset];\r
+        ASSERT(Free != NULL);\r
+        if (Free->Signature != POOL_FREE_SIGNATURE) {\r
+          AllFree = FALSE;\r
         }\r
-        Index -= 1;\r
+        Offset += LIST_TO_SIZE(Free->Index);\r
       }\r
 \r
       if (AllFree) {\r
@@ -616,18 +609,13 @@ CoreFreePoolI (
         //\r
         Free = (POOL_FREE *) &NewPage[0];\r
         ASSERT(Free != NULL);\r
-        Index = Free->Index;\r
         Offset = 0;\r
 \r
         while (Offset < Granularity) {\r
-          FSize = LIST_TO_SIZE(Index);\r
-          while (Offset + FSize <= Granularity) {\r
-            Free = (POOL_FREE *) &NewPage[Offset];\r
-            ASSERT(Free != NULL);\r
-            RemoveEntryList (&Free->Link);\r
-            Offset += FSize;\r
-          }\r
-          Index -= 1;\r
+          Free = (POOL_FREE *) &NewPage[Offset];\r
+          ASSERT(Free != NULL);\r
+          RemoveEntryList (&Free->Link);\r
+          Offset += LIST_TO_SIZE(Free->Index);\r
         }\r
 \r
         //\r