* [PATCH] tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo
@ 2011-03-23 20:57 David Scott
2011-03-31 18:03 ` Ian Jackson
2011-04-06 10:01 ` Ian Campbell
0 siblings, 2 replies; 3+ messages in thread
From: David Scott @ 2011-03-23 20:57 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1300913710 0
# Node ID 1f503b4a8ece2dc6f4c27477400fce5a6f253c67
# Parent 67525892e2c6ee27c25438d43699397c5a3e0272
tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo.
The function returns an array of optional records, one per possible pCPU.
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
diff -r 67525892e2c6 -r 1f503b4a8ece tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 23 20:51:51 2011 +0000
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 23 20:55:10 2011 +0000
@@ -167,6 +167,15 @@
physcap: int32;
}
+type topology =
+{
+ core: int;
+ socket: int;
+ node: int;
+}
+
+type topologyinfo = topology option array
+
type sched_credit =
{
weight: int;
@@ -203,6 +212,8 @@
external button_press : domid -> button -> unit = "stub_xl_button_press"
external physinfo : unit -> physinfo = "stub_xl_physinfo"
+external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo"
+
external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get"
external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set"
diff -r 67525892e2c6 -r 1f503b4a8ece tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 23 20:51:51 2011 +0000
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 23 20:55:10 2011 +0000
@@ -167,6 +167,15 @@
physcap: int32;
}
+type topology =
+{
+ core: int;
+ socket: int;
+ node: int;
+}
+
+type topologyinfo = topology option array
+
type sched_credit =
{
weight: int;
@@ -203,6 +212,8 @@
external button_press : domid -> button -> unit = "stub_xl_button_press"
external physinfo : unit -> physinfo = "stub_xl_physinfo"
+external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo"
+
external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get"
external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set"
diff -r 67525892e2c6 -r 1f503b4a8ece tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 23 20:51:51 2011 +0000
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 23 20:55:10 2011 +0000
@@ -386,6 +386,29 @@
CAMLreturn(v);
}
+static value Val_topologyinfo(libxl_topologyinfo *c_val)
+{
+ CAMLparam0();
+ CAMLlocal3(v, topology, topologyinfo);
+ int i;
+
+ topologyinfo = caml_alloc_tuple(c_val->coremap.entries);
+ for (i = 0; i < c_val->coremap.entries; i++) {
+ v = Val_int(0); /* None */
+ if (c_val->coremap.array[i] != LIBXL_CPUARRAY_INVALID_ENTRY) {
+ topology = caml_alloc_tuple(3);
+ Store_field(topology, 0, Val_int(c_val->coremap.array[i]));
+ Store_field(topology, 1, Val_int(c_val->socketmap.array[i]));
+ Store_field(topology, 2, Val_int(c_val->nodemap.array[i]));
+ v = caml_alloc(1, 0); /* Some */
+ Store_field(v, 0, topology);
+ }
+ Store_field(topologyinfo, i, v);
+ }
+
+ CAMLreturn(topologyinfo);
+}
+
value stub_xl_disk_add(value info, value domid)
{
CAMLparam2(info, domid);
@@ -661,6 +684,24 @@
CAMLreturn(physinfo);
}
+value stub_xl_topologyinfo(value unit)
+{
+ CAMLparam1(unit);
+ CAMLlocal1(topologyinfo);
+ libxl_topologyinfo c_topologyinfo;
+ int ret;
+ INIT_STRUCT();
+
+ INIT_CTX();
+ ret = libxl_get_topologyinfo(&ctx, &c_topologyinfo);
+ if (ret != 0)
+ failwith_xl("topologyinfo", &lg);
+ FREE_CTX();
+
+ topologyinfo = Val_topologyinfo(&c_topologyinfo);
+ CAMLreturn(topologyinfo);
+}
+
value stub_xl_sched_credit_domain_get(value domid)
{
CAMLparam1(domid);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo
2011-03-23 20:57 [PATCH] tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo David Scott
@ 2011-03-31 18:03 ` Ian Jackson
2011-04-06 10:01 ` Ian Campbell
1 sibling, 0 replies; 3+ messages in thread
From: Ian Jackson @ 2011-03-31 18:03 UTC (permalink / raw)
To: David Scott; +Cc: xen-devel
David Scott writes ("[Xen-devel] [PATCH] tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo"):
> tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo.
Applied, thanks.
Ian.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo
2011-03-23 20:57 [PATCH] tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo David Scott
2011-03-31 18:03 ` Ian Jackson
@ 2011-04-06 10:01 ` Ian Campbell
1 sibling, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2011-04-06 10:01 UTC (permalink / raw)
To: Dave Scott; +Cc: xen-devel@lists.xensource.com
On Wed, 2011-03-23 at 20:57 +0000, Dave Scott wrote:
> # HG changeset patch
> # User David Scott <dave.scott@eu.citrix.com>
> # Date 1300913710 0
> # Node ID 1f503b4a8ece2dc6f4c27477400fce5a6f253c67
> # Parent 67525892e2c6ee27c25438d43699397c5a3e0272
> tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo.
>
> The function returns an array of optional records, one per possible pCPU.
This doesn't fit in terribly well with the libxl IDL, which specifies a
tuple of arrays rather than an array of tuples.
Although the interface doesn't appear to enforce it, I think the 3
arrays are allways populated with the same set of present CPUs. So in
this case though I think the IDL is wrong and the array of tuples
representation is much saner. I think I'll change the IDL as I try to
autogen the type...
Ian.
>
> Signed-off-by: David Scott <dave.scott@eu.citrix.com>
>
> diff -r 67525892e2c6 -r 1f503b4a8ece tools/ocaml/libs/xl/xl.ml
> --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 23 20:51:51 2011 +0000
> +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 23 20:55:10 2011 +0000
> @@ -167,6 +167,15 @@
> physcap: int32;
> }
>
> +type topology =
> +{
> + core: int;
> + socket: int;
> + node: int;
> +}
> +
> +type topologyinfo = topology option array
> +
> type sched_credit =
> {
> weight: int;
> @@ -203,6 +212,8 @@
> external button_press : domid -> button -> unit = "stub_xl_button_press"
> external physinfo : unit -> physinfo = "stub_xl_physinfo"
>
> +external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo"
> +
> external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get"
> external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set"
>
> diff -r 67525892e2c6 -r 1f503b4a8ece tools/ocaml/libs/xl/xl.mli
> --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 23 20:51:51 2011 +0000
> +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 23 20:55:10 2011 +0000
> @@ -167,6 +167,15 @@
> physcap: int32;
> }
>
> +type topology =
> +{
> + core: int;
> + socket: int;
> + node: int;
> +}
> +
> +type topologyinfo = topology option array
> +
> type sched_credit =
> {
> weight: int;
> @@ -203,6 +212,8 @@
> external button_press : domid -> button -> unit = "stub_xl_button_press"
> external physinfo : unit -> physinfo = "stub_xl_physinfo"
>
> +external topologyinfo: unit -> topologyinfo = "stub_xl_topologyinfo"
> +
> external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get"
> external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set"
>
> diff -r 67525892e2c6 -r 1f503b4a8ece tools/ocaml/libs/xl/xl_stubs.c
> --- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 23 20:51:51 2011 +0000
> +++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 23 20:55:10 2011 +0000
> @@ -386,6 +386,29 @@
> CAMLreturn(v);
> }
>
> +static value Val_topologyinfo(libxl_topologyinfo *c_val)
> +{
> + CAMLparam0();
> + CAMLlocal3(v, topology, topologyinfo);
> + int i;
> +
> + topologyinfo = caml_alloc_tuple(c_val->coremap.entries);
> + for (i = 0; i < c_val->coremap.entries; i++) {
> + v = Val_int(0); /* None */
> + if (c_val->coremap.array[i] != LIBXL_CPUARRAY_INVALID_ENTRY) {
> + topology = caml_alloc_tuple(3);
> + Store_field(topology, 0, Val_int(c_val->coremap.array[i]));
> + Store_field(topology, 1, Val_int(c_val->socketmap.array[i]));
> + Store_field(topology, 2, Val_int(c_val->nodemap.array[i]));
> + v = caml_alloc(1, 0); /* Some */
> + Store_field(v, 0, topology);
> + }
> + Store_field(topologyinfo, i, v);
> + }
> +
> + CAMLreturn(topologyinfo);
> +}
> +
> value stub_xl_disk_add(value info, value domid)
> {
> CAMLparam2(info, domid);
> @@ -661,6 +684,24 @@
> CAMLreturn(physinfo);
> }
>
> +value stub_xl_topologyinfo(value unit)
> +{
> + CAMLparam1(unit);
> + CAMLlocal1(topologyinfo);
> + libxl_topologyinfo c_topologyinfo;
> + int ret;
> + INIT_STRUCT();
> +
> + INIT_CTX();
> + ret = libxl_get_topologyinfo(&ctx, &c_topologyinfo);
> + if (ret != 0)
> + failwith_xl("topologyinfo", &lg);
> + FREE_CTX();
> +
> + topologyinfo = Val_topologyinfo(&c_topologyinfo);
> + CAMLreturn(topologyinfo);
> +}
> +
> value stub_xl_sched_credit_domain_get(value domid)
> {
> CAMLparam1(domid);
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-04-06 10:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-23 20:57 [PATCH] tools: ocaml: Add an ocaml binding for libxl_get_topologyinfo in the style of libxl_get_physinfo David Scott
2011-03-31 18:03 ` Ian Jackson
2011-04-06 10:01 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).