CentOS 保守的州长,不错的错误

Not*_*lyn 5 centos cpu-frequency

我将我的 CentOS 6 CPU 调控器从按需(默认)更改为保守的,并在重新启动 cpufreq 服务后得到了这个:

/etc/rc5.d/S13cpuspeed:第88行:/sys/devices/system/cpu/cpufreq/conservative/ignore_nice_load:文件或目录不存在

所以我该怎么做?我应该创建文件,如果是,我应该在那里放什么?

slm*_*slm 9

对于 3.x 内核

CPUFreq 的接口在较新的内核中发生了变化。这将包括 CentOS 6。您可以在 Red Hat Enterprise Linux (RHEL) 文档中阅读有关整个界面的信息:第 3 章核心基础架构和机制

特别是关于CPUFreq Setup的部分。以下是设置它所需的步骤。

CPUFreq 驱动程序

$ ls -1 /lib/modules/`uname -r`/kernel/arch/x86/kernel/cpu/cpufreq/
acpi-cpufreq.ko
mperf.ko
p4-clockmod.ko
pcc-cpufreq.ko
powernow-k8.ko
speedstep-lib.ko
Run Code Online (Sandbox Code Playgroud)

加载合适的驱动程序

$ modprobe acpi-cpufreq
Run Code Online (Sandbox Code Playgroud)

安装 cpupower 工具

$ yum install cpupowerutils
Run Code Online (Sandbox Code Playgroud)

查看州长

$ cpupower frequency-info --governors
analyzing CPU 0:
ondemand userspace performance
Run Code Online (Sandbox Code Playgroud)

所以我们目前只加载了这 3 个调控器:ondemanduserspaceperformance

加载缺少的调控器

您可以获得所有可用的州长列表。

$ ls -1 /lib/modules/`uname -r`/kernel/drivers/cpufreq/
cpufreq_conservative.ko
cpufreq_ondemand.ko
cpufreq_powersave.ko
cpufreq_stats.ko
freq_table.ko

$ modprobe cpufreq_powersave
Run Code Online (Sandbox Code Playgroud)

到目前为止确认模块:

$ lsmod |grep cpuf
cpufreq_powersave       1196  0 
cpufreq_ondemand       10544  8 
acpi_cpufreq            7763  0 
freq_table              4936  2 cpufreq_ondemand,acpi_cpufreq
mperf                   1557  1 acpi_cpufreq
Run Code Online (Sandbox Code Playgroud)

确认加载了哪些调速器

$ cpupower frequency-info --governors
analyzing CPU 0:
powersave ondemand userspace performance
Run Code Online (Sandbox Code Playgroud)

查看当前政策

$ cpupower frequency-info
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0 1 2 3 4 5 6 7
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 1.60 GHz - 3.20 GHz
  available frequency steps: 3.20 GHz, 3.20 GHz, 3.07 GHz, 2.93 GHz, 2.80 GHz, 2.67 GHz, 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz
  available cpufreq governors: powersave, ondemand, userspace, performance
  current policy: frequency should be within 1.60 GHz and 3.20 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.60 GHz (asserted by call to hardware).
  boost state support:
    Supported: yes
    Active: yes
    2500 MHz max turbo 4 active cores
    2500 MHz max turbo 3 active cores
    2500 MHz max turbo 2 active cores
    2600 MHz max turbo 1 active cores
Run Code Online (Sandbox Code Playgroud)

在上面的输出中,您可以看到我当前的策略是ondemand。要调整策略和速度,请使用以下命令:

$ cpupower frequency-set --governor performance
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
Run Code Online (Sandbox Code Playgroud)

确认新州长

$ cpupower frequency-info
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0 1 2 3 4 5 6 7
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 1.60 GHz - 3.20 GHz
  available frequency steps: 3.20 GHz, 3.20 GHz, 3.07 GHz, 2.93 GHz, 2.80 GHz, 2.67 GHz, 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz
  available cpufreq governors: powersave, ondemand, userspace, performance
  current policy: frequency should be within 1.60 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 3.20 GHz (asserted by call to hardware).
  boost state support:
    Supported: yes
    Active: yes
    2500 MHz max turbo 4 active cores
    2500 MHz max turbo 3 active cores
    2500 MHz max turbo 2 active cores
    2600 MHz max turbo 1 active cores
Run Code Online (Sandbox Code Playgroud)

您还可以使用cpupower frequency-set --min <freq> --max <freq>. 有关您可以使用 的更多详细信息,cpupower frequency-set请参阅此页面

在没有 cpupowerutils 的情况下执行上述操作

所以最后,如果您没有安装 cpupowerutils 包,您可以与它进行交互,就像在之前的 2.6 内核中所做的那样。主要是您将值回显到sysfs文件系统中。

例如

$ echo 360000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
Run Code Online (Sandbox Code Playgroud)

对于 2.6 内核

您可以在此站点上阅读有关各种cpufreq 功能的信息

使用 cpufreq 在 Linux 中调整 CPU 频率的摘录

ignore_nice_load - 此参数的值为“0”或“1”。当设置为“0”(默认值)时,所有进程都计入“cpu 利用率”值。当设置为“1”时,以“nice”值运行的进程在总体使用情况计算中将不计入(因此被忽略)。如果您在笔记本电脑上运行 CPU 密集型计算,而您不关心完成需要多长时间,这将非常有用,因为您可以“优化”它并防止它参与决定是否增加 CPU 频率的过程。要打开它,请执行以下操作。

sudo sh -c "echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load"
Run Code Online (Sandbox Code Playgroud)

我会在这个文件中放一个 0,因为这应该是默认值。如果您有任何长时间运行的 niced 进程,我非常怀疑,您可以将其设置为 1。