Which tool is "master" for system CPU governor and frequency control

Can someone tell me if there is a "master" controller for CPU frequency, and which one it is? As reported in this other posting about "cpupower", the "governor" is being changed dynamically by an unknown background process/service, some time (variable) after having set that governor to "userspace" with a fixed frequency (not maximum).

The report from

man -k freq

gives me the following possibilities:

cpufreq-set (1)      - A small tool which allows a user to modify cpufreq settings.
cpupower-frequency-set (1) - A small tool which allows to modify cpufreq settings.
mate-cpufreq-selector (1) - A generic command line tool to change the cpu frequency.

However, none of those seem to reflect the scripts that I've located under /etc/init.d:

  • cpufrequtils (using cpufreq-set)
  • loadcpufreq

If I enter the command "cpufreq-info", I get the following (only first of 4):

cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to [email protected], please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 4.0 us.
  hardware limits: 800 MHz - 2.60 GHz
  available frequency steps: 2.60 GHz, 1.90 GHz, 1.40 GHz, 800 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 800 MHz and 2.60 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.90 GHz (asserted by call to hardware).
  cpufreq stats: 2.60 GHz:3.01%, 1.90 GHz:42.81%, 1.40 GHz:4.25%, 800 MHz:49.94%  (61384)

That clearly shows the module being used is "acpi-cpufreq", but when I do "lsmod", it is not among the Kernel modules listed, and neither is ACPI.

BUT ... "ps -ef | grep acpi" does show the ACPI daemon as running! Asking systemctl to report the units, it list the following:

UNIT                                 LOAD   ACTIVE SUB     DESCRIPTION
accounts-daemon.service              loaded active running Accounts Service
acpid.service                        loaded active running ACPI event daemon
alsa-restore.service                 loaded active exited  Save/Restore Sound Card State
apache2.service                      loaded active running The Apache HTTP Server
apparmor.service                     loaded active exited  Load AppArmor profiles
apport.service                       loaded active exited  LSB: automatic crash report generation
atop.service                         loaded active running Atop advanced performance monitor
atopacct.service                     loaded active running Atop process accounting daemon
avahi-daemon.service                 loaded active running Avahi mDNS/DNS-SD Stack
binfmt-support.service               loaded active exited  Enable support for additional executable binary formats
clamav-freshclam.service             loaded active running ClamAV virus database updater
colord.service                       loaded active running Manage, Install and Generate Color Profiles
console-setup.service                loaded active exited  Set console font and keymap
cpufrequtils.service                 loaded active exited  LSB: set CPUFreq kernel parameters
cpupower-gui-helper.service          loaded active running cpupower-gui system helper
cron.service                         loaded active running Regular background program processing daemon
cups-browsed.service                 loaded active running Make remote CUPS printers available locally
cups.service                         loaded active running CUPS Scheduler
dbus.service                         loaded active running D-Bus System Message Bus
dnscrypt-proxy-resolvconf.service    loaded active exited  DNSCrypt proxy resolvconf support
dnscrypt-proxy.service               loaded active running DNSCrypt client proxy
[email protected]                   loaded active running Getty on tty1
glances.service                      loaded active running Glances
hddtemp.service                      loaded active exited  LSB: disk temperature monitoring daemon
[email protected]                  loaded active exited  ifup for enp2s0
ifupdown-pre.service                 loaded active exited  Helper to synchronize boot up for ifupdown
irqbalance.service                   loaded active running irqbalance daemon
kerneloops.service                   loaded active running Tool to automatically collect and submit kernel crash signatures
keyboard-setup.service               loaded active exited  Set the console keyboard layout
kmod-static-nodes.service            loaded active exited  Create List of Static Device Nodes
laptop-mode.service                  loaded active exited  Laptop Mode Tools
lightdm.service                      loaded active running Light Display Manager
lm-sensors.service                   loaded active exited  Initialize hardware monitoring sensors
loadcpufreq.service                  loaded active exited  LSB: Load kernel modules needed to enable cpufreq scaling
ModemManager.service                 loaded active running Modem Manager
netperf.service                      loaded active running LSB: network benchmark
networkd-dispatcher.service          loaded active running Dispatcher daemon for systemd-networkd
networking.service                   loaded active exited  Raise network interfaces
NetworkManager-wait-online.service   loaded active exited  Network Manager Wait Online
NetworkManager.service               loaded active running Network Manager
openvpn.service                      loaded active exited  OpenVPN service
plymouth-quit-wait.service           loaded active exited  Hold until boot process finishes up
plymouth-read-write.service          loaded active exited  Tell Plymouth To Write Out Runtime Data
plymouth-start.service               loaded active exited  Show Plymouth Boot Screen
polkit.service                       loaded active running Authorization Manager
rsyslog.service                      loaded active running System Logging Service
rtkit-daemon.service                 loaded active running RealtimeKit Scheduling Policy Service
setvtrgb.service                     loaded active exited  Set console scheme
smartmontools.service                loaded active running Self Monitoring and Reporting Technology (SMART) Daemon
snap.cups.cups-browsed.service       loaded active running Service for snap application cups.cups-browsed
snap.cups.cupsd.service              loaded active running Service for snap application cups.cupsd
snapd.apparmor.service               loaded active exited  Load AppArmor profiles managed internally by snapd
snapd.seeded.service                 loaded active exited  Wait until snapd is fully seeded
snapd.service                        loaded active running Snap Daemon
spacenavd.service                    loaded active running 3Dconnexion Input Devices Userspace Driver
sysstat.service                      loaded active exited  Resets System Activity Logs
systemd-binfmt.service               loaded active exited  Set Up Additional Binary Formats
systemd-journal-flush.service        loaded active exited  Flush Journal to Persistent Storage
systemd-journald.service             loaded active running Journal Service
systemd-logind.service               loaded active running User Login Management
systemd-modules-load.service         loaded active exited  Load Kernel Modules
systemd-networkd.service             loaded active running Network Configuration
systemd-random-seed.service          loaded active exited  Load/Save Random Seed
systemd-remount-fs.service           loaded active exited  Remount Root and Kernel File Systems
systemd-resolved.service             loaded active running Network Name Resolution
systemd-sysctl.service               loaded active exited  Apply Kernel Variables
systemd-sysusers.service             loaded active exited  Create System Users
systemd-timesyncd.service            loaded active running Network Time Synchronization
systemd-tmpfiles-setup-dev.service   loaded active exited  Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service       loaded active exited  Create Volatile Files and Directories
systemd-udev-trigger.service         loaded active exited  Coldplug All udev Devices
systemd-udevd.service                loaded active running Rule-based Manager for Device Events and Files
systemd-update-utmp.service          loaded active exited  Record System Boot/Shutdown in UTMP
systemd-user-sessions.service        loaded active exited  Permit User Sessions
tlp.service                          loaded active exited  LSB: tlp start/stop script
udisks2.service                      loaded active running Disk Manager
ufw.service                          loaded active exited  Uncomplicated firewall
unattended-upgrades.service          loaded active running Unattended Upgrades Shutdown
upower.service                       loaded active running Daemon for power management
[email protected]        loaded active exited  User Runtime Directory /run/user/1000
[email protected]                    loaded active running User Manager for UID 1000
wpa_supplicant.service               loaded active running WPA supplicant

That list shows both acpid.service and cpufrequtils.service, cpupower-gui-helper.service, and loadcpufreq.service.

Also, looking at /etc/init.d/loadcpufreq script, it sets "acpi-cpufreq" as a default, failsafe module specification.

Looking at the source for each of loadcpufreq and cpufrequtils,

  • loadcpufreq appears to have more conditional logic programmed for hardware, whereas
  • cpufrequtils seems to rely more on the /system and /proc trees more directly.

Also, if I understood loadcpufreq correctly, it specifically loads a kernel module to achieve its objective, but any listing of the Kernel modules does not show any of the modules that the conditionals seem to indicate that it would load.

root:~# lsmod | sort

ahci                   49152  11
asus_atk0110           24576  0
atl1e                  49152  0
autofs4                49152  2
bfq                    86016  3
binfmt_misc            24576  1
bluetooth             704512  0
ccp                   106496  1 kvm_amd
cec                    61440  1 drm_kms_helper
cfg80211              974848  0
crc_itu_t              16384  1 firewire_core
dm_log                 20480  2 dm_region_hash,dm_mirror
dm_mirror              24576  0
dm_region_hash         24576  1 dm_mirror
drm                   622592  8 drm_kms_helper,radeon,drm_ttm_helper,ttm
drm_kms_helper        311296  1 radeon
drm_ttm_helper         16384  1 radeon
ecc                    36864  1 ecdh_generic
ecdh_generic           16384  1 bluetooth
edac_mce_amd           36864  0
efi_pstore             16384  0
fb_sys_fops            16384  1 drm_kms_helper
ff_memless             24576  1 hid_logitech
firewire_core          81920  1 firewire_ohci
firewire_ohci          49152  0
hid                   151552  3 hid_logitech,usbhid,hid_generic
hid_generic            16384  0
hid_logitech           45056  0
i2c_algo_bit           16384  1 radeon
i2c_piix4              32768  0
input_leds             16384  0
ip_tables              32768  0
joydev                 32768  0
k10temp                16384  0
kvm                  1036288  1 kvm_amd
kvm_amd               155648  0
ledtrig_audio          16384  1 snd_hda_codec_generic
libahci                49152  1 ahci
lp                     28672  0
mac_hid                16384  0
Module                  Size  Used by
msr                    16384  0
nvram                  16384  0
parport                69632  3 parport_pc,lp,ppdev
parport_pc             49152  0
pata_acpi              16384  0
pata_atiixp            16384  0
ppdev                  24576  0
psmouse               176128  0
radeon               1839104  5
rc_core                65536  1 cec
sch_fq_codel           20480  2
serio_raw              20480  0
snd                   106496  17 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_timer,snd_hda_codec_via,snd_pcm,snd_rawmidi
snd_hda_codec         163840  4 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_via
snd_hda_codec_generic   102400  1 snd_hda_codec_via
snd_hda_codec_hdmi     77824  1
snd_hda_codec_via      24576  1
snd_hda_core          110592  5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_codec_via
snd_hda_intel          53248  3
snd_hwdep              16384  1 snd_hda_codec
snd_intel_dspcfg       28672  1 snd_hda_intel
snd_intel_sdw_acpi     20480  1 snd_intel_dspcfg
snd_pcm               143360  4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_core
snd_rawmidi            49152  1 snd_seq_midi
snd_seq                77824  2 snd_seq_midi,snd_seq_midi_event
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
snd_seq_midi           20480  0
snd_seq_midi_event     16384  1 snd_seq_midi
snd_timer              40960  2 snd_seq,snd_pcm
soundcore              16384  1 snd
st                     65536  0
syscopyarea            16384  1 drm_kms_helper
sysfillrect            20480  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
tls                   114688  0
ttm                    86016  2 radeon,drm_ttm_helper
usbhid                 65536  1 hid_logitech
wmi                    32768  1 wmi_bmof
wmi_bmof               16384  0
x_tables               53248  1 ip_tables

root:~# 

So ... I am at a loss as to "which train I should board", the one for loadcpufreq or cpufrequtils, because "cpupower" is clearly not the master for CPU governor control.

Please note: I normally use the script I shared in that earlier posting, but today I decided to use the "mate-cpufreq-selector" utility. I chose "userspace" and set both Min freq and Max freq to the same value of 1900MHz. The mysterious "gremlin" once again changed that back to "ondemand" with the frequency visually showing changes from 800MHz to 2.6GHz, confirming its mode now being "ondemand".

Can someone who actually knows point me to the correct tool that I should be using?

In the boot.log.1 file, I see this reference:

Starting LSB: Load kernel …d to enable cpufreq scaling...

Unfortunately that was "truncated" and I can't see the name of the module that was loaded. :frowning:

Is there a way to have the system report such lines without that "truncation" or to specify a different length (i.e. 256 instead of 80) ?


Also, I noticed this reference to a service named "org.mate.CPUFreqSelector" in my syslog:

Oct 12 14:45:20 OasisMega1 dbus-daemon[3075]: [system] Successfully activated service 'org.mate.CPUFreqSelector'

I will see if I can locate that service and "tweak" it to my satisfaction, so that the frequency will be "locked" at the setting I want to be permanent. :slight_smile:

---- update ----

Apparently there is no such service !!!

systemctl status org.mate.CPUFreqSelector

reports:

Unit org.mate.CPUFreqSelector.service could not be found.

Unit mate.CPUFreqSelector.service could not be found.

Unit CPUFreqSelector.service could not be found.

:frowning:

----- update 2 -----
Just found stumbled on this:

root:/var/log# systemctl -l | grep freq
  cpufrequtils.service                                                                      loaded active exited    LSB: set CPUFreq kernel parameters
  loadcpufreq.service                                                                       loaded active exited    LSB: Load kernel modules needed to enable cpufreq scaling
root:/var/log# 

----- update 3 -----

I've made the changes for my desired default overrides, in what I believe to be the service script, "/etc/init.d/cpufrequtils":

root:/etc/init.d/Oasis# diff   ../cpufrequtils   cpufrequtils.Oasis
46a47,49
> GOVERNOR="userspace"
> MAX_SPEED="1900"
> MIN_SPEED="1900"
root/etc/init.d/Oasis# 

I've reset the systemd service as follows:

systemctl daemon-reload
systemctl force-reload cpufrequtils.service

cpufrequtils is being reloaded, as confirmed by the following:

Oct 12 17:28:12 OasisMega1 systemd[1]: Reloading LSB: set CPUFreq kernel parameters...
Oct 12 17:28:12 OasisMega1 cpufrequtils[11546]:  * CPUFreq Utilities: Setting userspace CPUFreq governor...
Oct 12 17:28:12 OasisMega1 cpufrequtils[11546]:  * CPU0...
Oct 12 17:28:12 OasisMega1 cpufrequtils[11546]:  * CPU1...
Oct 12 17:28:12 OasisMega1 cpufrequtils[11546]:  * CPU2...
Oct 12 17:28:12 OasisMega1 cpufrequtils[11546]:  * CPU3...
Oct 12 17:28:12 OasisMega1 cpufrequtils[11546]:    ...done.
Oct 12 17:28:12 OasisMega1 systemd[1]: Reloaded LSB: set CPUFreq kernel parameters.

But the panel App still shows that the CPU governor is "Ondemand" and the frequency is "vascillating" up and down. :frowning:

Where am I going wrong ?

Where I am at ...

It seems to me that there may be a conflict between governor control using "cpupower" and having the panel App "mate-cpufreq-selector" running (if only for visibility). :frowning:

The panel app does not look to adopt settings that are currently active but, instead, enforce a programmed default at startup. My opinion is that using that approach is incorrect.

Next, once the App is running, if I use cpupower to set values, the App will show those values but, after some random delay, it takes over and imposes an "ondemand" governor. :frowning:

I have removed the panel App, and it seems that nothing is "interfering" with my manually set governor. So I will have to live without the visual of the status on the panel App's display! "Woe is me!!!"

So .. that is the end of that conflict. I will eventually submit my "findings" to those responsible for the panel App.

I am shifting my attention to addressing the next phase in this journey: creating a startup service for systemd! :slight_smile:

I have details which I will post under a separate topic.

1 Like