这是本节的多页打印视图。 点击此处打印.

返回本页常规视图.

硬件配置

Ubuntu Server硬件相关配置工作

1 - 查看cpu频率

查看当前cpu各个核心的实时频率

cpufreq-info

需要安装 cpufrequtils :

sudo apt-get install cpufrequtils

然后执行:

$ cpufreq-info
                  
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 4294.55 ms.
  hardware limits: 1.20 GHz - 3.50 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 1.20 GHz and 3.50 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 1.20 GHz.
analyzing CPU 1:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 4294.55 ms.
  hardware limits: 1.20 GHz - 3.50 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 1.20 GHz and 3.50 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 1.20 GHz.
......

如果想快速概括的查看所有内核的实时频率,可以这样:

$ cpufreq-info | grep "current CPU frequency"
  current CPU frequency is 1.38 GHz.
  current CPU frequency is 1.23 GHz.
  current CPU frequency is 1.20 GHz.
  current CPU frequency is 1.20 GHz.
  current CPU frequency is 1.20 GHz.
  current CPU frequency is 1.20 GHz.
  current CPU frequency is 1.20 GHz.
......

也可以这样每秒钟刷新一下:

watch -n1 "lscpu | grep MHz | awk '{print $1}'";

auto-cpufreq

https://snapcraft.io/auto-cpufreq

参考资料

2 - cpu压力测试

对cpu进行压力测试

主要是想看一下压力测试时cpu的频率,看是否工作在性能模式。

备注: 对于x99主板,则同时可以检验一下鸡血bios是否生效

sysbench

安装sysbench:

sudo apt install sysbench

执行cpu压力测试:

sysbench cpu --threads=40 run

很欣喜的看到x99双路主板上两个e5 2666 v3 cpu在鸡血bios之后都可以跑在全核3.5G的频率:

cpufreq-info | grep "current CPU"
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.
  current CPU frequency is 3.49 GHz.

stress

参考资料

3 - 电源模式

设置CPU电源模式

查看电源模式

$ cpufreq-info
                  
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 4294.55 ms.
  hardware limits: 1.20 GHz - 3.50 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 1.20 GHz and 3.50 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 1.20 GHz.

设置电源模式

设置电源模式为 “performance”:

sudo bash -c 'for i in {0..31}; do cpufreq-set -c $i -g performance; done'

设置电源模式为 “powersave”:

sudo bash -c 'for i in {0..31}; do cpufreq-set -c $i -g powersave; done'

设置电源模式为 “ondemand”:

sudo bash -c 'for i in {0..31}; do cpufreq-set -c $i -g ondemand; done'

参考资料