malloc: use large ZoneHigh when there is enough memory

In case there is enough memory installed use a large ZoneHigh.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2022-04-25 09:25:31 +02:00
parent 3b91e8e9fe
commit dc88f9b72d
2 changed files with 11 additions and 6 deletions

View File

@ -17,7 +17,8 @@
// Maximum number of map entries in the e820 map // Maximum number of map entries in the e820 map
#define BUILD_MAX_E820 32 #define BUILD_MAX_E820 32
// Space to reserve in high-memory for tables // Space to reserve in high-memory for tables
#define BUILD_MAX_HIGHTABLE (256*1024) #define BUILD_MIN_HIGHTABLE (256*1024)
#define BUILD_MAX_HIGHTABLE (16*1024*1024)
// Largest supported externaly facing drive id // Largest supported externaly facing drive id
#define BUILD_MAX_EXTDRIVE 16 #define BUILD_MAX_EXTDRIVE 16
// Number of bytes the smbios may be and still live in the f-segment // Number of bytes the smbios may be and still live in the f-segment

View File

@ -423,7 +423,7 @@ malloc_preinit(void)
// Populate temp high ram // Populate temp high ram
u32 highram_start = 0; u32 highram_start = 0;
u32 highram_size = BUILD_MAX_HIGHTABLE; u32 highram_size = 0;
int i; int i;
for (i=e820_count-1; i>=0; i--) { for (i=e820_count-1; i>=0; i--) {
struct e820entry *en = &e820_list[i]; struct e820entry *en = &e820_list[i];
@ -434,10 +434,14 @@ malloc_preinit(void)
continue; continue;
u32 s = en->start, e = end; u32 s = en->start, e = end;
if (!highram_start) { if (!highram_start) {
u32 newe = ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN); u32 new_max = ALIGN_DOWN(e - BUILD_MAX_HIGHTABLE, MALLOC_MIN_ALIGN);
if (newe <= e && newe >= s) { u32 new_min = ALIGN_DOWN(e - BUILD_MIN_HIGHTABLE, MALLOC_MIN_ALIGN);
highram_start = newe; if (new_max <= e && new_max >= s + BUILD_MAX_HIGHTABLE) {
e = newe; highram_start = e = new_max;
highram_size = BUILD_MAX_HIGHTABLE;
} else if (new_min <= e && new_min >= s) {
highram_start = e = new_min;
highram_size = BUILD_MIN_HIGHTABLE;
} }
} }
alloc_add(&ZoneTmpHigh, s, e); alloc_add(&ZoneTmpHigh, s, e);