Skip to content

Commit a4bc2bb

Browse files
committed
CA-422187: more accurate claims and debug messages
We noticed that xenguest releases 32 unused pages from the domain's claim. These are from the low 1MiB video range, so avoid requesting it. Also always print memory free statistics when `wait_xen_free_mem` is called. Turns out `scrub_pages` is always 0, since this never got implemented in Xen (it is hardcoded to 0). Signed-off-by: Edwin Török <[email protected]>
1 parent 9549104 commit a4bc2bb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ocaml/xenopsd/xc/domain.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ let wait_xen_free_mem ~xc ?(maximum_wait_time_seconds = 64) required_memory_kib
244244
in
245245
(* At exponentially increasing intervals, write *)
246246
(* a debug message saying how long we've waited: *)
247-
if is_power_of_2 accumulated_wait_time_seconds then
247+
if
248+
accumulated_wait_time_seconds = 0
249+
|| is_power_of_2 accumulated_wait_time_seconds
250+
then
248251
debug
249252
"Waited %i second(s) for memory to become available: %Ld KiB free, %Ld \
250253
KiB scrub, %Ld KiB required"
@@ -1000,7 +1003,7 @@ let numa_placement domid ~vcpus ~cores ~memory affinity =
10001003
__FUNCTION__ domid ;
10011004
None
10021005
in
1003-
let nr_pages = Int64.div memory 4096L |> Int64.to_int in
1006+
let nr_pages = (Int64.div memory 4096L |> Int64.to_int) - 32 in
10041007
try
10051008
D.debug "NUMAClaim domid %d: local claim on node %d: %d pages" domid
10061009
node nr_pages ;
@@ -1129,7 +1132,9 @@ let build_pre ~xc ~xs ~vcpus ~memory ~hard_affinity domid =
11291132
A failure here is a hard failure: we'd fail allocating
11301133
memory later anyway
11311134
*)
1132-
let nr_pages = Int64.div memory 4096L |> Int64.to_int in
1135+
let nr_pages =
1136+
(Int64.div memory 4096L |> Int64.to_int) - 32
1137+
in
11331138
let xcext = Xenctrlext.get_handle () in
11341139
D.debug "NUMAClaim domid %d: global claim: %d pages" domid
11351140
nr_pages ;

0 commit comments

Comments
 (0)