Skip to content

CP-54087: adding RRD2 metric - runnable_vcpus #6551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: feature/vcpu-runnable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ let dss_vcpus xc doms =
let ( ++ ) = Int64.add in
try
let ri = Xenctrl.domain_get_runstate_info xc domid in
let runnable_vcpus_ds =
match ri.Xenctrl.runnable with
| 0L ->
[]
| _ ->
[
( Rrd.VM uuid
, Ds.ds_make ~name:"runnable_vcpus" ~units:"(fraction)"
~value:
(Rrd.VT_Float
(Int64.to_float ri.Xenctrl.runnable /. 1.0e9)
)
~description:
"Fraction of time that vCPUs of the domain are runnable"
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
)
]
in
( Rrd.VM uuid
, Ds.ds_make ~name:"runstate_fullrun" ~units:"(fraction)"
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time0 /. 1.0e9))
Expand Down Expand Up @@ -133,6 +151,7 @@ let dss_vcpus xc doms =
~min:0.0 ~max:1.0 ()
)
:: dss
@ runnable_vcpus_ds
with _ -> dss
in
try cpus 0 dss with _ -> dss
Expand Down
11 changes: 8 additions & 3 deletions ocaml/xenopsd/c_stubs/xenctrlext_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ CAMLprim value stub_xenctrlext_get_runstate_info(value xch_val, value domid)
CAMLparam2(xch_val, domid);
#if defined(XENCTRL_HAS_GET_RUNSTATE_INFO)
CAMLlocal1(result);
xc_runstate_info_t info;
xc_runstate_info_t info = { 0 };
int retval;
xc_interface *xch = xch_of_val(xch_val);
uint32_t c_domid = Int_val(domid);

retval = xc_get_runstate_info(xch, Int_val(domid), &info);
caml_release_runtime_system();
retval = xc_get_runstate_info(xch, c_domid, &info);
caml_acquire_runtime_system();
if (retval < 0)
failwith_xc(xch);

Expand All @@ -126,8 +129,9 @@ CAMLprim value stub_xenctrlext_get_runstate_info(value xch_val, value domid)
1 : missed_changes (int32)
2 : state_entry_time (int64)
3-8 : times (int64s)
9 : runnable (int64)
*/
result = caml_alloc_tuple(9);
result = caml_alloc_tuple(10);
Store_field(result, 0, caml_copy_int32(info.state));
Store_field(result, 1, caml_copy_int32(info.missed_changes));
Store_field(result, 2, caml_copy_int64(info.state_entry_time));
Expand All @@ -137,6 +141,7 @@ CAMLprim value stub_xenctrlext_get_runstate_info(value xch_val, value domid)
Store_field(result, 6, caml_copy_int64(info.time[3]));
Store_field(result, 7, caml_copy_int64(info.time[4]));
Store_field(result, 8, caml_copy_int64(info.time[5]));
Store_field(result, 9, caml_copy_int64(info.runnable));

CAMLreturn(result);
#else
Expand Down
1 change: 1 addition & 0 deletions ocaml/xenopsd/xc/xenctrlext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type runstateinfo = {
; time3: int64
; time4: int64
; time5: int64
; runnable: int64
}

external domain_get_runstate_info : handle -> int -> runstateinfo
Expand Down
1 change: 1 addition & 0 deletions ocaml/xenopsd/xc/xenctrlext.mli
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type runstateinfo = {
; time3: int64
; time4: int64
; time5: int64
; runnable: int64
}

external domain_get_runstate_info : handle -> int -> runstateinfo
Expand Down
Loading