Skip to content

Commit 4dac0b6

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/cpupri: Replace NR_CPUS arrays
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 <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Linus Torvalds <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 944770a commit 4dac0b6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

kernel/sched/cpupri.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/gfp.h>
3131
#include <linux/sched.h>
3232
#include <linux/sched/rt.h>
33+
#include <linux/slab.h>
3334
#include "cpupri.h"
3435

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

222+
cp->cpu_to_pri = kcalloc(nr_cpu_ids, sizeof(int), GFP_KERNEL);
223+
if (!cp->cpu_to_pri)
224+
goto cleanup;
225+
221226
for_each_possible_cpu(i)
222227
cp->cpu_to_pri[i] = CPUPRI_INVALID;
228+
223229
return 0;
224230

225231
cleanup:
@@ -236,6 +242,7 @@ void cpupri_cleanup(struct cpupri *cp)
236242
{
237243
int i;
238244

245+
kfree(cp->cpu_to_pri);
239246
for (i = 0; i < CPUPRI_NR_PRIORITIES; i++)
240247
free_cpumask_var(cp->pri_to_cpu[i].mask);
241248
}

kernel/sched/cpupri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct cpupri_vec {
1717

1818
struct cpupri {
1919
struct cpupri_vec pri_to_cpu[CPUPRI_NR_PRIORITIES];
20-
int cpu_to_pri[NR_CPUS];
20+
int *cpu_to_pri;
2121
};
2222

2323
#ifdef CONFIG_SMP

0 commit comments

Comments
 (0)