Re: [bug report] x86, sched: Bail out of frequency invariance if turbo frequency is unknown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2022-05-05 at 10:05 +0300, Dan Carpenter wrote:
> Hello Giovanni Gherdovich,
> 
> The patch 51beea8862a3: "x86, sched: Bail out of frequency invariance
> if turbo frequency is unknown" from May 31, 2020, leads to the
> following Smatch static checker warning:
> 
> 	arch/x86/kernel/cpu/aperfmperf.c:274 intel_set_max_freq_ratio()
> 	error: uninitialized symbol 'turbo_freq'.
> 
> arch/x86/kernel/cpu/aperfmperf.c
>     242 static bool __init intel_set_max_freq_ratio(void)
>     243 {
>     244         u64 base_freq, turbo_freq;
>     245         u64 turbo_ratio;
>     246 
>     247         if (slv_set_max_freq_ratio(&base_freq, &turbo_freq))
>                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Imagine this fails.
> 
>     248                 goto out;
>     249 
>     250         if (x86_match_cpu(has_glm_turbo_ratio_limits) &&
>     251             skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1))
>     252                 goto out;
>     253 
>     254         if (x86_match_cpu(has_knl_turbo_ratio_limits) &&
>     255             knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1))
>     256                 goto out;
>     257 
>     258         if (x86_match_cpu(has_skx_turbo_ratio_limits) &&
>     259             skx_set_max_freq_ratio(&base_freq, &turbo_freq, 4))
>     260                 goto out;
>     261 
>     262         if (core_set_max_freq_ratio(&base_freq, &turbo_freq))
>     263                 goto out;
>     264 
>     265         return false;
>     266 
>     267 out:
>     268         /*
>     269          * Some hypervisors advertise X86_FEATURE_APERFMPERF
>     270          * but then fill all MSR's with zeroes.
>     271          * Some CPUs have turbo boost but don't declare any turbo ratio
>     272          * in MSR_TURBO_RATIO_LIMIT.
>     273          */
> --> 274         if (!base_freq || !turbo_freq) {
>                     ^^^^^^^^^^^^^^^^^^^^^^^^^
> Uninitialized.  Although I notice that base_freq is also unintialized
> and that predates your patch...  So I should probably send this bug
> report to someone else...  Sorry?
> 

Hello Dan,

I'm the right person for this report, as I think I wrote both the buggy
patch and the buggy code that predates it. I'm taking a moment to check
what's going on, as that really look like a dumb mistake.

Thanks for the report, I'll follow up.

Giovanni




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux