Skip to contentSkip to conversation

xl: check for meaningful combination of sedf config file parameters

PATCH Superseded Dario Faggioli 3 participants 9 messages Jun 4, 2012 – Jun 6, 2012

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xl: check for meaningful combination of sedf config file parameters

As we do it in the implementation of `xl sched-sedf -d ...', some consistency checking is needed while parsing the sedf scheduling parameters provided via config file. Not doing this results in the call libxl_domain_sched_params_set() to fail, and no parameters being enforced for the domain.

Note we do this at config file parsing time as that gives us the chance of bailing out early. It would have been pointless to add it within sched_sedf_domain_set() (in libxl), as the very same thing is done in the hypervisor, and the result is being checked and returned to the caller already.

tools/libxl/xl_cmdimpl.c +22 -3
@@ -561,6 +561,7 @@ static void parse_config_data(const char
     long l;
     XLU_Config *config;
     XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids;
+    int opt_w = 0, opt_p = 0, opt_s = 0;
     int pci_power_mgmt = 0;
     int pci_msitranslate = 1;
     int pci_permissive = 0;
@@ -632,18 +633,36 @@ static void parse_config_data(const char
 
     /* the following is the actual config parsing with overriding
      * values in the structures */
-    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0)) {
         b_info->sched_params.weight = l;
+        opt_w = 1;
+    }
     if (!xlu_cfg_get_long (config, "cap", &l, 0))
         b_info->sched_params.cap = l;
-    if (!xlu_cfg_get_long (config, "period", &l, 0))
+    if (!xlu_cfg_get_long (config, "period", &l, 0)) {
         b_info->sched_params.period = l;
-    if (!xlu_cfg_get_long (config, "slice", &l, 0))
+        opt_p = 1;
+    }
+    if (!xlu_cfg_get_long (config, "slice", &l, 0)) {
         b_info->sched_params.slice = l;
+        opt_s = 1;
+    }
     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;
+    /* The sedf scheduler needs some more consistency checking */
+    if (opt_w && (opt_p || opt_s)) {
+        fprintf(stderr, "Either specify a weight OR a period and slice\n");
+        exit(1);
+    }
+    if (opt_w) {
+        b_info->sched_params.slice = 0;
+        b_info->sched_params.period = 0;
+    }
+    if (opt_p || opt_s)
+        b_info->sched_params.weight = 0;
+
 
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
#1 lore raw
Quoted 18 lines · Dario Faggioli

As we do it in the implementation of `xl sched-sedf -d ...', some consistency checking is needed while parsing the sedf scheduling parameters provided via config file. Not doing this results in the call libxl_domain_sched_params_set() to fail, and no parameters being enforced for the domain.

Note we do this at config file parsing time as that gives us the chance of bailing out early. It would have been pointless to add it within sched_sedf_domain_set() (in libxl), as the very same thing is done in the hypervisor, and the result is being checked and returned to the caller already.

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char · line 564

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +1 -0
@@ -561,6 +561,7 @@ static void parse_config_data(const char
     long l;
     XLU_Config *config;
     XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids;
+    int opt_w = 0, opt_p = 0, opt_s = 0;

These names don't make much sense in this context.

Perhaps you can just check each interesting option against the corresponding LIBXL_DOAIN_SCHED_PARAM_DEFAULT? That might make some long lines. Perhaps pulling this out into a separate valid_sched_params() would help with that?

Quoted 21 lines
tools/libxl/xl_cmdimpl.c +7 -3
     int pci_power_mgmt = 0;
     int pci_msitranslate = 1;
     int pci_permissive = 0;
@@ -632,18 +633,36 @@ static void parse_config_data(const char
 
     /* the following is the actual config parsing with overriding
      * values in the structures */
-    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0)) {
         b_info->sched_params.weight = l;
+        opt_w = 1;
+    }
     if (!xlu_cfg_get_long (config, "cap", &l, 0))
         b_info->sched_params.cap = l;
-    if (!xlu_cfg_get_long (config, "period", &l, 0))
+    if (!xlu_cfg_get_long (config, "period", &l, 0)) {
         b_info->sched_params.period = l;
-    if (!xlu_cfg_get_long (config, "slice", &l, 0))
+        opt_p = 1;
+    }
+    if (!xlu_cfg_get_long (config, "slice", &l, 0)) {

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char · line 656

Quoted 10 lines
tools/libxl/xl_cmdimpl.c +5 -0
         b_info->sched_params.slice = l;
+        opt_s = 1;
+    }
     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;
+    /* The sedf scheduler needs some more consistency checking */
+    if (opt_w && (opt_p || opt_s)) {
+        fprintf(stderr, "Either specify a weight OR a period and slice\n");

Does this constrain you from setting valid combinations of credit* parameters? I think not since period and slice are SEDF specific.

Quoted 12 lines
tools/libxl/xl_cmdimpl.c +9 -0
+        exit(1);
+    }
+    if (opt_w) {
+        b_info->sched_params.slice = 0;
+        b_info->sched_params.period = 0;
+    }
+    if (opt_p || opt_s)
+        b_info->sched_params.weight = 0;
+
 
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
#2 lore raw
Quoted 11 lines · Ian Campbell

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char · line 564

