Re: [RFC PATCH v3 03/10] timekeeping: Account for monotonicity adjustment in ntp_error
From: David Woodhouse
Date: Wed May 20 2026 - 19:36:58 EST
On Wed, 2026-05-20 at 16:27 -0700, John Stultz wrote:
>
> > --- a/kernel/time/timekeeping.c
> > +++ b/kernel/time/timekeeping.c
> > @@ -2317,6 +2317,7 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk,
> > tk->tkr_mono.mult += mult_adj;
> > tk->xtime_interval += interval;
> > tk->tkr_mono.xtime_nsec -= offset;
> > + tk->ntp_error += offset << tk->ntp_error_shift;
> > }
>
> Having the details in the comment above this block would have still
> been nice, but..
>
I couldn't get past the fact that it ought to be *obvious* that if we
adjust xtime_nsec, we have to adjust ntp_error accordingly. Having it
in the very next line should be comment enough.
But I guess I could add something to the comment block, saying
something along the lines of
* When subtracting offset from xtime_nsec, the same offset has to
* be added to ntp_error, which accumulates the delta between the
* time reported in xtime_nsec, and the intended time.
In retrospect, I realise that's probably what you were asking me for
before, but I was being dim. Apologies.
> Acked-by: John Stultz <jstultz@xxxxxxxxxx>
Thanks.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature