Skip to contentSkip to conversation

sched: print information about scheduler granularity

PATCH Superseded Sergey Dyasli 3 participants 13 messages Apr 16, 2020 – Apr 17, 2020

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: print information about scheduler granularity

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity. Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [ 45.914314] Scheduler: SMP Credit Scheduler (credit) in 2-way core-scheduling mode

---
CC: Juergen Gross <[email protected]>
CC: Dario Faggioli <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>

---
 xen/common/sched/core.c    | 10 ++++++++--
 xen/common/sched/cpupool.c | 30 +++++++++++++++++++++++++++++-
 xen/common/sched/private.h |  2 ++
 3 files changed, 39 insertions(+), 3 deletions(-)
xen/common/sched/core.c +8 -2
index d4a6489929..b1b09a159b 100644
@@ -2883,6 +2883,7 @@ void scheduler_enable(void)
 void __init scheduler_init(void)
 {
     struct domain *idle_domain;
+    char sched_gran[20];
     int i;
 
     scheduler_enable();
@@ -2937,7 +2938,9 @@ void __init scheduler_init(void)
         BUG();
     register_cpu_notifier(&cpu_schedule_nfb);
 
-    printk("Using scheduler: %s (%s)\n", ops.name, ops.opt_name);
+    printk("Using scheduler: %s (%s) in %s-scheduling mode\n",
+           ops.name, ops.opt_name,
+           sched_gran_str(sched_gran, sizeof(sched_gran)));
     if ( sched_init(&ops) )
         panic("scheduler returned error on init\n");
 
@@ -3267,6 +3270,7 @@ void schedule_dump(struct cpupool *c)
     unsigned int      i, j;
     struct scheduler *sched;
     cpumask_t        *cpus;
+    char              sched_gran[20];
 
     /* Locking, if necessary, must be handled withing each scheduler */
 
@@ -3276,7 +3280,9 @@ void schedule_dump(struct cpupool *c)
     {
         sched = c->sched;
         cpus = c->res_valid;
-        printk("Scheduler: %s (%s)\n", sched->name, sched->opt_name);
+        printk("Scheduler: %s (%s) in %s-scheduling mode\n",
+               sched->name, sched->opt_name,
+               sched_gran_str(sched_gran, sizeof(sched_gran)));
         sched_dump_settings(sched);
     }
     else
xen/common/sched/cpupool.c +29 -1
index d40345b585..a37b97f4c2 100644
@@ -38,7 +38,35 @@ static cpumask_t cpupool_locked_cpus;
 static DEFINE_SPINLOCK(cpupool_lock);
 
 static enum sched_gran __read_mostly opt_sched_granularity = SCHED_GRAN_cpu;
-static unsigned int __read_mostly sched_granularity = 1;
+static unsigned int __read_mostly sched_granularity;
+
+char *sched_gran_str(char *str, size_t size)
+{
+    char *mode = "";
+
+    switch ( opt_sched_granularity )
+    {
+    case SCHED_GRAN_cpu:
+        mode = "cpu";
+        break;
+    case SCHED_GRAN_core:
+        mode = "core";
+        break;
+    case SCHED_GRAN_socket:
+        mode = "socket";
+        break;
+    default:
+        ASSERT_UNREACHABLE();
+        break;
+    }
+
+    if ( sched_granularity )
+        snprintf(str, size, "%u-way %s", sched_granularity, mode);
+    else
+        snprintf(str, size, "%s", mode);
+
+    return str;
+}
 
 #ifdef CONFIG_HAS_SCHED_GRANULARITY
 static int __init sched_select_granularity(const char *str)
xen/common/sched/private.h +2 -0
index 367811a12f..fd49f545cb 100644
@@ -30,6 +30,8 @@ enum sched_gran {
     SCHED_GRAN_socket
 };
 
+char *sched_gran_str(char *str, size_t size);
+
 /*
  * In order to allow a scheduler to remap the lock->cpu mapping,
  * we have a per-cpu pointer, along with a pre-allocated set of
Signature · 1 line
2.17.1
#1 lore raw
Quoted 11 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity. Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [ 45.914314] Scheduler: SMP Credit Scheduler (credit) in 2-way core-scheduling mode

Hmm, do we need that?

The xen commandline ins part of the boot messages and is contained in the "xl info" output.

Juergen

#2 lore raw
Quoted 11 lines · Jürgen Groß
Quoted 10 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity. Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [   45.914314] Scheduler: SMP Credit Scheduler (credit) in 2-way core-scheduling mode

Quoted 6 lines
Quoted 1 line

Hmm, do we need that?

The xen commandline ins part of the boot messages and is contained in the "xl info" output.

It's true that you can see "sched-gran=core" in "xl info" output. But that's just the switch - not the end result. A user might want to verify that he did everything correctly and core-scheduling mode has indeed been enabled.

--
Thanks,
Sergey

#3 lore raw
Quoted 14 lines · Sergey Dyasli
Quoted 13 lines · Jürgen Groß
Quoted 11 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity. Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [   45.914314] Scheduler: SMP Credit Scheduler (credit) in 2-way core-scheduling mode

Quoted 8 lines
Quoted 4 lines

Hmm, do we need that?

The xen commandline ins part of the boot messages and is contained in the "xl info" output.

It's true that you can see "sched-gran=core" in "xl info" output. But that's just the switch - not the end result. A user might want to verify that he did everything correctly and core-scheduling mode has indeed been enabled.

I'm planning to add this information in the pending hypfs (per cpupool).

I'm not opposed to your patch, but as soon as we have per-cpupool granularity it should be reverted again.

Juergen

#4 lore raw
Quoted 17 lines · Jürgen Groß
Quoted 16 lines · Sergey Dyasli
Quoted 15 lines · Jürgen Groß
Quoted 11 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity. Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [   45.914314] Scheduler: SMP Credit Scheduler (credit) in 2-way core-scheduling mode

Hmm, do we need that?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

The xen commandline ins part of the boot messages and is contained in the "xl info" output.

It's true that you can see "sched-gran=core" in "xl info" output. But that's just the switch - not the end result. A user might want to verify that he did everything correctly and core-scheduling mode has indeed been enabled.

I'm planning to add this information in the pending hypfs (per cpupool).

hypfs is certainly nice, but I doubt it'll be available for Xen 4.13.

Quoted 2 lines

I'm not opposed to your patch, but as soon as we have per-cpupool granularity it should be reverted again.

"xl debug-keys r" already prints the granularity information per cpupool. It's just opt_sched_granularity is currently a single global variable. Once per-cpupool granularity is implemented, sched_gran_str() should simply gain granularity as a parameter.

--
Thanks,
Sergey

#5 lore raw
In reply to Jürgen Groß
Quoted 14 lines · Jürgen Groß
Quoted 6 lines · Sergey Dyasli
Quoted 4 lines · Jürgen Groß

The xen commandline ins part of the boot messages and is contained
in the "xl info" output.

Quoted 6 lines

It's true that you can see "sched-gran=core" in "xl info" output. But that's
just the switch - not the end result. A user might want to verify that he did
everything correctly and core-scheduling mode has indeed been enabled.

Quoted 3 lines

I'm not opposed to your patch, but as soon as we have per-cpupool granularity it should be reverted again.

Why reverted? Each cpupool dumps its own scheduling information. With per-pool granularity, we'll see something like

cpupool: Pool-A
Scheduler: SMP Credit Scheduler (credit)
Scheduling granularity: cpu
...
cpupool: Pool-B
Scheduler: SMP Credit Scheduler (credit)
Scheduling granularity: core

etc.

Or am I missing something?

Regards

Signature · 6 lines
Dario Faggioli, Ph.D
http://about.me/dario.faggioli
Virtualization Software Engineer
SUSE Labs, SUSE https://www.suse.com/
-------------------------------------------------------------------
<<This happens because _I_ choose it to happen!>> (Raistlin Majere)
#6 lore raw
Quoted 29 lines · Dario Faggioli
Quoted 14 lines · Jürgen Groß
Quoted 6 lines · Sergey Dyasli
Quoted 4 lines · Jürgen Groß

The xen commandline ins part of the boot messages and is contained
in the "xl info" output.

Quoted 6 lines

It's true that you can see "sched-gran=core" in "xl info" output. But that's
just the switch - not the end result. A user might want to verify that he did
everything correctly and core-scheduling mode has indeed been enabled.

Quoted 3 lines

I'm not opposed to your patch, but as soon as we have per-cpupool granularity it should be reverted again.

Why reverted? Each cpupool dumps its own scheduling information. With per-pool granularity, we'll see something like

cpupool: Pool-A
Scheduler: SMP Credit Scheduler (credit)
Scheduling granularity: cpu
...
cpupool: Pool-B
Scheduler: SMP Credit Scheduler (credit)
Scheduling granularity: core

Quoted 3 lines

etc.

Or am I missing something?

"Reworking" might have been a better wording.

The patch is looking only at the global variable opt_sched_granularity for deciding which granularity to print out.

Juergen

#7 lore raw
In reply to Sergey Dyasli
Quoted 4 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity.

I like the idea. However, I don't like how verbose and long that line becomes.

Quoted 10 lines

Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [ 45.914314] Scheduler: SMP Credit Scheduler (credit) in 2-
way core-scheduling mode

What about adding an entry, just below these ones. Something looking like, for instance (both at boot and in the debug-key dump):

"Scheduling granularity: cpu"

(or "core", or "socket")

Also

Quoted 23 lines
xen/common/sched/cpupool.c +15 -1
@@ -38,7 +38,35 @@ static cpumask_t cpupool_locked_cpus;
 static DEFINE_SPINLOCK(cpupool_lock);
 
 static enum sched_gran __read_mostly opt_sched_granularity =
 SCHED_GRAN_cpu;
-static unsigned int __read_mostly sched_granularity = 1;
+static unsigned int __read_mostly sched_granularity;
+
+char *sched_gran_str(char *str, size_t size)
+{
+    char *mode = "";
+
+    switch ( opt_sched_granularity )
+    {
+    case SCHED_GRAN_cpu:
+        mode = "cpu";
+        break;
+    case SCHED_GRAN_core:
+        mode = "core";
+        break;
+    case SCHED_GRAN_socket:

xen/common/sched/cpupool.c static cpumask_t cpupool_locked_cpus; · line 66

Quoted 10 lines
xen/common/sched/cpupool.c +9 -0
+        mode = "socket";
+        break;
+    default:
+        ASSERT_UNREACHABLE();
+        break;
+    }
+
+    if ( sched_granularity )
+        snprintf(str, size, "%u-way %s", sched_granularity, mode);
 

I'm not sure about using the value of the enum like this.

E.g., in a system with 4 threads per core, enabling core scheduling granularity would mean having 4 vCPUs in the scheduling units. But this will still print "2-way core-scheduling", which I think would sound confusing.

So I'd just go with "cpu", "core" and "socket" strings.

Regards

Signature · 6 lines
Dario Faggioli, Ph.D
http://about.me/dario.faggioli
Virtualization Software Engineer
SUSE Labs, SUSE https://www.suse.com/
-------------------------------------------------------------------
<<This happens because _I_ choose it to happen!>> (Raistlin Majere)
#8 lore raw
Quoted 53 lines · Dario Faggioli
Quoted 4 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity.

I like the idea. However, I don't like how verbose and long that line becomes.

Quoted 10 lines

Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [ 45.914314] Scheduler: SMP Credit Scheduler (credit) in 2-
way core-scheduling mode

What about adding an entry, just below these ones. Something looking like, for instance (both at boot and in the debug-key dump):

"Scheduling granularity: cpu"

(or "core", or "socket")

Also

Quoted 26 lines
xen/common/sched/cpupool.c +18 -1
@@ -38,7 +38,35 @@ static cpumask_t cpupool_locked_cpus;
  static DEFINE_SPINLOCK(cpupool_lock);
 
  static enum sched_gran __read_mostly opt_sched_granularity =
 SCHED_GRAN_cpu;
-static unsigned int __read_mostly sched_granularity = 1;
+static unsigned int __read_mostly sched_granularity;
+
+char *sched_gran_str(char *str, size_t size)
+{
+    char *mode = "";
+
+    switch ( opt_sched_granularity )
+    {
+    case SCHED_GRAN_cpu:
+        mode = "cpu";
+        break;
+    case SCHED_GRAN_core:
+        mode = "core";
+        break;
+    case SCHED_GRAN_socket:
+        mode = "socket";
+        break;
+    default:
Quoted 8 lines

xen/common/sched/cpupool.c static cpumask_t cpupool_locked_cpus; · line 70

Quoted 7 lines
xen/common/sched/cpupool.c +6 -0
+        ASSERT_UNREACHABLE();
+        break;
+    }
+
+    if ( sched_granularity )
+        snprintf(str, size, "%u-way %s", sched_granularity, mode);
 

I'm not sure about using the value of the enum like this.

enum? sched_granularity holds the number of cpus per scheduling resource. opt_sched_granularity is the enum.

Quoted 5 lines

E.g., in a system with 4 threads per core, enabling core scheduling granularity would mean having 4 vCPUs in the scheduling units. But this will still print "2-way core-scheduling", which I think would sound confusing.

It would print "4-way", of course.

Quoted 2 lines

So I'd just go with "cpu", "core" and "socket" strings.

No, this is not a good idea. With e.g. smt=0 you'll be able to have "1-way core" which is much more informative than "core".

Juergen

#9 lore raw
Quoted 19 lines · Jürgen Groß
Quoted 18 lines · Dario Faggioli
Quoted 4 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity.

I like the idea. However, I don't like how verbose and long that line becomes.

Quoted 10 lines

  Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [   45.914314] Scheduler: SMP Credit Scheduler (credit) in 2- way core-scheduling mode

Quoted 6 lines
Quoted 6 lines

What about adding an entry, just below these ones. Something looking like, for instance (both at boot and in the debug-key dump):

"Scheduling granularity: cpu"

(or "core", or "socket")

I agree that the line becomes too long. I'll print the new information on a separate line as you suggest in v2.

Quoted 46 lines
Quoted 28 lines

Also

Quoted 25 lines
xen/common/sched/cpupool.c +0 -0
@@ -38,7 +38,35 @@ static cpumask_t cpupool_locked_cpus;
   static DEFINE_SPINLOCK(cpupool_lock);

  static enum sched_gran __read_mostly opt_sched_granularity = SCHED_GRAN_cpu;

xen/common/sched/cpupool.c +18 -1
-static unsigned int __read_mostly sched_granularity = 1;
+static unsigned int __read_mostly sched_granularity;
+
+char *sched_gran_str(char *str, size_t size)
+{
+    char *mode = "";
+
+    switch ( opt_sched_granularity )
+    {
+    case SCHED_GRAN_cpu:
+        mode = "cpu";
+        break;
+    case SCHED_GRAN_core:
+        mode = "core";
+        break;
+    case SCHED_GRAN_socket:
+        mode = "socket";
+        break;
+    default:
Quoted 8 lines
Quoted 7 lines

+        ASSERT_UNREACHABLE();
+        break;
+    }
+
+    if ( sched_granularity )
+        snprintf(str, size, "%u-way %s", sched_granularity, mode);

I'm not sure about using the value of the enum like this.

enum? sched_granularity holds the number of cpus per scheduling resource. opt_sched_granularity is the enum.

Quoted 5 lines

E.g., in a system with 4 threads per core, enabling core scheduling granularity would mean having 4 vCPUs in the scheduling units. But this will still print "2-way core-scheduling", which I think would sound confusing.

Quoted 7 lines

It would print "4-way", of course.

Quoted 2 lines

So I'd just go with "cpu", "core" and "socket" strings.

No, this is not a good idea. With e.g. smt=0 you'll be able to have "1-way core" which is much more informative than "core".

Can confirm the above. "sched-gran=core" on a Knights Mill produces:
(XEN) [ 232.018648] Scheduler: SMP Credit Scheduler (credit) in 4-way core-scheduling mode

While "sched-gran=core smt=0" gives:
(XEN) [ 259.337588] Scheduler: SMP Credit Scheduler (credit) in 1-way core-scheduling mode

--
Thanks,
Sergey

#10 lore raw
Quoted 81 lines · Sergey Dyasli
Quoted 19 lines · Jürgen Groß
Quoted 18 lines · Dario Faggioli
Quoted 4 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode is being used by the scheduler. Alleviate this by printing additional information about the selected granularity.

I like the idea. However, I don't like how verbose and long that line becomes.

Quoted 10 lines

  Messages now look like these:

1. boot
(XEN) [00089808f0ea7496] Using scheduler: SMP Credit Scheduler (credit) in core-scheduling mode

2. xl debug-keys r
(XEN) [   45.914314] Scheduler: SMP Credit Scheduler (credit) in 2- way core-scheduling mode

Quoted 6 lines
Quoted 6 lines

What about adding an entry, just below these ones. Something looking like, for instance (both at boot and in the debug-key dump):

"Scheduling granularity: cpu"

(or "core", or "socket")

I agree that the line becomes too long. I'll print the new information on a separate line as you suggest in v2.

Quoted 51 lines
Quoted 28 lines

Also

Quoted 25 lines
xen/common/sched/cpupool.c +18 -1
@@ -38,7 +38,35 @@ static cpumask_t cpupool_locked_cpus;
   static DEFINE_SPINLOCK(cpupool_lock);
   static enum sched_gran __read_mostly opt_sched_granularity =
 SCHED_GRAN_cpu;
-static unsigned int __read_mostly sched_granularity = 1;
+static unsigned int __read_mostly sched_granularity;
+
+char *sched_gran_str(char *str, size_t size)
+{
+    char *mode = "";
+
+    switch ( opt_sched_granularity )
+    {
+    case SCHED_GRAN_cpu:
+        mode = "cpu";
+        break;
+    case SCHED_GRAN_core:
+        mode = "core";
+        break;
+    case SCHED_GRAN_socket:
+        mode = "socket";
+        break;
+    default:
Quoted 8 lines

xen/common/sched/cpupool.c static cpumask_t cpupool_locked_cpus; · line 70

Quoted 7 lines
xen/common/sched/cpupool.c +6 -0
+        ASSERT_UNREACHABLE();
+        break;
+    }
+
+    if ( sched_granularity )
+        snprintf(str, size, "%u-way %s", sched_granularity, mode);
 

I'm not sure about using the value of the enum like this.

enum? sched_granularity holds the number of cpus per scheduling resource. opt_sched_granularity is the enum.

Quoted 5 lines

E.g., in a system with 4 threads per core, enabling core scheduling granularity would mean having 4 vCPUs in the scheduling units. But this will still print "2-way core-scheduling", which I think would sound confusing.

It would print "4-way", of course.

Quoted 2 lines

So I'd just go with "cpu", "core" and "socket" strings.

Quoted 8 lines
Quoted 2 lines

No, this is not a good idea. With e.g. smt=0 you'll be able to have "1-way core" which is much more informative than "core".

Can confirm the above. "sched-gran=core" on a Knights Mill produces:
(XEN) [ 232.018648] Scheduler: SMP Credit Scheduler (credit) in 4-way core-scheduling mode

While "sched-gran=core smt=0" gives:
(XEN) [ 259.337588] Scheduler: SMP Credit Scheduler (credit) in 1-way core-scheduling mode

You might want to consider not using the global variables [opt_]sched_granularity, but the per-cpupool ones. Right now they have the same value, but this might change in future...

Juergen

#11 lore raw
Quoted 10 lines · Jürgen Groß
Quoted 3 lines · Sergey Dyasli

While "sched-gran=core smt=0" gives:
(XEN) [ 259.337588] Scheduler: SMP Credit Scheduler (credit) in 1- way core-scheduling mode

You might want to consider not using the global variables [opt_]sched_granularity, but the per-cpupool ones. Right now they have
the same value, but this might change in future...

Yes, agreed.

Regards

Signature · 6 lines
Dario Faggioli, Ph.D
http://about.me/dario.faggioli
Virtualization Software Engineer
SUSE Labs, SUSE https://www.suse.com/
-------------------------------------------------------------------
<<This happens because _I_ choose it to happen!>> (Raistlin Majere)
#12 lore raw
In reply to Jürgen Groß
Quoted 29 lines · Jürgen Groß
Quoted 19 lines · Dario Faggioli
Quoted 18 lines · Sergey Dyasli
xen/common/sched/cpupool.c +17 -0
+char *sched_gran_str(char *str, size_t size)
+{
+    char *mode = "";
+
+    switch ( opt_sched_granularity )
+    {
+    case SCHED_GRAN_cpu:
+        mode = "cpu";
+        break;
+    case SCHED_GRAN_core:
+        mode = "core";
+        break;
+    case SCHED_GRAN_socket:
+        mode = "socket";
+        break;
+    default:
+        ASSERT_UNREACHABLE();
Quoted 8 lines
Quoted 7 lines
xen/common/sched/cpupool.c +5 -0
+        break;
+    }
+
+    if ( sched_granularity )
+        snprintf(str, size, "%u-way %s", sched_granularity,

mode);

I'm not sure about using the value of the enum like this.

Quoted 3 lines

enum? sched_granularity holds the number of cpus per scheduling resource. opt_sched_granularity is the enum.

Ah, indeed! I failed to see that the if and the snprintf above use that, and not opt_sched_granularity! Sorry for the confusion.

Quoted 5 lines
Quoted 1 line

So I'd just go with "cpu", "core" and "socket" strings.

No, this is not a good idea. With e.g. smt=0 you'll be able to have "1-way core" which is much more informative than "core".

True. And thinking to this cases, I agree that it makes sense to provide an information that takes that into account too.

I'm now not sure whether something like "1-way core-scheduling (or "1- way core-scheduling more") is really the best way to tell the user we're using using core-scheduling, but we have disabled SMT... Perhaps something like:

Scheduling granularity: core, 1CPU(s) per sched-resource

Or something like that?

Regards

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