Re: [RFC 1/2] x86/tsc: add a timer to make sure tsc_adjust is always checked

From: Thomas Gleixner
Date: Sat Apr 10 2021 - 14:46:45 EST


Feng,

On Sat, Apr 10 2021 at 22:38, Feng Tang wrote:
> On Sat, Apr 10, 2021 at 11:27:11AM +0200, Thomas Gleixner wrote:
>> > +static int __init start_sync_check_timer(void)
>> > +{
>> > + if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
>> > + return 0;
>> > +
>> > + timer_setup(&tsc_sync_check_timer, tsc_sync_check_timer_fn, 0);
>> > + tsc_sync_check_timer.expires = jiffies + SYNC_CHECK_INTERVAL;
>> > + add_timer(&tsc_sync_check_timer);
>> > +
>> > + return 0;
>> > +}
>> > +late_initcall(start_sync_check_timer);
>>
>> So right now, if someone adds 'tsc=reliable' on the kernel command line
>> then all of the watchdog checking, except for the idle enter TSC_ADJUST
>> check is disabled. The NOHZ full people are probably going to be pretty
>> unhappy about yet another unconditional timer they have to chase down.
>>
>> So this needs some more thought.
>
> 'tsc=reliable' in cmdline will set 'tsc_clocksource_reliable' to 1, so
> we can skip starting this timer if 'tsc_clocksource_reliable==1' ?

Then we can just ignore that patch alltogether because of 2/2 doing:

+ if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC) &&
+ boot_cpu_has(X86_FEATURE_NONSTOP_TSC) &&
+ boot_cpu_has(X86_FEATURE_TSC_ADJUST) &&
+ nr_online_nodes <= 2)
+ tsc_clocksource_reliable = 1;

....

I said for a reason:

>> So this needs some more thought.

Thanks,

tglx