You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.6 KiB
73 lines
2.6 KiB
From 93ba763d219be90b088b15a5fc585ff7f051e424 Mon Sep 17 00:00:00 2001
|
|
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Date: Mon, 25 Apr 2022 09:25:31 +0200
|
|
Subject: [PATCH 2/2] malloc: use large ZoneHigh when there is enough memory
|
|
|
|
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
RH-MergeRequest: 9: malloc: use large ZoneHigh when there is enough memory
|
|
RH-Bugzilla: 2227373
|
|
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
RH-Acked-by: Oliver Steffen <osteffen@redhat.com>
|
|
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
RH-Commit: [2/2] aa6072543a124ad152199d5263c590cb95609d81
|
|
|
|
In case there is enough memory installed use a large ZoneHigh.
|
|
|
|
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
(cherry picked from commit dc88f9b72df52b22c35b127b80c487e0b6fca4af)
|
|
---
|
|
src/config.h | 3 ++-
|
|
src/malloc.c | 14 +++++++++-----
|
|
2 files changed, 11 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/src/config.h b/src/config.h
|
|
index 93c8dbc2..9abe355b 100644
|
|
--- a/src/config.h
|
|
+++ b/src/config.h
|
|
@@ -17,7 +17,8 @@
|
|
// 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 ecd8c9ac..da840980 100644
|
|
--- a/src/malloc.c
|
|
+++ b/src/malloc.c
|
|
@@ -423,7 +423,7 @@ malloc_preinit(void)
|
|
|
|
// Populate temp high ram
|
|
u32 highram_start = 0;
|
|
- u32 highram_size = BUILD_MAX_HIGHTABLE;
|
|
+ u32 highram_size = 0;
|
|
int i;
|
|
for (i=e820_count-1; i>=0; i--) {
|
|
struct e820entry *en = &e820_list[i];
|
|
@@ -434,10 +434,14 @@ malloc_preinit(void)
|
|
continue;
|
|
u32 s = en->start, e = end;
|
|
if (!highram_start) {
|
|
- u32 newe = ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN);
|
|
- if (newe <= e && newe >= s) {
|
|
- highram_start = newe;
|
|
- e = newe;
|
|
+ u32 new_max = ALIGN_DOWN(e - BUILD_MAX_HIGHTABLE, MALLOC_MIN_ALIGN);
|
|
+ u32 new_min = ALIGN_DOWN(e - BUILD_MIN_HIGHTABLE, MALLOC_MIN_ALIGN);
|
|
+ if (new_max <= e && new_max >= s + BUILD_MAX_HIGHTABLE) {
|
|
+ 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);
|
|
--
|
|
2.37.3
|
|
|