On Sun, Jul 12, 2020 at 11:44:57PM -0400, George Koehler wrote: > Hello tech list, > > My CLOCK_MONOTONIC can jump backwards.
I can reproduce it here. Very unsettling. > It looks like a problem with tk_generation in the user timekeep page. > If tk_offset_count and tk_offset change but tk_generation doesn't change, > then libc can mix old and new values and calculate a bogus time. I don't follow. To review, the update protocol is: 1. Set tk_generation to zero; the update has begun. 2. Memory barrier. The side effects of step (1) are "visible" to other CPUs before those of step (3). 3. Update the other tk_* members from the active timehands. 4. Memory barrier. The side effects of step (3) are "visible" before those of step (5). 5. Set tk_generation to th_generation; the update is over. The timekeep page is consistent once more. -- As far as I can tell, tk_generation always changes after an update, during step (5). Please point to the place(s) in the code where the problem you describe occurs. I'm sorry if I'm missing something obvious here, it's late.