linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Miroslav Lichvar <mlichvar@redhat.com>
Cc: linux-kernel@vger.kernel.org, Prarit Bhargava <prarit@redhat.com>
Subject: Re: [PATCH] ntp: Make periodic RTC update more reliable
Date: Thu, 22 Aug 2013 12:36:25 -0700	[thread overview]
Message-ID: <52166839.80004@linaro.org> (raw)
In-Reply-To: <1375378295-3858-1-git-send-email-mlichvar@redhat.com>

On 08/01/2013 10:31 AM, Miroslav Lichvar wrote:
> The current code requires that the scheduled update of the RTC happens
> in the closest tick to the half of the second. This seems to be
> difficult to achieve reliably. The scheduled work may be missing the
> target time by a tick or two and be constantly rescheduled every second.
>
> Relax the limit to 10 ticks. As a typical RTC drifts in the 11-minute
> update interval by several milliseconds, this shouldn't affect the
> overall accuracy of the RTC much.
>
> Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
> ---
>  kernel/time/ntp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
> index 8f5b3b9..ab1fa7c 100644
> --- a/kernel/time/ntp.c
> +++ b/kernel/time/ntp.c
> @@ -475,6 +475,7 @@ static void sync_cmos_clock(struct work_struct *work)
>  	 * called as close as possible to 500 ms before the new second starts.
>  	 * This code is run on a timer.  If the clock is set, that timer
>  	 * may not expire at the correct time.  Thus, we adjust...
> +	 * We want the clock to be within a couple of ticks from the target.
>  	 */
>  	if (!ntp_synced()) {
>  		/*
> @@ -485,7 +486,7 @@ static void sync_cmos_clock(struct work_struct *work)
>  	}
>  
>  	getnstimeofday(&now);
> -	if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) {
> +	if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec * 5) {
>  		struct timespec adjust = now;
>  
>  		fail = -ENODEV;

Applied to my 3.12 branch.

thanks
-john

      reply	other threads:[~2013-08-22 19:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01 17:31 [PATCH] ntp: Make periodic RTC update more reliable Miroslav Lichvar
2013-08-22 19:36 ` John Stultz [this message]

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=52166839.80004@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=prarit@redhat.com \
    /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).