Commit 7f1867a5 authored by Dinakar Guniguntala's avatar Dinakar Guniguntala Committed by Linus Torvalds

[PATCH] Dynamic sched domains: ia64 changes

ia64 changes similar to kernel/sched.c.
Signed-off-by: default avatarDinakar Guniguntala <dino@in.ibm.com>
Acked-by: default avatarPaul Jackson <pj@sgi.com>
Acked-by: default avatarNick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 85d7b949
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* *
* Should use nodemask_t. * Should use nodemask_t.
*/ */
static int __devinit find_next_best_node(int node, unsigned long *used_nodes) static int find_next_best_node(int node, unsigned long *used_nodes)
{ {
int i, n, val, min_val, best_node = 0; int i, n, val, min_val, best_node = 0;
...@@ -66,7 +66,7 @@ static int __devinit find_next_best_node(int node, unsigned long *used_nodes) ...@@ -66,7 +66,7 @@ static int __devinit find_next_best_node(int node, unsigned long *used_nodes)
* should be one that prevents unnecessary balancing, but also spreads tasks * should be one that prevents unnecessary balancing, but also spreads tasks
* out optimally. * out optimally.
*/ */
static cpumask_t __devinit sched_domain_node_span(int node) static cpumask_t sched_domain_node_span(int node)
{ {
int i; int i;
cpumask_t span, nodemask; cpumask_t span, nodemask;
...@@ -96,7 +96,7 @@ static cpumask_t __devinit sched_domain_node_span(int node) ...@@ -96,7 +96,7 @@ static cpumask_t __devinit sched_domain_node_span(int node)
#ifdef CONFIG_SCHED_SMT #ifdef CONFIG_SCHED_SMT
static DEFINE_PER_CPU(struct sched_domain, cpu_domains); static DEFINE_PER_CPU(struct sched_domain, cpu_domains);
static struct sched_group sched_group_cpus[NR_CPUS]; static struct sched_group sched_group_cpus[NR_CPUS];
static int __devinit cpu_to_cpu_group(int cpu) static int cpu_to_cpu_group(int cpu)
{ {
return cpu; return cpu;
} }
...@@ -104,7 +104,7 @@ static int __devinit cpu_to_cpu_group(int cpu) ...@@ -104,7 +104,7 @@ static int __devinit cpu_to_cpu_group(int cpu)
static DEFINE_PER_CPU(struct sched_domain, phys_domains); static DEFINE_PER_CPU(struct sched_domain, phys_domains);
static struct sched_group sched_group_phys[NR_CPUS]; static struct sched_group sched_group_phys[NR_CPUS];
static int __devinit cpu_to_phys_group(int cpu) static int cpu_to_phys_group(int cpu)
{ {
#ifdef CONFIG_SCHED_SMT #ifdef CONFIG_SCHED_SMT
return first_cpu(cpu_sibling_map[cpu]); return first_cpu(cpu_sibling_map[cpu]);
...@@ -125,44 +125,36 @@ static struct sched_group *sched_group_nodes[MAX_NUMNODES]; ...@@ -125,44 +125,36 @@ static struct sched_group *sched_group_nodes[MAX_NUMNODES];
static DEFINE_PER_CPU(struct sched_domain, allnodes_domains); static DEFINE_PER_CPU(struct sched_domain, allnodes_domains);
static struct sched_group sched_group_allnodes[MAX_NUMNODES]; static struct sched_group sched_group_allnodes[MAX_NUMNODES];
static int __devinit cpu_to_allnodes_group(int cpu) static int cpu_to_allnodes_group(int cpu)
{ {
return cpu_to_node(cpu); return cpu_to_node(cpu);
} }
#endif #endif
/* /*
* Set up scheduler domains and groups. Callers must hold the hotplug lock. * Build sched domains for a given set of cpus and attach the sched domains
* to the individual cpus
*/ */
void __devinit arch_init_sched_domains(void) void build_sched_domains(const cpumask_t *cpu_map)
{ {
int i; int i;
cpumask_t cpu_default_map;
/* /*
* Setup mask for cpus without special case scheduling requirements. * Set up domains for cpus specified by the cpu_map.
* For now this just excludes isolated cpus, but could be used to
* exclude other special cases in the future.
*/ */
cpus_complement(cpu_default_map, cpu_isolated_map); for_each_cpu_mask(i, *cpu_map) {
cpus_and(cpu_default_map, cpu_default_map, cpu_online_map);
/*
* Set up domains. Isolated domains just stay on the dummy domain.
*/
for_each_cpu_mask(i, cpu_default_map) {
int group; int group;
struct sched_domain *sd = NULL, *p; struct sched_domain *sd = NULL, *p;
cpumask_t nodemask = node_to_cpumask(cpu_to_node(i)); cpumask_t nodemask = node_to_cpumask(cpu_to_node(i));
cpus_and(nodemask, nodemask, cpu_default_map); cpus_and(nodemask, nodemask, *cpu_map);
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
if (num_online_cpus() if (num_online_cpus()
> SD_NODES_PER_DOMAIN*cpus_weight(nodemask)) { > SD_NODES_PER_DOMAIN*cpus_weight(nodemask)) {
sd = &per_cpu(allnodes_domains, i); sd = &per_cpu(allnodes_domains, i);
*sd = SD_ALLNODES_INIT; *sd = SD_ALLNODES_INIT;
sd->span = cpu_default_map; sd->span = *cpu_map;
group = cpu_to_allnodes_group(i); group = cpu_to_allnodes_group(i);
sd->groups = &sched_group_allnodes[group]; sd->groups = &sched_group_allnodes[group];
p = sd; p = sd;
...@@ -173,7 +165,7 @@ void __devinit arch_init_sched_domains(void) ...@@ -173,7 +165,7 @@ void __devinit arch_init_sched_domains(void)
*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;
cpus_and(sd->span, sd->span, cpu_default_map); cpus_and(sd->span, sd->span, *cpu_map);
#endif #endif
p = sd; p = sd;
...@@ -190,7 +182,7 @@ void __devinit arch_init_sched_domains(void) ...@@ -190,7 +182,7 @@ void __devinit arch_init_sched_domains(void)
group = cpu_to_cpu_group(i); group = cpu_to_cpu_group(i);
*sd = SD_SIBLING_INIT; *sd = SD_SIBLING_INIT;
sd->span = cpu_sibling_map[i]; sd->span = cpu_sibling_map[i];
cpus_and(sd->span, sd->span, cpu_default_map); cpus_and(sd->span, sd->span, *cpu_map);
sd->parent = p; sd->parent = p;
sd->groups = &sched_group_cpus[group]; sd->groups = &sched_group_cpus[group];
#endif #endif
...@@ -198,9 +190,9 @@ void __devinit arch_init_sched_domains(void) ...@@ -198,9 +190,9 @@ void __devinit arch_init_sched_domains(void)
#ifdef CONFIG_SCHED_SMT #ifdef CONFIG_SCHED_SMT
/* Set up CPU (sibling) groups */ /* Set up CPU (sibling) groups */
for_each_cpu_mask(i, cpu_default_map) { for_each_cpu_mask(i, *cpu_map) {
cpumask_t this_sibling_map = cpu_sibling_map[i]; cpumask_t this_sibling_map = cpu_sibling_map[i];
cpus_and(this_sibling_map, this_sibling_map, cpu_default_map); cpus_and(this_sibling_map, this_sibling_map, *cpu_map);
if (i != first_cpu(this_sibling_map)) if (i != first_cpu(this_sibling_map))
continue; continue;
...@@ -213,7 +205,7 @@ void __devinit arch_init_sched_domains(void) ...@@ -213,7 +205,7 @@ void __devinit arch_init_sched_domains(void)
for (i = 0; i < MAX_NUMNODES; i++) { for (i = 0; i < MAX_NUMNODES; i++) {
cpumask_t nodemask = node_to_cpumask(i); cpumask_t nodemask = node_to_cpumask(i);
cpus_and(nodemask, nodemask, cpu_default_map); cpus_and(nodemask, nodemask, *cpu_map);
if (cpus_empty(nodemask)) if (cpus_empty(nodemask))
continue; continue;
...@@ -222,7 +214,7 @@ void __devinit arch_init_sched_domains(void) ...@@ -222,7 +214,7 @@ void __devinit arch_init_sched_domains(void)
} }
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
init_sched_build_groups(sched_group_allnodes, cpu_default_map, init_sched_build_groups(sched_group_allnodes, *cpu_map,
&cpu_to_allnodes_group); &cpu_to_allnodes_group);
for (i = 0; i < MAX_NUMNODES; i++) { for (i = 0; i < MAX_NUMNODES; i++) {
...@@ -233,12 +225,12 @@ void __devinit arch_init_sched_domains(void) ...@@ -233,12 +225,12 @@ void __devinit arch_init_sched_domains(void)
cpumask_t covered = CPU_MASK_NONE; cpumask_t covered = CPU_MASK_NONE;
int j; int j;
cpus_and(nodemask, nodemask, cpu_default_map); cpus_and(nodemask, nodemask, *cpu_map);
if (cpus_empty(nodemask)) if (cpus_empty(nodemask))
continue; continue;
domainspan = sched_domain_node_span(i); domainspan = sched_domain_node_span(i);
cpus_and(domainspan, domainspan, cpu_default_map); cpus_and(domainspan, domainspan, *cpu_map);
sg = kmalloc(sizeof(struct sched_group), GFP_KERNEL); sg = kmalloc(sizeof(struct sched_group), GFP_KERNEL);
sched_group_nodes[i] = sg; sched_group_nodes[i] = sg;
...@@ -266,7 +258,7 @@ void __devinit arch_init_sched_domains(void) ...@@ -266,7 +258,7 @@ void __devinit arch_init_sched_domains(void)
int n = (i + j) % MAX_NUMNODES; int n = (i + j) % MAX_NUMNODES;
cpus_complement(notcovered, covered); cpus_complement(notcovered, covered);
cpus_and(tmp, notcovered, cpu_default_map); cpus_and(tmp, notcovered, *cpu_map);
cpus_and(tmp, tmp, domainspan); cpus_and(tmp, tmp, domainspan);
if (cpus_empty(tmp)) if (cpus_empty(tmp))
break; break;
...@@ -293,7 +285,7 @@ void __devinit arch_init_sched_domains(void) ...@@ -293,7 +285,7 @@ void __devinit arch_init_sched_domains(void)
#endif #endif
/* Calculate CPU power for physical packages and nodes */ /* Calculate CPU power for physical packages and nodes */
for_each_cpu_mask(i, cpu_default_map) { for_each_cpu_mask(i, *cpu_map) {
int power; int power;
struct sched_domain *sd; struct sched_domain *sd;
#ifdef CONFIG_SCHED_SMT #ifdef CONFIG_SCHED_SMT
...@@ -359,13 +351,35 @@ void __devinit arch_init_sched_domains(void) ...@@ -359,13 +351,35 @@ void __devinit arch_init_sched_domains(void)
cpu_attach_domain(sd, i); cpu_attach_domain(sd, i);
} }
} }
/*
* Set up scheduler domains and groups. Callers must hold the hotplug lock.
*/
void arch_init_sched_domains(const cpumask_t *cpu_map)
{
cpumask_t cpu_default_map;
/*
* Setup mask for cpus without special case scheduling requirements.
* For now this just excludes isolated cpus, but could be used to
* exclude other special cases in the future.
*/
cpus_andnot(cpu_default_map, *cpu_map, cpu_isolated_map);
build_sched_domains(&cpu_default_map);
}
void __devinit arch_destroy_sched_domains(void) void arch_destroy_sched_domains(const cpumask_t *cpu_map)
{ {
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
int i; int i;
for (i = 0; i < MAX_NUMNODES; i++) { for (i = 0; i < MAX_NUMNODES; i++) {
cpumask_t nodemask = node_to_cpumask(i);
struct sched_group *oldsg, *sg = sched_group_nodes[i]; struct sched_group *oldsg, *sg = sched_group_nodes[i];
cpus_and(nodemask, nodemask, *cpu_map);
if (cpus_empty(nodemask))
continue;
if (sg == NULL) if (sg == NULL)
continue; continue;
sg = sg->next; sg = sg->next;
......
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