bootloader: Increase the "large allocation" threshhold to 128 KB.

Not all platforms can properly release memory allocated via
platform_allocate_region() at present; in particular the BIOS
loader seems to (at least partially) leak it. And due to how the
kernel args ranges are handed off to the kernel, it seems
allocated physical pages that aren't virtually mapped are
leaked at present as well.

That seems like a bug that we should likely fix, and moreover
the heap shouldn't use that facility at all (but instead
request bootloader-local memory if possible; on the BIOS
loader that will ultimately go through similar logic, but
on e.g. EFI it will be entirely separate.)

But in the meantime, we can just increase the size of the
"large allocation" threshhold so that packagefs temporary buffers
(of 64 and 93 KB) stay on the main heap, and don't hit that
facility at all. The "maximum boot loader heap usage" seems
to go up by about ~200 KB with this change (e.g. 588 KB -> 797 KB),
so increase the default heap size by 256 KB to compensate.

This fixes most of the rest of #14831: memory usage after the
boot has finished is down by over 100 MB (!). The remaining
problems and leaks can be dealt with in later changes.
This commit is contained in:
Augustin Cavalier 2024-10-09 22:19:45 -04:00
parent 10bba152b3
commit 38946ff82f

View File

@ -53,9 +53,9 @@
const static size_t kAlignment = 8;
// all memory chunks will be a multiple of this
const static size_t kDefaultHeapSize = (1024 + 256) * 1024;
const static size_t kDefaultHeapSize = (1024 + 512) * 1024;
// default initial heap size, unless overridden by platform loader
const static size_t kLargeAllocationThreshold = 16 * 1024;
const static size_t kLargeAllocationThreshold = 128 * 1024;
// allocations of this size or larger are allocated via
// platform_allocate_region()