From patchwork Fri Sep 30 02:54:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9357473 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 D44486077A for ; Fri, 30 Sep 2016 02:56:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C89B129D3E for ; Fri, 30 Sep 2016 02:56:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD5D929D43; Fri, 30 Sep 2016 02:56:38 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID 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 4941229D3E for ; Fri, 30 Sep 2016 02:56:38 +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 1bpny6-0002It-Aj; Fri, 30 Sep 2016 02:54:34 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpny5-0002I4-8P for xen-devel@lists.xenproject.org; Fri, 30 Sep 2016 02:54:33 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id B4/51-27233-8E3DDE75; Fri, 30 Sep 2016 02:54:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRWlGSWpSXmKPExsXiVRvkpPv88tt wg2nzVS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxnnz4yFRwxrDh9uJe1gXGzShcjF4eQwAxG iTs/jrOAOCwCa1gltr/8ygbiSAhcYpXYv3oDUxcjJ5ATI7H5cgcjhF0h0TitD8wWElCRuLl9F RPEqF+MElsbf7OAJIQF9CSOHP3BDmEHSVw++hDMZhMwkHizYy8riC0ioCRxb9VkoGYODmaBUo nHm8BmsgioSnQ8Og22l1fAR+LfydVg5ZwCvhK/tr1ggdjrI/F7+XI2EFtUQE5i5eUWVoh6QYm TM5+wQIzUlFi/Sx8kzCwgL7H97RzmCYwis5BUzUKomoWkagEj8ypG9eLUorLUIl1TvaSizPSM ktzEzBxdQwNjvdzU4uLE9NScxKRiveT83E2MwOCvZ2Bg3MF4+avTIUZJDiYlUV7Zo2/DhfiS8 lMqMxKLM+KLSnNSiw8xanBwCEw4O3c6kxRLXn5eqpIE79pLQHWCRanpqRVpmTnA+IQpleDgUR LhVQDGqBBvcUFibnFmOkTqFKMux5ap99YyCYHNkBLnbQKZIQBSlFGaBzcCliouMcpKCfMyMjA wCPEUpBblZpagyr9iFOdgVBLm3QYyhSczrwRu0yugI5iAjsg/+gbkiJJEhJRUA2Pe57xZOQeL tgrYF7RMOl8bZv32MW/znQlrPB0ueb0ovLjlZIvXlU8X3N7b7WJ7Idpe2PbeeZn/EplZXU56y sesDCbveqG77lrRFGbP9ruLg39G8Ba99dofVZzyVuizzmo//gVnDl5yvvwj2b4lPDH96KawB3 3vQ1ny3xT/c9/2x8rQYdv9bHYlluKMREMt5qLiRAA/LKO7EAMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1475204071!8133611!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28324 invoked from network); 30 Sep 2016 02:54:31 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-9.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 30 Sep 2016 02:54:31 -0000 Received: by mail-wm0-f66.google.com with SMTP id b184so1386395wma.3 for ; Thu, 29 Sep 2016 19:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=7OPin5r7RLQFAcjeiLEct87DXlzQ+fQYvb1K6a1RzO0=; b=jmb+oOV0+3fZWt9F3Im78geeGK0glDfxgBSQYFGa+C6VRQnIjlpl6RJa4YUgDSAXVO 28TMkayrfi2MIUQL1P9p3EGiWNot5M71leqOwhug3/8sb/zLwOvMCCcuO4EpFiAEAvSA lF+6iM0fZNnMUuWIi6ydNVLs1qsP14WwHU/1oJ+sgYCKj+zkxk8jxZPXYaUu0OIfHlVp ay4JwclEd+nkKJPvd1qz8QnBmUcFCyfwB8F0pwaNLXrZS4KRw5vQTH8k6Y04e2HdGJIb IHNphfJ5W0DXnluqW4G84DbJHbzy5uh3tlODboKS1sWeyXznBCFsicgoBOq1uY2BUIpB XdEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=7OPin5r7RLQFAcjeiLEct87DXlzQ+fQYvb1K6a1RzO0=; b=HJjnXrgjzunzxFHwcYqtkgucjSX6cXEuz2bCJz9qD67m8M/3QAYI0pkWmeQXuml+SK lHUf7ic3l4U6LKlUmdXWhRTtgE0MzrSyT5uwvlF+79W5am6Ymy73R5YhSxNlScLKQpKF 5HLFXUeZRX305MpnPzeOtbOY6PbujttHumlcqA3oLoo9Ne92MidAuSKBRDiBwmUsxnLN ZYmfTo8AB+N17o2GUBKjDXPW134baiFFtTure8UWNx+VgMm4dyjBYEMd03CbF1cTnu04 dTjoEMBP2SO+2h6f45tLrhorWmbEA3WHZ7g+ReNAwLiIE4GaZ3Cw5MkTkh2Lnu7fc8V8 sGeg== X-Gm-Message-State: AA6/9Rk+gfb8jseN5+p4aRE47vupGVeUFO98V91UW+Kbs/60Wg90n+vAdgbR1t9amdwRdw== X-Received: by 10.28.54.193 with SMTP id y62mr1393364wmh.96.1475204070979; Thu, 29 Sep 2016 19:54:30 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.126]) by smtp.gmail.com with ESMTPSA id u72sm1698511wmu.10.2016.09.29.19.54.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2016 19:54:30 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 30 Sep 2016 04:54:28 +0200 Message-ID: <147520406887.22544.17860143561838604699.stgit@Solace.fritz.box> In-Reply-To: <147520253247.22544.10673844222866363947.stgit@Solace.fritz.box> References: <147520253247.22544.10673844222866363947.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Wei Liu , Ian Jackson , George Dunlap Subject: [Xen-devel] [PATCH v2 10/10] xl: allow to set the ratelimit value online for Credit2 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Last part of the wiring necessary for allowing to change the value of the ratelimit_us parameter online, for Credit2 (like it is already for Credit1). Signed-off-by: Dario Faggioli Reviewed-by: George Dunlap Acked-by: Ian Jackson --- Cc: Ian Jackson Cc: Wei Liu --- docs/man/xl.pod.1.in | 9 ++++ tools/libxl/xl_cmdimpl.c | 91 +++++++++++++++++++++++++++++++++++++-------- tools/libxl/xl_cmdtable.c | 2 + 3 files changed, 86 insertions(+), 16 deletions(-) diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in index a2be541..803c67e 100644 --- a/docs/man/xl.pod.1.in +++ b/docs/man/xl.pod.1.in @@ -1089,6 +1089,15 @@ to 65535 and the default is 256. Restrict output to domains in the specified cpupool. +=item B<-s>, B<--schedparam> + +Specify to list or set pool-wide scheduler parameters. + +=item B<-r RLIMIT>, B<--ratelimit_us=RLIMIT> + +Attempts to limit the rate of context switching. It is basically the same +as B<--ratelimit_us> in B + =back =item B [I] diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index cb43c00..b317dde 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -6457,8 +6457,29 @@ static int sched_credit_pool_output(uint32_t poolid) return 0; } -static int sched_credit2_domain_output( - int domid) +static int sched_credit2_params_set(int poolid, + libxl_sched_credit2_params *scinfo) +{ + if (libxl_sched_credit2_params_set(ctx, poolid, scinfo)) { + fprintf(stderr, "libxl_sched_credit2_params_set failed.\n"); + return 1; + } + + return 0; +} + +static int sched_credit2_params_get(int poolid, + libxl_sched_credit2_params *scinfo) +{ + if (libxl_sched_credit2_params_get(ctx, poolid, scinfo)) { + fprintf(stderr, "libxl_sched_credit2_params_get failed.\n"); + return 1; + } + + return 0; +} + +static int sched_credit2_domain_output(int domid) { char *domname; libxl_domain_sched_params scinfo; @@ -6483,6 +6504,22 @@ static int sched_credit2_domain_output( return 0; } +static int sched_credit2_pool_output(uint32_t poolid) +{ + libxl_sched_credit2_params scparam; + char *poolname = libxl_cpupoolid_to_name(ctx, poolid); + + if (sched_credit2_params_get(poolid, &scparam)) + printf("Cpupool %s: [sched params unavailable]\n", poolname); + else + printf("Cpupool %s: ratelimit=%dus\n", + poolname, scparam.ratelimit_us); + + free(poolname); + + return 0; +} + static int sched_rtds_domain_output( int domid) { @@ -6582,17 +6619,6 @@ static int sched_rtds_pool_output(uint32_t poolid) return 0; } -static int sched_default_pool_output(uint32_t poolid) -{ - char *poolname; - - poolname = libxl_cpupoolid_to_name(ctx, poolid); - printf("Cpupool %s:\n", - poolname); - free(poolname); - return 0; -} - static int sched_domain_output(libxl_scheduler sched, int (*output)(int), int (*pooloutput)(uint32_t), const char *cpupool) { @@ -6838,17 +6864,22 @@ int main_sched_credit2(int argc, char **argv) { const char *dom = NULL; const char *cpupool = NULL; + int ratelimit = 0; int weight = 256; + bool opt_s = false; + bool opt_r = false; bool opt_w = false; int opt, rc; static struct option opts[] = { {"domain", 1, 0, 'd'}, {"weight", 1, 0, 'w'}, + {"schedparam", 0, 0, 's'}, + {"ratelimit_us", 1, 0, 'r'}, {"cpupool", 1, 0, 'p'}, COMMON_LONG_OPTS }; - SWITCH_FOREACH_OPT(opt, "d:w:p:", opts, "sched-credit2", 0) { + SWITCH_FOREACH_OPT(opt, "d:w:p:r:s", opts, "sched-credit2", 0) { case 'd': dom = optarg; break; @@ -6856,6 +6887,13 @@ int main_sched_credit2(int argc, char **argv) weight = strtol(optarg, NULL, 10); opt_w = true; break; + case 's': + opt_s = true; + break; + case 'r': + ratelimit = strtol(optarg, NULL, 10); + opt_r = true; + break; case 'p': cpupool = optarg; break; @@ -6871,10 +6909,31 @@ int main_sched_credit2(int argc, char **argv) return EXIT_FAILURE; } - if (!dom) { /* list all domain's credit scheduler info */ + if (opt_s) { + libxl_sched_credit2_params scparam; + uint32_t poolid = 0; + + if (cpupool) { + if (libxl_cpupool_qualifier_to_cpupoolid(ctx, cpupool, + &poolid, NULL) || + !libxl_cpupoolid_is_valid(ctx, poolid)) { + fprintf(stderr, "unknown cpupool \'%s\'\n", cpupool); + return EXIT_FAILURE; + } + } + + if (!opt_r) { /* Output scheduling parameters */ + if (sched_credit2_pool_output(poolid)) + return EXIT_FAILURE; + } else { /* Set scheduling parameters (so far, just ratelimit) */ + scparam.ratelimit_us = ratelimit; + if (sched_credit2_params_set(poolid, &scparam)) + return EXIT_FAILURE; + } + } else if (!dom) { /* list all domain's credit scheduler info */ if (sched_domain_output(LIBXL_SCHEDULER_CREDIT2, sched_credit2_domain_output, - sched_default_pool_output, + sched_credit2_pool_output, cpupool)) return EXIT_FAILURE; } else { diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index 78786fe..5a57342 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -265,6 +265,8 @@ struct cmd_spec cmd_table[] = { "[-d [-w[=WEIGHT]]] [-p CPUPOOL]", "-d DOMAIN, --domain=DOMAIN Domain to modify\n" "-w WEIGHT, --weight=WEIGHT Weight (int)\n" + "-s --schedparam Query / modify scheduler parameters\n" + "-r RLIMIT, --ratelimit_us=RLIMIT Set the scheduling rate limit, in microseconds\n" "-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL" }, { "sched-rtds",