MdeModulePkg: carve pool pages into the largest chunks possible

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.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17014 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ard Biesheuvel 2015-03-06 02:56:20 +00:00 committed by lgao4
parent 7e8e22056b
commit f8aabf6e4c
1 changed files with 9 additions and 3 deletions

View File

@ -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;
}
//