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

[Xen-devel] [RFC PATCH v2 5/7] Add cbs parameter support and removed sedf parameters with a LIBXL_API_VERSION gate from libxl.



From: Robbie VanVossen <robert.vanvossen@xxxxxxxxxxxxxxx>

We made an attempt at doing the versioning gate in this file.  Please let us
know if further changes are needed, and where they are needed to properly guard
the API.

Signed-off-by: Robert VanVossen <Robert.VanVossen@xxxxxxxxxxxxxxx>
Signed-off-by: Nathan Studer <nate.studer@xxxxxxxxx>

---
 docs/man/xl.cfg.pod.5       |    9 ++----
 tools/libxl/libxl.c         |   29 +++++++++++++++++++
 tools/libxl/libxl.h         |    1 +
 tools/libxl/libxl_create.c  |   61 ---------------------------------------
 tools/libxl/libxl_types.idl |    1 +
 tools/libxl/xl_cmdimpl.c    |   66 +++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/xl_cmdtable.c   |    5 ++++
 7 files changed, 104 insertions(+), 68 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
index a94d037..5c55298 100644
--- a/docs/man/xl.cfg.pod.5
+++ b/docs/man/xl.cfg.pod.5
@@ -212,14 +212,9 @@ The normal EDF scheduling usage in nanoseconds. it defines 
the time
 a domain get every period time.
 Honoured by the sedf scheduler.
 
-=item B<latency=N>
+=item B<soft=BOOLEAN>
 
-Scaled period if domain is doing heavy I/O.
-Honoured by the sedf scheduler.
-
-=item B<extratime=BOOLEAN>
-
-Flag for allowing domain to run in extra time.
+Flag for setting a domain or VCPU to run as a soft task.
 Honoured by the sedf scheduler.
 
 =back
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 900b8d4..ca8c1c5 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4932,13 +4932,21 @@ static int sched_sedf_domain_get(libxl__gc *gc, 
uint32_t domid,
 {
     uint64_t period;
     uint64_t slice;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     uint64_t latency;
     uint16_t extratime;
     uint16_t weight;
+#else
+    uint16_t soft;
+#endif
     int rc;
 
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     rc = xc_sedf_domain_get(CTX->xch, domid, &period, &slice, &latency,
                             &extratime, &weight);
+#else
+    rc = xc_sedf_domain_get(CTX->xch, domid, &period, &slice, &soft);
+#endif
     if (rc != 0) {
         LOGE(ERROR, "getting domain sched sedf");
         return ERROR_FAIL;
@@ -4948,9 +4956,13 @@ static int sched_sedf_domain_get(libxl__gc *gc, uint32_t 
domid,
     scinfo->sched = LIBXL_SCHEDULER_SEDF;
     scinfo->period = period / 1000000;
     scinfo->slice = slice / 1000000;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     scinfo->latency = latency / 1000000;
     scinfo->extratime = extratime;
     scinfo->weight = weight;
+#else
+    scinfo->soft = soft;
+#endif
 
     return 0;
 }
@@ -4960,14 +4972,22 @@ static int sched_sedf_domain_set(libxl__gc *gc, 
uint32_t domid,
 {
     uint64_t period;
     uint64_t slice;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     uint64_t latency;
     uint16_t extratime;
     uint16_t weight;
+#else
+    uint16_t soft;
+#endif
 
     int ret;
 
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     ret = xc_sedf_domain_get(CTX->xch, domid, &period, &slice, &latency,
                             &extratime, &weight);
+#else
+    ret = xc_sedf_domain_get(CTX->xch, domid, &period, &slice, &soft);
+#endif
     if (ret != 0) {
         LOGE(ERROR, "getting domain sched sedf");
         return ERROR_FAIL;
@@ -4977,15 +4997,24 @@ static int sched_sedf_domain_set(libxl__gc *gc, 
uint32_t domid,
         period = (uint64_t)scinfo->period * 1000000;
     if (scinfo->slice != LIBXL_DOMAIN_SCHED_PARAM_SLICE_DEFAULT)
         slice = (uint64_t)scinfo->slice * 1000000;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     if (scinfo->latency != LIBXL_DOMAIN_SCHED_PARAM_LATENCY_DEFAULT)
         latency = (uint64_t)scinfo->latency * 1000000;
     if (scinfo->extratime != LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT)
         extratime = scinfo->extratime;
     if (scinfo->weight != LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT)
         weight = scinfo->weight;
+#else
+    if (scinfo->soft != LIBXL_DOMAIN_SCHED_PARAM_SOFT_DEFAULT)
+        soft = scinfo->soft;
+#endif
 
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     ret = xc_sedf_domain_set(CTX->xch, domid, period, slice, latency,
                             extratime, weight);
+#else
+    ret = xc_sedf_domain_set(CTX->xch, domid, period, slice, soft);
+#endif
     if ( ret < 0 ) {
         LOGE(ERROR, "setting domain sched sedf");
         return ERROR_FAIL;
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 80947c3..eacd8f6 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1122,6 +1122,7 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, 
uint32_t poolid,
 #define LIBXL_DOMAIN_SCHED_PARAM_SLICE_DEFAULT     -1
 #define LIBXL_DOMAIN_SCHED_PARAM_LATENCY_DEFAULT   -1
 #define LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT -1
+#define LIBXL_DOMAIN_SCHED_PARAM_SOFT_DEFAULT      -1
 
 int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
                                   libxl_domain_sched_params *params);
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index d015cf4..83b593b 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -44,61 +44,6 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc,
     return 0;
 }
 
-static int sched_params_valid(libxl__gc *gc,
-                              uint32_t domid, libxl_domain_sched_params *scp)
-{
-    int has_weight = scp->weight != LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT;
-    int has_period = scp->period != LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT;
-    int has_slice = scp->slice != LIBXL_DOMAIN_SCHED_PARAM_SLICE_DEFAULT;
-    int has_extratime =
-                scp->extratime != LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT;
-
-    /* The sedf scheduler needs some more consistency checking */
-    if (libxl__domain_scheduler(gc, domid) == LIBXL_SCHEDULER_SEDF) {
-        if (has_weight && (has_period || has_slice))
-            return 0;
-        /* If you want a real-time domain, with its own period and
-         * slice, please, do provide both! */
-        if (has_period != has_slice)
-            return 0;
-
-        /*
-         * Idea is, if we specify a weight, then both period and
-         * slice has to be zero. OTOH, if we do specify a period and
-         * slice, it is weight that should be zeroed. See
-         * docs/misc/sedf_scheduler_mini-HOWTO.txt for more details
-         * on the meaningful combinations and their meanings.
-         */
-        if (has_weight) {
-            scp->slice = 0;
-            scp->period = 0;
-        }
-        else if (!has_period) {
-            /* No weight nor slice/period means best effort. Parameters needs
-             * some mangling in order to properly ask for that, though. */
-
-            /*
-             * Providing no weight does not make any sense if we do not allow
-             * the domain to run in extra time. On the other hand, if we have
-             * extra time, weight will be ignored (and zeroed) by Xen, but it
-             * can't be zero here, or the call for setting the scheduling
-             * parameters will fail. So, avoid the latter by setting a random
-             * weight (namely, 1), as it will be ignored anyway.
-             */
-
-            /* We can setup a proper best effort domain (extra time only)
-             * iff we either already have or are asking for some extra time. */
-            scp->weight = has_extratime ? scp->extratime : 1;
-            scp->period = 0;
-        } else {
-            /* Real-time domain: will get slice CPU time over every period */
-            scp->weight = 0;
-        }
-    }
-
-    return 1;
-}
-
 int libxl__domain_build_info_setdefault(libxl__gc *gc,
                                         libxl_domain_build_info *b_info)
 {
@@ -760,12 +705,6 @@ static void initiate_domain_create(libxl__egc *egc,
     ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info);
     if (ret) goto error_out;
 
-    if (!sched_params_valid(gc, domid, &d_config->b_info.sched_params)) {
-        LOG(ERROR, "Invalid scheduling parameters\n");
-        ret = ERROR_INVAL;
-        goto error_out;
-    }
-
     for (i = 0; i < d_config->num_disks; i++) {
         ret = libxl__device_disk_setdefault(gc, &d_config->disks[i]);
         if (ret) goto error_out;
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 52f1aa9..d02380e 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -294,6 +294,7 @@ libxl_domain_sched_params = Struct("domain_sched_params",[
     ("slice",        integer, {'init_val': 
'LIBXL_DOMAIN_SCHED_PARAM_SLICE_DEFAULT'}),
     ("latency",      integer, {'init_val': 
'LIBXL_DOMAIN_SCHED_PARAM_LATENCY_DEFAULT'}),
     ("extratime",    integer, {'init_val': 
'LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT'}),
+    ("soft",         integer, {'init_val': 
'LIBXL_DOMAIN_SCHED_PARAM_SOFT_DEFAULT'}),
     ])
 
 libxl_domain_build_info = Struct("domain_build_info",[
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 5195914..1f6f04b 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -838,10 +838,15 @@ static void parse_config_data(const char *config_source,
         b_info->sched_params.period = l;
     if (!xlu_cfg_get_long (config, "slice", &l, 0))
         b_info->sched_params.slice = l;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     if (!xlu_cfg_get_long (config, "latency", &l, 0))
         b_info->sched_params.latency = l;
     if (!xlu_cfg_get_long (config, "extratime", &l, 0))
         b_info->sched_params.extratime = l;
+#else
+    if (!xlu_cfg_get_long (config, "soft", &l, 0))
+        b_info->sched_params.soft = l;
+#endif
 
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
@@ -5181,14 +5186,20 @@ static int sched_sedf_domain_output(
     int rc;
 
     if (domid < 0) {
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
         printf("%-33s %4s %6s %-6s %7s %5s %6s\n", "Name", "ID", "Period",
                "Slice", "Latency", "Extra", "Weight");
+#else
+        printf("%-33s %4s %6s %-6s %5s\n", "Name", "ID", "Period",
+               "Slice", "Soft");
+#endif
         return 0;
     }
     rc = sched_domain_get(LIBXL_SCHEDULER_SEDF, domid, &scinfo);
     if (rc)
         return rc;
     domname = libxl_domid_to_name(ctx, domid);
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     printf("%-33s %4d %6d %6d %7d %5d %6d\n",
         domname,
         domid,
@@ -5197,6 +5208,14 @@ static int sched_sedf_domain_output(
         scinfo.latency,
         scinfo.extratime,
         scinfo.weight);
+#else
+    printf("%-33s %4d %6d %6d %5d\n",
+        domname,
+        domid,
+        scinfo.period,
+        scinfo.slice,
+        scinfo.soft);
+#endif
     free(domname);
     libxl_domain_sched_params_dispose(&scinfo);
     return 0;
@@ -5466,22 +5485,34 @@ int main_sched_sedf(int argc, char **argv)
     const char *cpupool = NULL;
     int period = 0, opt_p = 0;
     int slice = 0, opt_s = 0;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     int latency = 0, opt_l = 0;
     int extra = 0, opt_e = 0;
     int weight = 0, opt_w = 0;
+#else
+    int soft = 0, opt_t = 0;
+#endif
     int opt, rc;
     static struct option opts[] = {
         {"period", 1, 0, 'p'},
         {"slice", 1, 0, 's'},
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
         {"latency", 1, 0, 'l'},
         {"extra", 1, 0, 'e'},
         {"weight", 1, 0, 'w'},
+#else
+        {"soft", 1, 0, 't'},
+#endif
         {"cpupool", 1, 0, 'c'},
         COMMON_LONG_OPTS,
         {0, 0, 0, 0}
     };
 
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     SWITCH_FOREACH_OPT(opt, "d:p:s:l:e:w:c:h", opts, "sched-sedf", 0) {
+#else
+    SWITCH_FOREACH_OPT(opt, "d:p:s:t:c:h", opts, "sched-sedf", 0) {
+#endif
     case 'd':
         dom = optarg;
         break;
@@ -5493,6 +5524,7 @@ int main_sched_sedf(int argc, char **argv)
         slice = strtol(optarg, NULL, 10);
         opt_s = 1;
         break;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     case 'l':
         latency = strtol(optarg, NULL, 10);
         opt_l = 1;
@@ -5505,24 +5537,41 @@ int main_sched_sedf(int argc, char **argv)
         weight = strtol(optarg, NULL, 10);
         opt_w = 1;
         break;
+#else
+    case 't':
+        soft = strtol(optarg, NULL, 10);
+        opt_t = 1;
+        break;
+#endif
     case 'c':
         cpupool = optarg;
         break;
     }
 
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     if (cpupool && (dom || opt_p || opt_s || opt_l || opt_e || opt_w)) {
+#else
+    if (cpupool && (dom || opt_p || opt_s || opt_t)) {
+#endif
         fprintf(stderr, "Specifying a cpupool is not allowed with other "
                 "options.\n");
         return 1;
     }
+
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
     if (!dom && (opt_p || opt_s || opt_l || opt_e || opt_w)) {
+#else
+    if (!dom && (opt_p || opt_s || opt_t)) {
+#endif
         fprintf(stderr, "Must specify a domain.\n");
         return 1;
     }
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION > 0x040400
     if (opt_w && (opt_p || opt_s)) {
         fprintf(stderr, "Specifying a weight AND period or slice is not "
                 "allowed.\n");
     }
+#endif
 
     if (!dom) { /* list all domain's credit scheduler info */
         return -sched_domain_output(LIBXL_SCHEDULER_SEDF,
@@ -5532,7 +5581,11 @@ int main_sched_sedf(int argc, char **argv)
     } else {
         uint32_t domid = find_domain(dom);
 
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
         if (!opt_p && !opt_s && !opt_l && !opt_e && !opt_w) {
+#else
+        if (!opt_p && !opt_s) {
+#endif
             /* output sedf scheduler info */
             sched_sedf_domain_output(-1);
             return -sched_sedf_domain_output(domid);
@@ -5541,6 +5594,8 @@ int main_sched_sedf(int argc, char **argv)
             libxl_domain_sched_params_init(&scinfo);
             scinfo.sched = LIBXL_SCHEDULER_SEDF;
 
+
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
             if (opt_p) {
                 scinfo.period = period;
                 scinfo.weight = 0;
@@ -5558,6 +5613,17 @@ int main_sched_sedf(int argc, char **argv)
                 scinfo.period = 0;
                 scinfo.slice = 0;
             }
+#else
+            if (opt_p) {
+                scinfo.period = period;
+            }
+            if (opt_s) {
+                scinfo.slice = slice;
+            }
+            if (opt_t) {
+                scinfo.soft = soft;
+            }
+#endif
             rc = sched_domain_set(domid, &scinfo);
             libxl_domain_sched_params_dispose(&scinfo);
             if (rc)
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index 4279b9f..7f0aca4 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -269,12 +269,17 @@ struct cmd_spec cmd_table[] = {
       "-p MS, --period=MS             Relative deadline(ms)\n"
       "-s MS, --slice=MS              Worst-case execution time(ms).\n"
       "                               (slice < period)\n"
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION <= 0x040400
       "-l MS, --latency=MS            Scaled period (ms) when domain\n"
       "                               performs heavy I/O\n"
       "-e FLAG, --extra=FLAG          Flag (0 or 1) controls if domain\n"
       "                               can run in extra time\n"
       "-w FLOAT, --weight=FLOAT       CPU Period/slice (do not set with\n"
       "                               --period/--slice)\n"
+#else
+      "-t FLAG, --soft=FLAG           Flag (0 or 1) controls if domain\n"
+      "                               can run as a soft task\n"
+#endif
       "-c CPUPOOL, --cpupool=CPUPOOL  Restrict output to CPUPOOL"
     },
     { "domid",
-- 
1.7.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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