From patchwork Fri Sep 30 02:54:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9357471 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 D416B6077A for ; Fri, 30 Sep 2016 02:56:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8D3429D3E for ; Fri, 30 Sep 2016 02:56:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDA9129D43; Fri, 30 Sep 2016 02:56:37 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 301EE29D3E for ; Fri, 30 Sep 2016 02:56:37 +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 1bpny0-0002Eu-Uc; Fri, 30 Sep 2016 02:54:28 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpnxz-0002E2-Pl for xen-devel@lists.xenproject.org; Fri, 30 Sep 2016 02:54:27 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 31/63-03281-3E3DDE75; Fri, 30 Sep 2016 02:54:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHIsWRWlGSWpSXmKPExsXiVRvkqPvg8tt wg/1LuS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oz7++4yFuzWqdi8fhZzA+NtpS5GLg4hgRmM EpuOzWTuYuTkYBFYwyqxcxMHSEJC4BKrxMn39xhBEhICMRL3my5D2dUSX5c+AWsQElCRuLl9F RPEpF+MEq1//7KAJIQF9CSOHP3BDmGHSqyd3AnWwCZgIPFmx15WEFtEQEni3qrJTCA2s0CFxI qXN5ggrlCV2H9tIhuIzSvgLTHvSDuYzSngK/Fr2wsWiMU+Er+XLweLiwrISay83MIKUS8ocXL mE6AaDqCZmhLrd+lDjJeX2P52DvMERpFZSKpmIVTNQlK1gJF5FaNGcWpRWWqRrpGxXlJRZnpG SW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGYPjXMzAw7mDs2+t3iFGSg0lJlFf26NtwIb6k/ JTKjMTijPii0pzU4kOMGhwcAhPOzp3OJMWSl5+XqiTBu/YSUJ1gUWp6akVaZg4wQmFKJTh4lE R4FYBRKsRbXJCYW5yZDpE6xajLsWXqvbVMQmAzpMR5m0BmCIAUZZTmwY2AJYtLjLJSwryMDAw MQjwFqUW5mSWo8q8YxTkYlYR5P4FM4cnMK4Hb9AroCCagI/KPvgE5oiQRISXVwCijV3nNiUlS eTvLEpGyVfmyM4W5YpY697Du+MUb9Thds0gxddFx/QLpBxfkpzBs2Lxuc4Wl+ulpX2xXLdfTX PZRe4P5y19Z9Ru2FpfsvRVQ4nR0TjXD7f36Oqu5Gtg+/v0pVfLEYOfkzt51Yuv9G0xs4+rV1r PMf7h+Z9Lar4JTBGaI5PXbOCuxFGckGmoxFxUnAgD5E/eAEQMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1475204064!8133607!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28122 invoked from network); 30 Sep 2016 02:54:24 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-9.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 30 Sep 2016 02:54:24 -0000 Received: by mail-wm0-f65.google.com with SMTP id p138so1405790wmb.0 for ; Thu, 29 Sep 2016 19:54:24 -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=C25UIz5xCklT7QHLh+DHf9goE13wA+89d4SXu6Ajo3I=; b=bYiaCTZno46fTl11I7A6xgndHk+qxa2yqW8e0h5mT0+Wc4iF04Nv9r50IIGHQ/BwIT 7L01nBkiz1QXh0paR2ETMBowtobeugNWUPGIZ35byPaWPUFOhNvRhZ1scJpb1nkUD+Eg cVbdLhWQXMg8IDp6c6MTAUyC5yIpU6NxgnyqRD8BjyH74Iw4Gy3V5suhbtHRRcl30ai+ CCr5zA5kh28FZvQR6ClynD5VcExzYBlXd4/yFOXAVryZ++XcIOYWBYifzQVeyQuyDnkY JtHq29RD/v6bZmm+J1bG5aOQ2lkqF4/Vkd410BpbuTUkeJAk7jISTZkVaqAkxwELwZnM MBOw== 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=C25UIz5xCklT7QHLh+DHf9goE13wA+89d4SXu6Ajo3I=; b=m6zBs3FDtMquvNtf45piv6D7nBCoXe5/A4XnneUFHPrC4LfXxofpU4PehL5tqDmO+I dO06DPw7/o0gmh7fIlKsDV9f2pm3dAKRSVdDKzy97aUdFEC/2ofJJpphaHwQCc/DvGhi H7QJlurII5bybQPlPLeU/EQW2NMbS6mRAcSQ9VVBoW6In78EhH+TB+vdDMBJkxUDttSN pgn4Mip6a1XPNC/GEMHLUxOBZZBackDho9OfTkoe/yJ2H4YDNV+mrSED/8LBMUTPeVAg MI2z9A9i+o29l/xKF7wFvTARK05NIuY5JSLDapjh8NiMLY4c95mY8Bt1kjwkXc9ZNQmh L4fQ== X-Gm-Message-State: AA6/9RmJpTTn4J8IQbFo/asAjpcuAGMWUOjHCH16WOlTq0/tW9qoKdl107g7/5KAdE+5xw== X-Received: by 10.194.103.138 with SMTP id fw10mr4034259wjb.93.1475204063775; Thu, 29 Sep 2016 19:54:23 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.126]) by smtp.gmail.com with ESMTPSA id w203sm1702779wmw.7.2016.09.29.19.54.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2016 19:54:23 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 30 Sep 2016 04:54:21 +0200 Message-ID: <147520406186.22544.1059342691539063899.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: George Dunlap , Wei Liu , Ian Jackson Subject: [Xen-devel] [PATCH v2 09/10] libxl: 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 This is the remaining part of the plumbing (the libxl one) necessary to be able to change the value of the ratelimit_us parameter online, for Credit2 (like it is already for Credit1). Note that, so far, we were rejecting (for Credit1) a new value of zero, despite it is a pretty nice way to ask for the rate limiting to be disabled, and the hypervisor is already capable of dealing with it in that way. Therefore, we change things so that it is possible to do so, both for Credit1 and Credit2 Signed-off-by: Dario Faggioli --- Cc: Ian Jackson Cc: Wei Liu Cc: George Dunlap --- Changes from v1: * added the appropriate LIBXL_HAVE_, as requested during review. * coding style fixes put in previous patch, as requested during review. --- tools/libxl/libxl.c | 71 ++++++++++++++++++++++++++++++++++++++++--- tools/libxl/libxl.h | 11 +++++++ tools/libxl/libxl_types.idl | 4 ++ 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 606d71a..5a70564 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5229,6 +5229,19 @@ static int sched_credit_domain_set(libxl__gc *gc, uint32_t domid, return 0; } +static int sched_ratelimit_check(libxl__gc *gc, int ratelimit) +{ + if (ratelimit != 0 && + (ratelimit < XEN_SYSCTL_SCHED_RATELIMIT_MIN || + ratelimit > XEN_SYSCTL_SCHED_RATELIMIT_MAX)) { + LOG(ERROR, "Ratelimit out of range, valid range is from %d to %d", + XEN_SYSCTL_SCHED_RATELIMIT_MIN, XEN_SYSCTL_SCHED_RATELIMIT_MAX); + return ERROR_INVAL; + } + + return 0; +} + int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid, libxl_sched_credit_params *scinfo) { @@ -5266,11 +5279,8 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid, rc = ERROR_INVAL; goto out; } - if (scinfo->ratelimit_us < XEN_SYSCTL_SCHED_RATELIMIT_MIN - || scinfo->ratelimit_us > XEN_SYSCTL_SCHED_RATELIMIT_MAX) { - LOG(ERROR, "Ratelimit out of range, valid range is from %d to %d", - XEN_SYSCTL_SCHED_RATELIMIT_MIN, XEN_SYSCTL_SCHED_RATELIMIT_MAX); - rc = ERROR_INVAL; + rc = sched_ratelimit_check(gc, scinfo->ratelimit_us); + if (rc) { goto out; } if (scinfo->ratelimit_us > scinfo->tslice_ms*1000) { @@ -5297,6 +5307,57 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid, return rc; } +int libxl_sched_credit2_params_get(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_credit2_params *scinfo) +{ + struct xen_sysctl_credit2_schedule sparam; + int r, rc; + GC_INIT(ctx); + + r = xc_sched_credit2_params_get(ctx->xch, poolid, &sparam); + if (r < 0) { + LOGE(ERROR, "getting Credit2 scheduler parameters"); + rc = ERROR_FAIL; + goto out; + } + + scinfo->ratelimit_us = sparam.ratelimit_us; + + rc = 0; + out: + GC_FREE; + return rc; +} + + +int libxl_sched_credit2_params_set(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_credit2_params *scinfo) +{ + struct xen_sysctl_credit2_schedule sparam; + int r, rc; + GC_INIT(ctx); + + rc = sched_ratelimit_check(gc, scinfo->ratelimit_us); + if (rc) { + goto out; + } + + sparam.ratelimit_us = scinfo->ratelimit_us; + + r = xc_sched_credit2_params_set(ctx->xch, poolid, &sparam); + if ( r < 0 ) { + LOGE(ERROR, "Setting Credit2 scheduler parameters"); + rc = ERROR_FAIL; + goto out; + } + + scinfo->ratelimit_us = sparam.ratelimit_us; + + out: + GC_FREE; + return rc; +} + static int sched_credit2_domain_get(libxl__gc *gc, uint32_t domid, libxl_domain_sched_params *scinfo) { diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 7cfa540..969a089 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -281,6 +281,13 @@ #define LIBXL_HAVE_QEMU_MONITOR_COMMAND 1 /* + * LIBXL_HAVE_SCHED_CREDIT2_PARAMS indicates the existance of a + * libxl_sched_credit2_params structure, containing Credit2 scheduler + * wide parameters (i.e., the ratelimiting value). + */ +#define LIBXL_HAVE_SCHED_CREDIT2_PARAMS 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility @@ -1992,6 +1999,10 @@ int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid, libxl_sched_credit_params *scinfo); int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid, libxl_sched_credit_params *scinfo); +int libxl_sched_credit2_params_get(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_credit2_params *scinfo); +int libxl_sched_credit2_params_set(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_credit2_params *scinfo); /* Scheduler Per-domain parameters */ diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 98bfc3a..de5996e 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -834,6 +834,10 @@ libxl_sched_credit_params = Struct("sched_credit_params", [ ("ratelimit_us", integer), ], dispose_fn=None) +libxl_sched_credit2_params = Struct("sched_credit2_params", [ + ("ratelimit_us", integer), + ], dispose_fn=None) + libxl_domain_remus_info = Struct("domain_remus_info",[ ("interval", integer), ("allow_unsafe", libxl_defbool),