Skip to content

Commit 95367e1

Browse files
committed
CA-422187: safer defaults for global claims
Xen may have already allocated some memory for the domain, and the overhead is only an estimate. A global claim failing is a hard failure, so instead use a more conservative estimate: `memory.build_start_mib`. This is similar to `required_host_free_mib`, but doesn't take overhead into account. Eventually we'd want to have another argument to the create hypercall that tells it what NUMA node(s) to use, and then we can include all the overhead too there. For the single node claim keep the amount as it was, it is only a best effort claim. Fixes: 060d792 ("CA-422188: either always use claims or never use claims") Signed-off-by: Edwin Török <edwin.torok@citrix.com>
1 parent 112db1f commit 95367e1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ocaml/xenopsd/xc/domain.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,8 @@ let build_pre ~xc ~xs ~vcpus ~memory ~hard_affinity domid =
11151115
in
11161116
let memory =
11171117
Int64.(mul memory.required_host_free_mib (shift_left 1L 20))
1118+
and memory_hard =
1119+
Int64.(mul memory.build_start_mib (shift_left 1L 20))
11181120
in
11191121
match numa_placement domid ~vcpus ~cores ~memory affinity with
11201122
| None ->
@@ -1129,7 +1131,7 @@ let build_pre ~xc ~xs ~vcpus ~memory ~hard_affinity domid =
11291131
A failure here is a hard failure: we'd fail allocating
11301132
memory later anyway
11311133
*)
1132-
let nr_pages = Int64.div memory 4096L |> Int64.to_int in
1134+
let nr_pages = Int64.div memory_hard 4096L |> Int64.to_int in
11331135
let xcext = Xenctrlext.get_handle () in
11341136
D.debug "NUMAClaim domid %d: global claim: %d pages" domid
11351137
nr_pages ;

0 commit comments

Comments
 (0)