一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

用cpufreq给CPU临时调整主频

时间:2015-10-06 编辑:简简单单 来源:一聚教程网


#32位系统
yum install -y cpufreq-utils.i386
#64位系统
yum install -y cpufreq-utils.x86_64

#查看当前CPU工作频率和状态
cpufreq-info

a) 查看cpu类型、当前频率、支持频率、运行模式等
cpufreq-info, cpufreq-selector, cpufreq-set。

[root@apiof.com ~]# cpufreq-info
cpufrequtils 007: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: powernow-k8
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 1000 ns.
  hardware limits: 800 MHz - 1.60 GHz
  available frequency steps: 1.60 GHz, 1.28 GHz, 800 MHz
  available cpufreq governors: ondemand, userspace, performance
  current policy: frequency should be within 800 MHz and 1.60 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz (asserted by call to hardware).
analyzing CPU 1:
  driver: powernow-k8
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 1000 ns.
  hardware limits: 800 MHz - 1.60 GHz
  available frequency steps: 1.60 GHz, 1.28 GHz, 800 MHz
  available cpufreq governors: ondemand, userspace, performance
  current policy: frequency should be within 800 MHz and 1.60 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz (asserted by call to hardware).

b)选择需要调整的cpu  
   sudo cpufreq-selector -c cpu号
    或者
   sudo cpufreq-set -c cpu号

    可能对双核或多核cpu进行选择。我的不是双核,没法实验,还请有duo core的朋友实验一下并跟帖汇报情况。

c)调整cpu频率
     sudo cpufreq-selector -f 你所需要的频率
    或者
sudo cpufreq-set -f 你所需要的频率

    注意,此处的频率必须是以KHz为单位,并且是可以达到的频率(也就是用cpufreq-info查看到的各个频率),cpu频率=倍频x外频。以下凡是涉及频率的一律如此。

d)调整cpu频率上下限
   sudo cpufreq-set -d 频率下限
     sudo cpufreq-set -u 频率上限

   因此,可能可以对cpu进行降频或者超频。有些人肯定会跃跃欲试的,嘿嘿。

e)调整cpu运行模式
sudo cpufreq-selecotr -g 模式
    或者
   suod cpufreq-set -g 模式
    这里,模式就是执行cpufreq-info后看到的所支持的模式。比如我的支持以下几种:powersave, userspace, ondemand, conservative, performance。

    powersave, 是无论如何都只会保持最低频率的所谓“省电”模式;
    userspace,   是自定义频率时的模式,这个是当你设定特定频率时自动转变的;
    ondemand, 默认模式。一有cpu计算量的任务,就会立即达到最大频率运行,等执行完毕就立即回到最低频率;
    conservative,翻译成保守(中庸)模式,会自动在频率上下限调整,和ondemand的区别在于它会按需分配频率,而不是一味追求最高频率;
    performance,顾名思义只注重效率,无论如何一直保持以最大频率运行。

热门栏目