Skip to contentSkip to conversation

sched: print information about scheduling granularity

PATCH Superseded Sergey Dyasli 3 participants 4 messages Apr 20, 2020 – Apr 21, 2020

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sched: print information about scheduling granularity

Currently it might be not obvious which scheduling mode (e.g. core- scheduling) is being used by the scheduler. Alleviate this by printing additional information about the selected granularity per-cpupool.

Note: per-cpupool granularity selection is not implemented yet.
The single global value is being used for each cpupool.

---
v2:
- print information on a separate line
- use per-cpupool granularity
- updated commit message

CC Juergen Gross <[email protected]>
CC Dario Faggioli <[email protected]>
CC George Dunlap <[email protected]>
CC Jan Beulich <[email protected]>
---
 xen/common/sched/cpupool.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
xen/common/sched/cpupool.c +26 -0
index d40345b585..68106f6c15 100644
@@ -40,6 +40,30 @@ 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 void sched_gran_print(enum sched_gran mode, unsigned int gran)
+{
+    char *str = "";
+
+    switch ( mode )
+    {
+    case SCHED_GRAN_cpu:
+        str = "cpu";
+        break;
+    case SCHED_GRAN_core:
+        str = "core";
+        break;
+    case SCHED_GRAN_socket:
+        str = "socket";
+        break;
+    default:
+        ASSERT_UNREACHABLE();
+        break;
+    }
+
+    printk("Scheduling granularity: %s, %u CPU%s per sched-resource\n",
+           str, gran, gran == 1 ? "" : "s");
+}
+
 #ifdef CONFIG_HAS_SCHED_GRANULARITY
 static int __init sched_select_granularity(const char *str)
 {
@@ -115,6 +139,7 @@ static void __init cpupool_gran_init(void)
         warning_add(fallback);
 
     sched_granularity = gran;
+    sched_gran_print(opt_sched_granularity, sched_granularity);
 }
 
 unsigned int cpupool_get_granularity(const struct cpupool *c)
@@ -911,6 +936,7 @@ void dump_runq(unsigned char key)
     {
         printk("Cpupool %d:\n", (*c)->cpupool_id);
         printk("Cpus: %*pbl\n", CPUMASK_PR((*c)->cpu_valid));
+        sched_gran_print((*c)->gran, cpupool_get_granularity(*c));
         schedule_dump(*c);
     }
 
Signature · 1 line
2.17.1
#1 lore raw

xen/common/sched/cpupool.c static DEFINE_SPINLOCK(cpupool_lock); · line 45

