From: Stephen Hemminger <shemminger@osdl.org>
To: john stultz <johnstul@us.ibm.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH] linux-2.5.59_lost-tick_A0
Date: 24 Jan 2003 15:13:13 -0800 [thread overview]
Message-ID: <1043449992.10150.29.camel@dell_ss3.pdx.osdl.net> (raw)
In-Reply-To: <1043189962.15683.82.camel@w-jstultz2.beaverton.ibm.com>
Minor nit: detect_lost_tick could be static and inline.
On Tue, 2003-01-21 at 14:59, john stultz wrote:
> All,
> This patch addresses the following problem: Linux cannot properly
> handle the case where interrupts are disabled for longer then two ticks.
>
> Quick background:
> gettimeofday() calculates wall time using roughly the following
> equation: xtime + (jiffies - wall_jiffies) + timer->get_offset()
>
> When a tick is lost, the system is able to compensate short-term because
> even though jiffies is not incremented, timer->get_offset() (which is
> hardware based) continues to increase. However this falls apart, because
> if after 3 or so lost-ticks an interrupt does occur, jiffies is
> incremented only once and we reset timer->get_offset() effectively
> loosing the time we had been compensating for. This causes brief
> inconsistencies in time, in addition to causing system time to drift
> behind that of other systems.
>
> This patch solves the problem by checking when an interrupt occurs if
> timer->get_offset() is a value greater then 2 ticks. If so, it
> increments jiffies appropriately.
>
> Comments, flames and suggestions are requested and welcome.
>
> thanks
> -john
>
> diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
> --- a/arch/i386/kernel/time.c Tue Jan 21 14:14:18 2003
> +++ b/arch/i386/kernel/time.c Tue Jan 21 14:14:18 2003
> @@ -265,6 +265,21 @@
> #endif
> }
>
> +/*Lost tick detection and compensation*/
> +void detect_lost_tick(void)
> +{
> + /*read time since last interrupt*/
> + unsigned long delta = timer->get_offset();
> +
> + /*check if delta is greater then two ticks*/
> + if(delta > 2*(1000000/HZ)){
> + /*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
> @@ -281,6 +296,7 @@
> */
> 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/
--
Stephen Hemminger <shemminger@osdl.org>
Open Source Devlopment Lab
next prev parent reply other threads:[~2003-01-24 23:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-21 22:59 john stultz
2003-01-21 23:32 ` Andrew Morton
2003-01-21 23:48 ` john stultz
2003-01-22 5:00 ` Valdis.Kletnieks
2003-01-24 23:13 ` Stephen Hemminger [this message]
2003-01-24 23:06 ` john stultz
[not found] <1043189962.15683.82.camel@w-jstultz2.beaverton.ibm.com.suse.lists.linux.kernel>
2003-01-21 23:27 ` Andi Kleen
2003-01-21 23:31 ` john stultz
2003-01-21 23:48 ` Andi Kleen
2003-01-21 23:49 ` john stultz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1043449992.10150.29.camel@dell_ss3.pdx.osdl.net \
--to=shemminger@osdl.org \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®