Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-18 Thread John Stultz
On Fri, Apr 18, 2025 at 12:00 AM Thomas Gleixner wrote: > On Fri, Apr 18 2025 at 08:37, Thomas Gleixner wrote: > > On Thu, Apr 17 2025 at 17:46, John Stultz wrote: > >> Instead it seems like we should just do: > >> tk->coarse_nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; > > > > You end

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-18 Thread John Stultz
On Thu, Apr 17, 2025 at 11:37 PM Thomas Gleixner wrote: > On Thu, Apr 17 2025 at 17:46, John Stultz wrote: > > On Sat, Apr 5, 2025 at 2:40 PM Thomas Gleixner wrote: > >> +static inline void tk_update_coarse_nsecs(struct timekeeper *tk, u64 > >> offset) > >> +{ > >> + offset *= tk->tkr_mono

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-18 Thread John Stultz
On Sat, Apr 5, 2025 at 2:40 PM Thomas Gleixner wrote: > > Lei Chen raised an issue with CLOCK_MONOTONIC_COARSE seeing time > inconsistencies. Lei tracked down that this was being caused by the > adjustment > > tk->tkr_mono.xtime_nsec -= offset; > > which is made to compensate for the unaccumul

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-18 Thread Thomas Gleixner
On Fri, Apr 18 2025 at 08:37, Thomas Gleixner wrote: > On Thu, Apr 17 2025 at 17:46, John Stultz wrote: >> Instead it seems like we should just do: >> tk->coarse_nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; > > You end up with the same problem again because xtime_nsec can move > backward

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-17 Thread Thomas Gleixner
On Thu, Apr 17 2025 at 17:46, John Stultz wrote: > On Sat, Apr 5, 2025 at 2:40 PM Thomas Gleixner wrote: >> @@ -1831,6 +1847,8 @@ void timekeeping_resume(void) >> /* Re-base the last cycle value */ >> tks->tkr_mono.cycle_last = cycle_now; >> tks->tkr_raw.cycle_last = cycle

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-17 Thread John Stultz
On Sat, Apr 5, 2025 at 2:40 PM Thomas Gleixner wrote: > > Lei Chen raised an issue with CLOCK_MONOTONIC_COARSE seeing time > inconsistencies. Lei tracked down that this was being caused by the > adjustment > > tk->tkr_mono.xtime_nsec -= offset; > > which is made to compensate for the unaccumul

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-17 Thread Thomas Gleixner
On Wed, Apr 16 2025 at 22:29, John Stultz wrote: > Looking over the patch, it seems ok to me, but in a test run with it, > I've seen an error with CLOCK_REALTIME_COARSE during the > clocksource-switch test (as well as some seemingly unrelated test > errors, which I need to investigate) so I'm look

[PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-05 Thread Thomas Gleixner
Lei Chen raised an issue with CLOCK_MONOTONIC_COARSE seeing time inconsistencies. Lei tracked down that this was being caused by the adjustment tk->tkr_mono.xtime_nsec -= offset; which is made to compensate for the unaccumulated cycles in offset when the multiplicator is adjusted forward, so