Merge pull request #3896 from antonlacon/le10-systemd-cpufreq

init: move cpufreq tuning to systemd service
This commit is contained in:
MilhouseVH 2019-11-15 17:50:36 +00:00 committed by GitHub
commit ecbd566302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 22 deletions

View File

@ -966,15 +966,6 @@ prepare_sysroot() {
# hide kernel log messages on console
echo '1 4 1 7' > /proc/sys/kernel/printk
# set ondemand up_threshold
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ]; then
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
else
for f in $(ls /sys/devices/system/cpu/cpufreq/policy*/ondemand/up_threshold 2>/dev/null) ; do
echo 50 > $f
done
fi
# run platform_init script if exists
if [ -f "./platform_init" ]; then
./platform_init

View File

@ -206,6 +206,9 @@ post_makeinstall_target() {
cp $PKG_DIR/scripts/userconfig-setup $INSTALL/usr/bin
cp $PKG_DIR/scripts/usercache-setup $INSTALL/usr/bin
# use systemd to set cpufreq governor and tunables
find_file_path scripts/cpufreq && cp -PRv $FOUND_PATH $INSTALL/usr/bin
mkdir -p $INSTALL/usr/sbin
cp $PKG_DIR/scripts/kernel-overlays-setup $INSTALL/usr/sbin
@ -268,4 +271,5 @@ post_install() {
enable_service usercache.service
enable_service kernel-overlays.service
enable_service hwdb.service
enable_service cpufreq.service
}

View File

@ -0,0 +1,17 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
SYS_CPUFREQ_GOV=$( cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor )
SYS_CPUFREQ_DIR="/sys/devices/system/cpu/cpufreq"
# Configure frequency scaling properties
if [ $SYS_CPUFREQ_GOV = "ondemand" ]; then
for policy in ${SYS_CPUFREQ_DIR}/ondemand ${SYS_CPUFREQ_DIR}/policy*/; do
if [ -e $policy/up_threshold ]; then
echo 50 > $policy/up_threshold
fi
done
fi

View File

@ -0,0 +1,11 @@
[Unit]
Description=Set CPU frequency governor and its tunables
ConditionPathExists=/usr/bin/cpufreq
[Service]
Type=oneshot
ExecStart=/usr/bin/cpufreq
RemainAfterExit=yes
[Install]
WantedBy=basic.target

View File

@ -0,0 +1,18 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
SYS_CPUFREQ_GOV=$( cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor )
SYS_ONDEMAND_DIR="/sys/devices/system/cpu/cpufreq/ondemand/"
# Configure frequency scaling properties
if [ "${SYS_CPUFREQ_GOV}" = "ondemand" ]; then
echo 1 > "${SYS_ONDEMAND_DIR}/io_is_busy"
echo 50 > "${SYS_ONDEMAND_DIR}/up_threshold"
echo 100000 > "${SYS_ONDEMAND_DIR}/sampling_rate"
echo 50 > "${SYS_ONDEMAND_DIR}/sampling_down_factor"
else
echo "cpufreq: settings not found for current cpu governor." | systemd-cat -p info
fi

View File

@ -1,13 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
# Enable io_is_busy for improved sdhost performance - essentially, equivalent of force_turbo=1 but for mmc
echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy
# Configure frequency scaling properties - should improve performance a little (turbo, in most cases)
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo 100000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor

View File

@ -0,0 +1,18 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
SYS_CPUFREQ_GOV=$( cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor )
SYS_ONDEMAND_DIR="/sys/devices/system/cpu/cpufreq/ondemand/"
# Configure frequency scaling properties
if [ "${SYS_CPUFREQ_GOV}" = "ondemand" ]; then
echo 1 > "${SYS_ONDEMAND_DIR}/io_is_busy"
echo 50 > "${SYS_ONDEMAND_DIR}/up_threshold"
echo 100000 > "${SYS_ONDEMAND_DIR}/sampling_rate"
echo 50 > "${SYS_ONDEMAND_DIR}/sampling_down_factor"
else
echo "cpufreq: settings not found for current cpu governor." | systemd-cat -p info
fi