Skip to content

Commit f0ac28a

Browse files
committed
Update memory model for PV-in-PVH
Signed-off-by: Rob Hoes <[email protected]>
1 parent 139c282 commit f0ac28a

File tree

1 file changed

+61
-34
lines changed

1 file changed

+61
-34
lines changed

memory/memory.ml

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -82,47 +82,60 @@ let mib_of_bytes_used value = divide_rounding_up value bytes_per_mib
8282
let mib_of_kib_used value = divide_rounding_up value kib_per_mib
8383
let mib_of_pages_used value = divide_rounding_up value pages_per_mib
8484

85-
(* === Domain memory breakdown ============================================== *)
86-
87-
(* ╤ ╔══════════╗ ╤ *)
88-
(* │ ║ shadow ║ │ *)
89-
(* │ ╠══════════╣ │ *)
90-
(* overhead │ ║ extra ║ │ *)
91-
(* │ ║ external ║ │ *)
92-
(* │ ╠══════════╣ ╤ │ *)
93-
(* │ ║ extra ║ │ │ *)
94-
(* │ ║ internal ║ │ │ *)
95-
(* ╠══════════╣ ╤ │ │ footprint *)
96-
(* │ ║ video │ │ │ *)
97-
(* ╠══════════╣ ╤ │ actual │ xen │ *)
98-
(* │ ║ ║ │ │ / │ maximum │ *)
99-
(* │ target │ │ *)
100-
(* │ ║ guest ║ │ │ build │ / │ │ *)
101-
(* │ ║ │ start │ total │ │ *)
102-
(* static │ ║ ║ │ │ │ │ │ *)
103-
(* maximum │ ╟──────────╢ │ ╧ ╧ ╧ ╧ *)
104-
(* │ ║ ║ │ *)
105-
(* │ ║ ║ │ *)
106-
(* │ ║ balloon ║ │ build *)
107-
(* │ ║ ║ │ maximum *)
108-
(* │ ║ ║ │ *)
109-
(* ╧ ╚══════════╝ ╧ *)
110-
111-
(* === Domain memory breakdown: HVM guests ================================== *)
85+
(* === Domain memory breakdown ======================================================= *)
86+
87+
(* ╤ ╔══════════╗ *)
88+
(* │ ║ shadow ║ *)
89+
(* │ ╠══════════╣ *)
90+
(* overhead │ ║ extra ║ *)
91+
(* │ ║ external ║ *)
92+
(* │ ╠══════════╣ ╤ │ *)
93+
(* │ ║ extra ║ │ │ *)
94+
(* │ ║ internal ║ │ │ *)
95+
(* ╠══════════╣ ╤ ╤ ╤ │ │ footprint *)
96+
(* │ ║ shim ║ │ │ │ │ │ *)
97+
(* ╠══════════╣ ╤ │ │ xen │ *)
98+
(* │ ║ video │ actual │ maximum │ *)
99+
(*╠══════════╣ ╤ │ / │ │ *)
100+
(* │ ║ ║ │ │ build │ target │ total │ │ *)
101+
(* │ ║ guest ║ │ │ start │ │ *)
102+
(* static │ ║ ║ │ │ │ │ │ *)
103+
(* maximum │ ╟──────────╢ │ ╧ ╧ ╧ ╧ *)
104+
(* │ ║ ║ │ *)
105+
(* │ ║ ║ │ *)
106+
(* │ ║ balloon ║ │ build *)
107+
(* │ ║ ║ │ maximum *)
108+
(* │ ║ ║ │ *)
109+
(* ╧ ╚══════════╝ ╧ *)
110+
111+
(* === Domain memory breakdown: HVM guests =========================================== *)
112112

113113
module type MEMORY_MODEL_DATA = sig
114114
val extra_internal_mib : int64
115115
val extra_external_mib : int64
116+
val shim_mib : int64 -> int64
117+
val can_start_ballooned_down : bool
116118
end
117119

