mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 21:50:52 +07:00
cpufreqscaling: rework
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
278433eff1
commit
c48bbb44f3
@ -1,7 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Make things safer
|
||||
set -euo pipefail
|
||||
#
|
||||
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium>
|
||||
#
|
||||
# This is free software, licensed under the MIT License.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
# Get cpu cores count minus 1, to allow maping from 0
|
||||
cpucorecount=$(cat /proc/cpuinfo | grep processor | wc -l)
|
||||
@ -17,27 +20,31 @@ while true; do
|
||||
if [ "${1}" = "ondemand" ] || [ "${1}" = "conservative" ]; then
|
||||
if [ -f "/usr/lib/modules/cpufreq_${1}.ko" ]; then
|
||||
modprobe cpufreq_${1}
|
||||
if [ "$governor" != "${1}" ]; then
|
||||
for i in $(seq 0 "${cpucorecount}"); do
|
||||
echo "${1}" >/sys/devices/system/cpu/cpu"${i}"/cpufreq/scaling_governor
|
||||
done
|
||||
fi
|
||||
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
|
||||
else
|
||||
if [ "$governor" != "${1}" ]; then
|
||||
elif [ "${1}" = "schedutil" ]; then
|
||||
if [ "${governor}" != "${1}" ]; then
|
||||
for i in $(seq 0 "${cpucorecount}"); do
|
||||
echo "${1}" >/sys/devices/system/cpu/cpu"${i}"/cpufreq/scaling_governor
|
||||
echo "${1}" >/sys/devices/system/cpu/cpu${i}/cpufreq/scaling_governor
|
||||
done
|
||||
fi
|
||||
fi
|
||||
sleep 5
|
||||
# Check if the governor is set correctly
|
||||
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
|
||||
if [ "$governor" = "${1}" ]; then
|
||||
if [ "${governor}" = "${1}" ]; then
|
||||
echo "Governor set to ${1}"
|
||||
break
|
||||
exit 0
|
||||
else
|
||||
echo "Failed to set governor to ${1}"
|
||||
break
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
done
|
@ -39,6 +39,7 @@ EOF
|
||||
mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
|
||||
ln -vsf /usr/lib/systemd/system/cpufreqscaling.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/cpufreqscaling.service
|
||||
else
|
||||
[ "${2}" != "schedutil" ] && cp -vf /usr/lib/modules/cpufreq_${2}.ko /tmpRoot/usr/lib/modules/cpufreq_${2}.ko
|
||||
mkdir -p "/tmpRoot/usr/lib/systemd/system"
|
||||
DEST="/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
|
||||
cat << EOF > ${DEST}
|
||||
@ -50,7 +51,6 @@ After=multi-user.target
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/sbin/rescaler.sh ${2}
|
||||
|
||||
[Install]
|
||||
|
Loading…
Reference in New Issue
Block a user