linux-mips
[Top] [All Lists]

Re: [PATCH] loosing time with CPU counter timer

To: linux-mips@linux-mips.org
Subject: Re: [PATCH] loosing time with CPU counter timer
From: Jun Sun <jsun@mvista.com>
Date: Mon, 21 Apr 2003 14:22:03 -0700
Cc: jsun@mvista.com
In-reply-to: <20030414171655.G1642@mvista.com>; from jsun@mvista.com on Mon, Apr 14, 2003 at 05:16:55PM -0700
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20030414171655.G1642@mvista.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.2.5i
On Mon, Apr 14, 2003 at 05:16:55PM -0700, Jun Sun wrote:
> 
> This patch fixes an ancient timer bug.
> 
> If one uses CPU counter as the system timer, it looses time
> over the time.
> 
> Basically, timer_interrupt() does the following when it serves
> an cpu counter interrupt (only relavent part shown);
> 
> 0) interrupt happens
> 1) read cpu counter;
> 2) add it with cycles_per_jiffy, and set the value to compare
>    register.
> 
> The problem is that cpu counter could increase between 0) and 1),
> say by delta units.  Then the next timer interrupt is set to
> t0 + delta + cycles_per_unit, instead of t0 + cycles_per_unit,
> (where t0 is the current timer interrupt time)
> 
> Similar bug also exists in old-time.c, but anybody really cares? :)
> Especially it has been there for quite a while ....
> 
<snip>

After a refreshing weekend I realize there exists a much more
elegant fix for the problem.  :) See the patch attached.

Unfortuately I have already checked in the not-so-elegant fix.
So the actual patch to check in this time will be diff between 
this one and the previous patch.

Comments?

Jun

Attachment: junk1
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>