]> git.ipfire.org Git - thirdparty/grub.git/commit
mm: When adding a region, merge with region after as well as before
authorDaniel Axtens <dja@axtens.net>
Thu, 21 Apr 2022 05:24:15 +0000 (15:24 +1000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 4 Jul 2022 12:13:56 +0000 (14:13 +0200)
commit052e6068be622ff53f1238b449c300dbd0a8abcd
tree82a4b8d74cae5bd0fe7487a0fc6ef2014f17a752
parent1df8fe66c57087eb33bd6dc69f786ed124615aa7
mm: When adding a region, merge with region after as well as before

On x86_64-efi (at least) regions seem to be added from top down. The mm
code will merge a new region with an existing region that comes
immediately before the new region. This allows larger allocations to be
satisfied that would otherwise be the case.

On powerpc-ieee1275, however, regions are added from bottom up. So if
we add 3x 32MB regions, we can still only satisfy a 32MB allocation,
rather than the 96MB allocation we might otherwise be able to satisfy.

  * Define 'post_size' as being bytes lost to the end of an allocation
    due to being given weird sizes from firmware that are not multiples
    of GRUB_MM_ALIGN.

  * Allow merging of regions immediately _after_ existing regions, not
    just before. As with the other approach, we create an allocated
    block to represent the new space and the pass it to grub_free() to
    get the metadata right.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Tested-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Patrick Steinhardt <ps@pks.im>
grub-core/kern/mm.c
include/grub/mm_private.h