Skip to content

Commit

Permalink
sched/cpupri: Replace NR_CPUS arrays
Browse files Browse the repository at this point in the history
Tejun reported that his resume was failing due to order-3 allocations
from sched_domain building.

Replace the NR_CPUS arrays in there with a dynamically allocated
array.

Reported-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/n/tip-7cysnkw1gik45r864t1nkudh@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 22, 2014
1 parent 944770a commit 4dac0b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions kernel/sched/cpupri.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/gfp.h>
#include <linux/sched.h>
#include <linux/sched/rt.h>
#include <linux/slab.h>
#include "cpupri.h"

/* Convert between a 140 based task->prio, and our 102 based cpupri */
Expand Down Expand Up @@ -218,8 +219,13 @@ int cpupri_init(struct cpupri *cp)
goto cleanup;
}

cp->cpu_to_pri = kcalloc(nr_cpu_ids, sizeof(int), GFP_KERNEL);
if (!cp->cpu_to_pri)
goto cleanup;

for_each_possible_cpu(i)
cp->cpu_to_pri[i] = CPUPRI_INVALID;

return 0;

cleanup:
Expand All @@ -236,6 +242,7 @@ void cpupri_cleanup(struct cpupri *cp)
{
int i;

kfree(cp->cpu_to_pri);
for (i = 0; i < CPUPRI_NR_PRIORITIES; i++)
free_cpumask_var(cp->pri_to_cpu[i].mask);
}
2 changes: 1 addition & 1 deletion kernel/sched/cpupri.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct cpupri_vec {

struct cpupri {
struct cpupri_vec pri_to_cpu[CPUPRI_NR_PRIORITIES];
int cpu_to_pri[NR_CPUS];
int *cpu_to_pri;
};

#ifdef CONFIG_SMP
Expand Down

0 comments on commit 4dac0b6

Please sign in to comment.