Commit b74e6278fd6db5848163ccdc6e9d8eb6efdee9bd
Committed by
Ingo Molnar
1 parent
aa39477b56
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
sched: Fix KMALLOC_MAX_SIZE overflow during cpumask allocation
When allocating space for load_balance_mask, in sched_init, when CPUMASK_OFFSTACK is set, we've managed to spill over KMALLOC_MAX_SIZE on our 6144 core machine. The patch below breaks up the allocations so that they don't overflow the max alloc size. It also allocates the masks on the the node from which they'll most commonly be accessed, to minimize remote accesses on NUMA machines. Suggested-by: George Beshers <gbeshers@sgi.com> Signed-off-by: Alex Thorlton <athorlton@sgi.com> Cc: George Beshers <gbeshers@sgi.com> Cc: Russ Anderson <rja@sgi.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/1418928270-148543-1-git-send-email-athorlton@sgi.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Showing 1 changed file with 5 additions and 8 deletions Side-by-side Diff
kernel/sched/core.c
... | ... | @@ -7113,9 +7113,6 @@ |
7113 | 7113 | #ifdef CONFIG_RT_GROUP_SCHED |
7114 | 7114 | alloc_size += 2 * nr_cpu_ids * sizeof(void **); |
7115 | 7115 | #endif |
7116 | -#ifdef CONFIG_CPUMASK_OFFSTACK | |
7117 | - alloc_size += num_possible_cpus() * cpumask_size(); | |
7118 | -#endif | |
7119 | 7116 | if (alloc_size) { |
7120 | 7117 | ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT); |
7121 | 7118 | |
7122 | 7119 | |
7123 | 7120 | |
... | ... | @@ -7135,13 +7132,13 @@ |
7135 | 7132 | ptr += nr_cpu_ids * sizeof(void **); |
7136 | 7133 | |
7137 | 7134 | #endif /* CONFIG_RT_GROUP_SCHED */ |
7135 | + } | |
7138 | 7136 | #ifdef CONFIG_CPUMASK_OFFSTACK |
7139 | - for_each_possible_cpu(i) { | |
7140 | - per_cpu(load_balance_mask, i) = (void *)ptr; | |
7141 | - ptr += cpumask_size(); | |
7142 | - } | |
7143 | -#endif /* CONFIG_CPUMASK_OFFSTACK */ | |
7137 | + for_each_possible_cpu(i) { | |
7138 | + per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node( | |
7139 | + cpumask_size(), GFP_KERNEL, cpu_to_node(i)); | |
7144 | 7140 | } |
7141 | +#endif /* CONFIG_CPUMASK_OFFSTACK */ | |
7145 | 7142 | |
7146 | 7143 | init_rt_bandwidth(&def_rt_bandwidth, |
7147 | 7144 | global_rt_period(), global_rt_runtime()); |