[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/19] efi: mm: Always request a fixed number of pages on init
From: |
Daniel Axtens |
Subject: |
[PATCH 10/19] efi: mm: Always request a fixed number of pages on init |
Date: |
Tue, 12 Oct 2021 18:29:59 +1100 |
From: Patrick Steinhardt <ps@pks.im>
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 based on available memory will not make a lot of sense
anymore.
Remove this logic as a preparatory patch such that we'll instead defer
to the runtime memory allocator. Note that ideally, we'd want to change
this after dynamic requesting of pages has been implemented for the EFI
platform. But because we'll need to split up initialization of the
memory subsystem and the request of pages from the firmware, we'd have
to duplicate quite some logic at first only to remove it afterwards
again. This seems quite pointless, so we instead have patches slightly
out of order.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
grub-core/kern/efi/mm.c | 35 +++--------------------------------
1 file changed, 3 insertions(+), 32 deletions(-)
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 9838fb2f50db..4d276bc87a4c 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -38,9 +38,8 @@
a multiplier of 4KB. */
#define MEMORY_MAP_SIZE 0x3000
-/* The minimum and maximum heap size for GRUB itself. */
-#define MIN_HEAP_SIZE 0x100000
-#define MAX_HEAP_SIZE (1600 * 0x100000)
+/* The default heap size for GRUB itself in bytes. */
+#define DEFAULT_HEAP_SIZE 0x100000
static void *finish_mmap_buf = 0;
static grub_efi_uintn_t finish_mmap_size = 0;
@@ -478,23 +477,6 @@ filter_memory_map (grub_efi_memory_descriptor_t
*memory_map,
return filtered_desc;
}
-/* Return the total number of pages. */
-static grub_efi_uint64_t
-get_total_pages (grub_efi_memory_descriptor_t *memory_map,
- grub_efi_uintn_t desc_size,
- grub_efi_memory_descriptor_t *memory_map_end)
-{
- grub_efi_memory_descriptor_t *desc;
- grub_efi_uint64_t total = 0;
-
- for (desc = memory_map;
- desc < memory_map_end;
- desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
- total += desc->num_pages;
-
- return total;
-}
-
/* Add memory regions. */
static void
add_memory_regions (grub_efi_memory_descriptor_t *memory_map,
@@ -583,8 +565,6 @@ grub_efi_mm_init (void)
grub_efi_memory_descriptor_t *filtered_memory_map_end;
grub_efi_uintn_t map_size;
grub_efi_uintn_t desc_size;
- grub_efi_uint64_t total_pages;
- grub_efi_uint64_t required_pages;
int mm_status;
/* Prepare a memory region to store two memory maps. */
@@ -624,22 +604,13 @@ grub_efi_mm_init (void)
filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map,
desc_size, memory_map_end);
- /* By default, request a quarter of the available memory. */
- total_pages = get_total_pages (filtered_memory_map, desc_size,
- filtered_memory_map_end);
- required_pages = (total_pages >> 2);
- if (required_pages < BYTES_TO_PAGES (MIN_HEAP_SIZE))
- required_pages = BYTES_TO_PAGES (MIN_HEAP_SIZE);
- else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE))
- required_pages = BYTES_TO_PAGES (MAX_HEAP_SIZE);
-
/* Sort the filtered descriptors, so that GRUB can allocate pages
from smaller regions. */
sort_memory_map (filtered_memory_map, desc_size, filtered_memory_map_end);
/* Allocate memory regions for GRUB's memory management. */
add_memory_regions (filtered_memory_map, desc_size,
- filtered_memory_map_end, required_pages);
+ filtered_memory_map_end, BYTES_TO_PAGES
(DEFAULT_HEAP_SIZE));
#if 0
/* For debug. */
--
2.30.2
- [PATCH 04/19] mm: assert that we preserve header vs region alignment, (continued)
- [PATCH 04/19] mm: assert that we preserve header vs region alignment, Daniel Axtens, 2021/10/12
- [PATCH 02/19] grub-shell: pseries: don't pass fw_opt to qemu, Daniel Axtens, 2021/10/12
- [PATCH 05/19] mm: when adding a region, merge with region after as well as before, Daniel Axtens, 2021/10/12
- [PATCH 06/19] configure: properly pass through MM_DEBUG, Daniel Axtens, 2021/10/12
- [PATCH 07/19] Add memtool module with memory allocation stress-test, Daniel Axtens, 2021/10/12
- [PATCH 08/19] mm: Drop unused unloading of modules on OOM, Daniel Axtens, 2021/10/12
- [PATCH 10/19] efi: mm: Always request a fixed number of pages on init,
Daniel Axtens <=
- [PATCH 12/19] efi: mm: Pass up errors from `add_memory_regions ()`, Daniel Axtens, 2021/10/12
- [PATCH 09/19] mm: Allow dynamically requesting additional memory regions, Daniel Axtens, 2021/10/12
- [PATCH 11/19] efi: mm: Extract function to add memory regions, Daniel Axtens, 2021/10/12
- [PATCH 13/19] efi: mm: Implement runtime addition of pages, Daniel Axtens, 2021/10/12
- [PATCH 15/19] ieee1275: drop len -= 1 quirk in heap_init, Daniel Axtens, 2021/10/12
- [PATCH 14/19] ieee1275: request memory with ibm, client-architecture-support, Daniel Axtens, 2021/10/12
- [PATCH 17/19] [not for merge] print more debug info in mm, Daniel Axtens, 2021/10/12