A couple more observation now that we've agreed on the approach. On 01/08/2017 12:03, Paolo Bonzini wrote: > >>> Maybe what we want is some kind of "bool cycles_valid", and then >>> read_clock_and_systime can return it: >>> >>> >>> if (clock->read_clock_and_systime) { >>> systime_snapshot->cycles_valid = >>> clock->read_clock_and_systime( >>> &now, &systime_snapshot->cycles); Please pass the clocksource to the new function. However this: > + clock = tk->tkr_mono.clock; should then be READ_ONCE for the same reason mentioned in tk_clock_read's comments. Then, >>> } else { >>> now = tk_clock_read(&tk->tkr_mono); this can call clock->read(clock) directly, without going through tk_clock_read. Thanks, Paolo >>> systime_snapshot->cycles_valid = true; >>> systime_snapshot->cycles = now; >>> }