[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tools/ocaml/libs/xc: add OCaml stubs to query CPU policy


  • To: Edwin Torok <edvin.torok@xxxxxxxxxx>
  • From: Christian Lindig <christian.lindig@xxxxxxxxxx>
  • Date: Fri, 18 Jun 2021 13:09:38 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vxbhuTFtjVEcv91IEwFJSsJ5fZxpbROKbd6fvx6vsvQ=; b=YUW5XIWAtA3J7e1y7zlNc9BWuhUZFIX+bLe/3wRcWCFBNRPH/poY7/Ie5HBP4oJbHRE2+/5l8CHwdO6pOTZaSWoBlhMkt8CXcKbuSZL0/8rk7EM0FXW0XNtA39BPdN9FLlIgaWny4IQXMzMimmmVl6eS6Sv4jpXiHAW/w6CSbbHrDjD8rJhsB7YN92BjvN16c32Ai5nC12lQ005jbmHHYjKAh0L/Yq/9Lhd0p5/gj5pyNOkC4GilmOuEv3lUNhr418pmDIeAPNh9aqwIZAprP6rcWAzkLNe2R6f+h5IG6vc7FGF6vsnPY65EQpqfRWFmR977lvBpE5bMvkn1YpKpQQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QcZmemX2GVaumkco8Mk5kYU7A7qPmVJLv63YI/sZMznhkB8tDaPt0M4Tpl9Tpdog4SfpJYs8McpKCZ139KwaYFWKZfkAul5oQRFzVNrsJBxjEIRjrAckA84WF4w14gmzp+dq+12L36CYAsTdPkiDoDQfxwwCxE8Huud0IdhxDhmy3zA4Th5zUY4waE9NoWQtxO292J2NjKTTp2rwkXkFWCXXaTS9dQQtiKJykLl/gu/UGKAnPuKF0vj+xcydM9HBQSG8yI2uTJgEtbQj72Jj0mVq9uHNDik7L+qZ4GLzFATITzxxSzW1MoYueiZ+/Taz+pWe6uJxczIDGlhHfR24ug==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "David Scott" <dave@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Delivery-date: Fri, 18 Jun 2021 13:09:47 +0000
  • Ironport-hdrordr: A9a23:hMQPZq89wIyo90fcP75uk+C7I+orL9Y04lQ7vn2ZKCY0TiX8ra uTdZsguCMc5Ax6ZJhCo7G90de7Lk80nKQdibX5Vo3PYOCJggWVEL0=
  • Ironport-sdr: NYezggnu40RfmUJCsV1d4YtKdTjJiheEt1fWtwjvWGUGc0nLLTLRs8VnORJoOTFIrm9yScwvJy Vv1LAGpFjq8MIzD/qUuXoLGPR54XyQgyiSYM6HdVHy28sBdx2b8FJFalDg/LstSjWllQGgtS3P e7eZGGRTpDdUwnss1tOM/TTDpZxL2cO0dlYR3oz9Jd0O7JkRO8bUbVRkrx8CeY4iAi6Q+U46iS sZIfSSnBTgcMsDy9VZ5RTraBgKI/qSoaNC9597NiDN/Gokt3Se2lLHN0X+99aJa3AYmjHBWDR4 kLk=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXZC8pa/DYoLcU2065VvJ6EZGJjqsZvgMA
  • Thread-topic: [PATCH] tools/ocaml/libs/xc: add OCaml stubs to query CPU policy



On 18 Jun 2021, at 11:45, Edwin Török <edvin.torok@xxxxxxxxxx> wrote:

Introduces following functions in Xenctrl and associated types:
get_system_cpu_policy
cpu_policy_to_featureset,
string_of_xen_cpu_policy_index

These are wrappers around the existing C functions in xenctrl.h,
that will be used by xenopsd initially.

-Wno-declaration-after-statement is disabled to allow mixing
declarations and code to simplify writing the stubs
by using variable length arrays on the stack instead of
allocating/freeing memory
(which would require additional error-handling logic).

Signed-off-by: Edwin Török <edvin.torok@xxxxxxxxxx>
---
tools/ocaml/libs/xc/Makefile        |   2 +-
tools/ocaml/libs/xc/xenctrl.ml      |  37 ++++++
tools/ocaml/libs/xc/xenctrl.mli     |  71 ++++++++++
tools/ocaml/libs/xc/xenctrl_stubs.c | 195 ++++++++++++++++++++++++++++
4 files changed, 304 insertions(+), 1 deletion(-)

Acked-by: Christian Lindig <christian.lindig@xxxxxxxxxx>


+static CAMLprim value Val_leaves(const xen_cpuid_leaf_t *leaves, uint32_t nr_leaves)
+{
+    CAMLparam0();
+    CAMLlocal1(result);
+    uint32_t i;
+
+    result = caml_alloc(nr_leaves, 0);
+    for (i=0;i<nr_leaves;i++)
+        Store_field(result, i, Val_cpuid_leaf(&leaves[i]));
+
+    CAMLreturn(result);
+}

Is  caml_alloc(nr_leaves, 0) the right allocation? The 0 is the tag. There is another instance of this below. What is the type of the returned value from an OCaml perspective?

— C


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.