In preparation of the next patch, that serves allocations from higher-up bins if the current bin is depleted, this patch updates the carving up strategy to populate the largest bins first. To ensure that there will always be an allocation of the appropriate size made, the current allocation request is served first from the newly allocated memory region.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org> --- MdeModulePkg/Core/Dxe/Mem/Pool.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c index 0c5cf3d28451..23409d35c428 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c @@ -352,9 +352,15 @@ CoreAllocatePoolI ( } // - // Carve up new page into free pool blocks + // Serve the allocation request from the head of the allocated block // - Offset = 0; + Head = (POOL_HEAD *) NewPage; + Offset = LIST_TO_SIZE (Index); + + // + // Carve up remaining space into free pool blocks + // + Index = SIZE_TO_LIST (Granularity) - 1; while (Offset < Granularity) { ASSERT (Index < MAX_POOL_LIST); FSize = LIST_TO_SIZE(Index); @@ -371,7 +377,7 @@ CoreAllocatePoolI ( } ASSERT (Offset == Granularity); - Index = SIZE_TO_LIST(Size); + goto Done; } // -- 1.8.3.2 ------------------------------------------------------------------------------ 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-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel