On Thu, Sep 12, 2024 at 1:33 PM John Stultz <jstultz@xxxxxxxxxx> wrote: > > On Thu, Sep 12, 2024 at 1:18 PM Jeff Layton <jlayton@xxxxxxxxxx> wrote: > > On Thu, 2024-09-12 at 13:11 -0700, John Stultz wrote: > > > On Thu, Sep 12, 2024 at 11:02 AM Jeff Layton <jlayton@xxxxxxxxxx> wrote: > > > But instead, it seems like if something has happened since the cookie > > > value was saved (another cpu getting a fine grained timestamp), your > > > ktime_get_real_ts64_mg() will fall back to returning the same coarse > > > grained time saved to the cookie, as if no time had past? > > > > > > It seems like that could cause problems: > > > > > > cpu1 cpu2 > > > -------------------------------------------------------------------------- > > > t2a = ktime_get_coarse_real_ts64_mg > > > t1a = ktime_get_coarse_real_ts64_mg() > > > t1b = ktime_get_real_ts64_mg(t1a) > > > > > > t2b = ktime_get_real_ts64_mg(t2a) > > > > > > Where t2b will seem to be before t1b, even though it happened afterwards. > > > > > > > Ahh no, the subtle thing about atomic64_try_cmpxchg is that it > > overwrites "old" with the value that was currently there in the event > > that the cmp fails. > > Ah, ok. Thank you for the explanation there! > > > So, the try_cmpxchg there will either swap the new value into place, or > > if it was updated in the meantime, "old" will now refer to the value > > that's currently in the floor word. Either is fine in this case, so we > > don't need to retry anything. > > > Though if cpu2 then made another call to > ktime_get_coarse_real_ts64_mg(), the value returned there will be the > same as t1b? and would be before t2b? Oh, no. Apologies again, as I see t2b would be the same as t1b as well. Ok. -john