diff options
Diffstat (limited to 'kernel/sched.c')
| -rw-r--r-- | kernel/sched.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index b24e57a10f6f..59db86c915f9 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
| @@ -7279,13 +7279,21 @@ struct allmasks { | |||
| 7279 | }; | 7279 | }; |
| 7280 | 7280 | ||
| 7281 | #if NR_CPUS > 128 | 7281 | #if NR_CPUS > 128 |
| 7282 | #define SCHED_CPUMASK_ALLOC 1 | 7282 | #define SCHED_CPUMASK_DECLARE(v) struct allmasks *v |
| 7283 | #define SCHED_CPUMASK_FREE(v) kfree(v) | 7283 | static inline void sched_cpumask_alloc(struct allmasks **masks) |
| 7284 | #define SCHED_CPUMASK_DECLARE(v) struct allmasks *v | 7284 | { |
| 7285 | *masks = kmalloc(sizeof(**masks), GFP_KERNEL); | ||
| 7286 | } | ||
| 7287 | static inline void sched_cpumask_free(struct allmasks *masks) | ||
| 7288 | { | ||
| 7289 | kfree(masks); | ||
| 7290 | } | ||
| 7285 | #else | 7291 | #else |
| 7286 | #define SCHED_CPUMASK_ALLOC 0 | 7292 | #define SCHED_CPUMASK_DECLARE(v) struct allmasks _v, *v = &_v |
| 7287 | #define SCHED_CPUMASK_FREE(v) | 7293 | static inline void sched_cpumask_alloc(struct allmasks **masks) |
| 7288 | #define SCHED_CPUMASK_DECLARE(v) struct allmasks _v, *v = &_v | 7294 | { } |
| 7295 | static inline void sched_cpumask_free(struct allmasks *masks) | ||
| 7296 | { } | ||
| 7289 | #endif | 7297 | #endif |
| 7290 | 7298 | ||
| 7291 | #define SCHED_CPUMASK_VAR(v, a) cpumask_t *v = (cpumask_t *) \ | 7299 | #define SCHED_CPUMASK_VAR(v, a) cpumask_t *v = (cpumask_t *) \ |
| @@ -7361,9 +7369,8 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
| 7361 | return -ENOMEM; | 7369 | return -ENOMEM; |
| 7362 | } | 7370 | } |
| 7363 | 7371 | ||
| 7364 | #if SCHED_CPUMASK_ALLOC | ||
| 7365 | /* get space for all scratch cpumask variables */ | 7372 | /* get space for all scratch cpumask variables */ |
| 7366 | allmasks = kmalloc(sizeof(*allmasks), GFP_KERNEL); | 7373 | sched_cpumask_alloc(&allmasks); |
| 7367 | if (!allmasks) { | 7374 | if (!allmasks) { |
| 7368 | printk(KERN_WARNING "Cannot alloc cpumask array\n"); | 7375 | printk(KERN_WARNING "Cannot alloc cpumask array\n"); |
| 7369 | kfree(rd); | 7376 | kfree(rd); |
| @@ -7372,7 +7379,7 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
| 7372 | #endif | 7379 | #endif |
| 7373 | return -ENOMEM; | 7380 | return -ENOMEM; |
| 7374 | } | 7381 | } |
| 7375 | #endif | 7382 | |
| 7376 | tmpmask = (cpumask_t *)allmasks; | 7383 | tmpmask = (cpumask_t *)allmasks; |
| 7377 | 7384 | ||
| 7378 | 7385 | ||
| @@ -7626,13 +7633,13 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
| 7626 | cpu_attach_domain(sd, rd, i); | 7633 | cpu_attach_domain(sd, rd, i); |
| 7627 | } | 7634 | } |
| 7628 | 7635 | ||
| 7629 | SCHED_CPUMASK_FREE((void *)allmasks); | 7636 | sched_cpumask_free(allmasks); |
| 7630 | return 0; | 7637 | return 0; |
| 7631 | 7638 | ||
| 7632 | #ifdef CONFIG_NUMA | 7639 | #ifdef CONFIG_NUMA |
| 7633 | error: | 7640 | error: |
| 7634 | free_sched_groups(cpu_map, tmpmask); | 7641 | free_sched_groups(cpu_map, tmpmask); |
| 7635 | SCHED_CPUMASK_FREE((void *)allmasks); | 7642 | sched_cpumask_free(allmasks); |
| 7636 | kfree(rd); | 7643 | kfree(rd); |
| 7637 | return -ENOMEM; | 7644 | return -ENOMEM; |
| 7638 | #endif | 7645 | #endif |
