Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 874324 - sys-kernel/gentoo-sources: if smt is disable the frequency scaling does not work properly, in the linux kernel 5.15
Summary: sys-kernel/gentoo-sources: if smt is disable the frequency scaling does not w...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-02 20:39 UTC by tetumetal
Modified: 2023-04-12 20:19 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tetumetal 2022-10-02 20:39:35 UTC
I disabled the smt by using the kernel parameter nosmt=1, when booting the linux kernel. But, after I disabled it I noticed a weird behavior on the cpu frequency scaling. 

So, with smt enabled, I checked that I have 16 CPUs running at a frequency of 1396 MHz (using 'cpupower monitor'), if the CPU has no workload. However, when I reboot with disabled smt, I check that I have half of the CPUs, as expected, but running at boost frequency almost all the time, regardless of the workload.

I have a ryzen 4800U running a Gentoo hardened linux kernel version 5.15.X. This problem happens in kernel versions: 5.15.59, 5.15.52, 5.15.26, and 5.15.16. No idea about previous kernels.

I'm not sure if this is the right place to post this bug, or I shall contact people from the kernel community.

    Thanks,
Comment 1 Mike Pagano gentoo-dev 2022-10-04 17:34:55 UTC
Can you tell me what CPU Governor you are using?

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Comment 2 tetumetal 2022-10-05 18:39:31 UTC
Here are the test results (kernel boot with nosmt=1):

1- Using default scaling governor:

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
schedutil
schedutil
schedutil
schedutil
schedutil
schedutil
schedutil
schedutil

cpupower monitor
WARNING: at least one cpu is offline
    | Mperf              || Idle_Stats
 CPU| C0   | Cx   | Freq  || POLL | C1   | C2   | C3
   0|  0.35| 99.65|  4194||  0.00|  2.68|  0.10| 96.92
   2|  0.28| 99.72|  4204||  0.00|  0.03|  0.00| 99.76
   4|  0.16| 99.84|  4200||  0.00|  1.19|  0.58| 98.09
   6|  0.67| 99.33|  4193||  0.00|  0.94|  0.02| 98.45
   8|  0.30| 99.70|  4195||  0.00|  1.88|  0.00| 97.89
  10|  0.75| 99.25|  4199||  0.00|  2.01|  0.40| 96.98
  12|  0.47| 99.53|  4200||  0.00|  2.26|  0.33| 97.00
  14|  0.62| 99.38|  4190||  0.00|  3.61|  0.00| 95.84


2- Then, I switched to powersave:

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave

WARNING: at least one cpu is offline
    | Mperf              || Idle_Stats
 CPU| C0   | Cx   | Freq  || POLL | C1   | C2   | C3
   0|  0.06| 99.94|  4170||  0.00|  0.06|  0.00| 99.88
   2|  0.26| 99.74|  4153||  0.00|  0.00|  0.00| 99.79
   4|  0.82| 99.18|  4156||  0.00|  0.45|  0.20| 98.62
   6|  0.09| 99.91|  4149||  0.00|  0.15|  0.00| 99.77
   8|  0.70| 99.30|  4161||  0.00|  1.79|  0.00| 97.60
  10|  0.45| 99.55|  4170||  0.00|  1.12|  0.26| 98.26
  12|  0.39| 99.61|  4163||  0.00|  0.57|  0.92| 98.19
  14|  0.51| 99.49|  4163||  0.00|  1.58|  0.00| 98.00

P.S.1: This was the cpu load during the test: load average: 0.11, 0.07, 0.02

P.S.2: CPU info: 

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):                  16
  On-line CPU(s) list:   0,2,4,6,8,10,12,14
  Off-line CPU(s) list:  1,3,5,7,9,11,13,15
Vendor ID:               AuthenticAMD
  BIOS Vendor ID:        Advanced Micro Devices, Inc.
  Model name:            AMD Ryzen 7 4800U with Radeon Graphics
    BIOS Model name:     AMD Ryzen 7 4800U with Radeon Graphics
    CPU family:          23
    Model:               96
    Thread(s) per core:  1
    Core(s) per socket:  8
    Socket(s):           1
    Stepping:            1
    Frequency boost:     enabled
    CPU max MHz:         1800.0000
    CPU min MHz:         0.0000
    BogoMIPS:            3594.85
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fx
                         sr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor s
                         sse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a mi
                         salignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l
                         3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_n
                         i xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinv
                         d arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_v
                         mload vgif v_spec_ctrl umip rdpid overflow_recov succor smca
