diff options
| author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2008-02-13 15:33:16 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-13 16:29:25 -0500 |
| commit | aa02cd2d9bd1e24a230bd66a0a741b984d03915a (patch) | |
| tree | 06e341e095749048feabbe2ded236e5db38ee251 /arch | |
| parent | 10270d4838bdc493781f5a1cf2e90e9c34c9142f (diff) | |
xtime_lock vs update_process_times
Commit d3d74453c34f8fd87674a8cf5b8a327c68f22e99 ("hrtimer: fixup the
HRTIMER_CB_IRQSAFE_NO_SOFTIRQ fallback") broke several archs, and since
only Russell bothered to merge the fix, and Greg to ACK his arch, I'm
sending this for merger.
I have confirmation that the Alpha bit results in a booting kernel.
That leaves: blackfin, frv, sh and sparc untested.
The deadlock in question was found by Russell:
IRQ handle
-> timer_tick() - xtime seqlock held for write
-> update_process_times()
-> run_local_timers()
-> hrtimer_run_queues()
-> hrtimer_get_softirq_time() - tries to get a read lock
Now, Thomas assures me the fix is trivial, only do_timer() needs to be
done under the xtime_lock, and update_process_times() can savely be
removed from under it.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Greg Ungerer <gerg@uclinux.org>
CC: Richard Henderson <rth@twiddle.net>
CC: Bryan Wu <bryan.wu@analog.com>
CC: David Howells <dhowells@redhat.com>
CC: Paul Mundt <lethal@linux-sh.org>
CC: William Irwin <wli@holomorphy.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/alpha/kernel/time.c | 15 | ||||
| -rw-r--r-- | arch/blackfin/kernel/time.c | 8 | ||||
| -rw-r--r-- | arch/frv/kernel/time.c | 6 | ||||
| -rw-r--r-- | arch/m68knommu/kernel/time.c | 12 | ||||
| -rw-r--r-- | arch/sh/kernel/timers/timer-cmt.c | 9 | ||||
| -rw-r--r-- | arch/sh/kernel/timers/timer-mtu2.c | 2 | ||||
| -rw-r--r-- | arch/sparc/kernel/pcic.c | 2 | ||||
| -rw-r--r-- | arch/sparc/kernel/time.c | 7 |
8 files changed, 28 insertions, 33 deletions
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c index 1dd50d07693c..75480cab0893 100644 --- a/arch/alpha/kernel/time.c +++ b/arch/alpha/kernel/time.c | |||
| @@ -119,13 +119,8 @@ irqreturn_t timer_interrupt(int irq, void *dev) | |||
| 119 | state.partial_tick = delta & ((1UL << FIX_SHIFT) - 1); | 119 | state.partial_tick = delta & ((1UL << FIX_SHIFT) - 1); |
| 120 | nticks = delta >> FIX_SHIFT; | 120 | nticks = delta >> FIX_SHIFT; |
| 121 | 121 | ||
| 122 | while (nticks > 0) { | 122 | if (nticks) |
| 123 | do_timer(1); | 123 | do_timer(nticks); |
| 124 | #ifndef CONFIG_SMP | ||
| 125 | update_process_times(user_mode(get_irq_regs())); | ||
| 126 | #endif | ||
| 127 | nticks--; | ||
| 128 | } | ||
| 129 | 124 | ||
| 130 | /* | 125 | /* |
| 131 | * If we have an externally synchronized Linux clock, then update | 126 | * If we have an externally synchronized Linux clock, then update |
| @@ -141,6 +136,12 @@ irqreturn_t timer_interrupt(int irq, void *dev) | |||
| 141 | } | 136 | } |
| 142 | 137 | ||
| 143 | write_sequnlock(&xtime_lock); | 138 | write_sequnlock(&xtime_lock); |
| 139 | |||
| 140 | #ifndef CONFIG_SMP | ||
| 141 | while (nticks--) | ||
| 142 | update_process_times(user_mode(get_irq_regs())); | ||
| 143 | #endif | ||
| 144 | |||
| 144 | return IRQ_HANDLED; | 145 | return IRQ_HANDLED; |
| 145 | } | 146 | } |
| 146 | 147 | ||
diff --git a/arch/blackfin/kernel/time.c b/arch/blackfin/kernel/time.c index 5bd64e341df3..9bdc8f99183a 100644 --- a/arch/blackfin/kernel/time.c +++ b/arch/blackfin/kernel/time.c | |||
| @@ -137,9 +137,6 @@ irqreturn_t timer_interrupt(int irq, void *dummy) | |||
| 137 | 137 | ||
| 138 | do_timer(1); | 138 | do_timer(1); |
| 139 | 139 | ||
| 140 | #ifndef CONFIG_SMP | ||
| 141 | update_process_times(user_mode(get_irq_regs())); | ||
| 142 | #endif | ||
| 143 | profile_tick(CPU_PROFILING); | 140 | profile_tick(CPU_PROFILING); |
| 144 | 141 | ||
| 145 | /* | 142 | /* |
| @@ -161,6 +158,11 @@ irqreturn_t timer_interrupt(int irq, void *dummy) | |||
| 161 | last_rtc_update = xtime.tv_sec - 600; | 158 | last_rtc_update = xtime.tv_sec - 600; |
| 162 | } | 159 | } |
| 163 | write_sequnlock(&xtime_lock); | 160 | write_sequnlock(&xtime_lock); |
| 161 | |||
| 162 | #ifndef CONFIG_SMP | ||
| 163 | update_process_times(user_mode(get_irq_regs())); | ||
| 164 | #endif | ||
| 165 | |||
| 164 | return IRQ_HANDLED; | 166 | return IRQ_HANDLED; |
| 165 | } | 167 | } |
| 166 | 168 | ||
diff --git a/arch/frv/kernel/time.c b/arch/frv/kernel/time.c index 925fb0199a0f..69f6a4ef5d61 100644 --- a/arch/frv/kernel/time.c +++ b/arch/frv/kernel/time.c | |||
| @@ -63,6 +63,7 @@ static irqreturn_t timer_interrupt(int irq, void *dummy) | |||
| 63 | /* last time the cmos clock got updated */ | 63 | /* last time the cmos clock got updated */ |
| 64 | static long last_rtc_update = 0; | 64 | static long last_rtc_update = 0; |
| 65 | 65 | ||
| 66 | profile_tick(CPU_PROFILING); | ||
| 66 | /* | 67 | /* |
| 67 | * Here we are in the timer irq handler. We just have irqs locally | 68 | * Here we are in the timer irq handler. We just have irqs locally |
| 68 | * disabled but we don't know if the timer_bh is running on the other | 69 | * disabled but we don't know if the timer_bh is running on the other |
| @@ -73,8 +74,6 @@ static irqreturn_t timer_interrupt(int irq, void *dummy) | |||
| 73 | write_seqlock(&xtime_lock); | 74 | write_seqlock(&xtime_lock); |
| 74 | 75 | ||
| 75 | do_timer(1); | 76 | do_timer(1); |
| 76 | update_process_times(user_mode(get_irq_regs())); | ||
| 77 | profile_tick(CPU_PROFILING); | ||
| 78 | 77 | ||
| 79 | /* | 78 | /* |
| 80 | * If we have an externally synchronized Linux clock, then update | 79 | * If we have an externally synchronized Linux clock, then update |
| @@ -99,6 +98,9 @@ static irqreturn_t timer_interrupt(int irq, void *dummy) | |||
| 99 | #endif /* CONFIG_HEARTBEAT */ | 98 | #endif /* CONFIG_HEARTBEAT */ |
| 100 | 99 | ||
| 101 | write_sequnlock(&xtime_lock); | 100 | write_sequnlock(&xtime_lock); |
| 101 | |||
| 102 | update_process_times(user_mode(get_irq_regs())); | ||
| 103 | |||
| 102 | return IRQ_HANDLED; | 104 | return IRQ_HANDLED; |
| 103 | } | 105 | } |
| 104 | 106 | ||
diff --git a/arch/m68knommu/kernel/time.c b/arch/m68knommu/kernel/time.c index 89cdbcaeb45f..0ccfb2ad6380 100644 --- a/arch/m68knommu/kernel/time.c +++ b/arch/m68knommu/kernel/time.c | |||
| @@ -42,14 +42,12 @@ irqreturn_t arch_timer_interrupt(int irq, void *dummy) | |||
| 42 | /* last time the cmos clock got updated */ | 42 | /* last time the cmos clock got updated */ |
| 43 | static long last_rtc_update=0; | 43 | static long last_rtc_update=0; |
| 44 | 44 | ||
| 45 | if (current->pid) | ||
| 46 | profile_tick(CPU_PROFILING); | ||
| 47 | |||
| 45 | write_seqlock(&xtime_lock); | 48 | write_seqlock(&xtime_lock); |
| 46 | 49 | ||
| 47 | do_timer(1); | 50 | do_timer(1); |
| 48 | #ifndef CONFIG_SMP | ||
| 49 | update_process_times(user_mode(get_irq_regs())); | ||
| 50 | #endif | ||
| 51 | if (current->pid) | ||
| 52 | profile_tick(CPU_PROFILING); | ||
| 53 | 51 | ||
| 54 | /* | 52 | /* |
| 55 | * If we have an externally synchronized Linux clock, then update | 53 | * If we have an externally synchronized Linux clock, then update |
| @@ -67,6 +65,10 @@ irqreturn_t arch_timer_interrupt(int irq, void *dummy) | |||
| 67 | } | 65 | } |
| 68 | 66 | ||
| 69 | write_sequnlock(&xtime_lock); | 67 | write_sequnlock(&xtime_lock); |
| 68 | |||
| 69 | #ifndef CONFIG_SMP | ||
| 70 | update_process_times(user_mode(get_irq_regs())); | ||
| 71 | #endif | ||
| 70 | return(IRQ_HANDLED); | 72 | return(IRQ_HANDLED); |
| 71 | } | 73 | } |
| 72 | 74 | ||
diff --git a/arch/sh/kernel/timers/timer-cmt.c b/arch/sh/kernel/timers/timer-cmt.c index 499e07beebe2..71312324b5de 100644 --- a/arch/sh/kernel/timers/timer-cmt.c +++ b/arch/sh/kernel/timers/timer-cmt.c | |||
| @@ -100,16 +100,7 @@ static irqreturn_t cmt_timer_interrupt(int irq, void *dev_id) | |||
| 100 | timer_status &= ~0x80; | 100 | timer_status &= ~0x80; |
| 101 | ctrl_outw(timer_status, CMT_CMCSR_0); | 101 | ctrl_outw(timer_status, CMT_CMCSR_0); |
| 102 | 102 | ||
| 103 | /* | ||
| 104 | * Here we are in the timer irq handler. We just have irqs locally | ||
| 105 | * disabled but we don't know if the timer_bh is running on the other | ||
| 106 | * CPU. We need to avoid to SMP race with it. NOTE: we don' t need | ||
| 107 | * the irq version of write_lock because as just said we have irq | ||
| 108 | * locally disabled. -arca | ||
| 109 | */ | ||
| 110 | write_seqlock(&xtime_lock); | ||
| 111 | handle_timer_tick(); | 103 | handle_timer_tick(); |
| 112 | write_sequnlock(&xtime_lock); | ||
| 113 | 104 | ||
| 114 | return IRQ_HANDLED; | 105 | return IRQ_HANDLED; |
| 115 | } | 106 | } |
diff --git a/arch/sh/kernel/timers/timer-mtu2.c b/arch/sh/kernel/timers/timer-mtu2.c index b7499a2a9188..463cd08f9517 100644 --- a/arch/sh/kernel/timers/timer-mtu2.c +++ b/arch/sh/kernel/timers/timer-mtu2.c | |||
| @@ -100,9 +100,7 @@ static irqreturn_t mtu2_timer_interrupt(int irq, void *dev_id) | |||
| 100 | ctrl_outb(timer_status, MTU2_TSR_1); | 100 | ctrl_outb(timer_status, MTU2_TSR_1); |
| 101 | 101 | ||
| 102 | /* Do timer tick */ | 102 | /* Do timer tick */ |
| 103 | write_seqlock(&xtime_lock); | ||
| 104 | handle_timer_tick(); | 103 | handle_timer_tick(); |
| 105 | write_sequnlock(&xtime_lock); | ||
| 106 | 104 | ||
| 107 | return IRQ_HANDLED; | 105 | return IRQ_HANDLED; |
| 108 | } | 106 | } |
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index 4cd5d7818dc6..a6a6f9823370 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c | |||
| @@ -713,10 +713,10 @@ static irqreturn_t pcic_timer_handler (int irq, void *h) | |||
| 713 | write_seqlock(&xtime_lock); /* Dummy, to show that we remember */ | 713 | write_seqlock(&xtime_lock); /* Dummy, to show that we remember */ |
| 714 | pcic_clear_clock_irq(); | 714 | pcic_clear_clock_irq(); |
| 715 | do_timer(1); | 715 | do_timer(1); |
| 716 | write_sequnlock(&xtime_lock); | ||
| 716 | #ifndef CONFIG_SMP | 717 | #ifndef CONFIG_SMP |
| 717 | update_process_times(user_mode(get_irq_regs())); | 718 | update_process_times(user_mode(get_irq_regs())); |
| 718 | #endif | 719 | #endif |
| 719 | write_sequnlock(&xtime_lock); | ||
| 720 | return IRQ_HANDLED; | 720 | return IRQ_HANDLED; |
| 721 | } | 721 | } |
| 722 | 722 | ||
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c index 00b393c3a4a0..cfaf22c05bc4 100644 --- a/arch/sparc/kernel/time.c +++ b/arch/sparc/kernel/time.c | |||
| @@ -128,10 +128,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id) | |||
| 128 | clear_clock_irq(); | 128 | clear_clock_irq(); |
| 129 | 129 | ||
| 130 | do_timer(1); | 130 | do_timer(1); |
| 131 | #ifndef CONFIG_SMP | ||
| 132 | update_process_times(user_mode(get_irq_regs())); | ||
| 133 | #endif | ||
| 134 | |||
| 135 | 131 | ||
| 136 | /* Determine when to update the Mostek clock. */ | 132 | /* Determine when to update the Mostek clock. */ |
| 137 | if (ntp_synced() && | 133 | if (ntp_synced() && |
| @@ -145,6 +141,9 @@ irqreturn_t timer_interrupt(int irq, void *dev_id) | |||
| 145 | } | 141 | } |
| 146 | write_sequnlock(&xtime_lock); | 142 | write_sequnlock(&xtime_lock); |
| 147 | 143 | ||
| 144 | #ifndef CONFIG_SMP | ||
| 145 | update_process_times(user_mode(get_irq_regs())); | ||
| 146 | #endif | ||
| 148 | return IRQ_HANDLED; | 147 | return IRQ_HANDLED; |
| 149 | } | 148 | } |
| 150 | 149 | ||
