Skip to contentSkip to conversation

schedulers: validate / correct global data just once

PATCH In review Jan Beulich 3 participants 6 messages Jun 29, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 schedulers: validate / correct global data just once

Also mark command line parsing routine __init.

---
For credit2 I'm not sure the relatively verbose logging of all parameters should really happen upon every initialization. Otoh emitting it at boot time when the scheduler isn't actually used may also be confusing.

xen/common/sched_credit.c +32 -23
@@ -2156,6 +2156,36 @@ csched_dump(const struct scheduler *ops)
     spin_unlock_irqrestore(&prv->lock, flags);
 }
 
+static int __init
+csched_global_init(void)
+{
+    if ( sched_credit_tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX
+         || sched_credit_tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN )
+    {
+        printk("WARNING: sched_credit_tslice_ms outside of valid range [%d,%d].\n"
+               " Resetting to default %u\n",
+               XEN_SYSCTL_CSCHED_TSLICE_MIN,
+               XEN_SYSCTL_CSCHED_TSLICE_MAX,
+               CSCHED_DEFAULT_TSLICE_MS);
+        sched_credit_tslice_ms = CSCHED_DEFAULT_TSLICE_MS;
+    }
+
+    if ( MICROSECS(sched_ratelimit_us) > MILLISECS(sched_credit_tslice_ms) )
+        printk("WARNING: sched_ratelimit_us >"
+               "sched_credit_tslice_ms is undefined\n"
+               "Setting ratelimit to tslice\n");
+
+    if ( vcpu_migration_delay_us > XEN_SYSCTL_CSCHED_MGR_DLY_MAX_US )
+    {
+        vcpu_migration_delay_us = 0;
+        printk("WARNING: vcpu_migration_delay outside of valid range [0,%d]us.\n"
+               "Resetting to default: %u\n",
+               XEN_SYSCTL_CSCHED_MGR_DLY_MAX_US, vcpu_migration_delay_us);
+    }
+
+    return 0;
+}
+
 static int
 csched_init(struct scheduler *ops)
 {
@@ -2186,36 +2216,13 @@ csched_init(struct scheduler *ops)
     INIT_LIST_HEAD(&prv->active_sdom);
     prv->master = UINT_MAX;
 
-    if ( sched_credit_tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX
-         || sched_credit_tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN )
-    {
-        printk("WARNING: sched_credit_tslice_ms outside of valid range [%d,%d].\n"
-               " Resetting to default %u\n",
-               XEN_SYSCTL_CSCHED_TSLICE_MIN,
-               XEN_SYSCTL_CSCHED_TSLICE_MAX,
-               CSCHED_DEFAULT_TSLICE_MS);
-        sched_credit_tslice_ms = CSCHED_DEFAULT_TSLICE_MS;
-    }
-
     __csched_set_tslice(prv, sched_credit_tslice_ms);
 
     if ( MICROSECS(sched_ratelimit_us) > MILLISECS(sched_credit_tslice_ms) )
-    {
-        printk("WARNING: sched_ratelimit_us >" 
-               "sched_credit_tslice_ms is undefined\n"
-               "Setting ratelimit to tslice\n");
         prv->ratelimit = prv->tslice;
-    }
     else
         prv->ratelimit = MICROSECS(sched_ratelimit_us);
 
-    if ( vcpu_migration_delay_us > XEN_SYSCTL_CSCHED_MGR_DLY_MAX_US )
-    {
-        vcpu_migration_delay_us = 0;
-        printk("WARNING: vcpu_migration_delay outside of valid range [0,%d]us.\n"
-               "Resetting to default: %u\n",
-               XEN_SYSCTL_CSCHED_MGR_DLY_MAX_US, vcpu_migration_delay_us);
-    }
     prv->vcpu_migr_delay = MICROSECS(vcpu_migration_delay_us);
 
     return 0;
@@ -2266,6 +2273,8 @@ static const struct scheduler sched_cred
     .sched_id       = XEN_SCHEDULER_CREDIT,
     .sched_data     = NULL,
 
+    .global_init    = csched_global_init,
+
     .insert_vcpu    = csched_vcpu_insert,
     .remove_vcpu    = csched_vcpu_remove,
 
xen/common/sched_credit2.c +30 -21

78 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jan Beulich

Also mark command line parsing routine __init.

In fact...

Quoted 6 lines

For credit2 I'm not sure the relatively verbose logging of all parameters should really happen upon every initialization. Otoh emitting
it at boot time when the scheduler isn't actually used may also be confusing.

... I think it is ok to have these messages printed just once, during boot, for all the schedulers we support (and that have been compiled in).

The info about some parameters having been adjusted, although not printed every time a scheduler instance is created, will always be available in logs/xl dmesg, if one needs it.

About the confusion, perhaps adding a printk(), in each global_init hook, saying something like "Credit Scheduler: global parameter initialization" (and the same for Credit2, etc) would help.

My rev-by tag stands if that is added in this patch (and even if a different wording is used). But I am also fine with the patch to go in without that, as I consider it an improvement of the current situation anyway.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Software Engineer @ SUSE https://www.suse.com/

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 15:47, <[email protected]> wrote:

My rev-by tag stands if that is added in this patch (and even if a different wording is used). But I am also fine with the patch to go in without that, as I consider it an improvement of the current situation anyway.

I was more considering this the possible subject of another patch.

Thanks, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 11 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 15:47, <[email protected]> wrote:

My rev-by tag stands if that is added in this patch (and even if a different wording is used). But I am also fine with the patch to go in
without that, as I consider it an improvement of the current situation
anyway.

I was more considering this the possible subject of another patch.

Sure, and for me, that's perfectly fine!

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Software Engineer @ SUSE https://www.suse.com/

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
In reply to Jan Beulich
Quoted 12 lines · Jan Beulich

Also mark command line parsing routine __init.

---
For credit2 I'm not sure the relatively verbose logging of all parameters should really happen upon every initialization. Otoh emitting it at boot time when the scheduler isn't actually used may also be confusing.

xen/common/sched_credit.c csched_dump(const struct scheduler *ops) · line 2163

Quoted 8 lines
xen/common/sched_credit.c +5 -0
@@ -2156,6 +2156,36 @@ csched_dump(const struct scheduler *ops)
     spin_unlock_irqrestore(&prv->lock, flags);
 }
 
+static int __init
+csched_global_init(void)
+{
+    if ( sched_credit_tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX
+         || sched_credit_tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN )

Mind fixing the style to

if ( sched_credit_tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX || sched_credit_tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN )

as you're moving it?

Otherwise, LGTM.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 15:52, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich

Also mark command line parsing routine __init.

---
For credit2 I'm not sure the relatively verbose logging of all parameters should really happen upon every initialization. Otoh emitting it at boot time when the scheduler isn't actually used may also be confusing.

xen/common/sched_credit.c csched_dump(const struct scheduler *ops) · line 2163

Quoted 8 lines
xen/common/sched_credit.c +5 -0
@@ -2156,6 +2156,36 @@ csched_dump(const struct scheduler *ops)
     spin_unlock_irqrestore(&prv->lock, flags);
 }
 
+static int __init
+csched_global_init(void)
+{
+    if ( sched_credit_tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX
+         || sched_credit_tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN )

Mind fixing the style to

Quoted 4 lines

if ( sched_credit_tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX ||
sched_credit_tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN )

as you're moving it?

Oh, sure - I should have noticed this myself.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel