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

[Xen-changelog] [xen-unstable] Support of xl sched-credit2



# HG changeset patch
# User Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
# Date 1322483487 -3600
# Node ID a24347b2e65b6357213ed8362fb566d73b3142b7
# Parent  9aaa11d5fab3a47d545a07797e80f7cb5ff7b57e
Support of xl sched-credit2

Supports the xl subcommand sched-credit2.

Signed-off-by: juergen.gross@xxxxxxxxxxxxxx
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---


diff -r 9aaa11d5fab3 -r a24347b2e65b docs/man/xl.pod.1
--- a/docs/man/xl.pod.1 Mon Nov 28 13:27:15 2011 +0100
+++ b/docs/man/xl.pod.1 Mon Nov 28 13:31:27 2011 +0100
@@ -676,6 +676,35 @@
 
 =back
 
+=item B<sched-credit2> [I<OPTIONS>]
+
+Set or get credit2 scheduler parameters.  The credit2 scheduler is a
+proportional fair share CPU scheduler built from the ground up to be
+work conserving on SMP hosts.
+
+Each domain (including Domain0) is assigned a weight.
+
+B<OPTIONS>
+
+=over 4
+
+=item B<-d DOMAIN>, B<--domain=DOMAIN>
+
+Specify domain for which scheduler parameters are to be modified or retrieved.
+Mandatory for modifying scheduler parameters.
+
+=item B<-w WEIGHT>, B<--weight=WEIGHT>
+
+A domain with a weight of 512 will get twice as much CPU as a domain
+with a weight of 256 on a contended host. Legal weights range from 1
+to 65535 and the default is 256.
+
+=item B<-p CPUPOOL>, B<--cpupool=CPUPOOL>
+
+Restrict output to domains in the specified cpupool.
+
+=back
+
 =back
 
 =head1 CPUPOOLS COMMANDS
diff -r 9aaa11d5fab3 -r a24347b2e65b tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Nov 28 13:27:15 2011 +0100
+++ b/tools/libxl/libxl.c       Mon Nov 28 13:31:27 2011 +0100
@@ -2729,6 +2729,59 @@
     return 0;
 }
 
+int libxl_sched_credit2_domain_get(libxl_ctx *ctx, uint32_t domid,
+                                   libxl_sched_credit2 *scinfo)
+{
+    struct xen_domctl_sched_credit2 sdom;
+    int rc;
+
+    rc = xc_sched_credit2_domain_get(ctx->xch, domid, &sdom);
+    if (rc != 0) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
+                         "getting domain sched credit2");
+        return ERROR_FAIL;
+    }
+
+    scinfo->weight = sdom.weight;
+
+    return 0;
+}
+
+int libxl_sched_credit2_domain_set(libxl_ctx *ctx, uint32_t domid,
+                                   libxl_sched_credit2 *scinfo)
+{
+    struct xen_domctl_sched_credit2 sdom;
+    xc_domaininfo_t domaininfo;
+    int rc;
+
+    rc = xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo);
+    if (rc < 0) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
+        return ERROR_FAIL;
+    }
+    if (rc != 1 || domaininfo.domain != domid)
+        return ERROR_INVAL;
+
+
+    if (scinfo->weight < 1 || scinfo->weight > 65535) {
+        LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
+            "Cpu weight out of range, valid values are within range from "
+            "1 to 65535");
+        return ERROR_INVAL;
+    }
+
+    sdom.weight = scinfo->weight;
+
+    rc = xc_sched_credit2_domain_set(ctx->xch, domid, &sdom);
+    if ( rc < 0 ) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
+                         "setting domain sched credit2");
+        return ERROR_FAIL;
+    }
+
+    return 0;
+}
+
 static int trigger_type_from_string(char *trigger_name)
 {
     if (!strcmp(trigger_name, "nmi"))
diff -r 9aaa11d5fab3 -r a24347b2e65b tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Mon Nov 28 13:27:15 2011 +0100
+++ b/tools/libxl/libxl.h       Mon Nov 28 13:31:27 2011 +0100
@@ -567,6 +567,10 @@
                                   libxl_sched_credit *scinfo);
 int libxl_sched_credit_domain_set(libxl_ctx *ctx, uint32_t domid,
                                   libxl_sched_credit *scinfo);
+int libxl_sched_credit2_domain_get(libxl_ctx *ctx, uint32_t domid,
+                                   libxl_sched_credit2 *scinfo);
+int libxl_sched_credit2_domain_set(libxl_ctx *ctx, uint32_t domid,
+                                   libxl_sched_credit2 *scinfo);
 int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
                        char *trigger_name, uint32_t vcpuid);
 int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq);
diff -r 9aaa11d5fab3 -r a24347b2e65b tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl       Mon Nov 28 13:27:15 2011 +0100
+++ b/tools/libxl/libxl_types.idl       Mon Nov 28 13:31:27 2011 +0100
@@ -382,3 +382,7 @@
     ("weight", integer),
     ("cap", integer),
     ], dispose_fn=None)
+
+libxl_sched_credit2 = Struct("sched_credit2", [
+    ("weight", integer),
+    ], dispose_fn=None)
diff -r 9aaa11d5fab3 -r a24347b2e65b tools/libxl/xl.h
--- a/tools/libxl/xl.h  Mon Nov 28 13:27:15 2011 +0100
+++ b/tools/libxl/xl.h  Mon Nov 28 13:31:27 2011 +0100
@@ -55,6 +55,7 @@
 int main_memmax(int argc, char **argv);
 int main_memset(int argc, char **argv);
 int main_sched_credit(int argc, char **argv);
