Skip to content

Commit e5c2612

Browse files
authored
CP-53827, xenopsd: claim pages for domain on pre_build phase (xapi-project#6355)
This way xen can track the memory intended to be used for each domain and fail early, if necessary. This is done on numa_placement because the code is intended to change and do per-numa-node memory claims in the near future. Testing is in progress
2 parents 94d24a9 + a810aeb commit e5c2612

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

ocaml/xenopsd/c_stubs/xenctrlext_stubs.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,27 @@ CAMLprim value stub_xenforeignmemory_unmap(value fmem, value mapping)
671671
CAMLreturn(Val_unit);
672672
}
673673

674+
CAMLprim value stub_xenctrlext_domain_claim_pages(value xch_val, value domid_val,
675+
value nr_pages_val)
676+
{
677+
CAMLparam3(xch_val, domid_val, nr_pages_val);
678+
int retval, the_errno;
679+
xc_interface* xch = xch_of_val(xch_val);
680+
uint32_t domid = Int_val(domid_val);
681+
unsigned long nr_pages = Int_val(nr_pages_val);
682+
683+
caml_release_runtime_system();
684+
retval = xc_domain_claim_pages(xch, domid, nr_pages);
685+
the_errno = errno;
686+
caml_acquire_runtime_system();
687+
688+
if(retval < 0) {
689+
raise_unix_errno_msg(the_errno,
690+
"Error when trying to claim memory pages");
691+
}
692+
CAMLreturn(Val_unit);
693+
}
694+
674695
/*
675696
* Local variables:
676697
* indent-tabs-mode: t

ocaml/xenopsd/xc/domain.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,15 +886,18 @@ let numa_placement domid ~vcpus ~memory =
886886
Softaffinity.plan ~vm host nodea
887887
)
888888
in
889-
match hint with
889+
let xcext = get_handle () in
890+
( match hint with
890891
| None ->
891892
D.debug "NUMA-aware placement failed for domid %d" domid
892893
| Some soft_affinity ->
893894
let cpua = CPUSet.to_mask soft_affinity in
894-
let xcext = get_handle () in
895895
for i = 0 to vcpus - 1 do
896896
Xenctrlext.vcpu_setaffinity_soft xcext domid i cpua
897897
done
898+
) ;
899+
let nr_pages = Int64.div memory 4096L |> Int64.to_int in
900+
Xenctrlext.domain_claim_pages xcext domid nr_pages
898901

899902
let build_pre ~xc ~xs ~vcpus ~memory ~has_hard_affinity domid =
900903
let open Memory in

ocaml/xenopsd/xc/xenctrlext.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,6 @@ external combine_cpu_policies : int64 array -> int64 array -> int64 array
108108

109109
external policy_is_compatible : int64 array -> int64 array -> string option
110110
= "stub_xenctrlext_featuresets_are_compatible"
111+
112+
external domain_claim_pages : handle -> domid -> int -> unit
113+
= "stub_xenctrlext_domain_claim_pages"

ocaml/xenopsd/xc/xenctrlext.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ external combine_cpu_policies : int64 array -> int64 array -> int64 array
9090

9191
external policy_is_compatible : int64 array -> int64 array -> string option
9292
= "stub_xenctrlext_featuresets_are_compatible"
93+
94+
external domain_claim_pages : handle -> domid -> int -> unit
95+
= "stub_xenctrlext_domain_claim_pages"

0 commit comments

Comments
 (0)