:p
atchew
Login
Gerd Hoffmann (2): malloc: use variable for ZoneHigh size malloc: use large ZoneHigh when there is enough memory src/config.h | 3 ++- src/malloc.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) -- 2.35.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org
Use the variable highram_size instead of the BUILD_MAX_HIGHTABLE #define for the ZoneHigh size. Initialize the new variable with the old #define, so behavior does not change. This allows to easily adjust the ZoneHigh size at runtime in a followup patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- src/malloc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/malloc.c b/src/malloc.c index XXXXXXX..XXXXXXX 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) e820_add(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED); // Populate temp high ram - u32 highram = 0; + u32 highram_start = 0; + u32 highram_size = BUILD_MAX_HIGHTABLE; int i; for (i=e820_count-1; i>=0; i--) { struct e820entry *en = &e820_list[i]; @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) if (en->type != E820_RAM || end > 0xffffffff) continue; u32 s = en->start, e = end; - if (!highram) { - u32 newe = ALIGN_DOWN(e - BUILD_MAX_HIGHTABLE, MALLOC_MIN_ALIGN); + if (!highram_start) { + u32 newe = ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN); if (newe <= e && newe >= s) { - highram = newe; + highram_start = newe; e = newe; } } @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) // Populate regions alloc_add(&ZoneTmpLow, BUILD_STACK_ADDR, BUILD_EBDA_MINIMUM); - if (highram) { - alloc_add(&ZoneHigh, highram, highram + BUILD_MAX_HIGHTABLE); - e820_add(highram, BUILD_MAX_HIGHTABLE, E820_RESERVED); + if (highram_start) { + dprintf(3, "malloc: using %dk for ZoneHigh\n", highram_size / 1024); + alloc_add(&ZoneHigh, highram_start, highram_start + highram_size); + e820_add(highram_start, highram_size, E820_RESERVED); } } -- 2.35.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org
In case there is enough memory installed use a large ZoneHigh. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- src/config.h | 3 ++- src/malloc.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.h b/src/config.h index XXXXXXX..XXXXXXX 100644 --- a/src/config.h +++ b/src/config.h @@ -XXX,XX +XXX,XX @@ // Maximum number of map entries in the e820 map #define BUILD_MAX_E820 32 // 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 #define BUILD_MAX_EXTDRIVE 16 // Number of bytes the smbios may be and still live in the f-segment diff --git a/src/malloc.c b/src/malloc.c index XXXXXXX..XXXXXXX 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) // Populate temp high ram u32 highram_start = 0; - u32 highram_size = BUILD_MAX_HIGHTABLE; + u32 highram_size = BUILD_MIN_HIGHTABLE; int i; for (i=e820_count-1; i>=0; i--) { struct e820entry *en = &e820_list[i]; @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) continue; u32 s = en->start, e = end; if (!highram_start) { + if (e > BUILD_MAX_HIGHTABLE * 16) + highram_size = BUILD_MAX_HIGHTABLE; u32 newe = ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN); if (newe <= e && newe >= s) { highram_start = newe; -- 2.35.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org
v3: - check size instead of end address. Gerd Hoffmann (2): malloc: use variable for ZoneHigh size malloc: use large ZoneHigh when there is enough memory src/config.h | 3 ++- src/malloc.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) -- 2.35.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org
Use the variable highram_size instead of the BUILD_MAX_HIGHTABLE #define for the ZoneHigh size. Initialize the new variable with the old #define, so behavior does not change. This allows to easily adjust the ZoneHigh size at runtime in a followup patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- src/malloc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/malloc.c b/src/malloc.c index XXXXXXX..XXXXXXX 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) e820_add(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED); // Populate temp high ram - u32 highram = 0; + u32 highram_start = 0; + u32 highram_size = BUILD_MAX_HIGHTABLE; int i; for (i=e820_count-1; i>=0; i--) { struct e820entry *en = &e820_list[i]; @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) if (en->type != E820_RAM || end > 0xffffffff) continue; u32 s = en->start, e = end; - if (!highram) { - u32 newe = ALIGN_DOWN(e - BUILD_MAX_HIGHTABLE, MALLOC_MIN_ALIGN); + if (!highram_start) { + u32 newe = ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN); if (newe <= e && newe >= s) { - highram = newe; + highram_start = newe; e = newe; } } @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) // Populate regions alloc_add(&ZoneTmpLow, BUILD_STACK_ADDR, BUILD_EBDA_MINIMUM); - if (highram) { - alloc_add(&ZoneHigh, highram, highram + BUILD_MAX_HIGHTABLE); - e820_add(highram, BUILD_MAX_HIGHTABLE, E820_RESERVED); + if (highram_start) { + dprintf(3, "malloc: using %dk for ZoneHigh\n", highram_size / 1024); + alloc_add(&ZoneHigh, highram_start, highram_start + highram_size); + e820_add(highram_start, highram_size, E820_RESERVED); } } -- 2.35.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org
In case there is enough memory installed use a large ZoneHigh. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- src/config.h | 3 ++- src/malloc.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.h b/src/config.h index XXXXXXX..XXXXXXX 100644 --- a/src/config.h +++ b/src/config.h @@ -XXX,XX +XXX,XX @@ // Maximum number of map entries in the e820 map #define BUILD_MAX_E820 32 // 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 #define BUILD_MAX_EXTDRIVE 16 // Number of bytes the smbios may be and still live in the f-segment diff --git a/src/malloc.c b/src/malloc.c index XXXXXXX..XXXXXXX 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) // Populate temp high ram u32 highram_start = 0; - u32 highram_size = BUILD_MAX_HIGHTABLE; + u32 highram_size = BUILD_MIN_HIGHTABLE; int i; for (i=e820_count-1; i>=0; i--) { struct e820entry *en = &e820_list[i]; @@ -XXX,XX +XXX,XX @@ malloc_preinit(void) continue; u32 s = en->start, e = end; if (!highram_start) { + if (e - s > BUILD_MAX_HIGHTABLE * 16) + highram_size = BUILD_MAX_HIGHTABLE; u32 newe = ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN); if (newe <= e && newe >= s) { highram_start = newe; -- 2.35.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org