diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-01-14 01:11:39 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-01-14 21:59:03 -0500 |
commit | 0215f7d8c53fb192cd4491ede0ece5cca6b5db57 (patch) | |
tree | 3c72b3f85caf97ec9a2d42367a32a06df5623e1a /arch/powerpc/kernel/time.c | |
parent | 30c826358d10c1d6f8147de3310b97488daec830 (diff) |
powerpc: Fix races with irq_work
If we set irq_work on a processor and immediately afterward, before the
irq work has a chance to be processed, we change the decrementer value,
we can seriously delay the handling of that irq_work.
Fix it by checking in a few places for pending irq work, first before
changing the decrementer in decrementer_set_next_event() and after
changing it in the same function and in timer_interrupt().
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/time.c')
-rw-r--r-- | arch/powerpc/kernel/time.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index afb1b56ef4fa..b3dab20acf34 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -536,6 +536,9 @@ void timer_interrupt(struct pt_regs * regs) | |||
536 | now = *next_tb - now; | 536 | now = *next_tb - now; |
537 | if (now <= DECREMENTER_MAX) | 537 | if (now <= DECREMENTER_MAX) |
538 | set_dec((int)now); | 538 | set_dec((int)now); |
539 | /* We may have raced with new irq work */ | ||
540 | if (test_irq_work_pending()) | ||
541 | set_dec(1); | ||
539 | __get_cpu_var(irq_stat).timer_irqs_others++; | 542 | __get_cpu_var(irq_stat).timer_irqs_others++; |
540 | } | 543 | } |
541 | 544 | ||
@@ -802,8 +805,16 @@ static void __init clocksource_init(void) | |||
802 | static int decrementer_set_next_event(unsigned long evt, | 805 | static int decrementer_set_next_event(unsigned long evt, |
803 | struct clock_event_device *dev) | 806 | struct clock_event_device *dev) |
804 | { | 807 | { |
808 | /* Don't adjust the decrementer if some irq work is pending */ | ||
809 | if (test_irq_work_pending()) | ||
810 | return 0; | ||
805 | __get_cpu_var(decrementers_next_tb) = get_tb_or_rtc() + evt; | 811 | __get_cpu_var(decrementers_next_tb) = get_tb_or_rtc() + evt; |
806 | set_dec(evt); | 812 | set_dec(evt); |
813 | |||
814 | /* We may have raced with new irq work */ | ||
815 | if (test_irq_work_pending()) | ||
816 | set_dec(1); | ||
817 | |||
807 | return 0; | 818 | return 0; |
808 | } | 819 | } |
809 | 820 | ||