xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] tools/libxc: add interface for GNTTABOP_query_size
@ 2017-06-30  7:21 Dongli Zhang
  2017-06-30  7:21 ` [PATCH 2/2] tools: utility to dump guest grant table info Dongli Zhang
  2017-06-30 13:57 ` [PATCH 1/2] tools/libxc: add interface for GNTTABOP_query_size Wei Liu
  0 siblings, 2 replies; 5+ messages in thread
From: Dongli Zhang @ 2017-06-30  7:21 UTC (permalink / raw)
  To: xen-devel; +Cc: wei.liu2, ian.jackson

This patch adds new interface for GNTTABOP_query_size in libxc to help
query the current grant table frames and maximum grant table frames for a
specific domain.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 tools/libxc/include/xenctrl.h |  1 +
 tools/libxc/xc_gnttab.c       | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 1629f41..155c69e 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1597,6 +1597,7 @@ int xc_gnttab_op(xc_interface *xch, int cmd,
                  void * op, int op_size, int count);
 /* Logs iff hypercall bounce fails, otherwise doesn't. */
 
+int xc_gnttab_query_size(xc_interface *xch, struct gnttab_query_size *query);
 int xc_gnttab_get_version(xc_interface *xch, int domid); /* Never logs */
 grant_entry_v1_t *xc_gnttab_map_table_v1(xc_interface *xch, int domid, int *gnt_num);
 grant_entry_v2_t *xc_gnttab_map_table_v2(xc_interface *xch, int domid, int *gnt_num);
diff --git a/tools/libxc/xc_gnttab.c b/tools/libxc/xc_gnttab.c
index af53fac..81a89fe 100644
--- a/tools/libxc/xc_gnttab.c
+++ b/tools/libxc/xc_gnttab.c
@@ -38,6 +38,18 @@ int xc_gnttab_op(xc_interface *xch, int cmd, void * op, int op_size, int count)
     return ret;
 }
 
+int xc_gnttab_query_size(xc_interface *xch, struct gnttab_query_size *query)
+{
+    int rc;
+
+    rc = xc_gnttab_op(xch, GNTTABOP_query_size, query, sizeof(*query), 1);
+
+    if ( rc || (query->status != GNTST_okay) )
+        ERROR("Could not query dom %d's grant size\n", query->dom);
+
+    return rc;
+}
+
 int xc_gnttab_get_version(xc_interface *xch, int domid)
 {
     struct gnttab_get_version query;
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] tools: utility to dump guest grant table info
  2017-06-30  7:21 [PATCH 1/2] tools/libxc: add interface for GNTTABOP_query_size Dongli Zhang
@ 2017-06-30  7:21 ` Dongli Zhang
  2017-06-30 14:07   ` Wei Liu
  2017-06-30 16:25   ` Konrad Rzeszutek Wilk
  2017-06-30 13:57 ` [PATCH 1/2] tools/libxc: add interface for GNTTABOP_query_size Wei Liu
  1 sibling, 2 replies; 5+ messages in thread
From: Dongli Zhang @ 2017-06-30  7:21 UTC (permalink / raw)
  To: xen-devel; +Cc: wei.liu2, ian.jackson

As both xen-netfront and xen-blkfront support multi-queue, they would
consume a lot of grant table references when there are many paravirtual
devices and vcpus assigned to guest. Guest domU might panic or hang due to
grant allocation failure when nr_grant_frames in guest has reached its max
value.

This utility would help the administrators to monitor the guest grant table
frame usage on dom0 side so that it is not required to debug on guest
kernel side for crash/hang analysis anymore.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 tools/misc/Makefile           |  4 ++++
 tools/misc/xen-gnttab-query.c | 45 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 tools/misc/xen-gnttab-query.c

diff --git a/tools/misc/Makefile b/tools/misc/Makefile
index 8152f7b..d081b4b 100644
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -31,6 +31,7 @@ INSTALL_SBIN                   += xenperf
 INSTALL_SBIN                   += xenpm
 INSTALL_SBIN                   += xenwatchdogd
 INSTALL_SBIN                   += xen-livepatch
+INSTALL_SBIN                   += xen-gnttab-query
 INSTALL_SBIN += $(INSTALL_SBIN-y)
 
 # Everything to be installed in a private bin/
@@ -108,4 +109,7 @@ xen-lowmemd: xen-lowmemd.o
 xencov: xencov.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
+xen-gnttab-query: xen-gnttab-query.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
+
 -include $(DEPS)