Quoted 9 lines · Sergey Dyasli
xen/common/sched/cpupool.c +3 -0
@@ -40,6 +40,30 @@ 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 void sched_gran_print(enum sched_gran mode, unsigned int gran)
+{
+    char *str = "";

const please (could easily be added while committing of course)

Jan

#2 lore raw
In reply to Sergey Dyasli
Quoted 6 lines · Sergey Dyasli

Currently it might be not obvious which scheduling mode (e.g. core- scheduling) is being used by the scheduler. Alleviate this by printing additional information about the selected granularity per-cpupool.

Note: per-cpupool granularity selection is not implemented yet.
The single global value is being used for each cpupool.

This is misleading. You are using the per-cpupool values, but they are all the same right now.

Quoted 33 lines

---
v2:
- print information on a separate line
- use per-cpupool granularity
- updated commit message

CC Juergen Gross <[email protected]>
CC Dario Faggioli <[email protected]>
CC George Dunlap <[email protected]>
CC Jan Beulich <[email protected]>
---
  xen/common/sched/cpupool.c | 26 ++++++++++++++++++++++++++
  1 file changed, 26 insertions(+)
xen/common/sched/cpupool.c +9 -0
index d40345b585..68106f6c15 100644
@@ -40,6 +40,30 @@ 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 void sched_gran_print(enum sched_gran mode, unsigned int gran)
+{
+    char *str = "";
+
+    switch ( mode )
+    {
+    case SCHED_GRAN_cpu:
+        str = "cpu";
+        break;

xen/common/sched/cpupool.c static DEFINE_SPINLOCK(cpupool_lock); · line 61

Quoted 10 lines
xen/common/sched/cpupool.c +10 -0
+    case SCHED_GRAN_core:
+        str = "core";
+        break;
+    case SCHED_GRAN_socket:
+        str = "socket";
+        break;
+    default:
+        ASSERT_UNREACHABLE();
+        break;
+    }

With this addition it might make sense to have an array indexed by mode to get the string. This array could then be used in sched_select_granularity(), too.

Quoted 17 lines
xen/common/sched/cpupool.c +6 -0
+
+    printk("Scheduling granularity: %s, %u CPU%s per sched-resource\n",
+           str, gran, gran == 1 ? "" : "s");
+}
+
  #ifdef CONFIG_HAS_SCHED_GRANULARITY
  static int __init sched_select_granularity(const char *str)
  {
@@ -115,6 +139,7 @@ static void __init cpupool_gran_init(void)
          warning_add(fallback);
 
      sched_granularity = gran;
+    sched_gran_print(opt_sched_granularity, sched_granularity);
  }
 
  unsigned int cpupool_get_granularity(const struct cpupool *c)

xen/common/sched/cpupool.c void dump_runq(unsigned char key) · line 941

Quoted 6 lines
xen/common/sched/cpupool.c +1 -0
@@ -911,6 +936,7 @@ void dump_runq(unsigned char key)
      {
          printk("Cpupool %d:\n", (*c)->cpupool_id);
          printk("Cpus: %*pbl\n", CPUMASK_PR((*c)->cpu_valid));
+        sched_gran_print((*c)->gran, cpupool_get_granularity(*c));
          schedule_dump(*c);
      }

Juergen

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

Currently it might be not obvious which scheduling mode (e.g. core- scheduling) is being used by the scheduler. Alleviate this by printing additional information about the selected granularity per-cpupool.

Note: per-cpupool granularity selection is not implemented yet. The single global value is being used for each cpupool.

This is misleading. You are using the per-cpupool values, but they are all the same right now.

This is what I meant by my note, but I might need to improve the wording since the current one looks ambiguous to you.

Quoted 39 lines
Quoted 39 lines

---
v2:
- print information on a separate line
- use per-cpupool granularity
- updated commit message

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

---
  xen/common/sched/cpupool.c | 26 ++++++++++++++++++++++++++

  1 file changed, 26 insertions(+)
xen/common/sched/cpupool.c +15 -0
index d40345b585..68106f6c15 100644
@@ -40,6 +40,30 @@ 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 void sched_gran_print(enum sched_gran mode, unsigned int gran)
+{
+    char *str = "";
+
+    switch ( mode )
+    {
+    case SCHED_GRAN_cpu:
+        str = "cpu";
+        break;
+    case SCHED_GRAN_core:
+        str = "core";
+        break;
+    case SCHED_GRAN_socket:
+        str = "socket";
+        break;
Quoted 8 lines

xen/common/sched/cpupool.c static DEFINE_SPINLOCK(cpupool_lock); · line 61

Quoted 4 lines
xen/common/sched/cpupool.c +4 -0
+    default:
+        ASSERT_UNREACHABLE();
+        break;
+    }

With this addition it might make sense to have an array indexed by mode to get the string. This array could then be used in sched_select_granularity(), too.

I had thoughts about that, and with your suggestion looks like I need to go and do it.

Quoted 14 lines
Quoted 14 lines
xen/common/sched/cpupool.c +6 -0
+
+    printk("Scheduling granularity: %s, %u CPU%s per sched-resource\n",
+           str, gran, gran == 1 ? "" : "s");
+}
+
   #ifdef CONFIG_HAS_SCHED_GRANULARITY
   static int __init sched_select_granularity(const char *str)
   {
@@ -115,6 +139,7 @@ static void __init cpupool_gran_init(void)
           warning_add(fallback);
       sched_granularity = gran;
+    sched_gran_print(opt_sched_granularity, sched_granularity);
   }
Quoted 9 lines

xen/common/sched/cpupool.c void dump_runq(unsigned char key) · line 941

Quoted 8 lines
xen/common/sched/cpupool.c +1 -0
   unsigned int cpupool_get_granularity(const struct cpupool *c)
@@ -911,6 +936,7 @@ void dump_runq(unsigned char key)
       {
           printk("Cpupool %d:\n", (*c)->cpupool_id);
           printk("Cpus: %*pbl\n", CPUMASK_PR((*c)->cpu_valid));
+        sched_gran_print((*c)->gran, cpupool_get_granularity(*c));
           schedule_dump(*c);
       }

--
Thanks,
Sergey