Skip to content

Instantly share code, notes, and snippets.

@jyxjjj
Last active December 9, 2022 05:48
Show Gist options
  • Save jyxjjj/46d687fca5b75fff0f5c480b71129b8d to your computer and use it in GitHub Desktop.
Save jyxjjj/46d687fca5b75fff0f5c480b71129b8d to your computer and use it in GitHub Desktop.
CPU Freq Settings For Intel CPUs On Linux, tested with Intel Core I9-11900K
#!/bin/bash
# min cpu freq to 2.0GHz
echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu8/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu9/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu10/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu11/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu12/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu13/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu14/cpufreq/scaling_min_freq
echo 2000000 > /sys/devices/system/cpu/cpu15/cpufreq/scaling_min_freq
# set max cpu freq to 3.5GHz
echo 3500000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu8/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu9/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu10/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu11/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu12/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu13/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu14/cpufreq/scaling_max_freq
echo 3500000 > /sys/devices/system/cpu/cpu15/cpufreq/scaling_max_freq
# show current cpu freq
sleep 2
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
# set cpu preference to balance_power
sleep 2
echo balance_performance > /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu1/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu2/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu3/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu4/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu5/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu6/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu7/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu8/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu9/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu10/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu11/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu12/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu13/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu14/cpufreq/energy_performance_preference
echo balance_performance > /sys/devices/system/cpu/cpu15/cpufreq/energy_performance_preference
# show current cpu preference
sleep 1
cat /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
# set cpu governor to performance
sleep 2
echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu8/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu9/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu10/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu11/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu12/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu13/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu14/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu15/cpufreq/scaling_governor
# show current cpu governor
sleep 1
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# show min percent
echo 10 > /sys/devices/system/cpu/intel_pstate/min_perf_pct
sleep 1
cat /sys/devices/system/cpu/intel_pstate/min_perf_pct
# show max percent
echo 100 > /sys/devices/system/cpu/intel_pstate/max_perf_pct
sleep 1
cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
#!/bin/bash
# min cpu freq to 4.5GHz
echo 4500000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu8/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu9/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu10/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu11/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu12/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu13/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu14/cpufreq/scaling_min_freq
echo 4500000 > /sys/devices/system/cpu/cpu15/cpufreq/scaling_min_freq
# set max cpu freq to 5.1GHz
echo 5300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu8/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu9/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu10/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu11/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu12/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu13/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu14/cpufreq/scaling_max_freq
echo 5300000 > /sys/devices/system/cpu/cpu15/cpufreq/scaling_max_freq
# show current cpu freq
sleep 2
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
# set cpu preference to performance
sleep 2
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu1/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu2/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu3/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu4/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu5/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu6/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu7/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu8/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu9/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu10/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu11/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu12/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu13/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu14/cpufreq/energy_performance_preference
echo performance > /sys/devices/system/cpu/cpu15/cpufreq/energy_performance_preference
# show current cpu preference
sleep 1
cat /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
# set cpu governor to performance
sleep 2
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
echo performance > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu8/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu9/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu10/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu11/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu12/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu13/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu14/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu15/cpufreq/scaling_governor
# show current cpu governor
sleep 1
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# show min percent
echo 50 > /sys/devices/system/cpu/intel_pstate/min_perf_pct
sleep 1
cat /sys/devices/system/cpu/intel_pstate/min_perf_pct
# show max percent
echo 100 > /sys/devices/system/cpu/intel_pstate/max_perf_pct
sleep 1
cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
#!/bin/bash
# min cpu freq to 1.0GHz
echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu8/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu9/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu10/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu11/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu12/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu13/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu14/cpufreq/scaling_min_freq
echo 1000000 > /sys/devices/system/cpu/cpu15/cpufreq/scaling_min_freq
# set max cpu freq to 3.0GHz
echo 3000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu8/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu9/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu10/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu11/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu12/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu13/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu14/cpufreq/scaling_max_freq
echo 3000000 > /sys/devices/system/cpu/cpu15/cpufreq/scaling_max_freq
# show current cpu freq
sleep 2
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
# set cpu preference to balance_power
sleep 2
echo balance_power > /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu1/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu2/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu3/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu4/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu5/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu6/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu7/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu8/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu9/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu10/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu11/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu12/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu13/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu14/cpufreq/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpu15/cpufreq/energy_performance_preference
# show current cpu preference
sleep 1
cat /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
# set cpu governor to performance
sleep 2
echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu8/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu9/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu10/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu11/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu12/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu13/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu14/cpufreq/scaling_governor
echo powersave > /sys/devices/system/cpu/cpu15/cpufreq/scaling_governor
# show current cpu governor
sleep 1
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# show min percent
echo 10 > /sys/devices/system/cpu/intel_pstate/min_perf_pct
sleep 1
cat /sys/devices/system/cpu/intel_pstate/min_perf_pct
# show max percent
echo 100 > /sys/devices/system/cpu/intel_pstate/max_perf_pct
sleep 1
cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment