linux cpu 超频,Linux 调整 cstate 实现cpu超频

本文介绍了如何在Ubuntu系统中通过修改GRUB配置文件和设置CPU scaling_governor来实现CPU超频。具体步骤包括在`/etc/default/grub`中添加`processor.max_cstate=0`和`intel_idle.max_cstate=0`,更新GRUB,以及将CPU模式设置为`performance`。此外,还提到了使用`cpufreq-utils`工具查看和调整CPU频率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ubuntu 设置

与开机项有关的参数设置在 /etc/default/grub,可以对其进行调整

cat /etc/default/grub

# If you change this file, run 'update-grub' afterwards to update

# /boot/grub/grub.cfg.

# For full documentation of the options in this file, see:

# info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0

GRUB_TIMEOUT_STYLE=hidden

GRUB_TIMEOUT=10

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs

# This works with Linux (no patch required) and with any kernel that obtains

# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)

#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)

#GRUB_TERMINAL=console

# The resolution used on graphical terminal

# note that you can use only modes which your graphic card supports via VBE

# you can see them in real GRUB with the command `vbeinfo'

#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux

#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries

#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start

#GRUB_INIT_TUNE="480 440 1"

然后找到 GRUB_CMDLINE_LINUX_DEFAULT 所在的那行,增加配置

processor.max_cstate=0

intel_idle.max_cstate=0

sudo vim /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash processor.max_cstate=0 intel_idle.max_cstate=0"

然后更新 grub

sudo update-grub

另外可以设置CPU的scale-governor

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

## 设置CPU模式, 分别根据CPU 0-n 的编号进行设置

echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor

echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor

systemctl disable ondemand

/etc/rc.local

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq

重启后即可实现超频。

sudo reboot now

使用命令

cpufreq-info 查看当前 CPU 运行

cpufreq-set 也可以进行单独设置

cpufreq-aperf 用于计算一段时间内的平均频率

sudo apt 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: 800 MHz - 3.60 GHz

available cpufreq governors: performance, powersave

current policy: frequency should be within 800 MHz and 3.60 GHz.

The governor "performance" may decide which speed to use

within this range.

current CPU frequency is 1.52 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: 800 MHz - 3.60 GHz

available cpufreq governors: performance, powersave

current policy: frequency should be within 800 MHz and 3.60 GHz.

The governor "performance" may decide which speed to use

within this range.

current CPU frequency is 2.66 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: 4294.55 ms.

hardware limits: 800 MHz - 3.60 GHz

available cpufreq governors: performance, powersave

current policy: frequency should be within 800 MHz and 3.60 GHz.

The governor "performance" may decide which speed to use

within this range.

current CPU frequency is 960 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: 4294.55 ms.

hardware limits: 800 MHz - 3.60 GHz

available cpufreq governors: performance, powersave

current policy: frequency should be within 800 MHz and 3.60 GHz.

The governor "performance" may decide which speed to use

within this range.

current CPU frequency is 1.05 GHz.

Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: watchdog: BUG: soft lockup - CPU#55 stuck for 22s! [kworker/55:0:3030] Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: ip_protocol_deliver_rcu+0x19/0x180 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: Modules linked in: 8021q(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: ip_local_deliver_finish+0x44/0x50 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: garp(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: __netif_receive_skb_one_core+0x55/0x80 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: process_backlog+0x8a/0x140 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: mrp(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: napi_poll+0x8f/0x1b0 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: bridge(E) stp(E) Jul 16 11:47:13 hpubms033213202226.wulan01 syslog-ng[7143]: syslog-ng starting up; version='3.6.4' Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: net_rx_action+0xaa/0x1b0 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: llc(E) veth(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: __do_softirq+0xba/0x264 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: nfsv3(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: asm_call_irq_on_stack+0xf/0x20 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: nfs_acl(E) nfs(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: </IRQ> Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: lockd(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: do_softirq_own_stack+0x37/0x40 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: irq_exit_rcu+0xab/0xf0 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: grace(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: common_interrupt+0x74/0x130 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: sunrpc(E) nfs_ssc(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: asm_common_interrupt+0x1e/0x40 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: fscache(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: RIP: 0010:acpi_idle_do_entry+0x4f/0x60 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: cls_bpf(E) sch_ingress(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: Code: 15 1a d8 15 02 ed c3 e9 df fd ff ff 65 48 8b 04 25 80 ef 01 00 48 8b 00 a8 08 75 ea e9 07 00 00 00 0f 00 2d 7d fa 67 00 fb f4 <fa> c3 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc 0f 1f 44 00 00 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: xt_conntrack(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: RSP: 0018:ffffa742003cfe80 EFLAGS: 00000246 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: xt_addrtype(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: RAX: 0000000000004000 RBX: 0000000000000001 RCX: ffff92bc3e8f4a80 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: RDX: ffff92bc3e8c0000 RSI: ffff92c045aed000 RDI: ffff92c045aed064 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: xt_set(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: RBP: ffff91c0e3057800 R08: ffffffffab1eea20 R09: 00000000000003e4 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: R10: ffff92bc3e8f2824 R11: 00000000000003e2 R12: 0000000000000001 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: xt_MASQUERADE(E) xt_mark(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: R13: ffffffffab1eeaa0 R14: 0000000000000001 R15: 0000000000000000 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: acpi_idle_enter+0x7d/0xb0 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: ip_set_hash_ipportnet(E) ip_set_hash_ipportip(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: cpuidle_enter_state+0x84/0x330 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: ip_set_hash_ipport(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: cpuidle_enter+0x29/0x40 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: ip_set_bitmap_port(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: cpuidle_idle_call+0x128/0x1b0 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: do_idle+0x72/0xd0 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: ip_set(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: cpu_startup_entry+0x19/0x20 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: secondary_startup_64_no_verify+0xb0/0xbb Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: dummy(E) Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: CPU: 101 PID: 521 Comm: ksoftirqd/101 Kdump: loaded Tainted: G S OE 5.10.112-100.alios7.x86_64 #1 Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: net_ratelimit: 59 callbacks suppressed Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: eth0: hw csum failure Jul 16 11:47:13 hpubms033213202226.wulan01 kernel: skb len=56 headroom=98 headlen=56 tailroom=550
最新发布
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值