• Matt Redfearn's avatar
    MIPS: bootmem: When relocatable, free memory below kernel · 61cd52d4
    Matt Redfearn authored
    The kernel reserves all memory before the _end symbol as bootmem,
    however, once the kernel can be relocated elsewhere in memory this may
    result in a large amount of wasted memory. The assumption is that the
    memory between the link and relocated address of the kernel may be
    released back to the available memory pool.
    
    Memory statistics for a Malta with the kernel relocating by
    16Mb, without the patch:
    Memory: 105952K/131072K available (4604K kernel code, 242K rwdata,
    892K rodata, 1280K init, 183K bss, 25120K reserved, 0K cma-reserved)
    And with the patch:
    Memory: 122336K/131072K available (4604K kernel code, 242K rwdata,
    892K rodata, 1280K init, 183K bss, 8736K reserved, 0K cma-reserved)
    
    The 16Mb offset is removed from the reserved region and added back to
    the available region.
    Signed-off-by: default avatarMatt Redfearn <matt.redfearn@imgtec.com>
    Cc: Aaro Koskinen <aaro.koskinen@nokia.com>
    Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
    Cc: Alexander Sverdlin <alexander.sverdlin@gmail.com>
    Cc: Jaedon Shin <jaedon.shin@gmail.com>
    Cc: James Hogan <james.hogan@imgtec.com>
    Cc: Jonas Gorski <jogo@openwrt.org>
    Cc: Paul Burton <paul.burton@imgtec.com>
    Cc: linux-mips@linux-mips.org
    Cc: kernel-hardening@lists.openwall.com
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/12986/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
    61cd52d4
setup.c 20.2 KB