diff options
Diffstat (limited to 'arch/ia64')
-rw-r--r-- | arch/ia64/kernel/domain.c | 90 |
1 files changed, 69 insertions, 21 deletions
diff --git a/arch/ia64/kernel/domain.c b/arch/ia64/kernel/domain.c index bbb8efe126b..e907109983f 100644 --- a/arch/ia64/kernel/domain.c +++ b/arch/ia64/kernel/domain.c | |||
@@ -120,10 +120,10 @@ static int cpu_to_phys_group(int cpu) | |||
120 | * gets dynamically allocated. | 120 | * gets dynamically allocated. |
121 | */ | 121 | */ |
122 | static DEFINE_PER_CPU(struct sched_domain, node_domains); | 122 | static DEFINE_PER_CPU(struct sched_domain, node_domains); |
123 | static struct sched_group *sched_group_nodes[MAX_NUMNODES]; | 123 | static struct sched_group **sched_group_nodes_bycpu[NR_CPUS]; |
124 | 124 | ||
125 | static DEFINE_PER_CPU(struct sched_domain, allnodes_domains); | 125 | static DEFINE_PER_CPU(struct sched_domain, allnodes_domains); |
126 | static struct sched_group sched_group_allnodes[MAX_NUMNODES]; | 126 | static struct sched_group *sched_group_allnodes_bycpu[NR_CPUS]; |
127 | 127 | ||
128 | static int cpu_to_allnodes_group(int cpu) | 128 | static int cpu_to_allnodes_group(int cpu) |
129 | { | 129 | { |
@@ -138,6 +138,21 @@ static int cpu_to_allnodes_group(int cpu) | |||
138 | void build_sched_domains(const cpumask_t *cpu_map) | 138 | void build_sched_domains(const cpumask_t *cpu_map) |
139 | { | 139 | { |
140 | int i; | 140 | int i; |
141 | #ifdef CONFIG_NUMA | ||
142 | struct sched_group **sched_group_nodes = NULL; | ||
143 | struct sched_group *sched_group_allnodes = NULL; | ||
144 | |||
145 | /* | ||
146 | * Allocate the per-node list of sched groups | ||
147 | */ | ||
148 | sched_group_nodes = kmalloc(sizeof(struct sched_group*)*MAX_NUMNODES, | ||
149 | GFP_ATOMIC); | ||
150 | if (!sched_group_nodes) { | ||
151 | printk(KERN_WARNING "Can not alloc sched group node list\n"); | ||
152 | return; | ||
153 | } | ||
154 | sched_group_nodes_bycpu[first_cpu(*cpu_map)] = sched_group_nodes; | ||
155 | #endif | ||
141 | 156 | ||
142 | /* | 157 | /* |
143 | * Set up domains for cpus specified by the cpu_map. | 158 | * Set up domains for cpus specified by the cpu_map. |
@@ -150,8 +165,21 @@ void build_sched_domains(const cpumask_t *cpu_map) | |||
150 | cpus_and(nodemask, nodemask, *cpu_map); | 165 | cpus_and(nodemask, nodemask, *cpu_map); |
151 | 166 | ||
152 | #ifdef CONFIG_NUMA | 167 | #ifdef CONFIG_NUMA |
153 | if (num_online_cpus() | 168 | if (cpus_weight(*cpu_map) |
154 | > SD_NODES_PER_DOMAIN*cpus_weight(nodemask)) { | 169 | > SD_NODES_PER_DOMAIN*cpus_weight(nodemask)) { |
170 | if (!sched_group_allnodes) { | ||
171 | sched_group_allnodes | ||
172 | = kmalloc(sizeof(struct sched_group) | ||
173 | * MAX_NUMNODES, | ||
174 | GFP_KERNEL); | ||
175 | if (!sched_group_allnodes) { | ||
176 | printk(KERN_WARNING | ||
177 | "Can not alloc allnodes sched group\n"); | ||
178 | break; | ||
179 | } | ||
180 | sched_group_allnodes_bycpu[i] | ||
181 | = sched_group_allnodes; | ||
182 | } | ||
155 | sd = &per_cpu(allnodes_domains, i); | 183 | sd = &per_cpu(allnodes_domains, i); |
156 | *sd = SD_ALLNODES_INIT; | 184 | *sd = SD_ALLNODES_INIT; |
157 | sd->span = *cpu_map; | 185 | sd->span = *cpu_map; |
@@ -214,8 +242,9 @@ void build_sched_domains(const cpumask_t *cpu_map) | |||
214 | } | 242 | } |
215 | 243 | ||
216 | #ifdef CONFIG_NUMA | 244 | #ifdef CONFIG_NUMA |
217 | init_sched_build_groups(sched_group_allnodes, *cpu_map, | 245 | if (sched_group_allnodes) |
218 | &cpu_to_allnodes_group); | 246 | init_sched_build_groups(sched_group_allnodes, *cpu_map, |
247 | &cpu_to_allnodes_group); | ||
219 | 248 | ||
220 | for (i = 0; i < MAX_NUMNODES; i++) { | 249 | for (i = 0; i < MAX_NUMNODES; i++) { |
221 | /* Set up node groups */ | 250 | /* Set up node groups */ |
@@ -226,8 +255,10 @@ void build_sched_domains(const cpumask_t *cpu_map) | |||
226 | int j; | 255 | int j; |
227 | 256 | ||
228 | cpus_and(nodemask, nodemask, *cpu_map); | 257 | cpus_and(nodemask, nodemask, *cpu_map); |
229 | if (cpus_empty(nodemask)) | 258 | if (cpus_empty(nodemask)) { |
259 | sched_group_nodes[i] = NULL; | ||
230 | continue; | 260 | continue; |
261 | } | ||
231 | 262 | ||
232 | domainspan = sched_domain_node_span(i); | 263 | domainspan = sched_domain_node_span(i); |
233 | cpus_and(domainspan, domainspan, *cpu_map); | 264 | cpus_and(domainspan, domainspan, *cpu_map); |
@@ -372,25 +403,42 @@ void arch_destroy_sched_domains(const cpumask_t *cpu_map) | |||
372 | { | 403 | { |
373 | #ifdef CONFIG_NUMA | 404 | #ifdef CONFIG_NUMA |
374 | int i; | 405 | int i; |
375 | for (i = 0; i < MAX_NUMNODES; i++) { | 406 | int cpu; |
376 | cpumask_t nodemask = node_to_cpumask(i); | ||
377 | struct sched_group *oldsg, *sg = sched_group_nodes[i]; | ||
378 | 407 | ||
379 | cpus_and(nodemask, nodemask, *cpu_map); | 408 | for_each_cpu_mask(cpu, *cpu_map) { |
380 | if (cpus_empty(nodemask)) | 409 | struct sched_group *sched_group_allnodes |
381 | continue; | 410 | = sched_group_allnodes_bycpu[cpu]; |
411 | struct sched_group **sched_group_nodes | ||
412 | = sched_group_nodes_bycpu[cpu]; | ||
382 | 413 | ||
383 | if (sg == NULL) | 414 | if (sched_group_allnodes) { |
415 | kfree(sched_group_allnodes); | ||
416 | sched_group_allnodes_bycpu[cpu] = NULL; | ||
417 | } | ||
418 | |||
419 | if (!sched_group_nodes) | ||
384 | continue; | 420 | continue; |
385 | sg = sg->next; | 421 | |
422 | for (i = 0; i < MAX_NUMNODES; i++) { | ||
423 | cpumask_t nodemask = node_to_cpumask(i); | ||
424 | struct sched_group *oldsg, *sg = sched_group_nodes[i]; | ||
425 | |||
426 | cpus_and(nodemask, nodemask, *cpu_map); | ||
427 | if (cpus_empty(nodemask)) | ||
428 | continue; | ||
429 | |||
430 | if (sg == NULL) | ||
431 | continue; | ||
432 | sg = sg->next; | ||
386 | next_sg: | 433 | next_sg: |
387 | oldsg = sg; | 434 | oldsg = sg; |
388 | sg = sg->next; | 435 | sg = sg->next; |
389 | kfree(oldsg); | 436 | kfree(oldsg); |
390 | if (oldsg != sched_group_nodes[i]) | 437 | if (oldsg != sched_group_nodes[i]) |
391 | goto next_sg; | 438 | goto next_sg; |
392 | sched_group_nodes[i] = NULL; | 439 | } |
440 | kfree(sched_group_nodes); | ||
441 | sched_group_nodes_bycpu[cpu] = NULL; | ||
393 | } | 442 | } |
394 | #endif | 443 | #endif |
395 | } | 444 | } |
396 | |||