All of lore.kernel.org
 help / color / mirror / Atom feed
From: linux@armlinux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] rtc: Allow rtc drivers to specify the tv_nsec value for ntp
Date: Thu, 23 Nov 2017 16:25:32 +0000	[thread overview]
Message-ID: <20171123162532.GA25597@n2100.armlinux.org.uk> (raw)
In-Reply-To: <20171123161040.GS31757@n2100.armlinux.org.uk>

On Thu, Nov 23, 2017 at 04:10:40PM +0000, Russell King - ARM Linux wrote:
> Using my program instead:
> 
> root at clearfog21:~# ./test-rtc
> 
> Warning: NTP synchronisation is enabled, measurements may be affected
> 
> RTC is currently trimmed to -39112 ppb
> Takes average of 65127ns to read RTC
> Took 64411ns to read RTC on second change
> 
> RTC Time: 23-11-2017 15:52:50
> System Time was:     15:52:50.000

PS, my program works by:

- switching to SCHED_FIFO scheduling
- timing how long it takes to read the RTC 100 times.
- timing how long it takes to read the RTC for real across a change
  in the number of seconds.
    if this is different by more than 25us from the average, then
    the entire measurement cycle is restarted until we hit this target.
- reporting the RTC time and the compensated system time half-way
  through the ioctl() to read the RTC, based on the average time
  taken to read the RTC.

This has the advantage that it's indepdendent of the kernel's UIE
implementation and RTC interrupt latency, and so can be much more
accurate than 1/HZ.

Its measurements have sufficient accuracy (when printed to microsecond
resolution) to show the effect of the RTC's trimming corrections where
RTCs apply trimming pulses every minute rather than every second.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up

  reply	other threads:[~2017-11-23 16:25 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13 17:54 [PATCH] rtc: Allow rtc drivers to specify the tv_nsec value for ntp Jason Gunthorpe
2017-11-23  9:54 ` Alexandre Belloni
2017-11-23 11:23   ` Russell King - ARM Linux
2017-11-23 12:04     ` Alexandre Belloni
2017-11-23 12:04       ` Alexandre Belloni
2017-11-23 12:53       ` Russell King - ARM Linux
2017-11-23 12:53         ` Russell King - ARM Linux
2017-11-24  0:13         ` J William Piggott
2017-11-24  0:13           ` J William Piggott
2017-11-27 20:18         ` Alexandre Belloni
2017-11-27 20:18           ` Alexandre Belloni
2017-11-27 20:29           ` Jason Gunthorpe
2017-11-27 20:29             ` Jason Gunthorpe
2017-11-28 10:03           ` Russell King - ARM Linux
2017-11-28 10:03             ` Russell King - ARM Linux
2017-11-23 15:04   ` Jason Gunthorpe
2017-11-23 15:36     ` Alexandre Belloni
2017-11-23 16:10       ` Russell King - ARM Linux
2017-11-23 16:25         ` Russell King - ARM Linux [this message]
2017-11-27 18:48         ` Alexandre Belloni
2017-11-23 16:33       ` Jason Gunthorpe
2017-11-27 15:43     ` Russell King - ARM Linux
2017-11-27 17:43       ` Russell King - ARM Linux
2017-11-27 18:59         ` Jason Gunthorpe
2017-11-27 17:35   ` John Stultz
2017-11-27 17:52     ` Russell King - ARM Linux
2017-11-27 18:44       ` Alexandre Belloni
2017-11-27 18:53         ` Russell King - ARM Linux
2017-11-27 19:18           ` Russell King - ARM Linux
2017-11-27 19:31           ` Alexandre Belloni
2017-11-28 10:20             ` Russell King - ARM Linux
2017-11-30 19:39               ` Alexandre Belloni
2017-11-30 19:39               ` Alexandre Belloni
2017-11-30 19:43                 ` 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=20171123162532.GA25597@n2100.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.