On 15.01.2026 09:00, Jan Beulich wrote:
> On 14.01.2026 18:49, Roger Pau Monné wrote:
>> On Tue, Jan 06, 2026 at 02:58:11PM +0100, Jan Beulich wrote:
>>> stime2tsc() guards against negative deltas by using 0 instead; I'm not
>>> quite sure that's correct either.
>>
>> Hm, we should likely do the same for stime2tsc() that you do for
>> get_s_time_fixed(). Given the current callers I think we might be
>> safe, but it's a risk.
>
> Will do then.
While doing so, I came to wonder if there isn't a reason for this "capping".
In local_time_calibration() we also have
/* Local time warps forward if it lags behind master time. */
if ( curr.local_stime < curr.master_stime )
curr.local_stime = curr.master_stime;
Which for the use of stime2tsc() in cstate_restore_tsc() might mean that
indeed there is a worry of the delta being negative, and the desire to
"warp forward" in that case.
Whereas for the other use in reprogram_timer() capping at 0 isn't overly
useful. By the time the value is used, it is likely in the past anyway.
Jan