Is it possible for each cpu to have it's own time?I'm not sure that a per-CPU value is enough; your patch can make
the problem much less frequent of course, but I'm not sure neither
detection nor correction are 100% reliable. Your addition is
basically a faster but less reliable version of the last_value
logic.
How is it less reliable than last_value logic?
Suppose CPU 1 is behind by 3 nanoseconds
CPU 0 CPU 1
time = 100 (at time 100)
time = 99 (at time 102)
time = 104 (at time 104)
time = 105 (at time 108)
Your patch will not detect this.
tsc_wrap_test starts to fail almost imediately,
I'll check how much tries it takes to fail for the first time, if it is
not too much I guess we could add check to check_system_tsc_reliable().