mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: "Richard Cochran" <richardcochran@gmail.com>,
	"Wen Gu" <guwen@linux.alibaba.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"John Stultz" <jstultz@google.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
	"Frederic Weisbecker" <frederic@kernel.org>,
	"Shuah Khan" <shuah@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Miroslav Lichvar" <mlichvar@redhat.com>,
	"Julien Ridoux" <ridouxj@amazon.com>,
	"Ryan Luu" <rluu@amazon.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 5/7] timekeeping: Drive time_offset skew via per-tick ntp_error transfer
Date: Wed, 27 May 2026 19:02:35 +0100	[thread overview]
Message-ID: <f47acc350ce10a48960556e8b26e4f617d90f236.camel@infradead.org> (raw)
In-Reply-To: <20260525135904.126282-6-dwmw2@infradead.org>

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

On Mon, 2026-05-25 at 14:54 +0100, David Woodhouse wrote:
> 
> @@ -460,9 +486,14 @@ int second_overflow(unsigned int tkid, time64_t secs)
>  	/* Compute the phase adjustment for the next second */
>  	ntpdata->tick_length	 = ntpdata->tick_length_base;
>  
> +	/*
> +	 * Set the per-tick skew rate for the tick code. This is in the
> +	 * same units as tick_length (ns << NTP_SCALE_SHIFT), and is
> +	 * rounded to a multiple of NTP_INTERVAL_FREQ so that the per-tick
> +	 * division in the tick code is exact.
> +	 */
>  	delta			 = ntp_offset_chunk(ntpdata, ntpdata->time_offset);
> -	ntpdata->time_offset	-= delta;
> -	ntpdata->tick_length	+= delta;
> +	ntpdata->skew_delta	 = div_s64(delta, NTP_INTERVAL_FREQ) * NTP_INTERVAL_FREQ;
>  
>  	/* Check PPS signal */
>  	pps_dec_valid(ntpdata);

It turns out the infinite impulse response really *is* infinite because
once time_offset gets low enough that ntp_offset_chunk() returns zero,
that last bit of time_offset is *never* drained.

And rounding down to a multiple of NTP_INTERVAL_FREQ as I do in this
patch, just increases the threshold below which it stops draining.

If I repost this series I'll set skew_delta to ±NTP_INTERVAL_FREQ if it
ends up zero when time_offset isn't. Otherwise I'll do it in a follow-
up.

In practice it barely matters; it's *fractions* of a nanosecond. But
it's annoying :)

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]

  reply	other threads:[~2026-05-27 18:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-25 13:54 [PATCH v4 0/7] timekeeping/ntp: Fix drift tracking precision David Woodhouse
2026-05-25 13:54 ` [PATCH v4 1/7] MAINTAINERS: Add Miroslav as timekeeping reviewer David Woodhouse
2026-05-25 13:54 ` [PATCH v4 2/7] timekeeping: Remove xtime_remainder from ntp_error accumulation David Woodhouse
2026-05-29 14:41   ` David Woodhouse
2026-05-25 13:54 ` [PATCH v4 3/7] timekeeping: Account for monotonicity adjustment in ntp_error David Woodhouse
2026-05-25 13:54 ` [PATCH v4 4/7] timekeeping: Guard against divide-by-zero in timekeeping_adjust David Woodhouse
2026-05-25 13:54 ` [PATCH v4 5/7] timekeeping: Drive time_offset skew via per-tick ntp_error transfer David Woodhouse
2026-05-27 18:02   ` David Woodhouse [this message]
2026-05-25 13:54 ` [PATCH v4 6/7] ntp: Convert adjtime() to use time_offset instead of tick_length inflation David Woodhouse
2026-05-25 13:54 ` [PATCH v4 7/7] ntp: Remove tick_length_base, use tick_length directly David Woodhouse

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=f47acc350ce10a48960556e8b26e4f617d90f236.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=anna-maria@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=frederic@kernel.org \
    --cc=guwen@linux.alibaba.com \
    --cc=jstultz@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=pabeni@redhat.com \
    --cc=peterz@infradead.org \
    --cc=richardcochran@gmail.com \
    --cc=ridouxj@amazon.com \
    --cc=rluu@amazon.com \
    --cc=sboyd@kernel.org \
    --cc=shuah@kernel.org \
    --cc=tglx@kernel.org \
    --cc=thomas.weissschuh@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

all inboxes | Powered by JetHome®