Skip to content

Commit ece6444

Browse files
authored
Make xcp-rrdp-cpu more robust (#6418)
Draft, because I still need to test it.
2 parents d1dd44e + 5ba4c8f commit ece6444

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

ocaml/xapi-idl/rrd/rrd_interface.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ let default_sockets_dir = "/var/lib/xcp"
2929

3030
let daemon_name = "xcp-rrdd"
3131

32+
let max_supported_vms = 1024
33+
3234
let default_path = ref (Filename.concat default_sockets_dir daemon_name)
3335

3436
let forwarded_path =

ocaml/xcp-rrdd/bin/rrdd/xcp_rrdd.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ let dss_mem_host xc =
225225
(** estimate the space needed to serialize all the dss_mem_vms in a host. the
226226
json-like serialization for the 3 dss in dss_mem_vms takes 622 bytes. these
227227
bytes plus some overhead make 1024 bytes an upper bound. *)
228-
let max_supported_vms = 1024
229228

230229
let bytes_per_mem_vm = 1024
231230

232-
let mem_vm_writer_pages = ((max_supported_vms * bytes_per_mem_vm) + 4095) / 4096
231+
let mem_vm_writer_pages =
232+
((Rrd_interface.max_supported_vms * bytes_per_mem_vm) + 4095) / 4096
233233

234234
let res_error fmt = Printf.ksprintf Result.error fmt
235235

ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,15 @@ let dss_hostload xc domains =
188188
let load =
189189
List.fold_left
190190
(fun acc (dom, _, domid) ->
191-
sum 0 dom.Xenctrl.max_vcpu_id (fun id ->
192-
let vcpuinfo = Xenctrl.domain_get_vcpuinfo xc domid id in
193-
if vcpuinfo.Xenctrl.online && not vcpuinfo.Xenctrl.blocked then
194-
1
195-
else
196-
0
191+
( try
192+
sum 0 dom.Xenctrl.max_vcpu_id (fun id ->
193+
let vcpuinfo = Xenctrl.domain_get_vcpuinfo xc domid id in
194+
if vcpuinfo.Xenctrl.online && not vcpuinfo.Xenctrl.blocked then
195+
1
196+
else
197+
0
198+
)
199+
with _ -> 0
197200
)
198201
+ acc
199202
)
@@ -230,14 +233,20 @@ let generate_cpu_ds_list xc () =
230233
let _, domains, _ = Xenctrl_lib.domain_snapshot xc in
231234
dss_pcpus xc @ dss_vcpus xc domains @ dss_loadavg () @ dss_hostload xc domains
232235

236+
(* 32 vCPUS ~8659 bytes, so 64 vCPUs should fit in 5 *)
237+
let cpu_pages_per_vm = 5
238+
233239
let _ =
234240
Xenctrl.with_intf (fun xc ->
235241
let _, domains, _ = Xenctrl_lib.domain_snapshot xc in
236242
Process.initialise () ;
237243
(* Share one page per PCPU and dom each *)
238244
let physinfo = Xenctrl.physinfo xc in
239-
let shared_page_count = physinfo.Xenctrl.nr_cpus + List.length domains in
240-
(* TODO: Can run out of pages if a lot of domains are added at runtime *)
245+
let shared_page_count =
246+
physinfo.Xenctrl.nr_cpus
247+
+ Int.max Rrd_interface.max_supported_vms (List.length domains)
248+
* cpu_pages_per_vm
249+
in
241250
Process.main_loop ~neg_shift:0.5
242251
~target:(Reporter.Local shared_page_count) ~protocol:Rrd_interface.V2
243252
~dss_f:(generate_cpu_ds_list xc)

0 commit comments

Comments
 (0)