Commit 3c94f343 authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka
Browse files

ipipe: timer: allocate cpumask dynamically

When a huge number of CPUs is available (e.g. CONFIG_MAXSMP/x86), we
might overflow the stack with cpumask_t variables in
ipipe_select_timer(). Allocate the cpumask we need there dynamically
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
parent 29230b15
......@@ -268,7 +268,7 @@ int ipipe_select_timers(const struct cpumask *mask)
struct clock_event_device *evtdev;
unsigned long flags;
unsigned cpu;
cpumask_t fixup;
cpumask_var_t fixup;
if (!__ipipe_hrclock_ok()) {
printk("I-pipe: high-resolution clock not working\n");
......@@ -282,6 +282,12 @@ int ipipe_select_timers(const struct cpumask *mask)
} else
hrclock_freq = __ipipe_hrclock_freq;
if (!zalloc_cpumask_var(&fixup, GFP_KERNEL)) {
return -ENODEV;
raw_spin_lock_irqsave(&lock, flags);
/* First, choose timers for the CPUs handled by ipipe */
......@@ -309,9 +315,9 @@ int ipipe_select_timers(const struct cpumask *mask)
* forwarded because they have the same IRQ as an ipipe-enabled
* timer.
cpumask_andnot(&fixup, cpu_online_mask, mask);
cpumask_andnot(fixup, cpu_online_mask, mask);
for_each_cpu(cpu, &fixup) {
for_each_cpu(cpu, fixup) {
list_for_each_entry(t, &timers, link) {
if (!cpumask_test_cpu(cpu, t->cpumask))
......@@ -322,6 +328,7 @@ int ipipe_select_timers(const struct cpumask *mask)
raw_spin_unlock_irqrestore(&lock, flags);
flags = ipipe_critical_enter(ipipe_timer_request_sync);
......@@ -330,6 +337,7 @@ int ipipe_select_timers(const struct cpumask *mask)
raw_spin_unlock_irqrestore(&lock, flags);
for_each_cpu(cpu, mask) {
per_cpu(ipipe_percpu.hrtimer_irq, cpu) = -1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment