linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miroslav Lichvar <mlichvar@redhat.com>
To: John Stultz <john.stultz@linaro.org>
Cc: Gabriel Beddingfield <gabe@nestlabs.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	linux-rtc@vger.kernel.org, Guy Erb <guy@nestlabs.com>,
	hharte@nestlabs.com
Subject: Re: Extreme time jitter with suspend/resume cycles
Date: Thu, 5 Oct 2017 13:08:08 +0200	[thread overview]
Message-ID: <20171005110808.GA19251@localhost> (raw)
In-Reply-To: <CALAqxLUO-62B0umVSUK979A+dApOLN3xt5nnZA5HKHsWnRz3KQ@mail.gmail.com>

On Wed, Oct 04, 2017 at 05:16:31PM -0700, John Stultz wrote:
> On Wed, Oct 4, 2017 at 9:11 AM, Gabriel Beddingfield <gabe@nestlabs.com> wrote:
> > We found that the problem is an interaction between the NTP code and
> > what I call the "delta_delta hack." (see [1] and [2]) This code
> > allocates a static variable in a function that contains an offset from
> > the system time to the persistent/rtc clock. It uses that time to
> > fudge the suspend timestamp so that on resume the sleep time will be
> > compensated. It's kind of a statistical hack that assumes things will
> > average out. It seems to have two main assumptions:
> >
> >   1. The persistent/rtc clock has only single-second precision
> >   2. The system does not frequently suspend/resume.
> >   3. If delta_delta is less than 2 seconds, these assumptions are "true"
> >
> > Because the delta_delta hack is trying to maintain an offset from the
> > system time to the persistent/rtc clock, any minor NTP corrections
> > that have occurred since the last suspend will be discarded. However,
> > the NTP subsystem isn't notified that this is happening -- and so it
> > causes some level of instability in its PLL logic.

This is interesting. What polling interval was ntpd using? If I
understand it correctly, with a high-resolution persistent clock the
delta-delta compensation should be very small and shouldn't disrupt
ntpd. Does this instability disappear when ntpd is not controlling the
clock (i.e. "disable ntp" in ntp.conf)?

> We should also figure out how to best handle ntpd in userspace dealing
> with frequent suspend/resume cycles. This is problematic, as the
> closest analogy is trying driving on the road while frequently falling
> asleep.  This is not something I think ntpd handles well.  I suspect
> our options are that any ntp adjustments being made might be made for
> far too long (causing potentially massive over-correction) or not at
> all, and not at all seems slightly better in my mind.

Yeah, controlling the clock in such conditions will be difficult. The
kernel/ntp PLL requires periodic updates. There is some code in
ntp_update_offset() that reduces the frequency adjustment when PLL
updates are missing, but I'm not actually sure if it works correctly
with suspend.

-- 
Miroslav Lichvar

  parent reply	other threads:[~2017-10-05 11:08 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 [this message]
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
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=20171005110808.GA19251@localhost \
    --to=mlichvar@redhat.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=gabe@nestlabs.com \
    --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).