Revision: 17013
          http://sourceforge.net/p/edk2/code/17013
Author:   lgao4
Date:     2015-03-06 02:55:35 +0000 (Fri, 06 Mar 2015)
Log Message:
-----------
MdeModulePkg: use index to traverse free pool pages

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 <[email protected]>
Reviewed-by: Liming Gao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Pool.c

Modified: trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Pool.c
===================================================================
--- trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Pool.c 2015-03-06 02:54:50 UTC (rev 
17012)
+++ trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Pool.c 2015-03-06 02:55:35 UTC (rev 
17013)
@@ -495,7 +495,6 @@
   UINTN       NoPages;
   UINTN       Size;
   CHAR8       *NewPage;
-  UINTN       FSize;
   UINTN       Offset;
   BOOLEAN     AllFree;
   UINTN       Granularity;
@@ -589,22 +588,16 @@
 
     if (Free->Signature == POOL_FREE_SIGNATURE) {
 
-      Index = Free->Index;
-
       AllFree = TRUE;
       Offset = 0;
 
       while ((Offset < Granularity) && (AllFree)) {
-        FSize = LIST_TO_SIZE(Index);
-        while (Offset + FSize <= Granularity) {
-          Free = (POOL_FREE *) &NewPage[Offset];
-          ASSERT(Free != NULL);
-          if (Free->Signature != POOL_FREE_SIGNATURE) {
-            AllFree = FALSE;
-          }
-          Offset += FSize;
+        Free = (POOL_FREE *) &NewPage[Offset];
+        ASSERT(Free != NULL);
+        if (Free->Signature != POOL_FREE_SIGNATURE) {
+          AllFree = FALSE;
         }
-        Index -= 1;
+        Offset += LIST_TO_SIZE(Free->Index);
       }
 
       if (AllFree) {
@@ -616,18 +609,13 @@
         //
         Free = (POOL_FREE *) &NewPage[0];
         ASSERT(Free != NULL);
-        Index = Free->Index;
         Offset = 0;
 
         while (Offset < Granularity) {
-          FSize = LIST_TO_SIZE(Index);
-          while (Offset + FSize <= Granularity) {
-            Free = (POOL_FREE *) &NewPage[Offset];
-            ASSERT(Free != NULL);
-            RemoveEntryList (&Free->Link);
-            Offset += FSize;
-          }
-          Index -= 1;
+          Free = (POOL_FREE *) &NewPage[Offset];
+          ASSERT(Free != NULL);
+          RemoveEntryList (&Free->Link);
+          Offset += LIST_TO_SIZE(Free->Index);
         }
 
         //


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to