]> git.hungrycats.org Git - linux/commitdiff
[PATCH] sched_domain debugging
authorAndrew Morton <akpm@osdl.org>
Mon, 10 May 2004 06:24:05 +0000 (23:24 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 10 May 2004 06:24:05 +0000 (23:24 -0700)
From: Nick Piggin <piggin@cyberone.com.au>

Anton was attempting to make a sched domain topology for his POWER5 and was
having some trouble.

This patch only includes code which is ifdefed out, but hopefully it will
be of some use to implementors.

Documentation/sched-domains.txt
kernel/sched.c

index 794e1a95d508de1605f662cfc21bb9fdc76bd3f0..b5da811fcbcb7df69676200a4234f47054b7bfa2 100644 (file)
@@ -46,3 +46,10 @@ The implementor should read comments in include/linux/sched.h:
 struct sched_domain fields, SD_FLAG_*, SD_*_INIT to get an idea of
 the specifics and what to tune.
 
+Implementors should change the line
+#undef SCHED_DOMAIN_DEBUG
+to
+#define SCHED_DOMAIN_DEBUG
+in kernel/sched.c as this enables an error checking parse of the sched domains
+which should catch most possible errors (described above). It also prints out
+the domain structure in a visual format.
index abbfb779e5eee8be3f638bf11562cab9e22f38c4..b3db2b977d76d7e0d1aa1e17a1c6d55f1025877e 100644 (file)
@@ -3395,9 +3395,87 @@ static void __init arch_init_sched_domains(void)
 #endif /* CONFIG_NUMA */
 #endif /* ARCH_HAS_SCHED_DOMAIN */
 
+#undef SCHED_DOMAIN_DEBUG
+#ifdef SCHED_DOMAIN_DEBUG
+void sched_domain_debug(void)
+{
+       int i;
+
+       for_each_cpu(i) {
+               int level = 0;
+               struct sched_domain *cpu_domain = cpu_sched_domain(i);
+
+               printk(KERN_DEBUG "CPU%d: %s\n",
+                               i, (cpu_online(i) ? " online" : "offline"));
+
+               do {
+                       int j;
+                       char str[NR_CPUS];
+                       struct sched_group *group = cpu_domain->groups;
+                       cpumask_t groupmask, tmp;
+
+                       cpumask_snprintf(str, NR_CPUS, cpu_domain->span);
+                       cpus_clear(groupmask);
+
+                       printk(KERN_DEBUG);
+                       for (j = 0; j < level + 1; j++)
+                               printk(" ");
+                       printk("domain %d: span %s\n", level, str);
+
+                       if (!cpu_isset(i, cpu_domain->span))
+                               printk(KERN_DEBUG "ERROR domain->span does not contain CPU%d\n", i);
+                       if (!cpu_isset(i, group->cpumask))
+                               printk(KERN_DEBUG "ERROR domain->groups does not contain CPU%d\n", i);
+
+                       printk(KERN_DEBUG);
+                       for (j = 0; j < level + 2; j++)
+                               printk(" ");
+                       printk("groups:");
+                       do {
+                               if (group == NULL) {
+                                       printk(" ERROR: NULL");
+                                       break;
+                               }
+
+                               if (cpus_weight(group->cpumask) == 0)
+                                       printk(" ERROR empty group:");
+
+                               cpus_and(tmp, groupmask, group->cpumask);
+                               if (cpus_weight(tmp) > 0)
+                                       printk(" ERROR repeated CPUs:");
+
+                               cpus_or(groupmask, groupmask, group->cpumask);
+
+                               cpumask_snprintf(str, NR_CPUS, group->cpumask);
+                               printk(" %s", str);
+
+                               group = group->next;
+                       } while (group != cpu_domain->groups);
+                       printk("\n");
+
+                       if (!cpus_equal(cpu_domain->span, groupmask))
+                               printk(KERN_DEBUG "ERROR groups don't span domain->span\n");
+
+                       level++;
+                       cpu_domain = cpu_domain->parent;
+
+                       if (cpu_domain) {
+                               cpus_and(tmp, groupmask, cpu_domain->span);
+                               if (!cpus_equal(tmp, groupmask))
+                                       printk(KERN_DEBUG "ERROR parent span is not a superset of domain->span\n");
+                       }
+
+               } while (cpu_domain);
+       }
+}
+#else
+#define sched_domain_debug() {}
+#endif
+
 void __init sched_init_smp(void)
 {
        arch_init_sched_domains();
+       sched_domain_debug();
 }
 #else
 void __init sched_init_smp(void)