xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <raistlin@linux.it>
To: xen-devel@lists.xen.org
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
	Juergen Gross <juergen.gross@ts.fujitsu.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>
Subject: [PATCH 2 of 2 v2] xl: check for meaningful combination of sedf config file parameters
Date: Thu, 07 Jun 2012 15:42:33 +0200	[thread overview]
Message-ID: <2a35be0bef3f16b8f136.1339076553@Solace> (raw)
In-Reply-To: <patchbomb.1339076551@Solace>

As it happens in the implementation of `xl sched-sedf -d ...', some
consistency checking is needed for the scheduling parameters when
they come from the config file.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -550,6 +550,31 @@ vcpp_out:
     return rc;
 }
 
+static int sched_params_valid(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;
+    libxl_domain_sched_params sci;
+
+    libxl_domain_sched_params_get(ctx, domid, &sci);
+
+    /* The sedf scheduler needs some more consistency checking */
+    if (sci.sched == LIBXL_SCHEDULER_SEDF) {
+        if (has_weight && (has_period || has_slice))
+            return 0;
+
+        if (has_weight) {
+            scp->slice = 0;
+            scp->period = 0;
+        }
+        if (has_period || has_slice)
+            scp->weight = 0;
+    }
+
+    return 1;
+}
+
 static void parse_config_data(const char *config_source,
                               const char *config_data,
                               int config_len,
@@ -644,6 +669,10 @@ static void parse_config_data(const char
         b_info->sched_params.latency = l;
     if (!xlu_cfg_get_long (config, "extratime", &l, 0))
         b_info->sched_params.extratime = l;
+    if (!sched_params_valid(&b_info->sched_params)) {
+        fprintf(stderr, "Invalid scheduling parameters\n");
+        exit(1);
+    }
 
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;

      parent reply	other threads:[~2012-06-07 13:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-07 13:42 [PATCH 0 of 2 v2] Sanity checking of scheduling parameters Dario Faggioli
2012-06-07 13:42 ` [PATCH 1 of 2 v2] libxl: propagete down the error from libxl_domain_sched_params_set Dario Faggioli
2012-06-07 16:41   ` Ian Jackson
2012-06-08  8:57     ` Dario Faggioli
2012-06-07 13:42 ` Dario Faggioli [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a35be0bef3f16b8f136.1339076553@Solace \
    --to=raistlin@linux.it \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=juergen.gross@ts.fujitsu.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).