Re: [PATCH] clocksource: Add heuristics to avoid switching away from TSC due to timer delay

From: Thomas Gleixner
Date: Tue Dec 04 2018 - 06:56:52 EST


Roland,

On Fri, 30 Nov 2018, Roland Dreier wrote:
> delta = clocksource_delta(csnow, cs->cs_last, cs->mask);
> +
> + /* If the cycle delta is beyond what we can safely
> + * convert to nsecs, and the watchdog clocksource
> + * suggests that we've overslept, skip checking this
> + * iteration to avoid marking a clocksource as
> + * unstable because of a severely delayed timer. */

/*
* Proper multiline comments look like this not like
* the above.
*/

That aside. Why are you trying to do heuristics on the delta?

We have way better information than that. The watchdog timer expiry time is
known and we can determine the exact delay of the timer.

The watchdog clocksource provides the maximum 'idle' time, i.e. the time
between two reads, in clocksource::max_idle_ns. That value is filled in
when the clocksource is configured.

So without doing speculation we can make an informed decision:

elapsed = jiffies_to_nsec(jiffies - watchdog_timer->expires) +
WATCHDOG_INTERVAL_NS;

if (elapsed > wdcs->max_idle_ns) {
Skip ......
}

Hmm?

Thanks,

tglx