ubuntu如何把调整cpu策略

一、安装cpu频率管理软件

sudo apt-get install cpufrequtils
二、查看cpu当前状态
cpufreq-info
feng@Heimerdinger:/sys/devices/system/cpu/cpu2/cpufreq$ 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: 0.97 ms.
  hardware limits: 500 MHz - 2.70 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 500 MHz and 2.70 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz.
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: 0.97 ms.
  hardware limits: 500 MHz - 2.70 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 500 MHz and 2.70 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz.
analyzing CPU 2:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 2
  CPUs which need to have their frequency coordinated by software: 2
  maximum transition latency: 0.97 ms.
  hardware limits: 500 MHz - 2.70 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 500 MHz and 2.70 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz.
analyzing CPU 3:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 3
  CPUs which need to have their frequency coordinated by software: 3
  maximum transition latency: 0.97 ms.
  hardware limits: 500 MHz - 2.70 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 500 MHz and 2.70 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz.
其中available cpufreq governors:performance,powersave表示我的cpu目前只支持高性能和省电两个模式

所有的策略模式包括powersave, userspace, ondemand, conservative, performance这几种

三、设置cpu策略(在此我设置的策略是performance)

sudo cpufreq-set -g performance
此刻cpu的频率就有所改变了,在查看cpu信息
feng@Heimerdinger:/sys/devices/system/cpu/cpu2/cpufreq$ 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: 0.97 ms.
  hardware limits: 500 MHz - 2.70 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 500 MHz and 2.70 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 2.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: 0.97 ms.
  hardware limits: 500 MHz - 2.70 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 500 MHz and 2.70 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 2.20 GHz.
analyzing CPU 2:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 2
  CPUs which need to have their frequency coordinated by software: 2
  maximum transition latency: 0.97 ms.
  hardware limits: 500 MHz - 2.70 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 500 MHz and 2.70 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 2.20 GHz.
analyzing CPU 3:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 3
  CPUs which need to have their frequency coordinated by software: 3
  maximum transition latency: 0.97 ms.
  hardware limits: 500 MHz - 2.70 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 500 MHz and 2.70 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 2.20 GHz.
四、设置当下策略下cpu频率
sudo cpufreq-set -d 1800m -u 2700m      //适用模式:powersave|ondemand|conservative|performance

sudo cpufreq-set -f {1800m~2700m}       //适用模式:userspace


 -d 设置最小频率

 -u 设置最大频率






  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要降低Ubuntu系统中的CPU使用率,可以采取多种策略,包括优化软件、调整系统设置以及监控资源使用情况等。下面提供一些基本步骤: ### 优化软件性能 1. **关闭不必要的服务**:通过运行 `systemctl stop` 和 `systemctl disable` 命令关闭不再需要的服务或启动项。 2. **更新软件包**:保持系统和应用最新状态有助于减少资源占用,可以通过 `sudo apt update && sudo apt upgrade` 来执行系统更新。 3. **管理后台进程**:使用工具如 `htop` 或 `top` 查看并结束高负载进程。打开终端输入 `htop` 可查看详细进程信息,并终止不必要的进程。 4. **使用轻量级应用程序替代**:某些复杂的应用程序消耗的资源较多,考虑使用功能相近的轻量化版本。 ### 调整系统设置 1. **减小屏幕刷新率**:通过修改显示配置文件,例如将桌面环境从60Hz降至30Hz或更低,以减轻GPU负担。可以在“系统设置” -> “外观” -> “显示器”选项中更改。 2. **限制电源管理策略**:对于笔记本用户来说,使用节能模式可能会导致性能下降。尝试调整电源设置以获取更好的性能。在“系统设置” -> “电源”部分进行操作。 3. **调整内存使用**:在特定任务下,降低虚拟内存大小可以提高性能。通过编辑 `/etc/sysctl.conf` 文件增加如下行: ``` vm.swappiness=10 ``` 然后运行 `sudo sysctl -p` 应用改动。 ### 监控资源使用 1. **使用资源监视器**:Ubuntu自带的资源监视器可以帮助识别CPU使用最频繁的应用或进程。打开它,可以看到所有活动进程及其CPU利用率详情。 2. **定期检查日志**:Linux的日志文件(通常位于 `/var/log` 目录下)可以提供有关系统异常事件的信息,帮助诊断性能问题。 3. **使用第三方工具**:安装并使用工具如 `mpstat`, `iostat` 或 `dstat` 进行深入分析系统的实时和历史性能数据。 通过上述措施,您可以有效地管理和优化Ubuntu系统的CPU使用率,提高整体性能和响应速度。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值