mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 21:50:52 +07:00
cpufreqscaling: add sanity check
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
340f2b8763
commit
351477b087
@ -13,9 +13,14 @@ cpucorecount=$(cat /proc/cpuinfo | grep processor | wc -l)
|
||||
cpucorecount=$((cpucorecount - 1))
|
||||
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
|
||||
|
||||
# Set correct cpufreq governor to allow user defined frequency scaling
|
||||
if [ "$governor" != "${1}" ]; then
|
||||
if [ -f "/usr/lib/modules/cpufreq_${1}" ] || [ "${1}" = "userspace" ]; then
|
||||
# Set correct cpufreq governor to allow user defined frequency scaling
|
||||
if [ "$governor" != "${1}" ]; then
|
||||
for i in $(seq 0 "${cpucorecount}"); do
|
||||
echo "${1}" >/sys/devices/system/cpu/cpu"${i}"/cpufreq/scaling_governor
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "No cpufreq_${1} module found"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -98,26 +98,30 @@ function userspace() {
|
||||
|
||||
# Deamonize the main function...
|
||||
while true; do
|
||||
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then
|
||||
if [ -f "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" ]; then
|
||||
rm -f /usr/sbin/stopscale
|
||||
# Get cpu cores count minus 1, to allow maping from 0
|
||||
cpucorecount=$(cat /proc/cpuinfo | grep processor | wc -l)
|
||||
cpucorecount=$((cpucorecount - 1))
|
||||
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
|
||||
|
||||
if [ -f "/usr/lib/modules/cpufreq_${1}" ] || [ "${1}" = "userspace" ]; then
|
||||
# Set correct cpufreq governor to allow user defined frequency scaling
|
||||
if [ "$governor" != "${1}" ]; then
|
||||
for i in $(seq 0 "${cpucorecount}"); do
|
||||
echo "${1}" >/sys/devices/system/cpu/cpu"${i}"/cpufreq/scaling_governor
|
||||
done
|
||||
fi
|
||||
|
||||
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
|
||||
if [ "$governor" = "userspace" ]; then
|
||||
userspace
|
||||
fi
|
||||
sleep 0.5
|
||||
else
|
||||
exit 0
|
||||
echo "No cpufreq_${1} module found"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user