mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 21:50:52 +07:00
cpufreqscaling: update
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
351477b087
commit
ed887db2bb
@ -13,7 +13,7 @@ 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
|
||||
if [ -f "/usr/lib/modules/cpufreq_${1}" ] || [ "${1}" = "schedutil" ]; then
|
||||
# Set correct cpufreq governor to allow user defined frequency scaling
|
||||
if [ "$governor" != "${1}" ]; then
|
||||
for i in $(seq 0 "${cpucorecount}"); do
|
||||
|
@ -17,7 +17,7 @@ set -euo pipefail
|
||||
#fi
|
||||
|
||||
# Frequency scaling function
|
||||
function userspace() {
|
||||
function main {
|
||||
|
||||
if [ $(cat /proc/cpuinfo | grep Intel | wc -l) -gt 0 ]; then
|
||||
CPU="INTEL"
|
||||
@ -98,30 +98,22 @@ function userspace() {
|
||||
|
||||
# Deamonize the main function...
|
||||
while true; do
|
||||
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
|
||||
echo "No cpufreq_${1} module found"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
if [ -f /usr/sbin/stopscale ]; then
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
# 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)
|
||||
# Set correct cpufreq governor to allow user defined frequency scaling
|
||||
if [ "$governor" != "userspace" ]; then
|
||||
for i in $(seq 0 "${cpucorecount}"); do
|
||||
echo "userspace" >/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
|
||||
main
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
@ -15,6 +15,7 @@ if [ "${1}" = "late" ]; then
|
||||
cp -vf /usr/sbin/unscaler.sh /tmpRoot/usr/sbin/unscaler.sh
|
||||
cp -vf /usr/sbin/rescaler.sh /tmpRoot/usr/sbin/rescaler.sh
|
||||
|
||||
if [ "${2}" = "userspace" ]; then
|
||||
mkdir -p "/tmpRoot/usr/lib/systemd/system"
|
||||
DEST="/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
|
||||
echo "[Unit]" >${DEST}
|
||||
@ -27,14 +28,34 @@ if [ "${1}" = "late" ]; then
|
||||
echo "User=root" >>${DEST}
|
||||
echo "Restart=always" >>${DEST}
|
||||
echo "RestartSec=30" >>${DEST}
|
||||
echo "ExecStart=/usr/sbin/scaler.sh \"${2}\"" >>${DEST}
|
||||
echo "ExecStart=/usr/sbin/scaler.sh" >>${DEST}
|
||||
echo >>${DEST}
|
||||
echo "[X-Synology]" >>${DEST}
|
||||
echo "Author=Virtualization Team" >>${DEST}
|
||||
|
||||
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
|
||||
mkdir -p "/tmpRoot/usr/lib/systemd/system"
|
||||
DEST="/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
|
||||
echo "[Unit]" >${DEST}
|
||||
echo "Description=Enable CPU Freq scaling" >>${DEST}
|
||||
echo "DefaultDependencies=no" >>${DEST}
|
||||
echo "IgnoreOnIsolate=true" >>${DEST}
|
||||
echo "After=multi-user.target" >>${DEST}
|
||||
echo >>${DEST}
|
||||
echo "[Service]" >>${DEST}
|
||||
echo "User=root" >>${DEST}
|
||||
echo "Type=oneshot" >>${DEST}
|
||||
echo "RemainAfterExit=yes" >>${DEST}
|
||||
echo "ExecStart=/usr/sbin/rescaler.sh \"${2}\"" >>${DEST}
|
||||
echo >>${DEST}
|
||||
echo "[X-Synology]" >>${DEST}
|
||||
echo "Author=Virtualization Team" >>${DEST}
|
||||
|
||||
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
|
||||
fi
|
||||
if [ ! -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then
|
||||
echo "copy esynoscheduler.db"
|
||||
mkdir -p /tmpRoot/usr/syno/etc/esynoscheduler
|
||||
|
Loading…
Reference in New Issue
Block a user