mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC][PATCH] linux-2.4.21-pre4_tsc-lost-tick_A0
@ 2003-01-31  0:17 john stultz
  2003-01-31  1:08 ` george anzinger
  0 siblings, 1 reply; 5+ messages in thread
From: john stultz @ 2003-01-31  0:17 UTC (permalink / raw)
  To: lkml

All,
	Occasionally due to hardware or software, its possible to miss multiple
timer interrupts. This can cause small inconsistencies in time as well
as time drifting behind other systems. 

This patch checks each timer interrupt, using the TSC, if we have missed
any ticks. Then if so, compensates jiffies for them. I have already
submitted a patch for 2.4 which does this for the cyclone-timer based
code, and I've been testing a version for 2.5 for all time sources (in
-mm6, I believe). 

Since this code affects more users then the cyclone-based version, I
want to be more careful and get more testing in the 2.5 tree before I
submit this. However, just so people wanting it can play with it and
test it themselves, I wanted to send this out for comments. 

I'm already somewhat cautious that loops_per_jiffy isn't going to cut it
with this patch (I'm thinking fast_gettimeoffset_quotient would probably
be better). So please let me know if you find any issues with this
patch.

thanks
-john

diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
--- a/arch/i386/kernel/time.c	Thu Jan 30 16:03:19 2003
+++ b/arch/i386/kernel/time.c	Thu Jan 30 16:03:19 2003
@@ -657,6 +657,7 @@
 	if(use_cyclone)
 		mark_timeoffset_cyclone();
 	else if (use_tsc) {
+		unsigned long delta = last_tsc_low;
 		/*
 		 * It is important that these two operations happen almost at
 		 * the same time. We do the RDTSC stuff first, since it's
@@ -700,6 +701,13 @@
 		   momentarily as they flip back to zero */
 		if (count == LATCH) {
 			count--;
+		}
+
+		/* lost tick compensation */
+		delta = last_tsc_low - delta;
+		if(delta >= 2*loops_per_jiffy){
+			delta = (delta/loops_per_jiffy)-1;
+			jiffies += delta;
 		}
 
 		count = ((LATCH-1) - count) * TICK_SIZE;




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-01-31 20:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-31  0:17 [RFC][PATCH] linux-2.4.21-pre4_tsc-lost-tick_A0 john stultz
2003-01-31  1:08 ` george anzinger
2003-01-31  1:22   ` john stultz
2003-01-31  1:41     ` george anzinger
2003-01-31 20:19       ` john stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome