From patchwork Fri Jun 30 07:21:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Zhang X-Patchwork-Id: 9818585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 08686603D7 for ; Fri, 30 Jun 2017 07:24:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 071C028504 for ; Fri, 30 Jun 2017 07:23:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF8F5285DA; Fri, 30 Jun 2017 07:23:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A51F5285E5 for ; Fri, 30 Jun 2017 07:23:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQqFB-0005DQ-Ep; Fri, 30 Jun 2017 07:21:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQqFA-0005DJ-6i for xen-devel@lists.xen.org; Fri, 30 Jun 2017 07:21:32 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id EB/4F-03612-BFBF5595; Fri, 30 Jun 2017 07:21:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsUyZ7p8oO6v36G RBpdarCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oxt28+yFcwRrViybw9bA+NugS5GLg4hgYlM Ens+X2DqYuQEcn4zSrTf0oZIbGCUOHd0FyOE080o8f53OytIFZuAjsS0A6dYQGwRAWmJa58vM 4LYzAJGErc2NjCD2MICThLLp20Gq2cRUJW4d2UvWxcjBwevgJvEu6lhIGEJATmJm+c6wco5Bd wlTk2awQhxhJtEz+UuRogaQ4nTD7cxTmDkW8DIsIpRvTi1qCy1SNdcL6koMz2jJDcxM0fX0MB MLze1uDgxPTUnMalYLzk/dxMjMEwYgGAH48zL/ocYJTmYlER5V14LjRTiS8pPqcxILM6ILyrN SS0+xKjBwSHQt2b1BUYplrz8vFQlCd6Lv4DqBItS01Mr0jJzgIEMUyrBwaMkwvvoKVCat7ggM bc4Mx0idYrRkuNO34YvTBzHZvz8xsSxaiaQFAKbJyXO6wsyTwCkIaM0D24cLNouMcpKCfMyAh 0rxFOQWpSbWYIq/4pRnINRSZj370+gKTyZeSVwW18BHcQEdJDwjBCQg0oSEVJSDYz7lX4GKvE sDk1be1ugsq3JROQeu0X0ttKt+6uN12gHv99bPe38jjJWXSm2Z3fXC8RIvOdud0+z8Gqqcizn muXVN+ni7ZopOsGzN9/NXqHIqvDkZGPzVr87C1akZHmpJXecqmnIlXHhylm0+Oda9ybNxZGT/ Yr/5F6ye7hhfXzhDoWOgGKOH0osxRmJhlrMRcWJAM2Wa2WxAgAA X-Env-Sender: dongli.zhang@oracle.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1498807289!52058327!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54149 invoked from network); 30 Jun 2017 07:21:30 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 30 Jun 2017 07:21:30 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v5U7LKD2026370 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Jun 2017 07:21:20 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v5U7LKAw028714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Jun 2017 07:21:20 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v5U7LJvW028337; Fri, 30 Jun 2017 07:21:20 GMT Received: from linux.cn.oracle.com (/10.182.70.224) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 30 Jun 2017 00:21:19 -0700 From: Dongli Zhang To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 15:21:31 +0800 Message-Id: <1498807291-3356-2-git-send-email-dongli.zhang@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498807291-3356-1-git-send-email-dongli.zhang@oracle.com> References: <1498807291-3356-1-git-send-email-dongli.zhang@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com Subject: [Xen-devel] [PATCH 2/2] tools: utility to dump guest grant table info X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 +#include +#include +#include + +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; +}