mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 21:50:52 +07:00
cpufreqscaling: add back
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
9ded8f32b4
commit
c2233cdc98
49
cpufreqscaling/all/usr/sbin/scaling.sh
Executable file
49
cpufreqscaling/all/usr/sbin/scaling.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium>
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the MIT License.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Make things safer
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Get cpu cores count minus 1, to allow maping from 0
|
||||||
|
cpucorecount=$(cat /proc/cpuinfo | grep processor | wc -l)
|
||||||
|
cpucorecount=$((cpucorecount - 1))
|
||||||
|
error=0
|
||||||
|
|
||||||
|
# Load the correct cpufreq module
|
||||||
|
if [ "${1}" = "ondemand" ] || [ "${1}" = "conservative" ]; then
|
||||||
|
if [ -f "/usr/lib/modules/cpufreq_${1}.ko" ]; then
|
||||||
|
modprobe cpufreq_${1}
|
||||||
|
echo "CPUFreqScaling: cpufreq_${1} loaded"
|
||||||
|
else
|
||||||
|
echo "CPUFreqScaling: cpufreq_${1} not found"
|
||||||
|
error=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# Deamonize the main function...
|
||||||
|
for i in $(seq 0 ${cpucorecount}); do
|
||||||
|
governor=$(cat /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_governor)
|
||||||
|
# Set correct cpufreq governor to allow frequency scaling
|
||||||
|
if [ "${governor}" != "${1}" ]; then
|
||||||
|
echo "${1}" >/sys/devices/system/cpu/cpu${i}/cpufreq/scaling_governor
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
sleep 10
|
||||||
|
# Check if the governor is set correctly
|
||||||
|
for i in $(seq 0 ${cpucorecount}); do
|
||||||
|
governor=$(cat /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_governor)
|
||||||
|
if [ "${governor}" = "${1}" ]; then
|
||||||
|
echo "CPUFreqScaling: Governor set to ${1}"
|
||||||
|
else
|
||||||
|
echo "CPUFreqScaling: Failed to set governor to ${1}"
|
||||||
|
error=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ ${error} -eq 1 ] && exit 1
|
||||||
|
exit 0
|
47
cpufreqscaling/install.sh
Executable file
47
cpufreqscaling/install.sh
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env ash
|
||||||
|
#
|
||||||
|
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium>
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the MIT License.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ "${1}" = "late" ]; then
|
||||||
|
echo "Installing cpufreqscalingscaling - ${1}"
|
||||||
|
mkdir -p "/tmpRoot/usr/arc/addons/"
|
||||||
|
cp -vf "${0}" "/tmpRoot/usr/arc/addons/"
|
||||||
|
|
||||||
|
cp -vf /usr/sbin/scaling.sh /tmpRoot/usr/sbin/scaling.sh
|
||||||
|
[ ! -f "/tmpRoot/usr/bin/echo" ] && cp -vf /usr/bin/echo /tmpRoot/usr/bin/echo || true
|
||||||
|
cp -f /usr/lib/modules/acpi_cpufreq.ko /tmpRoot/usr/lib/modules/acpi_cpufreq.ko
|
||||||
|
[ "${2}" != "schedutil" ] && cp -vf /usr/lib/modules/cpufreq_${2}.ko /tmpRoot/usr/lib/modules/cpufreq_${2}.ko && modprobe cpufreq_${2} || true
|
||||||
|
mkdir -p "/tmpRoot/usr/lib/systemd/system"
|
||||||
|
DEST="/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
|
||||||
|
cat <<EOF >${DEST}
|
||||||
|
[Unit]
|
||||||
|
Description=Enable CPU Freq scaling
|
||||||
|
DefaultDependencies=no
|
||||||
|
IgnoreOnIsolate=true
|
||||||
|
After=multi-user.target
|
||||||
|
After=udevrules.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
Type=simple
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=10
|
||||||
|
ExecStart=/usr/sbin/scaling.sh ${2}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
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
|
||||||
|
elif [ "${1}" = "uninstall" ]; then
|
||||||
|
echo "Installing cpufreqscalingscaling - ${1}"
|
||||||
|
|
||||||
|
rm -f "/tmpRoot/usr/lib/systemd/system/multi-user.target.wants/cpufreqscaling.service"
|
||||||
|
rm -f "/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
|
||||||
|
|
||||||
|
rm -f /tmpRoot/usr/sbin/scaling.sh
|
||||||
|
fi
|
20
cpufreqscaling/manifest.yml
Normal file
20
cpufreqscaling/manifest.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
version: 1
|
||||||
|
name: cpufreqscaling
|
||||||
|
description: "Enable CPU Freqscaling for DSM - Modify in Arc DSM Options"
|
||||||
|
system: false
|
||||||
|
beta: false
|
||||||
|
target: system
|
||||||
|
all:
|
||||||
|
install-script: "install.sh"
|
||||||
|
copy: "all"
|
||||||
|
apollolake: true
|
||||||
|
broadwell: true
|
||||||
|
broadwellnk: true
|
||||||
|
broadwellnkv2: true
|
||||||
|
broadwellntbap: true
|
||||||
|
denverton: true
|
||||||
|
geminilake: true
|
||||||
|
purley: true
|
||||||
|
v1000: true
|
||||||
|
r1000: true
|
||||||
|
epyc7002: true
|
Loading…
Reference in New Issue
Block a user