在Linux下,可通过cpufreq-info,cpufreq-info,cpufreq-selector等命令来查看以及设置CPU的频率。 这些命令加载了内核的acpi_cpufreq模块,可通过以下命令查看是否加载。
lsmod | grep "acpi_cpufreq"
其中cpufreq-info的输出示例信息如下:
analyzing CPU 7:
  driver: acpi-cpufreq
  CPUs which need to switch frequency at the same time: 7
  hardware limits: 1.20 GHz - 2.13 GHz
  available frequency steps: 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz
  available cpufreq governors: ondemand, userspace, performance
  current policy: frequency should be within 1.20 GHz and 2.13 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.20 GHz.
上面给除了当前CPU的频率范围,频率的策略,以及整个CPU可是设置的频率。 其中governor就是CPU频率的策略,上面列出的CPU有三种策略,onemand(表示系统可以通过动态调整频率,降低功耗,具体的调整策略和内核的功耗管理算法有关),userspace(表示用户可以自己设定cpu的频率),performance(表示CPU总是在最高主频下工作)。 可通过cpufreq-set以及cpufreq-selector来设置CPU的频率以及策略。 cpufreq-set的用法如下:
Usage: cpufreq-set [options]
Options:
  -c CPU, --cpu CPU        number of CPU where cpufreq settings shall be modified
  -d FREQ, --min FREQ      new minimum CPU frequency the governor may select
  -u FREQ, --max FREQ      new maximum CPU frequency the governor may select
  -g GOV, --governor GOV   new cpufreq governor
  -f FREQ, --freq FREQ     specific frequency to be set. Requires userspace
                           governor to be available and loaded
  -h, --help           Prints out this screen
cpufreq-selector的用法如下:
Usage: cpufreq-set [options]
Options:
  -c CPU, --cpu CPU        number of CPU where cpufreq settings shall be modified
  -d FREQ, --min FREQ      new minimum CPU frequency the governor may select
  -u FREQ, --max FREQ      new maximum CPU frequency the governor may select
  -g GOV, --governor GOV   new cpufreq governor
  -f FREQ, --freq FREQ     specific frequency to be set. Requires userspace
                           governor to be available and loaded
  -h, --help           Prints out this screen