[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAArYzrJHSFgiiPamMDfp9-nvHr1+SGfQ-tgOpJ5tgR5Wtw+Mnw@mail.gmail.com>
Date: Wed, 28 May 2025 09:39:31 -0700
From: Manu Bretelle <chantr4@...il.com>
To: "Gautham R. Shenoy" <gautham.shenoy@....com>
Cc: Mario Limonciello <mario.limonciello@....com>,
Dhananjay Ugwekar <Dhananjay.Ugwekar@....com>, "Rafael J . Wysocki" <rafael@...nel.org>,
Viresh Kumar <viresh.kumar@...aro.org>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, Adam Clark <Adam.Clark@....com>
Subject: Re: [PATCH] acpi-cpufreq: Fix max-frequency computation
>
> No, the patch has a bug. The nominal_frequency returned from the
> get_max_boost_ratio() function was in MHz, while cpufreq maintains
> frequencies in KHz due to which the computed max_frequency was
> incorrect and thus as a fallback, cpufreq reported P0 frequency as the
> cpuinfo_max_freq.
>
> Can you please try the following patch on top of the original one?
Thanks for the quick turnaround Gautham.
I applied this patch on top of a fresh Ubuntu 22.04 5.15.0-140-generic tree and
confirmed that CPU max MHz reports its original value.
Thanks!
Manu
$ uname -r
5.15.0-9991-generic
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 48 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 128
On-line CPU(s) list: 0-127
Vendor ID: AuthenticAMD
Model name: AMD EPYC 7713P 64-Core Processor
CPU family: 25
Model: 1
Thread(s) per core: 2
Core(s) per socket: 64
Socket(s): 1
Stepping: 1
Frequency boost: enabled
CPU max MHz: 3720.7029
CPU min MHz: 1500.0000
BogoMIPS: 3992.55
Flags: fpu vme de pse tsc msr pae mce cx8 apic
sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscal
l nx mmxext fxsr_opt pdpe1gb rdtscp lm
constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf
rapl pni pclmulqdq monitor ssse3 fma cx16
pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm
cmp_legacy svm extapic cr8_legacy abm
sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perf
ctr_core perfctr_nb bpext perfctr_llc
mwaitx cpb cat_l3 cdp_l3 invpcid_single hw_pstate ssbd mba ibrs ibpb
stibp vmmcall fsgsbase bmi1 avx2 smep bmi2
erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xs
aveopt xsavec xgetbv1 xsaves cqm_llc
cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdp
ru wbnoinvd amd_ppin arat npt lbrv
svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists
pausef
ilter pfthreshold v_vmsave_vmload vgif
v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succ
or smca fsrm
Virtualization features:
Virtualization: AMD-V
Caches (sum of all):
L1d: 2 MiB (64 instances)
L1i: 2 MiB (64 instances)
L2: 32 MiB (64 instances)
L3: 256 MiB (8 instances)
NUMA:
NUMA node(s): 1
NUMA node0 CPU(s): 0-127
Vulnerabilities:
Gather data sampling: Not affected
Itlb multihit: Not affected
L1tf: Not affected
Mds: Not affected
Meltdown: Not affected
Mmio stale data: Not affected
Reg file data sampling: Not affected
Retbleed: Not affected
Spec rstack overflow: Mitigation; safe RET
Spec store bypass: Mitigation; Speculative Store Bypass
disabled via prctl and seccomp
Spectre v1: Mitigation; usercopy/swapgs barriers and
__user pointer sanitization
Spectre v2: Mitigation; Retpolines; IBPB conditional;
IBRS_FW; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected;
BHI Not affected
Srbds: Not affected
Tsx async abort: Not affected
>
>
> ------------------------x8------------------------------------------------
>
> From 13d5c28823ed03353059801281d3b22e9f139a8d Mon Sep 17 00:00:00 2001
> From: "Gautham R. Shenoy" <gautham.shenoy@....com>
> Date: Wed, 28 May 2025 16:43:33 +0530
> Subject: [PATCH] acpi-cpufreq: Fix nominal_freq units to KHz in get_max_boost_ratio()
>
> commit 083466754596 ("cpufreq: ACPI: Fix max-frequency computation")
> modified get_max_boost_ratio() to return the nominal_freq advertised
> in the _CPC object for the purposes of computing the maximum
> frequency. The frequencies advertised in _CPC objects are in MHz but
> cpufreq expects the frequency to be in KHz. Because the
> nominal_frequency was not converted to KHz, the cpuinfo_max_frequency
> that got computed was incorrect and the cpufreq reported the P0
> frequency as the cpuinfo_max_freq.
>
> Fix this by returning nominal_freq in KHz in get_max_boost_ratio()
>
> Reported-by: Manu Bretelle <chantr4@...il.com>
> Closes: https://lore.kernel.org/lkml/aDaB63tDvbdcV0cg@HQ-GR2X1W2P57/
> Fixes: 083466754596 ("cpufreq: ACPI: Fix max-frequency computation")
> Signed-off-by: Gautham R. Shenoy <gautham.shenoy@....com>
Tested-by: Manu Bretelle <chantr4@...il.com>
> ---
> drivers/cpufreq/acpi-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index d26b610e4f24..76768fe213a9 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -660,7 +660,7 @@ static u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq)
> nominal_perf = perf_caps.nominal_perf;
>
> if (nominal_freq)
> - *nominal_freq = perf_caps.nominal_freq;
> + *nominal_freq = perf_caps.nominal_freq * 1000;
>
> if (!highest_perf || !nominal_perf) {
> pr_debug("CPU%d: highest or nominal performance missing\n", cpu);
> --
> 2.34.1
>
>
> --
> Thanks and Regards
> gautham.
Powered by blists - more mailing lists