LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Suggestion: use "performance" CPU frequency governor (https://www.linuxquestions.org/questions/slackware-14/suggestion-use-performance-cpu-frequency-governor-4175637326/)

EdGr 08-28-2018 01:42 PM

Suggestion: use "performance" CPU frequency governor
 
The default "ondemand" governor maps to "powersave" on modern Intel CPUs. The powersave governor takes several hundred milliseconds to ramp to maximum frequency.

To work around this, I have in my /etc/rc.d/rc.local:

Code:

/etc/rc.d/rc.cpufreq performance
The difference is measurable on benchmarks. Interactive response is snappier. The computers still idle efficiently.

Disclaimer - all of my computers are AC powered.
Ed

Darth Vader 08-28-2018 02:34 PM

Maybe that is useful for the Intel users, but for those having AMD processors your suggestion will make the CPU to stay at max frequency and the CPU fan to go nuts.

Also, for those with laptops, the "performance" governor will be a disaster no matter which company produced their CPUs. ;)

So, how about yourself to tune your "/etc/rc.d/rc.cpufreq" and be happy with your micro-benchmarks? I talk about this well commented line:

Code:

# Default CPU scaling governor to try.  Some possible choices are:
# performance:  The CPUfreq governor "performance" sets the CPU statically
#            to the highest frequency within the borders of scaling_min_freq
#            and scaling_max_freq.
# powersave:  The CPUfreq governor "powersave" sets the CPU statically to the
#            lowest frequency within the borders of scaling_min_freq and
#            scaling_max_freq.
# userspace:  The CPUfreq governor "userspace" allows the user, or any
#            userspace program running with UID "root", to set the CPU to a
#            specific frequency by making a sysfs file "scaling_setspeed"
#            available in the CPU-device directory.
# ondemand:  The CPUfreq governor "ondemand" sets the CPU depending on the
#            current usage.
# conservative:  The CPUfreq governor "conservative", much like the "ondemand"
#            governor, sets the CPU depending on the current usage.  It
#            differs in behaviour in that it gracefully increases and
#            decreases the CPU speed rather than jumping to max speed the
#            moment there is any load on the CPU.
# schedutil:  The CPUfreq governor "schedutil" aims at better integration with
#            the Linux kernel scheduler. Load estimation is achieved through
#            the scheduler's Per-Entity Load Tracking (PELT) mechanism, which
#            also provides information about the recent load.
SCALING_GOVERNOR=ondemand


abga 08-28-2018 03:03 PM

Indeed, the intel_pstate driver only supports "powersave" (default) and "performance" and I can confirm what EdGr reported, the default "powersave" is just too lazy. This "powersave" should be the equivalent of the "ondemand" governor that works under the acpi-cpufreq driver for other non-Intel CPUs, but it's not. Like the OP suggested, I always set the governor on "performance" for Intel CPUs, even on laptops, without experiencing any thermal issues, the fan is indeed spinning a little and doesn't stop, but then I'm only using new (power efficient) CPUs, past Haswell.
Good lecture:
https://www.kernel.org/doc/html/v4.1...el_pstate.html
+
https://www.kernel.org/doc/Documenta...user-guide.txt
https://www.kernel.org/doc/Documenta.../governors.txt

I wrote some notes some time ago and considered disabling the intel_pstate driver and using the acpi-cpufreq instead, checking if its "ondemand" governor(algorithm) is better(faster) than the intel_pstate "powersave", but forgot about it. Thankful now about this thread, reminding me about it. Will need to go through these when I'll find some time available:
https://unix.stackexchange.com/quest...r-conservative
https://www.phoronix.com/scan.php?pa...linux315&num=1

EdGr 08-28-2018 03:33 PM

Darth Vader - the comments in rc.cpufreq are obsolete for modern Intel CPUs.

abga - thanks for the links!

On my Intel Nehalem, Sandy Bridge, and Haswell-E CPUs, there are only two governors, "performance" and "powersave". "Powersave" makes the Haswell-E desktop sluggish. "Performance" cuts its power consumption in half when idle. I have measured both. :)

My Sandy Bridge laptop does not mind being run in performance mode on AC power. Unfortunately, the laptop no longer has a working battery.
Ed

RadicalDreamer 08-28-2018 05:02 PM

ondemand works fine for me. If I am using something demanding it takes a few seconds for it to ramp up. I tried performance recently for Rise of the Tomb Raider because that was their recommendation. After the game ended the CPU frequency was still at about max on a few cores. I like how ondemand is ondemand. Plasma 5 running Firefox only requires ~1.60 Ghz on all cores so I don't need it to run at about 4 Ghz all the time.

lougavulin 08-28-2018 06:22 PM

When governor is set "ondemand", is there a way to follow dynamically the status change ? Or is it just to look at cpu activities ?

dugan 08-28-2018 07:12 PM

https://www.kernel.org/doc/Documenta...user-guide.txt

The current frequency of cpu 0 is at:

/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

You could, say, have Conky "cat" that every second.

Daedra 08-28-2018 07:53 PM

with conky I use
Code:

awk '/cpu MHz/{i++}i==1{printf "%.f",$4; exit}' /proc/cpuinfo
to show the cpu freq changes in real time.

EdGr 08-28-2018 08:01 PM

Keep in mind the frequency adjustments are much more rapid than you can observe.

The way to measure the difference is to write a benchmark which goes from idle to full load and back to idle in less than one second.
Ed

Daedra 08-28-2018 08:16 PM

Quote:

Originally Posted by lougavulin (Post 5897276)
When governor is set "ondemand", is there a way to follow dynamically the status change ? Or is it just to look at cpu activities ?

to see it in a terminal in realtime you can also use

Code:

watch grep \"cpu MHz\" /proc/cpuinfo
and EdGr, what you said is true but I think viewing the change every second or so give you the information you would need.

RadicalDreamer 08-28-2018 08:29 PM

2 Attachment(s)
I did a before and after Slackware64 Current update. Here is ondemand and performance frequencies according to cpufreq-info. Plasma 5, one xterm open, and Firefox open with just this page with an i7 Ivy Bridge 3770. Performance has the CPU running ~2.20 GHz more.

One issue I came across with Rise of the Tomb Raider is that I couldn't set it back and forth from ondemand to performance on the command line. I tried /etc/rc.d/rc.cpufreq performance and it would change to performance but when I tried to set it back to ondemand the CPU still acted like it was on performance based on cpufreq-info and rc.cpufreq would report it as on performance. I was using these instructions under "More Performance Options": https://docs.slackware.com/studioware:tips_and_hints

denydias 08-29-2018 12:06 AM

I have this on my laptops:

Code:

$ ls -l /etc/pm/power.d/powermgmt
-rwxr-xr-x 1 root root 2197 jul 12 05:31 /etc/pm/power.d/powermgmt*
$ cat /etc/pm/power.d/powermgmt
#!/bin/sh
# File          : powermgmt
# Author        : Deny Dias <http://mexapi.macpress.com.br>
# Description  : Manage various power related features according to the source.
# License      : GPLv3
# Last Modified : 2015-07-12

# AC settings
if on_ac_power; then

  # Set CPU Governor: Performance
  /sbin/modprobe cpufreq_performance > /dev/null 2>&1
  for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
    do echo performance > $cpu;
  done

  # Disable PCI autosuspend
  for pci in /sys/bus/pci/devices/*/power/control;
    do echo on > $pci;
  done

  # Disable Laptop-Mode disk writing
  #echo 0 > /proc/sys/vm/laptop_mode

  # Set VM writeback timeout: 500
  #echo 500 > /proc/sys/vm/dirty_writeback_centisecs

  # Set SATA channel: max performance
  #for sata in /sys/class/scsi_host/host*/link_power_management_policy;
  #  do echo max_performance > $sata;
  #done

  # Disabile audio_card power saving
  echo 0 > /sys/module/snd_hda_intel/parameters/power_save_controller
  echo 0 > /sys/module/snd_hda_intel/parameters/power_save

  # Disable USB autosuspend
  #for usb in /sys/bus/usb/devices/*/power/level;
  #  do echo on > $usb;
  #done

# Battery settings
else

  # Set CPU Governor: PowerSave
  /sbin/modprobe cpufreq_powersave > /dev/null 2>&1
  for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
    do echo powersave > $cpu;
  done

  # Enable PCI autosuspend
  for pci in /sys/bus/pci/devices/*/power/control;
    do echo auto > $pci;
  done

  # Enable Laptop-Mode disk writing
  #echo 5 > /proc/sys/vm/laptop_mode

  # Set SATA channel: power saving
  #for sata in /sys/class/scsi_host/host*/link_power_management_policy;
  #  do echo min_power > $sata;
  #done

  # Set VM writeback timeout: 1500
  #echo 1500 > /proc/sys/vm/dirty_writeback_centisecs

  # Enable audio_card power saving
  echo 1 > /sys/module/snd_hda_intel/parameters/power_save
  echo 1 > /sys/module/snd_hda_intel/parameters/power_save_controller

  # Enable USB autosuspend
  #for usb in /sys/bus/usb/devices/*/power/level;
  #  do echo auto > $usb;
  #done
fi

Edit: Oh! And also this in /etc/rc.d/rc.local:

Code:

# Disable Ethernet Wake-on LAN to save power
/usr/sbin/ethtool -s eth0 wol d


Didier Spaier 08-29-2018 03:31 AM

This thread can be marked as solved:
Code:

Tue Aug 28 22:05:19 UTC 2018
a/sysvinit-scripts-2.1-noarch-18.txz:  Rebuilt.
  rc.cpufreq: for CPUs that use intel_pstate, default to the performance
  governor. The performance governor provides power savings while avoiding
  the ramp-up lag caused by using "ondemand", which defaults to "powersave"
  on these systems. Thanks to EdGr.

Thanks EdGr and Pat.

lougavulin 08-29-2018 04:14 AM

Thank you all for your answers and explanations ! :)

EdGr 08-29-2018 04:54 AM

Marking thread as solved. We just got faster computers. :)
Ed


All times are GMT -5. The time now is 03:28 AM.