CPU freq never hits minimum level... wondering if some routing process is causing it

When booted into OpenWrt on my x86/64 machine, the CPU freq never hits 400 MHz which it does under other distros when idle.

# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
powersave
# cat /sys/devices/system/cpu/amd_pstate/status
active
# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver
amd-pstate-epp

I disabled all extra daemons (snort, samba4, etc.) as well as all interfaces but still, the CPU freq idles around 1,394 MHz. I am wondering what monitoring command I can use to see all calls to the CPU or to /proc/interrupts or to something else that might explain why the CPU freq does not drop.

I have been using htop and sorting by CPU% and the only things >0.0 are:

  • htop itself but I do not believe it is to blame since I can boot the identical hardware into another distro and see 400 MHz across all cores
  • /sbin/procd occasionally gets some fraction of a CPU

If I run: watch cat /proc/interrupts I see both the Local timer interrupts, Rescheduling interrupts, and Function call interrupts going up by hundreds but I do not know which PIDs are doing it.

Any thoughts are welcomed.

Check /proc/interrupts and /proc/net/softnet_stats -> maybe network traffic is distributed across all cores and they never sleep?

1 Like

If I cat both of those repeatedly, I get different values which means they are changing.

EDIT: maybe as I test, I can connect to the local console and unplug both of the NICs (one goes to the modem and the other to a smart switch). I would think that would put a stop to any traffic.

Unplugging both cables did not stop the number of interrupts. Iā€™m wondering how I can see which PID is making them?

Run htop -> F2 Setup -> unhide kernel threads, add CPU usage detail -> check what comes first.

I am not seeing anything register. I nthe screenshot htop is taking 1.5% but there are refreshes where is it 0.0. Also, when booted into Arch, htop happily reads 400 MHz for all cores:

Try changing clocksource:

cat /sys/devices/system/clocksource/clocksource0/available_clocksource
cat /sys/devices/system/clocksource/clocksource0/current_clocksource
echo tsc > /sys/devices/system/clocksource/clocksource0/current_clocksource

Seems to be using tsc by default:

# cat /sys/devices/system/clocksource/clocksource0/available_clocksource
tsc hpet acpi_pm 
# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc

I echoed the other two to the current_clocksource file but found no change in the freqs.

1 Like

There are two power usage parameters that might (or not) help: I can get my i7-6700T to ~900MHz in power save mode. From lscpu: CPU min MHz: 800.0000

If that does not solve your problem, maybe try going back cpufreq scaling driver: is it possible other distros use it? I did notice that the older cpufreq driver gets CPU usage lower that the current/new one. That way you can control min/max frequencies as well as the aggressiveness of the scaling algorithm.

powersave_power() {
    for p in /sys/devices/system/cpu/cpufreq/policy*; do
        echo powersave > "${p}"/scaling_governor
        echo power > "${p}"/energy_performance_preference
    done
}
performance_performance() {
    for p in /sys/devices/system/cpu/cpufreq/policy*; do
        echo performance > "${p}"/scaling_governor
        echo performance > "${p}"/energy_performance_preference
    done
}

Thanks for the reply. I did find that /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference was set to 'performance' but changing it to 'power' did not change the lowest freq. Even when I had this in combo with disabling all interfaces and all daemons (except for rpcd).

I am thinking that there must be a difference in kernel config between Arch and OpenWrt which is causing this.

I did notice that Arch builds the following:

% i=devfreq
% zgrep -i $i /proc/config.gz
CONFIG_DEVFREQ_THERMAL=y
CONFIG_PM_DEVFREQ=y
# DEVFREQ Governors
CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=m
CONFIG_DEVFREQ_GOV_PERFORMANCE=m
CONFIG_DEVFREQ_GOV_POWERSAVE=m
CONFIG_DEVFREQ_GOV_USERSPACE=m
CONFIG_DEVFREQ_GOV_PASSIVE=m
# DEVFREQ Drivers
CONFIG_PM_DEVFREQ_EVENT=y

But OpwnWrt does not:

# zgrep -i $i /proc/config.gz
# CONFIG_PM_DEVFREQ is not set

Has absolutely nothing to do with CPU frequency. grep .mk files in kernel tree if yo ucannot find option in menuconfig.

1 Like

As a test, I imaged a stock snapshot r27289 to a spare nvme and booted into it. I found that same issue there (basically nothing configured) which makes me think that problem lies in the OpenWrt kernel configs.

I think you typed in wrong thread. OpenWRT will not configure anything for you past 1st network adapter LAN 2nd adapter wan with respective dhcp client and server combination.

Right thread. My point was on a minimal setup, the cores are still idling high.

Maybe share CPUID for starters? Like is it EPIA or EPIC etc?

It is an AMD Ryzen 7 5800U.

# 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):                   16
  On-line CPU(s) list:    0-15
Vendor ID:                AuthenticAMD
  BIOS Vendor ID:         Advanced Micro Devices, Inc.
  Model name:             AMD Ryzen 7 5800U with Radeon Graphics
    BIOS Model name:      AMD Ryzen 7 5800U with Radeon Graphics          Unknown CPU @ 1.9GHz
    BIOS CPU family:      107
    CPU family:           25
    Model:                80
    Thread(s) per core:   2
    Core(s) per socket:   8
    Socket(s):            1
    Stepping:             0
    CPU(s) scaling MHz:   50%
    CPU max MHz:          4507.0000
    CPU min MHz:          400.0000
    BogoMIPS:             3793.21
    Flags:                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht s
                          yscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid a
                          perfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdra
                          nd lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt t
                          ce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 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 xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf
                           xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid deco
                          deassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku vaes vpclmulqdq rdpid
                           overflow_recov succor smca fsrm debug_swap
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:                     16 MiB (1 instance)
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:   Vulnerable: Safe RET, no microcode
  Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
  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 affec
                          ted; BHI Not affected
  Srbds:                  Not affected
  Tsx async abort:        Not affected

Reset BIOS to defaults? Should be saying turbo frequency available instead.

On my desktop (AMD Ryzen 9 5950X) which does reach its minimum CPU freq on idle, I am seeing similar output for the scaling MHz: line. It does not output the turbo frequency.

EDIT: I did reset the BIOS, and I am getting the same output, just a percentage.

1 Like

Can you run OpenWRT inside KVM of ARCH? You know that radeon graphics piece may be of some use too?