Commit 1a848870 authored by Siddha, Suresh B's avatar Siddha, Suresh B Committed by Linus Torvalds

[PATCH] sched: introduce child field in sched_domain

Introduce the child field in sched_domain struct and use it in
sched_balance_self().

We will also use this field in cleaning up the sched group cpu_power
setup(done in a different patch) code.
Signed-off-by: default avatarSuresh Siddha <suresh.b.siddha@intel.com>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Acked-by: default avatarNick Piggin <nickpiggin@yahoo.com.au>
Cc: Paul Jackson <pj@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 74732646
...@@ -74,6 +74,7 @@ static inline int node_to_first_cpu(int node) ...@@ -74,6 +74,7 @@ static inline int node_to_first_cpu(int node)
#define SD_NODE_INIT (struct sched_domain) { \ #define SD_NODE_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 8, \ .min_interval = 8, \
.max_interval = 32, \ .max_interval = 32, \
......
...@@ -59,6 +59,7 @@ void build_cpu_to_node_map(void); ...@@ -59,6 +59,7 @@ void build_cpu_to_node_map(void);
#define SD_CPU_INIT (struct sched_domain) { \ #define SD_CPU_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 1, \ .min_interval = 1, \
.max_interval = 4, \ .max_interval = 4, \
...@@ -84,6 +85,7 @@ void build_cpu_to_node_map(void); ...@@ -84,6 +85,7 @@ void build_cpu_to_node_map(void);
#define SD_NODE_INIT (struct sched_domain) { \ #define SD_NODE_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 8, \ .min_interval = 8, \
.max_interval = 8*(min(num_online_cpus(), 32)), \ .max_interval = 8*(min(num_online_cpus(), 32)), \
......
...@@ -22,6 +22,7 @@ extern unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES]; ...@@ -22,6 +22,7 @@ extern unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES];
#define SD_NODE_INIT (struct sched_domain) { \ #define SD_NODE_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 8, \ .min_interval = 8, \
.max_interval = 32, \ .max_interval = 32, \
......
...@@ -43,6 +43,7 @@ extern int pcibus_to_node(struct pci_bus *bus); ...@@ -43,6 +43,7 @@ extern int pcibus_to_node(struct pci_bus *bus);
#define SD_NODE_INIT (struct sched_domain) { \ #define SD_NODE_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 8, \ .min_interval = 8, \
.max_interval = 32, \ .max_interval = 32, \
......
...@@ -31,6 +31,7 @@ extern int __node_distance(int, int); ...@@ -31,6 +31,7 @@ extern int __node_distance(int, int);
#define SD_NODE_INIT (struct sched_domain) { \ #define SD_NODE_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 8, \ .min_interval = 8, \
.max_interval = 32, \ .max_interval = 32, \
......
...@@ -644,6 +644,7 @@ struct sched_group { ...@@ -644,6 +644,7 @@ struct sched_group {
struct sched_domain { struct sched_domain {
/* These fields must be setup */ /* These fields must be setup */
struct sched_domain *parent; /* top domain must be null terminated */ struct sched_domain *parent; /* top domain must be null terminated */
struct sched_domain *child; /* bottom domain must be null terminated */
struct sched_group *groups; /* the balancing groups of the domain */ struct sched_group *groups; /* the balancing groups of the domain */
cpumask_t span; /* span of all CPUs in this domain */ cpumask_t span; /* span of all CPUs in this domain */
unsigned long min_interval; /* Minimum balance interval ms */ unsigned long min_interval; /* Minimum balance interval ms */
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
#define SD_SIBLING_INIT (struct sched_domain) { \ #define SD_SIBLING_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 1, \ .min_interval = 1, \
.max_interval = 2, \ .max_interval = 2, \
...@@ -119,6 +120,7 @@ ...@@ -119,6 +120,7 @@
#define SD_CPU_INIT (struct sched_domain) { \ #define SD_CPU_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 1, \ .min_interval = 1, \
.max_interval = 4, \ .max_interval = 4, \
...@@ -146,6 +148,7 @@ ...@@ -146,6 +148,7 @@
#define SD_ALLNODES_INIT (struct sched_domain) { \ #define SD_ALLNODES_INIT (struct sched_domain) { \
.span = CPU_MASK_NONE, \ .span = CPU_MASK_NONE, \
.parent = NULL, \ .parent = NULL, \
.child = NULL, \
.groups = NULL, \ .groups = NULL, \
.min_interval = 64, \ .min_interval = 64, \
.max_interval = 64*num_online_cpus(), \ .max_interval = 64*num_online_cpus(), \
......
...@@ -1286,21 +1286,29 @@ static int sched_balance_self(int cpu, int flag) ...@@ -1286,21 +1286,29 @@ static int sched_balance_self(int cpu, int flag)
while (sd) { while (sd) {
cpumask_t span; cpumask_t span;
struct sched_group *group; struct sched_group *group;
int new_cpu; int new_cpu, weight;
int weight;
if (!(sd->flags & flag)) {
sd = sd->child;
continue;
}
span = sd->span; span = sd->span;
group = find_idlest_group(sd, t, cpu); group = find_idlest_group(sd, t, cpu);
if (!group) if (!group) {
goto nextlevel; sd = sd->child;
continue;
}
new_cpu = find_idlest_cpu(group, t, cpu); new_cpu = find_idlest_cpu(group, t, cpu);
if (new_cpu == -1 || new_cpu == cpu) if (new_cpu == -1 || new_cpu == cpu) {
goto nextlevel; /* Now try balancing at a lower domain level of cpu */
sd = sd->child;
continue;
}
/* Now try balancing at a lower domain level */ /* Now try balancing at a lower domain level of new_cpu */
cpu = new_cpu; cpu = new_cpu;
nextlevel:
sd = NULL; sd = NULL;
weight = cpus_weight(span); weight = cpus_weight(span);
for_each_domain(cpu, tmp) { for_each_domain(cpu, tmp) {
...@@ -5448,12 +5456,18 @@ static void cpu_attach_domain(struct sched_domain *sd, int cpu) ...@@ -5448,12 +5456,18 @@ static void cpu_attach_domain(struct sched_domain *sd, int cpu)
struct sched_domain *parent = tmp->parent; struct sched_domain *parent = tmp->parent;
if (!parent) if (!parent)
break; break;
if (sd_parent_degenerate(tmp, parent)) if (sd_parent_degenerate(tmp, parent)) {
tmp->parent = parent->parent; tmp->parent = parent->parent;
if (parent->parent)
parent->parent->child = tmp;
}
} }
if (sd && sd_degenerate(sd)) if (sd && sd_degenerate(sd)) {
sd = sd->parent; sd = sd->parent;
if (sd)
sd->child = NULL;
}
sched_domain_debug(sd, cpu); sched_domain_debug(sd, cpu);
...@@ -6288,6 +6302,8 @@ static int build_sched_domains(const cpumask_t *cpu_map) ...@@ -6288,6 +6302,8 @@ static int build_sched_domains(const cpumask_t *cpu_map)
*sd = SD_NODE_INIT; *sd = SD_NODE_INIT;
sd->span = sched_domain_node_span(cpu_to_node(i)); sd->span = sched_domain_node_span(cpu_to_node(i));
sd->parent = p; sd->parent = p;
if (p)
p->child = sd;
cpus_and(sd->span, sd->span, *cpu_map); cpus_and(sd->span, sd->span, *cpu_map);
#endif #endif
...@@ -6297,6 +6313,8 @@ static int build_sched_domains(const cpumask_t *cpu_map) ...@@ -6297,6 +6313,8 @@ static int build_sched_domains(const cpumask_t *cpu_map)
*sd = SD_CPU_INIT; *sd = SD_CPU_INIT;
sd->span = nodemask; sd->span = nodemask;
sd->parent = p; sd->parent = p;
if (p)
p->child = sd;
sd->groups = &sched_group_phys[group]; sd->groups = &sched_group_phys[group];
#ifdef CONFIG_SCHED_MC #ifdef CONFIG_SCHED_MC
...@@ -6307,6 +6325,7 @@ static int build_sched_domains(const cpumask_t *cpu_map) ...@@ -6307,6 +6325,7 @@ static int build_sched_domains(const cpumask_t *cpu_map)
sd->span = cpu_coregroup_map(i); sd->span = cpu_coregroup_map(i);
cpus_and(sd->span, sd->span, *cpu_map); cpus_and(sd->span, sd->span, *cpu_map);
sd->parent = p; sd->parent = p;
p->child = sd;
sd->groups = &sched_group_core[group]; sd->groups = &sched_group_core[group];
#endif #endif
...@@ -6318,6 +6337,7 @@ static int build_sched_domains(const cpumask_t *cpu_map) ...@@ -6318,6 +6337,7 @@ static int build_sched_domains(const cpumask_t *cpu_map)
sd->span = cpu_sibling_map[i]; sd->span = cpu_sibling_map[i];
cpus_and(sd->span, sd->span, *cpu_map); cpus_and(sd->span, sd->span, *cpu_map);
sd->parent = p; sd->parent = p;
p->child = sd;
sd->groups = &sched_group_cpus[group]; sd->groups = &sched_group_cpus[group];
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment