On Fri, May 15, 2026, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) > to consider: > - [High] Unintended clobbering of the global `cpu_khz` variable in > `native_calibrate_tsc()` due to a missing local variable declaration. > -- > > commit 36e45379d4c9f40ae24c5c323b4f0471c94c6bef > Author: Sean Christopherson <[email protected]> > > x86/tsc: Add standalone helper for getting CPU frequency from CPUID > > This commit extracts the logic for getting the CPU frequency via CPUID into > a new standalone helper function. It also updates the TSC calibration code > to use this new helper. > > > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c > > --- a/arch/x86/kernel/tsc.c > > +++ b/arch/x86/kernel/tsc.c > > [ ... ] > > > @@ -754,13 +772,8 @@ unsigned long native_calibrate_tsc(void) > > * clock, but we can easily calculate it to a high degree of accuracy > > * by considering the crystal ratio and the CPU speed. > > */ > > - if (!info.crystal_khz && boot_cpu_data.cpuid_level >= CPUID_LEAF_FREQ) { > > - unsigned int eax_base_mhz, ebx, ecx, edx; > > - > > - cpuid(CPUID_LEAF_FREQ, &eax_base_mhz, &ebx, &ecx, &edx); > > - info.crystal_khz = eax_base_mhz * 1000 * > > - info.denominator / info.numerator; > > - } > > + if (!info.crystal_khz && !cpuid_get_cpu_freq(&cpu_khz)) > > + info.crystal_khz = cpu_khz * info.denominator / info.numerator; > > Does this unintentionally clobber the global cpu_khz variable?
Yep. I don't think I even realized there was such a global variable. Probably makes sense to use a different name for the local variables.