118120
module HVM_memory_model_data : MEMORY_MODEL_DATA = struct
119121
let extra_internal_mib = 1L
120122
let extra_external_mib = 1L
123+
let shim_mib _ = 0L
124+
let can_start_ballooned_down = true
121125
end
122126

123127
module Linux_memory_model_data : MEMORY_MODEL_DATA = struct
124128
let extra_internal_mib = 0L
125129
let extra_external_mib = 1L
130+
let shim_mib _ = 0L
131+
let can_start_ballooned_down = true
132+
end
133+
134+
module PVinPVH_memory_model_data : MEMORY_MODEL_DATA = struct
135+
let extra_internal_mib = 1L
136+
let extra_external_mib = 1L
137+
let shim_mib static_max_mib = 20L +++ (static_max_mib /// 110L)
138+
let can_start_ballooned_down = false
126139
end
127140

128141
type memory_config = {
@@ -131,17 +144,30 @@ type memory_config = {
131144
xen_max_mib : int64;
132145
shadow_mib : int64;
133146
required_host_free_mib : int64;
147+
overhead_mib : int64;
134148
}
135149

136150
module Memory_model (D : MEMORY_MODEL_DATA) = struct
137151

138-
let build_max_mib static_max_mib video_mib = static_max_mib --- (Int64.of_int video_mib)
152+
let build_max_mib static_max_mib video_mib =
153+
static_max_mib ---
154+
(Int64.of_int video_mib) +++
155+
(D.shim_mib static_max_mib)
139156

140-
let build_start_mib target_mib video_mib = target_mib --- (Int64.of_int video_mib)
157+
let build_start_mib static_max_mib target_mib video_mib =
158+
if D.can_start_ballooned_down then
159+
target_mib ---
160+
(Int64.of_int video_mib) +++
161+
(D.shim_mib target_mib)
162+
else
163+
build_max_mib static_max_mib video_mib
141164

142165
let xen_max_offset_mib = D.extra_internal_mib
143166

144-
let xen_max_mib target_mib = target_mib +++ xen_max_offset_mib
167+
let xen_max_mib static_max_mib =
168+
static_max_mib +++
169+
xen_max_offset_mib +++
170+
(D.shim_mib static_max_mib)
145171

146172
let shadow_mib static_max_mib vcpu_count multiplier =
147173
let vcpu_pages = 256L *** (Int64.of_int vcpu_count) in
@@ -156,7 +182,8 @@ module Memory_model (D : MEMORY_MODEL_DATA) = struct
156182
let overhead_mib static_max_mib vcpu_count multiplier =
157183
D.extra_internal_mib +++
158184
D.extra_external_mib +++
159-
(shadow_mib static_max_mib vcpu_count multiplier)
185+
(shadow_mib static_max_mib vcpu_count multiplier) +++
186+
(D.shim_mib static_max_mib)
160187

161188
let footprint_mib target_mib static_max_mib vcpu_count multiplier =
162189
target_mib +++ (overhead_mib static_max_mib vcpu_count multiplier)
@@ -166,14 +193,14 @@ module Memory_model (D : MEMORY_MODEL_DATA) = struct
166193
let full_config static_max_mib video_mib target_mib vcpus shadow_multiplier =
167194
{
168195
build_max_mib = build_max_mib static_max_mib video_mib;
169-
build_start_mib = build_start_mib target_mib video_mib;
196+
build_start_mib = build_start_mib static_max_mib target_mib video_mib;
170197
xen_max_mib = xen_max_mib static_max_mib;
171198
shadow_mib = shadow_mib static_max_mib vcpus shadow_multiplier;
172199
required_host_free_mib = footprint_mib target_mib static_max_mib vcpus shadow_multiplier;
200+
overhead_mib = overhead_mib static_max_mib vcpus shadow_multiplier;
173201
}
174202
end
175203

176204
module HVM = Memory_model (HVM_memory_model_data)
177205
module Linux = Memory_model (Linux_memory_model_data)
178-
179-
206+
module PVinPVH = Memory_model (PVinPVH_memory_model_data)

0 commit comments

Comments
 (0)