Virtualization features:
  Virtualization:        AMD-V
Caches (sum of all):
  L1d:                   256 KiB (8 instances)
  L1i:                   256 KiB (8 instances)
  L2:                    4 MiB (8 instances)
  L3:                    8 MiB (2 instances)
NUMA:
  NUMA node(s):          1
  NUMA node0 CPU(s):     0,2,4,6,8,10,12,14
Vulnerabilities:
  Itlb multihit:         Not affected
  L1tf:                  Not affected
  Mds:                   Not affected
  Meltdown:              Not affected
  Mmio stale data:       Not affected
  Retbleed:              Mitigation; untrained return thunk; SMT disabled
  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, STIBP always-on, RSB filling
  Srbds:                 Not affected
  Tsx async abort:       Not affected
Comment 3 tetumetal 2022-10-05 18:42:34 UTC
The only way to lower the frequency is by manually disabling the boost:

echo 0 > /sys/devices/system/cpu/cpufreq/boost
Comment 4 Mike Pagano gentoo-dev 2023-01-17 14:28:20 UTC
Not sure what to suggest here, have you made any progress on this ?
Have you moved on to later kernels?
Comment 5 Donald R. Gray Jr 2023-02-06 13:17:57 UTC
(In reply to Mike Pagano from comment #4)
> Not sure what to suggest here, have you made any progress on this ?
> Have you moved on to later kernels?

Unless this is working in a vanilla kernel & not gentoo-sources,(for example caused by a genpatch). I would say the proper action would be to have @tetumetal file this bug with kernel.org where there will be a lot more eyes on it.
Comment 6 Mike Pagano gentoo-dev 2023-02-07 18:32:16 UTC
I don't disagree. If you do file a bug upstream, can you please post the URL here?
Comment 7 Mike Pagano gentoo-dev 2023-04-09 22:03:35 UTC
Please let us know the bug number if you file a bug upstream
Comment 8 Enne Eziarc 2023-04-10 05:07:48 UTC
Passage of time may have rendered this bug obsolete, now that current stable gentoo-sources has the amd-pstate driver. I've just tested that in nosmt mode on my Zen2 (via `echo off >| /sys/devices/system/cpu/smt/control`) and the scaling works fine.
Comment 9 Mike Pagano gentoo-dev 2023-04-10 12:08:31 UTC
thanks for lettings us know
Comment 10 tetumetal 2023-04-12 20:16:22 UTC
hi people, apologies, I was a bit absent. 

I downgraded my kernel to 5.10.X since my system had some stability issues with 5.15.X. Also, 5.10.X will keep getting patches until Dec, 2026.

@Enne Eziarc

I disabled the smt after booting my zen2, the same way you did, and actually the frequency scaling worked fine. But, when I disabled the frequency scaling before booting (from grub by adding 'nosmt=1' as an extra input parameter for the kernel), still the frequency scaling did not work.

So, thanks for your suggestion!. I disabled the smt after booting by putting a script in /etc/local.d/
Comment 11 tetumetal 2023-04-12 20:19:45 UTC
(In reply to tetumetal from comment #10)
> hi people, apologies, I was a bit absent. 
> 
> I downgraded my kernel to 5.10.X since my system had some stability issues
> with 5.15.X. Also, 5.10.X will keep getting patches until Dec, 2026.
> 
> @Enne Eziarc
> 
> I disabled the smt after booting my zen2, the same way you did, and actually
> the frequency scaling worked fine. But, when I disabled the frequency
> scaling before booting (from grub by adding 'nosmt=1' as an extra input
> parameter for the kernel), still the frequency scaling did not work.
> 
> So, thanks for your suggestion!. I disabled the smt after booting by putting
> a script in /etc/local.d/

I mean, ... when I disabled the *SMT* before booting ..