本文主要是介绍LinuxTina动态调压调频配置与实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
动态调压调频功能配置菜单:
修改后,对应的.config DEFAULT 策略发生变化:
默认原来的策略是:
或者直接串口写入 echo performance >/sys/devices/system/cpu/cpufreq/policy0/scaling_governor动态修改。
查看支持的功耗策略:
[jenkins@localhost ~]$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
[jenkins@localhost ~]$
最大最小频率
[jenkins@localhost ~]$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_min_freq
800000
800000
800000
800000
800000
800000
800000
800000
800000
800000
800000
800000
800000
800000
800000
800000
[jenkins@localhost ~]$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
4900000
4900000
4900000
3600000
3600000
3600000
3600000
4900000
4900000
4900000
4900000
4900000
4900000
4900000
4900000
4900000
和lscpu的输出是match的
在某服务器主机上的显示:
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
用工具查看和配置
$ cpupower frequency-info
analyzing CPU 0:driver: intel_pstateCPUs which run at the same hardware frequency: 0CPUs which need to have their frequency coordinated by software: 0maximum transition latency: Cannot determine or is not supported.hardware limits: 800 MHz - 4.90 GHzavailable cpufreq governors: performance powersavecurrent policy: frequency should be within 800 MHz and 4.90 GHz.The governor "performance" may decide which speed to usewithin this range.current CPU frequency: Unable to call hardwarecurrent CPU frequency: 3.80 GHz (asserted by call to kernel)boost state support:Supported: yesActive: yes
设置
$ sudo cpupower frequency-set -g 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
Setting cpu: 8
Setting cpu: 9
Setting cpu: 10
Setting cpu: 11
Setting cpu: 12
Setting cpu: 13
Setting cpu: 14
Setting cpu: 15
或者用脚本
#!/bin/bash
cpunum=$(cat /proc/cpuinfo | grep processor | wc -l)
for i in `seq 0 $[$cpunum-1]`
dosudo echo performance > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_governor
done
动态查看
$ watch grep \"cpu MHz\" /proc/cpuinfo
$ sudo cpupower monitor|Nehalem || Mperf || Idle_Stats
CPU | C3 | C6 | PC3 | PC6 || C0 | Cx | Freq || POLL | C1 | C2 | C30| 0.00| 1.20| 83.14| 0.00|| 0.03| 99.97| 3660|| 0.00| 0.00| 0.00| 99.971| 0.00| 1.20| 83.14| 0.00|| 0.05| 99.95| 3752|| 0.00| 0.00| 1.73| 98.212| 0.00| 0.00| 83.14| 0.00|| 0.01| 99.99| 3808|| 0.00| 0.00| 0.00| 99.983| 0.00| 0.00| 83.14| 0.00|| 0.01| 99.99| 3771|| 0.00| 0.00| 0.00| 99.984| 0.00| 0.00| 83.14| 0.00|| 0.01| 99.99| 3673|| 0.00| 0.00| 0.00| 99.985| 0.00| 0.00| 83.14| 0.00|| 0.01| 99.99| 3599|| 0.00| 0.00| 0.00| 99.986| 0.00| 0.00| 83.14| 0.00|| 0.05| 99.95| 3784|| 0.00| 0.00| 0.00| 99.947| 0.00| 0.00| 83.14| 0.00|| 0.01| 99.99| 3790|| 0.00| 0.00| 0.00| 99.988| 0.00| 1.49| 83.14| 0.00|| 0.10| 99.90| 3768|| 0.00| 0.01| 2.87| 97.019| 0.00| 1.49| 83.14| 0.00|| 0.02| 99.98| 3472|| 0.00| 0.00| 0.00| 99.9810| 0.00| 0.57| 83.14| 0.00|| 0.43| 99.57| 3762|| 0.00| 0.00| 0.00| 99.5711| 0.00| 0.57| 83.14| 0.00|| 0.05| 99.95| 3718|| 0.00| 0.00| 0.54| 99.4012| 0.00| 97.06| 83.14| 0.00|| 0.15| 99.85| 3579|| 0.00| 0.04| 27.68| 72.1313| 0.00| 95.86| 83.14| 0.00|| 0.16| 99.84| 3585|| 0.00| 0.37| 3.48| 96.0014| 0.00| 99.86| 83.14| 0.00|| 0.10| 99.90| 3587|| 0.00| 0.00| 1.65| 98.2515| 0.00| 99.83| 83.14| 0.00|| 0.10| 99.90| 3586|| 0.00| 0.00| 2.34| 97.56
设置为performance之后,频率锁定在/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq.
关于动态调压调频的内核实现方法,可以关注核心注册跳压调频注册函数cpufreq_register_driver,设置__cpufreq_driver_target函数中.
change governer callstack.
可以看到,通过修改配置的方式实际上是将CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND关闭,并且打开CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE.
调整后,看下图就可以知道,系统在空载的情况下,CPU仍然是1.2G运转。
CPU: 0.0% usr 0.7% sys 0.0% nic 99.2% idle 0.0% io 0.0% irq 0.0% sirq
Load average: 0.00 0.00 0.00 1/58 929
[7m PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND[0m877 1 root S 1144 0.4 0 0.2 adbd887 1 root R 676 0.2 0 0.2 /sbin/swupdate-progress -w920 877 root S 916 0.3 0 0.0 /bin/sh894 1 root S 916 0.3 0 0.0 -/bin/sh929 920 root R 916 0.3 0 0.0 top1 0 root S 912 0.3 0 0.0 /sbin/init665 2 root SW 0 0.0 0 0.0 [kworker/0:2]3 2 root SW 0 0.0 0 0.0 [kworker/0:0]7 2 root SW 0 0.0 0 0.0 [rcu_preempt]5 2 root SW 0 0.0 0 0.0 [kworker/u2:0]6 2 root SW 0 0.0 0 0.0 [ksoftirqd/0]880 2 root SW 0 0.0 0 0.0 [file-storage]12 2 root SW 0 0.0 0 0.0 [kworker/u2:1]462 2 root SW 0 0.0 0 0.0 [spi0]262 2 root SW 0 0.0 0 0.0 [oom_reaper]11 2 root SW 0 0.0 0 0.0 [kdevtmpfs]268 2 root SW< 0 0.0 0 0.0 [kblockd]266 2 root SW< 0 0.0 0 0.0 [bioset]308 2 root SW 0 0.0 0 0.0 [irq/329-axp2101]304 2 root SW 0 0.0 0 0.0 [kworker/0:1]
root@(none):/sys/kernel/debug/clk# cat clk_summary[Jclock enable_cnt prepare_cnt rate accuracy phase
----------------------------------------------------------------------------------------osc48m 0 0 48000000 0 0osc48md4 0 0 12000000 0 0usbohci0_12m 0 0 12000000 0 0pll_periph0div25m 0 0 25000000 0 0ephy_25m 0 0 25000000 0 0hosc 13 13 24000000 0 0csi_master0 0 0 24000000 0 0dcxo_out 0 0 24000000 0 0spwm 0 0 24000000 0 0cpurapbs2 0 0 24000000 0 0cpurcpus 1 1 24000000 0 0cpurahbs 1 1 24000000 0 0cpurapbs1 2 2 24000000 0 0cpurpio 1 1 24000000 0 0stwi 1 1 24000000 0 0csi_master1 0 0 24000000 0 0mipi_host0 1 1 24000000 0 0usbphy0 1 1 24000000 0 0ths 1 1 24000000 0 0gpadc 1 1 24000000 0 0spi2 0 0 24000000 0 0spi1 0 0 24000000 0 0sdmmc2_rst 0 0 24000000 0 0sdmmc2_bus 0 0 24000000 0 0sdmmc2_mod 0 0 24000000 0 0sdmmc1_rst 0 0 24000000 0 0sdmmc1_bus 0 0 24000000 0 0sdmmc1_mod 0 0 24000000 0 0sdmmc0_rst 1 1 24000000 0 0sdmmc0_bus 1 1 24000000 0 0dbgsys 0 0 24000000 0 0avs 0 0 24000000 0 0apb2 1 1 24000000 0 0twi3 0 0 24000000 0 0twi2 0 0 24000000 0 0twi1 0 0 24000000 0 0twi0 0 0 24000000 0 0uart3 0 0 24000000 0 0uart2 0 0 24000000 0 0uart1 0 0 24000000 0 0uart0 1 1 24000000 0 0hoscd2 0 0 12000000 0 0pll_csi 0 0 336000000 0 0csi_top 0 0 336000000 0 0pll_audio 4 4 22579200 0 0codec_1x 1 1 22579200 0 0i2s0 1 1 22579200 0 0codec_4x 0 0 22579200 0 0i2s1 0 0 22579200 0 0pll_audiox2 0 0 45158400 0 0pll_audiox4 0 0 90316800 0 0pll_video0 2 2 99000000 0 0dspo 0 0 99000000 0 0tcon_lcd 1 1 99000000 0 0mipi_dphy0 1 1 24750000 0 0pll_video0x4 0 0 396000000 0 0pll_uni 3 4 600000000 0 0eise 0 0 600000000 0 0isp 0 0 300000000 0 0ve 0 1 600000000 0 0de 1 1 300000000 0 0g2d 1 1 300000000 0 0pll_unix2 1 1 1200000000 0 0sdmmc0_mod 1 1 300000000 0 0pll_periph0 4 4 600000000 0 0spi0 1 1 100000000 0 0cpurapbs2_pll 0 0 600000000 0 0cpurcpus_pll 0 0 600000000 0 0nna_rst 0 0 600000000 0 0apb1 2 2 100000000 0 0pio 1 1 100000000 0 0pwm 1 1 100000000 0 0ahb3 2 2 200000000 0 0display_top 1 1 200000000 0 0usbotg 1 1 200000000 0 0usbehci0 0 0 200000000 0 0usbohci0 0 0 200000000 0 0gmac 0 0 200000000 0 0psi 1 1 200000000 0 0ahb2 0 0 200000000 0 0ahb1 2 2 200000000 0 0iommu 1 1 200000000 0 0hstimer 0 0 200000000 0 0dma 1 1 200000000 0 0periph32k 0 0 32768 0 0pll_periph0x2 0 0 1200000000 0 0nna 0 0 1200000000 0 0ce 0 0 300000000 0 0pll_ddr0 0 0 1584000000 0 0sdram 0 0 1584000000 0 0mbus 0 0 396000000 0 0pll_cpu 0 0 1200000000 0 0cpu 0 0 1200000000 0 0cpuapb 0 0 300000000 0 0axi 0 0 400000000 0 0iosc 0 0 16000000 0 0losc 1 1 32768 0 0losc_out 1 1 32768 0 0cpurowc 0 0 32768 0 0
root@(none):/sys/kernel/debug/clk#
补充:
值得一提的是,这种动态调压调频的策略和配置方案并非ARM独有的,mainline的X84 make menuconfig的时候的配置几乎和ARM一样
如果关闭CPU 调频,可以直接关闭CONFIG_CPU_FREQ配置:
一些有用的调试节点:
intel x86 pc cpufreq hander register:
结束!
这篇关于LinuxTina动态调压调频配置与实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!