Re: [PATCH v2 3/4] efi: mm: Pass up errors from `add_memory_regions ()`

2021-08-15 Thread Patrick Steinhardt
On Mon, Aug 09, 2021 at 06:10:01PM +0200, Daniel Kiper wrote: > On Sun, Aug 08, 2021 at 03:31:49PM +0200, Patrick Steinhardt wrote: > > The function `add_memory_regions ()` is currently only called on system > > initialization to allocate a fixed amount of pages. As such, it didn't > > need to retu

[PATCH v3 1/6] mm: Drop unused unloading of modules on OOM

2021-08-15 Thread Patrick Steinhardt
In `grub_memalign ()`, there's a commented section which would allow for unloading of unneeded modules in case where there is not enough free memory available to satisfy a request. Given that this code is never compiled in, let's remove it together with `grub_dl_unload_unneeded()` Signed-off-by: P

[PATCH v3 0/6] Runtime allocation of memory regions

2021-08-15 Thread Patrick Steinhardt
Hi, this is the third version of my patch set to implement runtime allocation of additional memory regions. Changes compared to v2: - A new preparatory patch was added to remove unused code which unloaded modules on OOM. - Patch 2/4 has been split up into two patches: one to drop

[PATCH v3 3/6] efi: mm: Always request a fixed number of pages on init

2021-08-15 Thread Patrick Steinhardt
When initializing the EFI memory subsytem, we will by default request a quarter of the available memory, bounded by a minimum/maximum value. Given that we're about to extend the EFI memory system to dynamically request additional pages from the firmware as required, this scaling of requested memory

[PATCH v3 4/6] efi: mm: Extract function to add memory regions

2021-08-15 Thread Patrick Steinhardt
In preparation of support for runtime-allocating additional memory region, this patch extracts the function to retrieve the EFI memory map and add a subset of it to GRUB's own memory regions. Signed-off-by: Patrick Steinhardt --- grub-core/kern/efi/mm.c | 23 --- 1 file chang

[PATCH v3 2/6] mm: Allow dynamically requesting additional memory regions

2021-08-15 Thread Patrick Steinhardt
Currently, all platforms will set up their heap on initialization of the platform code. While this works mostly fine, it poses some limitations on memory management on us. Most notably, allocating big chunks of memory in the gigabyte range would require us to pre-request this many bytes from the fi

[PATCH v3 5/6] efi: mm: Pass up errors from `add_memory_regions ()`

2021-08-15 Thread Patrick Steinhardt
The function `add_memory_regions ()` is currently only called on system initialization to allocate a fixed amount of pages. As such, it didn't need to return any errors: in case it failed, we cannot proceed anyway. This will change with the upcoming support for requesting more memory from the firmw

[PATCH v3 6/6] efi: mm: Implement runtime addition of pages

2021-08-15 Thread Patrick Steinhardt
Adjust the interface of `grub_efi_mm_add_regions ()` to take a set of `GRUB_MM_ADD_REGION_*` flags, which most notably is currently only the `CONSECUTVE` flag. This allows us to set the function up as callback for the memory subsystem and have it call out to us in case there's not enough pages avai