LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 5407|回复: 5

[原创] 给笔记本电脑用户: cpufreqd 的配置方法

[复制链接]
发表于 2005-1-11 00:19:37 | 显示全部楼层 |阅读模式
用 notebook 如果不配好 speedstep, 风扇的声音会很烦, 电池时间当然也会减少 ---- 不过我倒不在意它, 因为基本不用电池.

常用的 speedstep 软件, 有 cpudyn, cpufreqd, powernowd, 而新版的 kernel 里面的  cpufreq_ondemand, 也能够按照系统负荷来调整 cpu 频率.

那为什么不直接用 cpufreq_ondemand 呢 ? 举个例子, 有些网站有些糟糕的 javascript, 会让 cpu 利用率到 100%, 我可不想为这些网站让 cpu 跑全速, 我希望cpu 只是跑 gcc/g++/make, 或者加上 bzip2, gzip 等时候, 才跑全速, 其他时候, 凉快一点好. 这就需要 cpufreqd 了, 核心自己, cpudyn 和 powernowd 做不到.


需要使用 speedstep, kernel  配置, 必须:

  1. 1. 提供操作 speedstep 的 api
  2.     例如 speedstep_smi, speedstep_ich,  speedstep_centrino 之类的, 核心配置的地方有说明, 根据自己机器的具体情况选择正确的就好了,
  3. 基本上是
  4.     centrino 当然是 名字都对应的 speedstep_centrino
  5.     图拉丁 PIII-M 和 P4-M 的机器, 可以用 speedstep-ich 模块 来访问 speedstep
  6.     铜矿 PIII 用 speedstep_smi

  7.     台式机 P4 也有一个 X86_P4_CLOCKMOD 接口

  8. 2. cpufreq governor
  9.     cpu 频率的控制者

  10.     如果 speedstep 那边已经加载了合适的模块, 那么加载 cpufreq_perfermance 这个 gover, 那么
  11.    cpu 会一直跑高速, 如果加载  cpufreq_powersafe 这个gover, 就会一直跑低速, 如果加载
  12.    cpufreq_ondemand 就让核心根据 cpu 负荷自动调整, 如果加载 cpufreq_userspace,  那么用户
  13.    级代码可以直接通过 /sys/devices/system/cpu/cpu0/cpufreq 来控制频率.

复制代码


cpudyn, cpufreqd, powernowd 他们除了需要有合适的 speedstep 接口, 相关的 gover, 还需要
/proc 或者 /sys 里面的用户级代码和核心代码的通信接口, 每个软件需要的不太一样,我懒得细细
检查, 编译核心的时候将每个接口选了, 包括这三个过时接口 /proc/cpufreq, /proc/sys/cpu/
/proc/acpi/processor/../performance, 反正这也不会增大多少开销.

cpufreqd 不会自动 load module, 所以, 用到的 cpufreq_gov, 就是 cpufreq_performance,
cpufreq_powersave, cpufreq_ondemand 那几个, 要么编译到内核里, 要么在 modules 中进行
装载.

我是让 cpufreqd 使用 acpi 而不是 apm 来工作的, 因此, 系统必须安装 acpid

我的 /etc/modules 如下

  1. speedstep-ich
  2. cpufreq_powersave
  3. cpufreq_performance
复制代码


我的 cpufreqd.conf 是为编译提供高速 cpu, 其他时候低速的, 如下

  1. # 这里省略掉了 profile 的定义, 用回缺省的就好.

  2. [General]
  3. pidfile=/var/run/cpufreqd.pid
  4. poll_interval=4
  5. pm_type=acpi #(acpi, apm or pmu)
  6. # Uncomment the following line to enable ACPI workaround (see cpufreqd.conf(5))
  7. # acpi_workaround=1
  8. verbosity=4 #(if you want a minimal logging set to 5)



  9. #非编译 ac
  10. [Rule]
  11. name=not_important
  12. ac=on                   # (on/off)
  13. battery_interval=0-100
  14. cpu_interval=0-100
  15. profile=lo_power


  16. #非编译 电池
  17. [Rule]
  18. name=not_important_bat
  19. ac=off                  # (on/off)
  20. battery_interval=0-100
  21. cpu_interval=0-100
  22. profile=lo_power


  23. #这两个, 即使 programs 没有匹配, 也会得到 14 分, 因此放在后面, 使得program不匹配的时候, 上面两个同分, 使用上面两个
  24. #gcc 编译, ac
  25. [Rule]
  26. name=important
  27. ac=on                   # (on/off)
  28. battery_interval=0-100
  29. programs=cc1,cc1plus,make
  30. cpu_interval=80-100
  31. profile=hi_boost

  32. #gcc 编译, 电池
  33. [Rule]
  34. name=important_bat
  35. ac=off                   # (on/off)
  36. battery_interval=0-100
  37. programs=cc1,cc1plus,make
  38. cpu_interval=80-100
  39. profile=hi_boost
复制代码




然后 killall -SIGHUP cpufreqd, cpufreqd 就能够正常工作了,  这样灵活的配置, windows 下面好象也只有 ibm/sony/toshiba 三家的程序可以做到
发表于 2005-6-2 09:56:19 | 显示全部楼层
cpufreqd有一个挺大的问题。。。
我从来都没有能够用它来驱动我的userspace governor。
有人试过吗?
回复 支持 反对

使用道具 举报

发表于 2006-6-12 21:12:21 | 显示全部楼层
I have installed the Cpufreqd and Gnome-cpufreq-applet following redsea's method, there are  two CPU frequence listed on the gnome pane (100% and 73%) and can be choosed  to run.
My question is:
How can configure it to list more CPU frequences?
回复 支持 反对

使用道具 举报

发表于 2006-6-12 21:42:37 | 显示全部楼层
powernowd最好用,安装也非常简单。
以在gentoo下安装powernowd为离,只要三步:
emerge -av powernowd
/etc/init.d/powernowd start
rc-update add powernowd default
回复 支持 反对

使用道具 举报

发表于 2006-6-13 10:02:58 | 显示全部楼层
I have installed powernowd (apt-get install powernowd).
When #/etc/init.d/powernowd start
I get:
powernowd: PowerNow Daemon v0.90, (c) 2003-2004 John Clemens
powernowd: Found 1 cpu:
Couldn't open file: No such file or directory
Couldn't open file: No such file or directory
Couldn't open file: No such file or directory
couldn't open govn's file for writing: No such file or directory
Couldn't get per-cpu data: Illegal seek
PowerNowd encountered and error and could not start.
Please make sure that:
- You are running a v2.5/v2.6 kernel or later
- That you have sysfs mounted /sys
- That you have the core cpufreq and cpufreq-userspace
   modules loaded into your kernel
- That you have the cpufreq driver for your cpu loaded,
   and that it works. (check dmesg for errors)
If all of the above are true, and you still have problems,
please email the author: clemej@alum.rpi.edu

What's the problem?
回复 支持 反对

使用道具 举报

发表于 2006-6-15 14:50:10 | 显示全部楼层
系统已经提示得很清楚了:
Post by dippybird
Please make sure that:
- You are running a v2.5/v2.6 kernel or later
- That you have sysfs mounted /sys
- That you have the core cpufreq and cpufreq-userspace
   modules loaded into your kernel
- That you have the cpufreq driver for your cpu loaded,
   and that it works. (check dmesg for errors)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表