Re: [PATCH v3] printk: fix zero-valued printk timestamps in early boot

Peter Zijlstra <[email protected]> Mon, 30 Mar 2026 14:05:38 +0200
Newsgroups org.kernel.vger.linux-embedded,org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon, Mar 30, 2026 at 12:42:59AM +0200, Thomas Gleixner wrote:
> Quite the contrary, I'm going to get rid of technical debt:
> 
>   The get_cycles() related changes in tsc.h are going to end up in a
>   obviously revised formal patch tomorrow as there is exactly _zero_
>   requirement to provide this as a functional interface.
> 
>   1) The default implementation in asm-generic returns 0
> 
>      Ergo any code depending on a functional implementation is broken
>      by definition.
> 
>   2) The ops/cycles metrics are as bogus as the infamous BogoMIPS metrics
>   
>      The "cycle" counter runs on almost all contemporary CPUs at a fixed
>      frequency, which is completely unrelated to the actual CPU
>      frequency and therefore to the actual CPU cycles.
> 
>      The only realistic metric is ops/sec and nothing else and that can
>      be trivially achieved by using the generic time getter interfaces.
> 
>      Those might end up resulting in bogus benchmark results too if the
>      underlying clocksource is jiffies, but that's again a matter of
>      accepting reality.
> 
>      If people really mandate that ops/bogo_cycles is required for the
>      very wrong reasons, then I'm happy to bring it back with a global
>      name change from get_cycles() to get_bogo_cycles() which excludes
>      it from any serious usage including printk.
> 
> Thanks,
> 
>         tglx
> ---
>  arch/x86/include/asm/tsc.h        |   11 ++--
>  arch/x86/kernel/platform-quirks.c |    2 
>  arch/x86/kernel/tsc.c             |   96 ++++++++++++++++++++++++++++++--------
>  3 files changed, 85 insertions(+), 24 deletions(-)
> 
> --- a/arch/x86/include/asm/tsc.h
> +++ b/arch/x86/include/asm/tsc.h
> @@ -76,10 +76,7 @@ extern void disable_TSC(void);
>  
>  static inline cycles_t get_cycles(void)
>  {
> -	if (!IS_ENABLED(CONFIG_X86_TSC) &&
> -	    !cpu_feature_enabled(X86_FEATURE_TSC))
> -		return 0;
> -	return rdtsc();
> +	return 0;
>  }
>  #define get_cycles get_cycles
>  

So this is probably going to break a bunch of generic stuff. There is a
fair amount of 'get_cycles' usage out in the tree.

Mostly it appears to be various test code.

But I do agree that get_cycles() is terrible and should go away.