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
951071545a
commit
340f2b8763
@ -14,8 +14,8 @@ 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
|
||||
if [ "$governor" != "${1}" ]; then
|
||||
for i in $(seq 0 "${cpucorecount}"); do
|
||||
echo "userspace" >/sys/devices/system/cpu/cpu"${i}"/cpufreq/scaling_governor
|
||||
echo "${1}" >/sys/devices/system/cpu/cpu"${i}"/cpufreq/scaling_governor
|
||||
done
|
||||
fi
|
||||
|
@ -17,9 +17,9 @@ set -euo pipefail
|
||||
#fi
|
||||
|
||||
# Frequency scaling function
|
||||
function main {
|
||||
function userspace() {
|
||||
|
||||
if [ $(cat /proc/cpuinfo |grep Intel |wc -l) -gt 0 ]; then
|
||||
if [ $(cat /proc/cpuinfo | grep Intel | wc -l) -gt 0 ]; then
|
||||
CPU="INTEL"
|
||||
else
|
||||
CPU="AMD"
|
||||
@ -98,25 +98,26 @@ function main {
|
||||
|
||||
# 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/sbin/stopscale ]; then
|
||||
exit 0
|
||||
# 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
|
||||
fi
|
||||
# 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
|
||||
|
@ -3,8 +3,8 @@
|
||||
# Make things safer
|
||||
set -euo pipefail
|
||||
|
||||
systemctl stop cpufreq-userspace-scaler.service
|
||||
systemctl disable cpufreq-userspace-scaler.service
|
||||
systemctl stop cpufreqscaling.service
|
||||
systemctl disable cpufreqscaling.service
|
||||
|
||||
# Get cpu cores count minus 1, to allow maping from 0
|
||||
cpucorecount=$(cat /proc/cpuinfo | grep processor | wc -l)
|
||||
@ -18,4 +18,4 @@ if [ "$governor" != "performance" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
touch /usr/sbin/stopscale
|
||||
touch /usr/sbin/stopscale
|
@ -27,13 +27,27 @@ if [ "${1}" = "late" ]; then
|
||||
echo "User=root" >>${DEST}
|
||||
echo "Restart=always" >>${DEST}
|
||||
echo "RestartSec=30" >>${DEST}
|
||||
echo "ExecStart=/usr/sbin/scaler.sh" >>${DEST}
|
||||
echo "ExecStart=/usr/sbin/scaler.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
|
||||
|
||||
if [ ! -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then
|
||||
echo "copy esynoscheduler.db"
|
||||
mkdir -p /tmpRoot/usr/syno/etc/esynoscheduler
|
||||
cp -vf /addons/esynoscheduler.db /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db
|
||||
fi
|
||||
echo "insert scaling... task to esynoscheduler.db"
|
||||
export LD_LIBRARY_PATH=/tmpRoot/bin:/tmpRoot/lib
|
||||
/tmpRoot/bin/sqlite3 /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db <<EOF
|
||||
DELETE FROM task WHERE task_name LIKE 'Rescaler';
|
||||
INSERT INTO task VALUES('Rescaler', '', 'bootup', '', 0, 0, 0, 0, '', 0, '/usr/sbin/rescaler.sh "${2}"', 'script', '{}', '', '', '{}', '{}');
|
||||
DELETE FROM task WHERE task_name LIKE 'Unscaler';
|
||||
INSERT INTO task VALUES('Unscaler', '', 'bootup', '', 0, 0, 0, 0, '', 0, '/usr/sbin/unscaler.sh', 'script', '{}', '', '', '{}', '{}');
|
||||
EOF
|
||||
elif [ "${1}" = "uninstall" ]; then
|
||||
echo "Installing cpufreqscalingscaling - ${1}"
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
version: 1
|
||||
name: cpufreqscaling
|
||||
description: "Enable CPU Freqscaling for DSM (Only use if CPU Frequency is not scaling expectedly)"
|
||||
system: false
|
||||
beta: true
|
||||
description: "Enable CPU Freqscaling for DSM"
|
||||
system: true
|
||||
beta: false
|
||||
all:
|
||||
install-script: "install.sh"
|
||||
copy: "all"
|
||||
|
Loading…
Reference in New Issue
Block a user