From: john stultz <johnstul@us.ibm.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: /proc/stat btime accuracy problem
Date: Wed, 01 Jun 2011 16:58:31 -0700 [thread overview]
Message-ID: <1306972711.11492.23.camel@work-vm> (raw)
In-Reply-To: <BANLkTi=yEMDLEo99WZm2Bt4pi_pog5igww@mail.gmail.com>
On Wed, 2011-06-01 at 17:35 -0600, Bjorn Helgaas wrote:
> On Wed, Jun 1, 2011 at 4:35 PM, john stultz <johnstul@us.ibm.com> wrote:
> > On Wed, 2011-06-01 at 14:50 -0600, Bjorn Helgaas wrote:
> >> timekeeping_init() basically does the following:
> >>
> >> xtime = RTC
> >> if (arch implements read_boot_clock())
> >> wall_to_monotonic = -read_boot_clock()
> >> else
> >> wall_to_monotonic = -xtime
> >>
> >> So wall_to_monotonic records some approximation of the system boot
> >> time, which is then used to derive the "btime" reported in /proc/stat.
> >>
> >> The problem I'm seeing is that xtime is updated on timer ticks, so
> >> uninterruptible code, like kernel serial printk, makes us miss ticks,
> >> so xtime falls behind the RTC.
> >
> > Huh. So this sort of issue was common back when we had tick-based
> > timekeeping (in combination with troubled hardware), but with the
> > current clocksource based timekeeping, occasional lost ticks shouldn't
> > really effect time.
>
> Makes sense. Your presentation here was a great help:
> http://sr71.net/~jstultz/tod/ols-presentation-final.pdf
>
> > Can you explain a bit more about what kind of hardware this is happening
> > on, and what clocksource is being used?
>
> Sure. This is an x86 box. Normally we're using the TSC clocksource,
> and I don't think the issue happens after that. I guess my
> experimentation so far has been with uninterruptible time before we
> register *any* clocksource (or at least before I see any "Switching to
> clocksource" messages).
Huh.
So yea, if we are very early at boot, we're likely using the jiffies
clocksource, which is basically a software-based tick counter, which
would be prone to lost-ticks issues if irqs were disabled for too long.
Do you know if this is this a relatively new issue?
My first instinct is "don't do that!" to whatever driver is disabling
irqs for so long. Do you know what's actually causing these long irq off
periods?
I assume you're noticing this offset by seeing that CLOCK_REALTIME is
off from the RTC right after boot? How severe is this? The RTC read is
only second granular, so there's a fair amount of error (~1 second)
possible right at boot, so this then must be many seconds worth of lost
ticks to be noticeable, right?
thanks
-john
next prev parent reply other threads:[~2011-06-01 23:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-01 20:50 /proc/stat btime accuracy problem Bjorn Helgaas
2011-06-01 22:35 ` john stultz
2011-06-01 23:35 ` Bjorn Helgaas
2011-06-01 23:58 ` john stultz [this message]
2011-06-02 0:31 ` Bjorn Helgaas
2011-06-02 0:49 ` john stultz
2011-06-02 6:34 ` Bjorn Helgaas
2011-06-07 5:20 ` Bjorn Helgaas
2011-06-07 17:50 ` john stultz
2011-06-08 1:03 ` john stultz
2011-06-08 4:16 ` Bjorn Helgaas
2011-06-02 10:00 ` Alan Cox
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=1306972711.11492.23.camel@work-vm \
--to=johnstul@us.ibm.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).