Quoted 8 lines
tools/libxl/xl_cmdimpl.c +1 -0
@@ -561,6 +561,7 @@ static void parse_config_data(const char
     long l;
     XLU_Config *config;
     XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids;
+    int opt_w = 0, opt_p = 0, opt_s = 0;

These names don't make much sense in this context.

Yeah, I agree... It's just I needed something :-/

Quoted 3 lines

Perhaps you can just check each interesting option against the corresponding LIBXL_DOAIN_SCHED_PARAM_DEFAULT?

Mmm... I was mistakenly thinking these default values not to be there yet, but I now see it. Yes, I guess I can do that.

Quoted 4 lines

That might make some long
lines. Perhaps pulling this out into a separate valid_sched_params() would help with that?

Maybe, but what to put here depends on your thought on the below...

Quoted 11 lines

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char · line 656

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +0 -0
     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;
tools/libxl/xl_cmdimpl.c +3 -0
+    /* The sedf scheduler needs some more consistency checking */
+    if (opt_w && (opt_p || opt_s)) {
+        fprintf(stderr, "Either specify a weight OR a period and slice\n");

Does this constrain you from setting valid combinations of credit* parameters? I think not since period and slice are SEDF specific.

I'd say not at all, for the exact reason you're suggesting. Then, if you ask what happens if you boot with sched=credit and then try to specify both a cpu_weight and a period, then yes, it will kick you out.

The whole point is, period and slice are only meaningful for sedf so, if you are using them, I take it like you meant to be using sedf, and thus asking for a cpu_weight at the same time is wrong.

Of course, one can think at it the other way around (scheduler is credit, so cpu_weight is fine and period and slice should be ignored). If that is better, I can add a libxl_is_the_scheduler_credit? kind of check to that if...

Thanks and Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 41 lines · Dario Faggioli
Quoted 11 lines · Ian Campbell

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char · line 564

Quoted 8 lines
tools/libxl/xl_cmdimpl.c +1 -0
@@ -561,6 +561,7 @@ static void parse_config_data(const char
     long l;
     XLU_Config *config;
     XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids;
+    int opt_w = 0, opt_p = 0, opt_s = 0;

These names don't make much sense in this context.

Yeah, I agree... It's just I needed something :-/

Quoted 3 lines

Perhaps you can just check each interesting option against the corresponding LIBXL_DOAIN_SCHED_PARAM_DEFAULT?

Mmm... I was mistakenly thinking these default values not to be there yet, but I now see it. Yes, I guess I can do that.

Quoted 4 lines

That might make some long
lines. Perhaps pulling this out into a separate valid_sched_params() would help with that?

Maybe, but what to put here depends on your thought on the below...

Quoted 11 lines

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char · line 656

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +0 -0
     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;
tools/libxl/xl_cmdimpl.c +3 -0
+    /* The sedf scheduler needs some more consistency checking */
+    if (opt_w && (opt_p || opt_s)) {
+        fprintf(stderr, "Either specify a weight OR a period and slice\n");

Does this constrain you from setting valid combinations of credit* parameters? I think not since period and slice are SEDF specific.

I'd say not at all, for the exact reason you're suggesting. Then, if you ask what happens if you boot with sched=credit and then try to specify both a cpu_weight and a period, then yes, it will kick you out.

Quoted 8 lines

The whole point is, period and slice are only meaningful for sedf so, if you are using them, I take it like you meant to be using sedf, and thus asking for a cpu_weight at the same time is wrong.

Of course, one can think at it the other way around (scheduler is credit, so cpu_weight is fine and period and slice should be ignored). If that is better, I can add a libxl_is_the_scheduler_credit? kind of check to that if...

Lets keep it simple for now and go with the "don't do that" answer -- i.e. reject as invalid setting weight and period regardless of the actual scheduler in use.

Ian.

#4 lore raw
In reply to Dario Faggioli

Dario Faggioli writes ("[PATCH] xl: check for meaningful combination of sedf config file parameters"):

Quoted 5 lines

As we do it in the implementation of `xl sched-sedf -d ...', some consistency checking is needed while parsing the sedf scheduling parameters provided via config file. Not doing this results in the call libxl_domain_sched_params_set() to fail, and no parameters being enforced for the domain.

Why does xl continue after libxl_domain_sched_params_set fails ?

Ian.

#5 lore raw
Quoted 9 lines · Ian Jackson

Dario Faggioli writes ("[PATCH] xl: check for meaningful combination of sedf config file parameters"):

Quoted 5 lines

As we do it in the implementation of `xl sched-sedf -d ...', some consistency checking is needed while parsing the sedf scheduling parameters provided via config file. Not doing this results in the call libxl_domain_sched_params_set() to fail, and no parameters being enforced for the domain.

Why does xl continue after libxl_domain_sched_params_set fails ?

Well, that I really don't know. It has always been like this I guess, it just print the related error about inconsistent/wrong scheduling parameters and then the domain is created with default ones.

Should we/I stop it?

Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Dario Faggioli writes ("Re: [PATCH] xl: check for meaningful combination of sedf config file parameters"):

Quoted 8 lines · Ian Jackson
Quoted 1 line

Why does xl continue after libxl_domain_sched_params_set fails ?

Well, that I really don't know. It has always been like this I guess, it just print the related error about inconsistent/wrong scheduling parameters and then the domain is created with default ones.

Should we/I stop it?

Please, yes. In general libxl's error handling is rather poor in places (although a lot of it has been improved).

Where you notice that (a) the thing you wanted to do doesn't work and
(b) xl blunders on anyway, it's best to fix (b) first, while you still have the test case, and then (a) :-).

Thanks,
Ian.

#7 lore raw
In reply to Ian Jackson
Quoted 8 lines · Ian Jackson

Dario Faggioli writes ("[PATCH] xl: check for meaningful combination of sedf config file parameters"):

Quoted 5 lines

As we do it in the implementation of `xl sched-sedf -d ...', some consistency checking is needed while parsing the sedf scheduling parameters provided via config file. Not doing this results in the call libxl_domain_sched_params_set() to fail, and no parameters being enforced for the domain.

Why does xl continue after libxl_domain_sched_params_set fails ?

Because libxl just carries on (in libxl__build_post) and doesn't propagate the error... It most likely shouldn't. I think we can change that separately though?

Ian.

#8 lore raw
Quoted 4 lines · Ian Campbell

Because libxl just carries on (in libxl__build_post) and doesn't propagate the error... It most likely shouldn't. I think we can change that separately though?

Taking care of this right now... it seems, next version of this patch will be a series of two patches. :-)

Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel