2

I am using cpufreq to scale my CPU frequency. But I do that by clicking cpufreq icon on the panel of Ubuntu 12.04.

If without a mouse, how can I show and scale CPU frequency by running commands in terminal?

Braiam
  • 35,991
Tim
  • 101,790
  • http://unix.stackexchange.com/questions/120328/how-to-set-the-cpu-freq-in-linux/120371#120371 – slm Oct 18 '14 at 20:36

1 Answers1

3
  • cpufreq-info - Utility to retrieve cpufreq kernel information. It will list available frequency steps, available governors, current policy etc.

  • cpufreq-set - A tool which allows to modify cpufreq settings (try e.g. cpufreq-set -g performance or cpufreq-set -f 2 GHz once you know what frequencies your CPU can be set to)

You can also retrieve information about you cpufreq state directly from /sys/devices/system/cpu/cpu*/cpufreq directory. For example available frequencies are stored in /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies.

jimmij
  • 47,140
  • thanks. (1) I found that I have not installed cpufrequtils. but I have indicator-cpufreq running on the panel of the desktop for me to change by mouse. (2) Can I modify /sys/devices/system/cpu/cpu*/cpufreq/scaling_setspeed for changing the frequecy? – Tim Oct 18 '14 at 18:28
  • Yes, you can do that instead of setfreq-set, at least works for me. – jimmij Oct 18 '14 at 18:35
  • Is it weird that I have installed indicator-cpufreq without installing cpufrequtils? Does the former not depend on the latter? What do the two depend on, libcpufreq0? – Tim Oct 18 '14 at 19:22
  • @Tim - look at the package mgmt for this info. – slm Oct 18 '14 at 19:41
  • jimmij, is it a good idea to put the change of cpu freq into some file the OS executs when it starts? http://unix.stackexchange.com/questions/163005/where-can-i-put-settings-that-are-run-with-root-and-last-from-start-of-os-till-i – Tim Oct 19 '14 at 16:54
  • I don't think any rc script from system start-up will be executed when system is waking up from pm-suspend. It sounds reasonable what peterph wrote there in the comment. – jimmij Oct 19 '14 at 18:29
  • Hi jimmij, I have two cores on my laptop called CPU 0 and CPU 1 in the output of cpufreq-info. sudo cpufreq-set -f 1.60 GHz -c 2 reports error, sudo cpufreq-set -f 1.60 GHz -c 0 and sudo cpufreq-set -f 1.60 GHz -c 1 don't change my cpu freq to 1.60 GHz although there is no error. – Tim Nov 03 '14 at 17:59
  • And which values are present in /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies? – jimmij Nov 03 '14 at 18:28
  • 2667000 2666000 2133000 1600000 800000, and how can I scale both cores, and scale just one? I will be notified, only when you write "@Tim". Thanks. – Tim Nov 03 '14 at 20:18
  • @Tim Try cpufreq-set -f 1.60GHz -c0 and cpufreq-set -f 1.60GHz -c1. Note missing space between frequency and metric prefix. At least this way it works for me. – jimmij Nov 03 '14 at 21:27
  • WOrks. But only one core at a time? can all cores at a time? – Tim Nov 03 '14 at 21:33
  • @Tim I think it is impossible. There is -r flag for cpufreq-set, but according to manual -f works only with -c. You should be able to write to /sys/.../cpu*/... devices with one line/command if this is the point. – jimmij Nov 03 '14 at 21:49
  • verbatim from current "man cpufreq-set": ... allows you to modify cpufreq settings without having to type e.g. "/sys/devices/system/cpu/cpu0/cpufreq/scaling_set_speed" all the time. -- so it is a "mere shortcut" (which is why the panel might not depend on the cli tool to be installed) – Till Kolditz Jul 09 '17 at 13:54