Cpufrequtils (简体中文)

From ArchWiki

Jump to: navigation, search


i18n
English
Русский
Español
Português
简体中文

Contents

[edit] 概要

Cpufrequtils 是一套被设计为协助 CPU 频率调节的工具,CPU 频率调节是一种主要被笔记本电脑用于让操作系统调节 CPU 速度的技术,而这取决于当前的系统负载和(或者)电源管理方案。例如,CPU 频率调节可以在笔记本电脑使用电池工作时,将 2Ghz 的处理器降低到 1Ghz 来延长续航时间,减少发热和减少风扇噪音。

若与 Pm-utils 一起使用,可以提供一套完整的电源管理功能。

[edit] 安装

Cpufrequtils 软件包可以从 Extra 软件源得到:

# pacman -S cpufrequtils

[edit] 设置

设置 CPU 频率调节需要三步:

  1. 加载合适的 CPU 频率调节驱动程序
  2. 加载需要的调速器
  3. 设置并加载 CPU 频率调节守护进程 (可选)

[edit] CPU 频率调节驱动程序

要使频率调节正常工作,操作系统必须知道您的 CPU 所具有的一些限制,为此,可以加载一个能读取、管理您的 CPU 规格的内核驱动。

大部分较新的笔记本电脑可以简单地使用 acpi-cpufreq 驱动,其他选项包括 p4-clockmod, powernow-k6, powernow-k7, powernow-k8,speedstep-centrino 驱动。

手动加载 CPU 频率调节驱动:

# modprobe acpi-cpufreq

若要自动加载驱动,将合适的驱动添加到 /etc/rc.conf 的 MODULES 列,如:

MODULES=( acpi-cpufreq vboxdrv fuse fglrx iwl3945 ... )

加载合适的 cpufreq 驱动后,您可以用一下命令来查看您的 CPU 的详细信息:

$ cpufreq-info

样板输出 cpufreq-info (Intel Duo Core T2500):

analyzing CPU 0:
 driver: acpi-cpufreq
 CPUs which need to switch frequency at the same time: 0 1
 hardware limits: 1000 MHz - 2.00 GHz
 available frequency steps: 2.00 GHz, 1.67 GHz, 1.33 GHz, 1000 MHz
 available cpufreq governors: ondemand, performance
 current policy: frequency should be within 1000 MHz and 2.00 GHz.
                 The governor "performance" may decide which speed to use
                 within this range.
 current CPU frequency is 2.00 GHz.
analyzing CPU 1:
 driver: acpi-cpufreq
 CPUs which need to switch frequency at the same time: 0 1
 hardware limits: 1000 MHz - 2.00 GHz
 available frequency steps: 2.00 GHz, 1.67 GHz, 1.33 GHz, 1000 MHz
 available cpufreq governors: ondemand, performance
 current policy: frequency should be within 1000 MHz and 2.00 GHz.
                 The governor "performance" may decide which speed to use
                 within this range.
 current CPU frequency is 2.00 GHz.

[edit] 调速器 (CPU 电源方案)

调速器可以被看作是预先设置好的 CPU 电源方案,它们必须被作为内核模块加载才能够被 kpowersave 和 gnome-power-manager 之类的程序识别。您可以加载多个调速器,但是在同一时间您只能激活一个。

可用的调速器:

  • performance (默认) -- Performance 调速器使 CPU 运行在最高频率,它已经被编译进内核。
  • cpufreq_ondemand (推荐) -- 根据系统负载动态调节 CPU 频率。
  • cpufreq_conservative -- 与 ondemand 相似但更为保守 (clock speed changes are more graceful)
  • cpufreq_powersave -- 使 CPU 运行在最低频率。
  • cpufreq_userspace -- 由用户手动选择 CPU 频率。

将需要的调速器加入 /etc/rc.conf 的 MODULES 列:

MODULES=(acpi-cpufreq cpufreq_ondemand cpufreq_powersave vboxdrv fuse fglrx iwl3945 ... )

作为选择,您可以以 root 执行 cpufreq-set 命令来手动设置调速器,但这在关机或重启后不会保存。如:

# cpufreq-set -g ondemand

运行 cpufreq-set --help 或者 man cpufreq-set 来获得更多信息。

添加cpu监视器 监视cpu频率的系统就有,右键单击面板,选择“添加到面板”,里面找到“cpu频率范围监视器”。 另外,如果嫌命令行麻烦,可以这么做 代码:

# sudo chmod +s /usr/bin/cpufreq-selector

然后,cpu频率范围监视器的首选项里就会多出一个“频率选择器”,显示菜单选择“频率和调速器”。鼠标左键单击cpu频率范围监视器,会发现“频率”和“调速器”两个菜单,就可以随便调了

[edit] 守护进程

cpufrequtils 也安装了一个守护进程,可以在启动系统的时候就设置调速器和 CPU 的最高、最低频率,而不需要额外的如 kpowersave 之类的程序。这对于运行轻量级桌面,如 Openbox 的人来说是一个完善的解决方案。

在启动守护进程之前,以 root 编辑 /etc/conf.d/cpufreq,选择需要的调速器并且设置 CPU 的最高、最低频率,例如:

#configuration for cpufreq control
# valid governors:
#  ondemand, performance, powersave,
#  conservative, userspace
governor="ondemand"

# valid suffixes: Hz, kHz (default), MHz, GHz, THz
min_freq="1GHz"
max_freq="2GHz"

注意: 精确的 min/max 数值可以由运行 cpufreq-info 查看 (在加载 CPU 驱动之后,如 modprobe acpi-cpufreq)。不过,这是可选的,您可以将它们完全忽略,例如删除或者注释这两行,这样它将会自动工作。

设置好配置文件后,可以运行以下命令来启动守护进程:

# /etc/rc.d/cpufreq start

若要在启动系统时自动加载守护进程,将 cpufreq 加到 /etc/rc.conf 的 DAEMONS 列,如:

DAEMONS=(syslog-ng hal cpufreq dhcdbd networkmanager !network !netfs @alsa @crond @cups @fam @ntpd @sshd)

[edit] 其他资源

CPU_Frequency_Scaling - 为桌面环境用户准备的一些额外信息。 (Arch Wiki Entry)
Pm-utils - 由 openSUSE 社区提供的挂起/休眠框架 (Arch Wiki Entry)

Personal tools