+int main_sched_credit2(int argc, char **argv);
 int main_domid(int argc, char **argv);
 int main_domname(int argc, char **argv);
 int main_rename(int argc, char **argv);
diff -r 9aaa11d5fab3 -r a24347b2e65b tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Mon Nov 28 13:27:15 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Mon Nov 28 13:31:27 2011 +0100
@@ -3807,6 +3807,53 @@
     return 0;
 }
 
+static int sched_credit2_domain_get(
+    int domid, libxl_sched_credit2 *scinfo)
+{
+    int rc;
+
+    rc = libxl_sched_credit2_domain_get(ctx, domid, scinfo);
+    if (rc)
+        fprintf(stderr, "libxl_sched_credit2_domain_get failed.\n");
+
+    return rc;
+}
+
+static int sched_credit2_domain_set(
+    int domid, libxl_sched_credit2 *scinfo)
+{
+    int rc;
+
+    rc = libxl_sched_credit2_domain_set(ctx, domid, scinfo);
+    if (rc)
+        fprintf(stderr, "libxl_sched_credit2_domain_set failed.\n");
+
+    return rc;
+}
+
+static int sched_credit2_domain_output(
+    int domid)
+{
+    char *domname;
+    libxl_sched_credit2 scinfo;
+    int rc;
+
+    if (domid < 0) {
+        printf("%-33s %4s %6s\n", "Name", "ID", "Weight");
+        return 0;
+    }
+    rc = sched_credit2_domain_get(domid, &scinfo);
+    if (rc)
+        return rc;
+    domname = libxl_domid_to_name(ctx, domid);
+    printf("%-33s %4d %6d\n",
+        domname,
+        domid,
+        scinfo.weight);
+    free(domname);
+    return 0;
+}
+
 static int sched_domain_output(
     uint32_t sched, int (*output)(int), const char *cpupool)
 {
@@ -3944,6 +3991,80 @@
     return 0;
 }
 
+int main_sched_credit2(int argc, char **argv)
+{
+    libxl_sched_credit2 scinfo;
+    const char *dom = NULL;
+    const char *cpupool = NULL;
+    int weight = 256, opt_w = 0;
+    int opt, rc;
+    int option_index = 0;
+    static struct option long_options[] = {
+        {"domain", 1, 0, 'd'},
+        {"weight", 1, 0, 'w'},
+        {"cpupool", 1, 0, 'p'},
+        {"help", 0, 0, 'h'},
+        {0, 0, 0, 0}
+    };
+
+    while (1) {
+        opt = getopt_long(argc, argv, "d:w:p:h", long_options, &option_index);
+        if (opt == -1)
+            break;
+        switch (opt) {
+        case 0: case 2:
+            return opt;
+        case 'd':
+            dom = optarg;
+            break;
+        case 'w':
+            weight = strtol(optarg, NULL, 10);
+            opt_w = 1;
+            break;
+        case 'p':
+            cpupool = optarg;
+            break;
+        case 'h':
+            help("sched-credit");
+            return 0;
+        }
+    }
+
+    if (cpupool && (dom || opt_w)) {
+        fprintf(stderr, "Specifying a cpupool is not allowed with other "
+                "options.\n");
+        return 1;
+    }
+    if (!dom && opt_w) {
+        fprintf(stderr, "Must specify a domain.\n");
+        return 1;
+    }
+
+    if (!dom) { /* list all domain's credit scheduler info */
+        return -sched_domain_output(XEN_SCHEDULER_CREDIT2,
+                                    sched_credit2_domain_output, cpupool);
+    } else {
+        find_domain(dom);
+
+        rc = sched_credit2_domain_get(domid, &scinfo);
+        if (rc)
+            return -rc;
+
+        if (!opt_w) { /* output credit2 scheduler info */
+            sched_credit2_domain_output(-1);
+            return -sched_credit2_domain_output(domid);
+        } else { /* set credit2 scheduler paramaters */
+            if (opt_w)
+                scinfo.weight = weight;
+            rc = sched_credit2_domain_set(domid, &scinfo);
+            if (rc)
+                return -rc;
+        }
+    }
+
+    return 0;
+}
+
 int main_domid(int argc, char **argv)
 {
     int opt;
diff -r 9aaa11d5fab3 -r a24347b2e65b tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Mon Nov 28 13:27:15 2011 +0100
+++ b/tools/libxl/xl_cmdtable.c Mon Nov 28 13:31:27 2011 +0100
@@ -198,6 +198,14 @@
       "-c CAP, --cap=CAP              Cap (int)\n"
       "-p CPUPOOL, --cpupool=CPUPOOL  Restrict output to CPUPOOL"
     },
+    { "sched-credit2",
+      &main_sched_credit2, 0,
+      "Get/set credit2 scheduler parameters",
+      "[-d <Domain> [-w[=WEIGHT]]] [-p CPUPOOL]",
+      "-d DOMAIN, --domain=DOMAIN     Domain to modify\n"
+      "-w WEIGHT, --weight=WEIGHT     Weight (int)\n"
+      "-p CPUPOOL, --cpupool=CPUPOOL  Restrict output to CPUPOOL"
+    },
     { "domid",
       &main_domid, 0,
       "Convert a domain name to domain id",

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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