linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Alan Cox <gnomes@lxorguk.ukuu.org.uk>,
	Gabriel Beddingfield <gabe@nestlabs.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	John Stultz <john.stultz@linaro.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	linux-rtc@vger.kernel.org, Guy Erb <guy@nestlabs.com>,
	hharte@nestlabs.com
Subject: Re: Introduce clock precision to help time travelers was Re: Extreme time jitter with suspend/resume cycles
Date: Wed, 18 Oct 2017 23:56:38 +0200	[thread overview]
Message-ID: <20171018215638.GA7487@amd> (raw)
In-Reply-To: <20171018212645.7htby4qmnfbep3vx@piout.net>

[-- Attachment #1: Type: text/plain, Size: 3035 bytes --]

On Wed 2017-10-18 23:26:45, Alexandre Belloni wrote:
> On 18/10/2017 at 23:08:28 +0200, Pavel Machek wrote:
> > On Wed 2017-10-18 21:34:49, Alan Cox wrote:
> > > > And even the boring ones have pretty imprecise RTCs... For example Nokia N9.
> > > > I only power it up from time to time, I believe it drifts something like
> > > > minute per month... For normal use with SIM card, it can probably correct
> > > > from GSM network if you happen to have a cell phone signal, but...
> > > > 
> > > > More interesting machines... Old thinkpad is running without CMOS battery.
> > > > ARM OLPC has _three_ RTCs, but not a single working one. N900 has working
> > > > RTC but no or dead backup battery. On these, RTC driver probably knows
> > > > time is not valid, but feeds the garbage into the system time, anyway. Ouch.
> > > > Neither Sharp Zaurus SL-5500 nor C-3000 had battery backup on RTC...
> > > 
> > > Not a new problem, RTC's used to cost lots of money 8)
> > > 
> > > Most early Unixen set the clock at boot from the superblock timestamp of
> > > the root fs, some with RTC's also used to scream at you if the superblock
> > > stamp was too far head of current time.That doesn't quite work with
> > > initrd but you can do the same in userspace on Linux so you'll at least
> > > get 'when I last booted it' and because it's always moving forward lots
> > > of other messes don't happen.
> > 
> > Yeah, that's what "swclock" module of init system does. Someone solved
> > that one for me. But... that's not good enough. In particular, I'd
> > like time not to be displayed when "swclock" was used. Nokia 6230
> > could do it, so linux should be able to do it, too.
> > 
> > It seems kernel should pass accurancy info, or at least "this time is
> > probably off by hours at least" from gettimeofday() and similar
> > syscalls...
> 
> The question being how do you expect the kernel to get that information?

I expect userland to tell kernel. "time is now 12.34, source is ntp,
to it is precise to milliseconds". Or maybe "time is now 23.45, source
is swclock, so it may be off by months".

> Some RTCs will tell you when they lost time/time accuracy and this
> should be properly reported by the driver. If not, this has to be
> implemented.

How is it reported to the userspace?

> For anything else, it is probably the job of userspace to try to be
> clever.

Userspace would be fine with me, but as far as I can tell, there's no
good way to do it in userspace.

My proposal would be: kernel keeps accuracy for timeofday.

If RTC says time is bad, accuracy is set to ~0.

settimeofday sets accuracy to 0 (completely accurate).

new_settimeofday gets new argument, accuracy.

new_gettimofday returns accuracy, too.

Does that sound sane? I'm not sure what other interfaces need to be extended.

Best regards,
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2017-10-18 21:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 16:11 Extreme time jitter with suspend/resume cycles Gabriel Beddingfield
2017-10-04 18:22 ` Thomas Gleixner
2017-10-04 23:10   ` Gabriel Beddingfield
2017-10-05  0:20     ` John Stultz
2017-10-05 16:46       ` Gabriel Beddingfield
2017-10-05 11:01     ` Thomas Gleixner
2017-10-05 16:47       ` Gabriel Beddingfield
2017-10-05 18:01         ` Thomas Gleixner
2017-10-05 20:51           ` Gabriel Beddingfield
2017-10-05 21:04             ` Thomas Gleixner
2017-10-05 21:12               ` Gabriel Beddingfield
2017-10-05 21:33               ` Thomas Gleixner
2017-10-05  0:16 ` John Stultz
2017-10-05 11:05   ` Thomas Gleixner
2017-10-05 14:11     ` Thomas Gleixner
2017-10-05 11:08   ` Miroslav Lichvar
2017-10-05 20:14   ` Gabriel Beddingfield
2017-10-05 21:31     ` Thomas Gleixner
2017-10-15  6:39 ` Introduce clock precision to help time travelers was " Pavel Machek
2017-10-18 20:34   ` Alan Cox
2017-10-18 21:08     ` Pavel Machek
2017-10-18 21:26       ` Alexandre Belloni
2017-10-18 21:56         ` Pavel Machek [this message]
2017-11-04 15:34           ` Alexandre Belloni

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=20171018215638.GA7487@amd \
    --to=pavel@ucw.cz \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=gabe@nestlabs.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=guy@nestlabs.com \
    --cc=hharte@nestlabs.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=sboyd@codeaurora.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).