[PATCH 23/23] sched: Dynamic sched_domain::level

From: Peter Zijlstra
Date: Thu Apr 07 2011 - 08:42:57 EST


Remove the SD_LV_ enum and use dynamic level assignments.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
include/linux/sched.h | 23 +++--------------------
kernel/cpuset.c | 2 +-
kernel/sched.c | 9 ++++++---
3 files changed, 10 insertions(+), 24 deletions(-)

Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -891,25 +891,6 @@ static inline struct cpumask *sched_grou
return to_cpumask(sg->cpumask);
}

-enum sched_domain_level {
- SD_LV_NONE = 0,
-#ifdef CONFIG_SCHED_SMT
- SD_LV_SIBLING,
-#endif
-#ifdef CONFIG_SCHED_MC
- SD_LV_MC,
-#endif
-#ifdef CONFIG_SCHED_BOOK
- SD_LV_BOOK,
-#endif
- SD_LV_CPU,
-#ifdef CONFIG_NUMA
- SD_LV_NODE,
- SD_LV_ALLNODES,
-#endif
- SD_LV_MAX
-};
-
struct sched_domain_attr {
int relax_domain_level;
};
@@ -918,6 +899,8 @@ struct sched_domain_attr {
.relax_domain_level = -1, \
}

+extern int sched_domain_level_max;
+
struct sched_domain {
/* These fields must be setup */
struct sched_domain *parent; /* top domain must be null terminated */
@@ -935,7 +918,7 @@ struct sched_domain {
unsigned int forkexec_idx;
unsigned int smt_gain;
int flags; /* See SD_* */
- enum sched_domain_level level;
+ int level;

/* Runtime fields. */
unsigned long last_balance; /* init to jiffies. units in jiffies */
Index: linux-2.6/kernel/cpuset.c
===================================================================
--- linux-2.6.orig/kernel/cpuset.c
+++ linux-2.6/kernel/cpuset.c
@@ -1164,7 +1164,7 @@ int current_cpuset_is_being_rebound(void
static int update_relax_domain_level(struct cpuset *cs, s64 val)
{
#ifdef CONFIG_SMP
- if (val < -1 || val >= SD_LV_MAX)
+ if (val < -1 || val >= sched_domain_level_max)
return -EINVAL;
#endif

Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -6942,7 +6942,6 @@ sd_init_##type(struct sched_domain_topol
{ \
struct sched_domain *sd = *per_cpu_ptr(tl->data.sd, cpu); \
*sd = SD_##type##_INIT; \
- sd->level = SD_LV_##type; \
SD_INIT_NAME(sd, type); \
sd->private = &tl->data; \
return sd; \
@@ -6964,13 +6963,14 @@ SD_INIT_FUNC(CPU)
#endif

static int default_relax_domain_level = -1;
+int sched_domain_level_max;

static int __init setup_relax_domain_level(char *str)
{
unsigned long val;

val = simple_strtoul(str, NULL, 0);
- if (val < SD_LV_MAX)
+ if (val < sched_domain_level_max)
default_relax_domain_level = val;

return 1;
@@ -7149,8 +7149,11 @@ struct sched_domain *build_sched_domain(

set_domain_attribute(sd, attr);
cpumask_and(sched_domain_span(sd), cpu_map, tl->mask(cpu));
- if (child)
+ if (child) {
+ sd->level = child->level + 1;
+ sched_domain_level_max = max(sched_domain_level_max, sd->level);
child->parent = sd;
+ }
sd->child = child;

return sd;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/