All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: "Arve Hjønnevåg" <arve@android.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, mingo@redhat.com, hpa@zytor.com,
	arnd@arndb.de, linux-tip-commits@vger.kernel.org
Subject: Re: [tip:timers/core] time: Add timekeeping_inject_sleeptime
Date: Fri, 29 Apr 2011 18:57:35 -0700	[thread overview]
Message-ID: <1304128655.30215.80.camel@work-vm> (raw)
In-Reply-To: <BANLkTi=9rW=U-Excx+xJb1h3mVvfEaxhKw@mail.gmail.com>

On Fri, 2011-04-29 at 18:12 -0700, Arve Hjønnevåg wrote:
>         /* RTC precision is 1 second; adjust delta for avg 1/2 sec err */
> -       set_normalized_timespec(&delta,
> +       set_normalized_timespec(&new_delta,
>                                 ts.tv_sec - oldtime,
>                                 ts.tv_nsec - (NSEC_PER_SEC >> 1));
> 
> +       /* prevent 1/2 sec errors from accumulating */
> +       delta_delta = timespec_sub(new_delta, delta);
> +       if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2)
> +               delta = new_delta;
>         return 0;

So, the basic idea is to keep the RTC vs CLOCK_REALTIME delta constant
(by using the same value as the last time) for each resume cycle
assuming it stays within +/-2 seconds.

If it changes more then that since the last suspend (due to user running
hwclock or the periodic NTP sync or drift of the uncorrected RTC) then
throw away the old value and use the new delta.


> @@ -80,6 +87,8 @@ static int rtc_resume(struct device *dev)
>                 return 0;
>         }
>         rtc_tm_to_time(&tm, &newtime);
> +       if (delta_delta.tv_sec < -1)
> +               newtime++;


So this part isn't quite clicking at the moment (forgive my brain, its a
sunny friday!). Wouldn't this trigger even if we threw away the old
delta (since nothing clears delta_delta)?

I'll spend some more time looking at it, but if you can clarify why we
want to inject a second here (and why there's not a corresponding dec
for delta_delta being > 1 sec to make it symmetric) it would help? 

thanks
-john





  reply	other threads:[~2011-04-30  1:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <tip-304529b1b6f8612ccbb4582e997051b48b94f4a4@git.kernel.org>
2011-04-29 23:28 ` [tip:timers/core] time: Add timekeeping_inject_sleeptime Arve Hjønnevåg
2011-04-30  0:23   ` Thomas Gleixner
2011-04-30  1:12     ` Arve Hjønnevåg
2011-04-30  1:57       ` John Stultz [this message]
2011-04-30  3:30         ` Arve Hjønnevåg
2011-04-30  0:24   ` John Stultz
2011-04-30  1:07     ` Arve Hjønnevåg

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=1304128655.30215.80.camel@work-vm \
    --to=john.stultz@linaro.org \
    --cc=arnd@arndb.de \
    --cc=arve@android.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.