diff --git a/tools/misc/xen-gnttab-query.c b/tools/misc/xen-gnttab-query.c
new file mode 100644
index 0000000..3f93a6c
--- /dev/null
+++ b/tools/misc/xen-gnttab-query.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <err.h>
+#include <xenctrl.h>
+
+void show_help(void)
+{
+    fprintf(stderr,
+            "xen-gnttab-query: query grant table info\n"
+            "Usage: xen-gnttab-query [domid (default 0)]\n");
+}
+
+int main(int argc, char *argv[])
+{
+    xc_interface *xch;
+    int domid, rc, c;
+    struct gnttab_query_size query;
+
+    while ( (c = getopt(argc, argv, "h")) != -1 )
+    {
+        switch ( c )
+        {
+        case 'h':
+            show_help();
+            return 0;
+        }
+    }
+
+    domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0;
+
+    xch = xc_interface_open(0, 0, 0);
+    if ( !xch )
+        errx(1, "failed to open control interface");
+
+    query.dom = domid;
+    rc = xc_gnttab_query_size(xch, &query);
+
+    if ( rc == 0 && (query.status == GNTST_okay) )
+        printf("domid=%d: nr_frames=%d, max_nr_frames=%d\n",
+               query.dom, query.nr_frames, query.max_nr_frames);
+
+    xc_interface_close(xch);
+
+    return 0;
+}
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] tools/libxc: add interface for GNTTABOP_query_size
  2017-06-30  7:21 [PATCH 1/2] tools/libxc: add interface for GNTTABOP_query_size Dongli Zhang
  2017-06-30  7:21 ` [PATCH 2/2] tools: utility to dump guest grant table info Dongli Zhang
@ 2017-06-30 13:57 ` Wei Liu
  1 sibling, 0 replies; 5+ messages in thread
From: Wei Liu @ 2017-06-30 13:57 UTC (permalink / raw)
  To: Dongli Zhang; +Cc: wei.liu2, ian.jackson, xen-devel

On Fri, Jun 30, 2017 at 03:21:30PM +0800, Dongli Zhang wrote:
> This patch adds new interface for GNTTABOP_query_size in libxc to help
> query the current grant table frames and maximum grant table frames for a
> specific domain.
> 
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
>  tools/libxc/include/xenctrl.h |  1 +
>  tools/libxc/xc_gnttab.c       | 12 ++++++++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 1629f41..155c69e 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -1597,6 +1597,7 @@ int xc_gnttab_op(xc_interface *xch, int cmd,
>                   void * op, int op_size, int count);
>  /* Logs iff hypercall bounce fails, otherwise doesn't. */
>  
> +int xc_gnttab_query_size(xc_interface *xch, struct gnttab_query_size *query);
>  int xc_gnttab_get_version(xc_interface *xch, int domid); /* Never logs */
>  grant_entry_v1_t *xc_gnttab_map_table_v1(xc_interface *xch, int domid, int *gnt_num);
>  grant_entry_v2_t *xc_gnttab_map_table_v2(xc_interface *xch, int domid, int *gnt_num);
> diff --git a/tools/libxc/xc_gnttab.c b/tools/libxc/xc_gnttab.c
> index af53fac..81a89fe 100644
> --- a/tools/libxc/xc_gnttab.c
> +++ b/tools/libxc/xc_gnttab.c
> @@ -38,6 +38,18 @@ int xc_gnttab_op(xc_interface *xch, int cmd, void * op, int op_size, int count)
>      return ret;
>  }
>  
> +int xc_gnttab_query_size(xc_interface *xch, struct gnttab_query_size *query)
> +{
> +    int rc;
> +
> +    rc = xc_gnttab_op(xch, GNTTABOP_query_size, query, sizeof(*query), 1);
> +
> +    if ( rc || (query->status != GNTST_okay) )
> +        ERROR("Could not query dom %d's grant size\n", query->dom);

%u please.

Otherwise:

Acked-by: Wei Liu <wei.liu2@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] tools: utility to dump guest grant table info
  2017-06-30  7:21 ` [PATCH 2/2] tools: utility to dump guest grant table info Dongli Zhang
@ 2017-06-30 14:07   ` Wei Liu
  2017-06-30 16:25   ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 5+ messages in thread
From: Wei Liu @ 2017-06-30 14:07 UTC (permalink / raw)
  To: Dongli Zhang; +Cc: wei.liu2, ian.jackson, xen-devel

