Source: MontaVista Software, Inc. George Anzinger Type: Defect Fix Keywords: Signed-off-by: George Anzinger Description: This patch changes the timer interrupt code for the RT patch to respect the xtime_lock which should protect jiffies and to collect offset information on jiffies interrupts. This offset info must be collected as soon as possible during the jiffies interrupt and also needs to be protected by the xtime_lock. The xtime_lock is thus a "raw" lock. arch/i386/kernel/time.c | 8 +++++--- include/linux/time.h | 2 +- kernel/timer.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) Index: topdir/kernel/timer.c =================================================================== --- topdir.orig/kernel/timer.c +++ topdir/kernel/timer.c @@ -946,7 +946,7 @@ unsigned long wall_jiffies = INITIAL_JIF * playing with xtime and avenrun. */ #ifndef ARCH_HAVE_XTIME_LOCK -DECLARE_SEQLOCK(xtime_lock); +DECLARE_RAW_SEQLOCK(xtime_lock); EXPORT_SYMBOL(xtime_lock); #endif Index: topdir/include/linux/time.h =================================================================== --- topdir.orig/include/linux/time.h +++ topdir/include/linux/time.h @@ -80,7 +80,7 @@ mktime (unsigned int year, unsigned int extern struct timespec xtime; extern struct timespec wall_to_monotonic; -extern seqlock_t xtime_lock; +extern raw_seqlock_t xtime_lock; static inline unsigned long get_seconds(void) { Index: topdir/arch/i386/kernel/time.c =================================================================== --- topdir.orig/arch/i386/kernel/time.c +++ topdir/arch/i386/kernel/time.c @@ -20,7 +20,7 @@ * monotonic gettimeofday() with fast_get_timeoffset(), * drift-proof precision TSC calibration on boot * (C. Scott Ananian , Andrew D. - * Balsa , Philip Gladstone ; + * Balsa , Philip Gladstone ; * ported from 2.0.35 Jumbo-9 by Michael Krause ). * 1998-12-16 Andrea Arcangeli * Fixed Jumbo-9 code in 2.1.131: do_gettimeofday was missing 1 jiffy @@ -224,7 +224,10 @@ EXPORT_SYMBOL(profile_pc); */ void direct_timer_interrupt(struct pt_regs *regs) { + write_seqlock(&xtime_lock); + cur_timer->mark_offset(); do_timer_interrupt_hook(regs); + write_sequnlock(&xtime_lock); } #endif @@ -254,6 +257,7 @@ static inline void do_timer_interrupt(in #endif #ifndef CONFIG_PREEMPT_HARDIRQS + cur_timer->mark_offset(); do_timer_interrupt_hook(regs); #endif @@ -312,8 +316,6 @@ irqreturn_t timer_interrupt(int irq, voi * locally disabled. -arca */ write_seqlock(&xtime_lock); - - cur_timer->mark_offset(); do_timer_interrupt(irq, NULL, regs);