xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add xl sched-credit2 sub command
@ 2011-11-14 14:05 Juergen Gross
  2011-11-17  5:52 ` Juergen Gross
  2011-11-24 16:38 ` Ian Jackson
  0 siblings, 2 replies; 3+ messages in thread
From: Juergen Gross @ 2011-11-14 14:05 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 454 bytes --]

Adds the sched-credit2 sub command to xl.

Signed-off-by: juergen.gross@ts.fujitsu.com


7 files changed, 184 insertions(+)
docs/man/xl.pod.1           |   20 ++++++++
tools/libxl/libxl.c         |   48 ++++++++++++++++++++
tools/libxl/libxl.h         |    4 +
tools/libxl/libxl_types.idl |    4 +
tools/libxl/xl.h            |    1 
tools/libxl/xl_cmdimpl.c    |  100 +++++++++++++++++++++++++++++++++++++++++++
tools/libxl/xl_cmdtable.c   |    7 +++



[-- Attachment #2: xen-staging.hg.patch --]
[-- Type: text/x-patch, Size: 8589 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1321279498 -3600
# Node ID 123596ca8b29d3fd992284b3cbe31a3f28da56e5
# Parent  0844b17df7a9dd885e98e505f14fc99c1951b483
add xl sched-credit2 sub command

Adds the sched-credit2 sub command to xl.

Signed-off-by: juergen.gross@ts.fujitsu.com

diff -r 0844b17df7a9 -r 123596ca8b29 docs/man/xl.pod.1
--- a/docs/man/xl.pod.1	Fri Nov 11 18:14:35 2011 +0000
+++ b/docs/man/xl.pod.1	Mon Nov 14 15:04:58 2011 +0100
@@ -607,6 +607,26 @@ no upper cap.
 
 =back
 
+=item B<sched-credit2> [ B<-d> I<domain-id> [ B<-w>[B<=>I<WEIGHT>] ] ]
+
+Set 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<PARAMETERS>
+
+=over 4
+
+=item I<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.
+
+=back
+
 =back
 
 =head1 CPUPOOLS COMMANDS
diff -r 0844b17df7a9 -r 123596ca8b29 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri Nov 11 18:14:35 2011 +0000
+++ b/tools/libxl/libxl.c	Mon Nov 14 15:04:58 2011 +0100
@@ -2728,6 +2728,54 @@ int libxl_sched_credit_domain_set(libxl_
     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, "setting 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 0844b17df7a9 -r 123596ca8b29 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Fri Nov 11 18:14:35 2011 +0000
+++ b/tools/libxl/libxl.h	Mon Nov 14 15:04:58 2011 +0100
@@ -567,6 +567,10 @@ int libxl_sched_credit_domain_get(libxl_
                                   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 0844b17df7a9 -r 123596ca8b29 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Fri Nov 11 18:14:35 2011 +0000
+++ b/tools/libxl/libxl_types.idl	Mon Nov 14 15:04:58 2011 +0100
@@ -372,3 +372,7 @@ libxl_sched_credit = Struct("sched_credi
     ("weight", integer),
     ("cap", integer),
     ], dispose_fn=None)
+
+libxl_sched_credit2 = Struct("sched_credit2", [
+    ("weight", integer),
+    ], dispose_fn=None)
diff -r 0844b17df7a9 -r 123596ca8b29 tools/libxl/xl.h
--- a/tools/libxl/xl.h	Fri Nov 11 18:14:35 2011 +0000
+++ b/tools/libxl/xl.h	Mon Nov 14 15:04:58 2011 +0100
@@ -55,6 +55,7 @@ int main_memmax(int argc, char **argv);
 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 0844b17df7a9 -r 123596ca8b29 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri Nov 11 18:14:35 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Mon Nov 14 15:04:58 2011 +0100
@@ -3708,6 +3708,42 @@ static void sched_credit_domain_output(
     free(domname);
 }
 
+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 void sched_credit2_domain_output(
+    int domid, libxl_sched_credit2 *scinfo)
+{
+    char *domname;
+    domname = libxl_domid_to_name(ctx, domid);
+    printf("%-33s %4d %6d\n",
+        domname,
+        domid,
+        scinfo->weight);
+    free(domname);
+}
+
 int main_sched_credit(int argc, char **argv)
 {
     libxl_dominfo *info;
@@ -3770,6 +3806,70 @@ int main_sched_credit(int argc, char **a
             if (opt_c)
                 scinfo.cap = cap;
             rc = sched_credit_domain_set(domid, &scinfo);
+            if (rc)
+                return -rc;
+        }
+    }
+
+    return 0;
+}
+
+int main_sched_credit2(int argc, char **argv)
+{
+    libxl_dominfo *info;
+    libxl_sched_credit2 scinfo;
+    int nb_domain, i;
+    const char *dom = NULL;
+    int weight = 256, opt_w = 0;
+    int opt, rc;
+
+    while ((opt = def_getopt(argc, argv, "d:w:", "sched-credit2", 0)) != -1) {
+        switch (opt) {
+        case 0: case 2:
+            return opt;
+        case 'd':
+            dom = optarg;
+            break;
+        case 'w':
+            weight = strtol(optarg, NULL, 10);
+            opt_w = 1;
+            break;
+        }
+    }
+
+    if (!dom && opt_w) {
+        fprintf(stderr, "Must specify a domain.\n");
+        return 1;
+    }
+
+    if (!dom) { /* list all domain's credit scheduler info */
+        info = libxl_list_domain(ctx, &nb_domain);
+        if (!info) {
+            fprintf(stderr, "libxl_domain_infolist failed.\n");
+            return 1;
+        }
+
+        printf("%-33s %4s %6s\n", "Name", "ID", "Weight");
+        for (i = 0; i < nb_domain; i++) {
+            rc = sched_credit2_domain_get(info[i].domid, &scinfo);
+            if (rc)
+                return -rc;
+            sched_credit2_domain_output(info[i].domid, &scinfo);
+        }
+    } else {
+        find_domain(dom);
+
+        rc = sched_credit2_domain_get(domid, &scinfo);
+        if (rc)
+            return -rc;
+
+        if (!opt_w) { /* output credit2 scheduler info */
+            printf("%-33s %4s %6s\n", "Name", "ID", "Weight");
+            sched_credit2_domain_output(domid, &scinfo);
+        } else { /* set credit scheduler paramaters */
+            if (opt_w)
+                scinfo.weight = weight;
+            rc = sched_credit2_domain_set(domid, &scinfo);
             if (rc)
                 return -rc;
         }
diff -r 0844b17df7a9 -r 123596ca8b29 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Fri Nov 11 18:14:35 2011 +0000
+++ b/tools/libxl/xl_cmdtable.c	Mon Nov 14 15:04:58 2011 +0100
@@ -196,6 +196,13 @@ struct cmd_spec cmd_table[] = {
       "-d DOMAIN, --domain=DOMAIN     Domain to modify\n"
       "-w WEIGHT, --weight=WEIGHT     Weight (int)\n"
       "-c CAP, --cap=CAP              Cap (int)"
+    },
+    { "sched-credit2",
+      &main_sched_credit2, 0,
+      "Get/set credit2 scheduler parameters",
+      "[-d <Domain> [-w[=WEIGHT]]]",
+      "-d DOMAIN, --domain=DOMAIN     Domain to modify\n"
+      "-w WEIGHT, --weight=WEIGHT     Weight (int)"
     },
     { "domid",
       &main_domid, 0,

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

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

* Re: [PATCH] add xl sched-credit2 sub command
  2011-11-14 14:05 [PATCH] add xl sched-credit2 sub command Juergen Gross
@ 2011-11-17  5:52 ` Juergen Gross
  2011-11-24 16:38 ` Ian Jackson
  1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2011-11-17  5:52 UTC (permalink / raw)
  To: xen-devel

On 11/14/2011 03:05 PM, Juergen Gross wrote:
> Adds the sched-credit2 sub command to xl.
>
> Signed-off-by: juergen.gross@ts.fujitsu.com

Long options are missing (I just copied it from sched-credit).

I'll repost a revised version of this patch as part of a series including
support of cpupools and sched-sedf.


Juergen

-- 
Juergen Gross                 Principal Developer Operating Systems
PDG ES&S SWE OS6                       Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions              e-mail: juergen.gross@ts.fujitsu.com
Domagkstr. 28                           Internet: ts.fujitsu.com
D-80807 Muenchen                 Company details: ts.fujitsu.com/imprint.html

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

* Re: [PATCH] add xl sched-credit2 sub command
  2011-11-14 14:05 [PATCH] add xl sched-credit2 sub command Juergen Gross
  2011-11-17  5:52 ` Juergen Gross
@ 2011-11-24 16:38 ` Ian Jackson
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Jackson @ 2011-11-24 16:38 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel

Juergen Gross writes ("[Xen-devel] [PATCH] add xl sched-credit2 sub command"):
> Adds the sched-credit2 sub command to xl.

Thanks, this looks like good stuff.

I have just one comment though.  Can you try to limit the length of
the lines ?  When I see them in my 80-column windows they wrap.  Try
to keep it to 70-75 columns to allow for quoting, +/- prefixes, etc.

Thanks,
Ian.

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

end of thread, other threads:[~2011-11-24 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14 14:05 [PATCH] add xl sched-credit2 sub command Juergen Gross
2011-11-17  5:52 ` Juergen Gross
2011-11-24 16:38 ` Ian Jackson

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