On Fri, Jun 30, 2017 at 03:21:31PM +0800, Dongli Zhang wrote:
> +
> +int main(int argc, char *argv[])
> +{
> +    xc_interface *xch;
> +    int domid, rc, c;
> +    struct gnttab_query_size query;
> +
> +    while ( (c = getopt(argc, argv, "h")) != -1 )
> +    {
> +        switch ( c )
> +        {
> +        case 'h':
> +            show_help();
> +            return 0;
> +        }
> +    }
> +
> +    domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0;

This is too simplistic. It basically means ./query -x 100 will not
report an error. You should use optind instead. See man 3 getopt for
examples.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] tools: utility to dump guest grant table info
  2017-06-30  7:21 ` [PATCH 2/2] tools: utility to dump guest grant table info Dongli Zhang
  2017-06-30 14:07   ` Wei Liu
@ 2017-06-30 16:25   ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2017-06-30 16:25 UTC (permalink / raw)
  To: Dongli Zhang; +Cc: ian.jackson, wei.liu2, xen-devel

On Fri, Jun 30, 2017 at 03:21:31PM +0800, Dongli Zhang wrote:
> As both xen-netfront and xen-blkfront support multi-queue, they would
> consume a lot of grant table references when there are many paravirtual
> devices and vcpus assigned to guest. Guest domU might panic or hang due to
> grant allocation failure when nr_grant_frames in guest has reached its max
> value.
> 
> This utility would help the administrators to monitor the guest grant table
> frame usage on dom0 side so that it is not required to debug on guest
> kernel side for crash/hang analysis anymore.
> 
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
>  tools/misc/Makefile           |  4 ++++
>  tools/misc/xen-gnttab-query.c | 45 +++++++++++++++++++++++++++++++++++++++++++

Would this be better name 'xen-diag' or such? And in the future
more diagnostic pieces could be added in? For example I can see
parts of xen-hptool moving in there.

>  2 files changed, 49 insertions(+)
>  create mode 100644 tools/misc/xen-gnttab-query.c
> 
> diff --git a/tools/misc/Makefile b/tools/misc/Makefile
> index 8152f7b..d081b4b 100644
> --- a/tools/misc/Makefile
> +++ b/tools/misc/Makefile
> @@ -31,6 +31,7 @@ INSTALL_SBIN                   += xenperf
>  INSTALL_SBIN                   += xenpm
>  INSTALL_SBIN                   += xenwatchdogd
>  INSTALL_SBIN                   += xen-livepatch
> +INSTALL_SBIN                   += xen-gnttab-query
>  INSTALL_SBIN += $(INSTALL_SBIN-y)
>  
>  # Everything to be installed in a private bin/
> @@ -108,4 +109,7 @@ xen-lowmemd: xen-lowmemd.o
>  xencov: xencov.o
>  	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
>  
> +xen-gnttab-query: xen-gnttab-query.o
> +	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
> +
>  -include $(DEPS)
> diff --git a/tools/misc/xen-gnttab-query.c b/tools/misc/xen-gnttab-query.c
> new file mode 100644
> index 0000000..3f93a6c
> --- /dev/null
> +++ b/tools/misc/xen-gnttab-query.c
> @@ -0,0 +1,45 @@

Please add Oracle's copyright (see the xen-livepatch.c for example).


> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <err.h>
> +#include <xenctrl.h>
> +
> +void show_help(void)
> +{
> +    fprintf(stderr,
> +            "xen-gnttab-query: query grant table info\n"
> +            "Usage: xen-gnttab-query [domid (default 0)]\n");
> +}
> +
> +int main(int argc, char *argv[])
> +{
> +    xc_interface *xch;
> +    int domid, rc, c;
> +    struct gnttab_query_size query;
> +
> +    while ( (c = getopt(argc, argv, "h")) != -1 )
> +    {
> +        switch ( c )
> +        {
> +        case 'h':
> +            show_help();
> +            return 0;
> +        }
> +    }
> +
> +    domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0;
> +
> +    xch = xc_interface_open(0, 0, 0);
> +    if ( !xch )
> +        errx(1, "failed to open control interface");
> +
> +    query.dom = domid;
> +    rc = xc_gnttab_query_size(xch, &query);
> +
> +    if ( rc == 0 && (query.status == GNTST_okay) )
> +        printf("domid=%d: nr_frames=%d, max_nr_frames=%d\n",
> +               query.dom, query.nr_frames, query.max_nr_frames);
> +
> +    xc_interface_close(xch);
> +
> +    return 0;
> +}
> -- 
> 2.7.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-30 16:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-30  7:21 [PATCH 1/2] tools/libxc: add interface for GNTTABOP_query_size Dongli Zhang
2017-06-30  7:21 ` [PATCH 2/2] tools: utility to dump guest grant table info Dongli Zhang
2017-06-30 14:07   ` Wei Liu
2017-06-30 16:25   ` Konrad Rzeszutek Wilk
2017-06-30 13:57 ` [PATCH 1/2] tools/libxc: add interface for GNTTABOP_query_size Wei Liu

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).