Re: [PATCH] make lost-tick detection more informative

From: Andrew Morton (akpm@digeo.com)
Date: Thu Jan 30 2003 - 16:14:17 EST


Dave Hansen wrote:
>
> The new lost-tick detection code is pretty cool,

I've actually disabled it in -mmnext, because I get too
much mail already.

If you want to slap this on top of that and some new
kernel-hacking debug config option, that would be neat.

 arch/i386/kernel/time.c | 36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+)

diff -puN arch/i386/kernel/time.c~lost-tick arch/i386/kernel/time.c
--- 25/arch/i386/kernel/time.c~lost-tick Wed Jan 29 14:12:23 2003
+++ 25-akpm/arch/i386/kernel/time.c Wed Jan 29 14:39:52 2003
@@ -266,6 +266,41 @@ static inline void do_timer_interrupt(in
 }
 
 /*
+ * Lost tick detection and compensation
+ */
+static inline void detect_lost_tick(void)
+{
+ /* read time since last interrupt */
+ unsigned long delta = timer->get_offset();
+ static unsigned long dbg_print;
+
+ /* check if delta is greater then two ticks */
+ if(delta >= 2*(1000000/HZ)){
+
+ /*
+ * only print debug info first 5 times
+ */
+ /*
+ * AKPM: disable this for now; it's nice, but irritating.
+ */
+ if (0 && dbg_print < 5) {
+ printk(KERN_WARNING "\nWarning! Detected %lu "
+ "micro-second gap between interrupts.\n",
+ delta);
+ printk(KERN_WARNING " Compensating for %lu lost "
+ "ticks.\n",
+ delta/(1000000/HZ)-1);
+ dump_stack();
+ dbg_print++;
+ }
+ /* calculate number of missed ticks */
+ delta = delta/(1000000/HZ)-1;
+ jiffies += delta;
+ }
+
+}
+
+/*
  * This is the same as the above, except we _also_ save the current
  * Time Stamp Counter value at the time of the timer interrupt, so that
  * we later on can estimate the time of day more exactly.
@@ -281,6 +316,7 @@ void timer_interrupt(int irq, void *dev_
          */
         write_lock(&xtime_lock);
 
+ detect_lost_tick();
         timer->mark_offset();
  
         do_timer_interrupt(irq, NULL, regs);

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Jan 31 2003 - 22:00:24 EST