diff --git a/package/lean/luci-app-cpufreq/Makefile b/package/lean/luci-app-cpufreq/Makefile index f7a1440565..b85e91d22f 100644 --- a/package/lean/luci-app-cpufreq/Makefile +++ b/package/lean/luci-app-cpufreq/Makefile @@ -1,16 +1,15 @@ - -# Copyright (C) 2016 Openwrt.org -# -# This is free software, licensed under the Apache License, Version 2.0 . +# SPDX-License-Identifier: GPL-3.0-only # +# Copyright (C) 2021 ImmortalWrt.org include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI for CPU Freq Setting LUCI_DEPENDS:=@(arm||aarch64) + PKG_NAME:=luci-app-cpufreq PKG_VERSION:=1 -PKG_RELEASE:=6 +PKG_RELEASE:=$(COMMITCOUNT) include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-cpufreq/luasrc/model/cbi/cpufreq.lua b/package/lean/luci-app-cpufreq/luasrc/model/cbi/cpufreq.lua index bee3b6006c..2b12a4db45 100644 --- a/package/lean/luci-app-cpufreq/luasrc/model/cbi/cpufreq.lua +++ b/package/lean/luci-app-cpufreq/luasrc/model/cbi/cpufreq.lua @@ -50,20 +50,19 @@ for _, policy_num in ipairs(string.split(policy_nums, " ")) do if e ~= "" then maxfreq:value(e) end end + sdfactor = s:taboption(policy_num, Value, "sdfactor" .. policy_num, translate("CPU Switching Sampling rate")) + sdfactor.datatype="range(1,100000)" + sdfactor.description = translate("The sampling rate determines how frequently the governor checks to tune the CPU (ms)") + sdfactor.placeholder = 10 + sdfactor.default = 10 + sdfactor:depends("governor", "ondemand") + upthreshold = s:taboption(policy_num, Value, "upthreshold" .. policy_num, translate("CPU Switching Threshold")) upthreshold.datatype="range(1,99)" upthreshold.description = translate("Kernel make a decision on whether it should increase the frequency (%)") upthreshold.placeholder = 50 upthreshold.default = 50 upthreshold:depends("governor", "ondemand") - - factor = s:taboption(policy_num, Value, "factor" .. policy_num, translate("CPU Switching Sampling rate")) - factor.datatype="range(1,100000)" - factor.description = translate("The sampling rate determines how frequently the governor checks to tune the CPU (ms)") - factor.placeholder = 10 - factor.default = 10 - factor:depends("governor", "ondemand") - end return mp diff --git a/package/lean/luci-app-cpufreq/po/zh_Hans/cpufreq.po b/package/lean/luci-app-cpufreq/po/zh_Hans/cpufreq.po index 48a4938a8a..bd818d7740 100644 --- a/package/lean/luci-app-cpufreq/po/zh_Hans/cpufreq.po +++ b/package/lean/luci-app-cpufreq/po/zh_Hans/cpufreq.po @@ -19,14 +19,14 @@ msgstr "待机 CPU 最小频率" msgid "Max Turbo Boost CPU Freq" msgstr "最大 Turbo Boost CPU 频率" -msgid "CPU Switching Threshold" -msgstr "CPU 切换频率触发阈值" - -msgid "Kernel make a decision on whether it should increase the frequency (%)" -msgstr "当 CPU 占用率超过 (%) 的情况下触发内核切换频率" - msgid "CPU Switching Sampling rate" msgstr "CPU 切换周期" msgid "The sampling rate determines how frequently the governor checks to tune the CPU (ms)" msgstr "CPU 检查切换的周期 (ms)。注意:过于频繁的切换频率会引起网络延迟抖动" + +msgid "CPU Switching Threshold" +msgstr "CPU 切换频率触发阈值" + +msgid "Kernel make a decision on whether it should increase the frequency (%)" +msgstr "当 CPU 占用率超过 (%) 的情况下触发内核切换频率" diff --git a/package/lean/luci-app-cpufreq/root/etc/init.d/cpufreq b/package/lean/luci-app-cpufreq/root/etc/init.d/cpufreq index 2df64d10a2..3da3089bd6 100755 --- a/package/lean/luci-app-cpufreq/root/etc/init.d/cpufreq +++ b/package/lean/luci-app-cpufreq/root/etc/init.d/cpufreq @@ -20,8 +20,8 @@ start() config_get_cpufreq "minfreq$i" > "/sys/devices/system/cpu/cpufreq/policy$i/scaling_min_freq" config_get_cpufreq "maxfreq$i" > "/sys/devices/system/cpu/cpufreq/policy$i/scaling_max_freq" if [ "$(config_get_cpufreq "governor$i")" = "ondemand" ]; then + config_get_cpufreq "sdfactor$i" > "/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor" config_get_cpufreq "upthreshold$i" > "/sys/devices/system/cpu/cpufreq/ondemand/up_threshold" - config_get_cpufreq "factor$i" > "/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor" fi done } diff --git a/package/lean/luci-app-cpufreq/root/etc/uci-defaults/cpufreq b/package/lean/luci-app-cpufreq/root/etc/uci-defaults/cpufreq index 8443be5799..15be1dce4f 100755 --- a/package/lean/luci-app-cpufreq/root/etc/uci-defaults/cpufreq +++ b/package/lean/luci-app-cpufreq/root/etc/uci-defaults/cpufreq @@ -1,5 +1,37 @@ #!/bin/sh +uci_write_config() { + uci set cpufreq.cpufreq.governor$1="$2" + uci set cpufreq.cpufreq.minfreq$1="$3" + uci set cpufreq.cpufreq.maxfreq$1="$4" + [ -n "$5" ] && uci set cpufreq.cpufreq.sdfactor$1="$5" + [ -n "$6" ] && uci set cpufreq.cpufreq.upthreshold$1="$6" + uci commit cpufreq +} + +CPU_POLICYS="$(find '/sys/devices/system/cpu/cpufreq/policy'* -maxdepth 0 | grep -Eo '[0-9]+')" +source "/etc/openwrt_release" +case "$DISTRIB_TARGET" in + "bcm27xx/bcm2710") + uci_write_config 0 ondemand 600000 1200000 10 50 + ;; + "ipq40xx") + uci_write_config 0 ondemand 300000 716000 10 50 + ;; + "ipq806x") + uci_write_config 0 ondemand 600000 716000 10 50 + echo "$CPU_POLICYS" | grep -q "1" && uci_write_config 1 ondemand 600000 716000 10 50 + ;; + "rockchip/armv8") + if echo "$CPU_POLICYS" | grep -q "4"; then + uci_write_config 0 schedutil 600000 1608000 + uci_write_config 4 schedutil 600000 2016000 + else + uci_write_config 0 schedutil 816000 1512000 + fi + ;; +esac + uci -q batch <<-EOF >/dev/null delete ucitrack.@cpufreq[-1] add ucitrack cpufreq