diff --git a/README.md b/README.md
index cb06ebe..d5441bf 100644
--- a/README.md
+++ b/README.md
@@ -8,48 +8,49 @@ Details see [the lead project](https://github.com/yc9559/sdm855-tune/commits/mas
## Profiles
-- powersave: based on balance mode, but with lower frequency limitation
+- powersave: based on balance mode, but with lower max frequency
- balance: smoother than the stock config with lower power consumption
-- performance: dynamic stune boost = 50 with no frequency limitation
+- performance: dynamic stune boost = 30 with no frequency limitation
- fast: providing stable performance capacity considering the TDP limitation of device chassis
```plain
-sdm855
-- powersave: 1.6+2.0g, boost 2.0+2.6g, min 0.3+0.7+0.8
-- balance: 1.8+2.4g, boost 2.4+2.7g, min 0.5+0.7+0.8
-- performance: 2.4+2.7g, boost 2.4+2.8g, min 0.5+0.7+0.8
-- fast: 1.8+2.6g, boost 2.4+2.8g, min 0.5+1.4+1.4
+sdm855/sdm855+
+- powersave: 1.7+1.6+2.4g, boost 1.7+2.0+2.6g, min 0.3+0.7+0.8
+- balance: 1.7+2.0+2.6g, boost 1.7+2.4+2.7g, min 0.5+0.7+0.8
+- performance: 1.7+2.4+2.8g, boost 1.7+2.4+2.8/2.9g, min 0.5+0.7+0.8
+- fast: 1.7+2.0+2.7g, boost 1.7+2.4+2.8/2.9g, min 0.5+1.2+1.2
sdm845
-- powersave: 1.8g, boost 2.2g, min 0.3+0.3
-- balance: 2.3g, boost 2.5g, min 0.5+0.8
-- performance: 2.8g, boost 2.8g, min 0.5+0.8
-- fast: 2.3g, boost 2.8g, min 0.5+1.6
+- powersave: 1.7+2.0g, boost 1.7+2.4g, min 0.3+0.3
+- balance: 1.7+2.4g, boost 1.7+2.7g, min 0.5+0.8
+- performance: 1.7+2.8g, boost 1.7+2.8g, min 0.5+0.8
+- fast: 1.7+2.4g, boost 1.7+2.8g, min 0.5+1.6
sdm730
-- powersave: 1.5g, boost 1.9g, min 0.3+0.3
-- balance: 1.9g, boost 2.1g, min 0.3+0.3
-- performance: 2.2g, boost 2.2g, min 0.5+0.6
-- fast: 1.9g, boost 2.2g, min 0.5+1.5
+- powersave: 1.7+1.5g, boost 1.7+1.9g, min 0.3+0.3
+- balance: 1.7+1.9g, boost 1.7+2.1g, min 0.5+0.6
+- performance: 1.8+2.2g, boost 1.8+2.2g, min 0.5+0.6
+- fast: 1.8+1.9g, boost 1.8+2.2g, min 0.5+1.2
sdm675
-- powersave: 1.5g, boost 1.7g, min 0.3+0.3
-- balance: 1.7g, boost 1.9g, min 0.3+0.3
-- performance: 2.0g, boost 2.0g, min 0.5+0.6
-- fast: 1.5g, boost 2.0g, min 0.5+1.5
+- powersave: 1.7+1.5g, boost 1.7+1.7g, min 0.3+0.3
+- balance: 1.7+1.7g, boost 1.7+1.9g, min 0.5+0.6
+- performance: 1.8+2.0g, boost 1.8+2.0g, min 0.5+0.6
+- fast: 1.8+1.7g, boost 1.8+2.0g, min 0.5+1.2
sdm710
-- powersave: 1.7g, boost 1.9g, min 0.3+0.3
-- balance: 2.0g, boost 2.1g, min 0.3+0.3
-- performance: 2.2g, boost 2.2g, min 0.5+0.6
-- fast: 2.0g, boost 2.2g, min 0.5+1.5
+- powersave: 1.7+1.8g, boost 1.7+2.0g, min 0.3+0.3
+- balance: 1.7+2.0g, boost 1.7+2.2g, min 0.5+0.6
+- performance: 1.7+2.2g, boost 1.7+2.2g, min 0.5+0.6
+- fast: 1.7+2.0g, boost 1.7+2.2g, min 0.5+1.5
```
## Requirements
1. sdm855 or sdm845 or sdm730 or sdm675 or sdm710
-2. Rooted
-3. Magisk >= 17.0
+2. Android >= 8.0
+3. Rooted
+4. Magisk >= 17.0
## Installation
@@ -62,23 +63,7 @@ sdm710
### Switching on boot
-1. Open `/sdcard/powercfg_panel.txt`, you will see:
-```plain
-
-Perfd-opt https://github.com/yc9559/perfd-opt/
-Author: Matt Yang
-Platform: sdm855
-Version: v1 (20190727)
-
-[status]
-Power mode: balance
-Last performed: 2019-07-27 10:33:28
-
-[settings]
-# Available mode: balance powersave performance fast
-default_mode=balance
-
-```
+1. Open `/sdcard/powercfg_panel.txt`
2. Edit line `default_mode=balance`
3. Reboot
diff --git a/common/service.sh b/common/service.sh
index 284ba66..9bf2236 100644
--- a/common/service.sh
+++ b/common/service.sh
@@ -2,12 +2,24 @@
# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
# This will make your scripts compatible even if Magisk change its mount point in the future
MODDIR=${0%/*}
+SCRIPT_DIR="$MODDIR/script"
-/vendor/bin/sh $MODDIR/system/vendor/bin/powercfg.sh
-/vendor/bin/sh $MODDIR/system/vendor/bin/powercfg_once.sh
+if [ "$(cat $SCRIPT_DIR/pathinfo.sh | grep "$PATH")" == "" ]; then
+ echo "" >> $SCRIPT_DIR/pathinfo.sh
+ echo "# prefer to use busybox provided by magisk" >> $SCRIPT_DIR/pathinfo.sh
+ echo "PATH=$PATH" >> $SCRIPT_DIR/pathinfo.sh
+fi
# support vtools
-cp -af $MODDIR/vtools-powercfg.sh /data/powercfg.sh
-cp -af $MODDIR/vtools-powercfg-base.sh /data/powercfg-base.sh
-chmod +x /data/powercfg.sh
-chmod +x /data/powercfg-base.sh
+cp -af $SCRIPT_DIR/vtools-powercfg.sh /data/powercfg.sh
+cp -af $SCRIPT_DIR/vtools-powercfg.sh /data/powercfg-base.sh
+chmod 755 /data/powercfg.sh
+chmod 755 /data/powercfg-base.sh
+
+# powercfg path provided by magisk module
+echo "sh $SCRIPT_DIR/powercfg.sh \"\$1\"" >> /data/powercfg.sh
+
+# not relying on executable permissions
+sh $SCRIPT_DIR/powercfg.sh
+sh $SCRIPT_DIR/powercfg_once.sh
+sh $SCRIPT_DIR/settings_override.sh
diff --git a/common/vtools-powercfg.sh b/common/vtools-powercfg.sh
deleted file mode 100644
index e6b6b33..0000000
--- a/common/vtools-powercfg.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Author: Matt Yang
-
-# powercfg wrapper for com.omarea.vtools
-# MAKE SURE THAT THE MAGISK MODULE "Perfd-opt" HAS BEEN INSTALLED
-
-powercfg_path="/vendor/bin/powercfg.sh"
-
-# suppress stderr
-(
-
-/vendor/bin/sh ${powercfg_path} $1
-
-# suppress stderr
-) 2>/dev/null
-
-exit 0
diff --git a/install.sh b/install.sh
index 6e8dbcd..e609edb 100644
--- a/install.sh
+++ b/install.sh
@@ -124,47 +124,35 @@ print_modname() {
ui_print ""
ui_print "Perfd-opt https://github.com/yc9559/perfd-opt/"
ui_print "Author: Matt Yang"
- ui_print "Version: v1 (20190727)"
+ ui_print "Version: v3 (20200222)"
ui_print ""
}
# Copy/extract your module files into $MODPATH in on_install.
on_install() {
- # cp custom files in ./common
- cp -af $TMPDIR/vtools-powercfg.sh $MODPATH/vtools-powercfg.sh
- cp -af $TMPDIR/vtools-powercfg-base.sh $MODPATH/vtools-powercfg-base.sh
-
target=`getprop ro.board.platform`
- ui_print "- The platform of this device is ${target}"
+ ui_print "- The platform of this device is $target"
- case "${target}" in
+ case "$target" in
"msmnile")
- ui_print "- Extracting module files"
- unzip -o "$ZIPFILE" 'profiles/*' -d $MODPATH >&2
- mv $MODPATH/profiles/sdm855/system $MODPATH/
- rm -rf $MODPATH/profiles
+ extract_common_file
+ extract_platform_file "sdm855"
;;
"sdm845")
- ui_print "- Extracting module files"
- unzip -o "$ZIPFILE" 'profiles/*' -d $MODPATH >&2
- mv $MODPATH/profiles/sdm845/system $MODPATH/
- rm -rf $MODPATH/profiles
+ extract_common_file
+ extract_platform_file "sdm845"
;;
"sm6150")
- ui_print "- Extracting module files"
- unzip -o "$ZIPFILE" 'profiles/*' -d $MODPATH >&2
- mv $MODPATH/profiles/sdm675_730/system $MODPATH/
- rm -rf $MODPATH/profiles
+ extract_common_file
+ extract_platform_file "sdm675_730"
;;
"sdm710")
- ui_print "- Extracting module files"
- unzip -o "$ZIPFILE" 'profiles/*' -d $MODPATH >&2
- mv $MODPATH/profiles/sdm710/system $MODPATH/
- rm -rf $MODPATH/profiles
+ extract_common_file
+ extract_platform_file "sdm710"
;;
*)
- abort "- ${target} not supported, terminated."
+ abort "- $target not supported, terminated."
;;
esac
}
@@ -182,8 +170,22 @@ set_permissions() {
# set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0
# set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0
# set_perm $MODPATH/system/lib/libart.so 0 0 0644
- set_perm $MODDIR/system/vendor/bin/powercfg.sh 0 2000 0755 u:object_r:vendor_file:s0
- set_perm $MODDIR/system/vendor/bin/powercfg_once.sh 0 2000 0755 u:object_r:vendor_file:s0
}
# You can add more functions to assist your custom script code
+
+extract_common_file() {
+ ui_print "- Extracting common module files"
+ unzip -o "$ZIPFILE" 'system/*' -d $MODPATH >&2
+ unzip -o "$ZIPFILE" 'script/*' -d $MODPATH >&2
+ unzip -o "$ZIPFILE" 'bin/*' -d $MODPATH >&2
+}
+
+# $1:platform_name
+extract_platform_file() {
+ ui_print "- Extracting platform module files"
+ unzip -o "$ZIPFILE" 'profiles/*' -d $MODPATH >&2
+ mv $MODPATH/profiles/$1/system $MODPATH/
+ mv $MODPATH/profiles/$1/powercfg_modes.sh $MODPATH/script/
+ rm -rf $MODPATH/profiles
+}
diff --git a/module.prop b/module.prop
index 4ced64c..56c85cc 100644
--- a/module.prop
+++ b/module.prop
@@ -1,6 +1,6 @@
id=perfd-opt
name=Perfd-opt
-version=v1 (20190727)
+version=v3 (20200222)
versionCode=1
author=Matt Yang
description=Provide better energy efficiency on EAS platforms by tuning CAF boostframework configuration. Repo: https://github.com/yc9559/perfd-opt/
diff --git a/profiles/sdm675_730/powercfg_modes.sh b/profiles/sdm675_730/powercfg_modes.sh
new file mode 100644
index 0000000..d92d036
--- /dev/null
+++ b/profiles/sdm675_730/powercfg_modes.sh
@@ -0,0 +1,138 @@
+#!/system/bin/sh
+# Platform Power Modes
+# Perfd-opt https://github.com/yc9559/perfd-opt/
+# Author: Matt Yang
+# Platform: sm6150
+# Version: v3 (20200222)
+
+BASEDIR="$(dirname "$0")"
+. $BASEDIR/pathinfo.sh
+. $BASEDIR/libpowercfg.sh
+
+# "365,366"="sdmmagpie"="sdm730"
+# "355,369"="msmsteppe"="sdm675"
+[ -f /sys/devices/soc0/soc_id ] && SOC_ID="$(cat /sys/devices/soc0/soc_id)"
+[ -f /sys/devices/system/soc/soc0/id ] && SOC_ID="$(cat /sys/devices/system/soc/soc0/id)"
+
+case "$SOC_ID" in
+ 365|366) PLATFORM_NAME="sdm730" ;;
+ 355|369) PLATFORM_NAME="sdm675" ;;
+esac
+BWMON_CPU_LLC="soc:qcom,cpu-cpu-llcc-bw"
+BWMON_LLC_DDR="soc:qcom,cpu-llcc-ddr-bw"
+BIG_L3_LAT="soc:qcom,cpu6-cpu-l3-lat"
+BIG_DDR_LAT="soc:qcom,cpu6-llcc-ddr-lat"
+STUNE_BG_CPUS="0-5"
+STUNE_FG_CPUS="0-7"
+
+apply_common()
+{
+ set_governor_param "scaling_governor" "0:schedutil 6:schedutil"
+ set_governor_param "schedutil/hispeed_load" "0:90 6:90"
+ set_governor_param "schedutil/hispeed_freq" "0:1000000 6:1200000"
+ set_cpufreq_max "0:9999000 6:9999000"
+ set_cpufreq_dyn_max "0:9999000 6:9999000"
+ lock_val "bw_hwmon" $DEVFREQ/$BWMON_CPU_LLC/governor
+ lock_val "bw_hwmon" $DEVFREQ/$BWMON_LLC_DDR/governor
+ mutate "0" $DEVFREQ/$BWMON_CPU_LLC/min_freq
+ mutate "0" $DEVFREQ/$BWMON_LLC_DDR/min_freq
+ lock_val "8000" $DEVFREQ/$BIG_L3_LAT/mem_latency/ratio_ceil
+ lock_val "800" $DEVFREQ/$BIG_DDR_LAT/mem_latency/ratio_ceil
+ mutate "0" $LPM/lpm_prediction
+ mutate "0" $LPM/sleep_disabled
+}
+
+apply_powersave()
+{
+ set_cpufreq_min "0:300000 6:300000"
+ case "$PLATFORM_NAME" in
+ sdm730) set_cpufreq_max "0:1708800 6:1555200" ;;
+ sdm675) set_cpufreq_max "0:1708800 6:1516800" ;;
+ esac
+ set_sched_migrate "95" "95" "140" "100"
+ set_corectl_param "min_cpus" "0:4 6:1"
+ set_governor_param "schedutil/pl" "0:0 6:0"
+ lock_val "0:1000000 6:1000000" $CPU_BOOST/input_boost_freq
+ lock_val "800" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "0" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "13000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "6000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "25" $LPM/bias_hyst
+}
+
+apply_balance()
+{
+ set_cpufreq_min "0:576000 6:652800"
+ case "$SOC_ID" in
+ sdm730) set_cpufreq_max "0:1708800 6:1939200" ;;
+ sdm675) set_cpufreq_max "0:1708800 6:1708800" ;;
+ esac
+ set_sched_migrate "95" "95" "140" "100"
+ set_corectl_param "min_cpus" "0:4 6:2"
+ set_governor_param "schedutil/pl" "0:0 6:0"
+ lock_val "0:1000000 6:1000000" $CPU_BOOST/input_boost_freq
+ lock_val "800" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "0" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "13000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "6000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "25" $LPM/bias_hyst
+}
+
+apply_performance()
+{
+ set_cpufreq_min "0:576000 6:652800"
+ case "$SOC_ID" in
+ sdm730) set_cpufreq_max "0:1804800 6:2208000" ;;
+ sdm675) set_cpufreq_max "0:1804800 6:2016000" ;;
+ esac
+ set_sched_migrate "80" "80" "100" "90"
+ set_corectl_param "min_cpus" "0:6 6:2"
+ set_governor_param "schedutil/pl" "0:0 6:1"
+ lock_val "0:1000000 6:1200000" $CPU_BOOST/input_boost_freq
+ lock_val "2000" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "10" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "15000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "7000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "100" $LPM/bias_hyst
+}
+
+apply_fast()
+{
+ set_cpufreq_min "0:576000 6:1209600"
+ case "$SOC_ID" in
+ sdm730) set_cpufreq_max "0:1804800 6:1939200" ;;
+ sdm675) set_cpufreq_max "0:1804800 6:1708800" ;;
+ esac
+ set_sched_migrate "80" "80" "100" "90"
+ set_corectl_param "min_cpus" "0:6 6:2"
+ set_governor_param "schedutil/pl" "0:1 6:1"
+ lock_val "0:1000000 6:1200000" $CPU_BOOST/input_boost_freq
+ lock_val "2000" $CPU_BOOST/input_boost_ms
+ lock_val "1" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "30" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "15000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "7000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "1000" $LPM/bias_hyst
+}
+
+apply_once()
+{
+ mutate "$STUNE_FG_CPUS" /dev/cpuset/foreground/cpus
+ lock_val "$STUNE_BG_CPUS" /dev/cpuset/restricted/cpus
+ lock_val "$STUNE_BG_CPUS" /dev/cpuset/display/cpus
+ set_corectl_param "enable" "0:1 6:1"
+ set_corectl_param "busy_down_thres" "0:20 6:20"
+ set_corectl_param "busy_up_thres" "0:40 6:40"
+ set_corectl_param "offline_delay_ms" "0:100 6:100"
+}
diff --git a/profiles/sdm675_730/system/vendor/bin/powercfg.sh b/profiles/sdm675_730/system/vendor/bin/powercfg.sh
deleted file mode 100644
index 69e0bd7..0000000
--- a/profiles/sdm675_730/system/vendor/bin/powercfg.sh
+++ /dev/null
@@ -1,284 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Author: Matt Yang
-# Platform: sm6150
-# Version: v1 (20190727)
-
-module_dir="/data/adb/modules/perfd-opt"
-panel_path="/sdcard/powercfg_panel.txt"
-
-# target power mode
-action=$1
-
-# $1:value $2:file path
-lock_val()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- chmod 0444 ${2}
- fi
-}
-
-# $1:value $2:file path
-mutate()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- fi
-}
-
-# stop before updating cfg
-stop_qti_perfd()
-{
- stop perf-hal-1-0
-}
-
-# start after updating cfg
-start_qti_perfd()
-{
- start perf-hal-1-0
-}
-
-# $1:mode(such as balance)
-update_qti_perfd()
-{
- rm /data/vendor/perfd/default_values
- cp -af ${module_dir}/system/vendor/etc/perf/perfd_profiles/${1}/* ${module_dir}/system/vendor/etc/perf/
-}
-
-# $1:key $return:value(string)
-read_cfg_value()
-{
- value=""
- if [ -f ${panel_path} ]; then
- value=`grep "^${1}=" "${panel_path}" | tr -d ' ' | cut -d= -f2`
- fi
- echo ${value}
-}
-
-apply_common()
-{
- # prevent foreground using big cluster, may be override
- mutate "0-5" /dev/cpuset/foreground/cpus
-
- # tend to online more cores to balance parallel tasks
- mutate "15" /sys/devices/system/cpu/cpu6/core_ctl/busy_up_thres
- mutate "5" /sys/devices/system/cpu/cpu6/core_ctl/busy_down_thres
- mutate "100" /sys/devices/system/cpu/cpu6/core_ctl/offline_delay_ms
-
- # unify scaling_min_freq, may be override
- mutate "576000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "652800" /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
-
- # unify scaling_max_freq, may be override
- mutate "1804800" /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
- mutate "2208000" /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq
-
- # unify group_migrate, may be override
- mutate "110" /proc/sys/kernel/sched_group_upmigrate
- mutate "100" /proc/sys/kernel/sched_group_downmigrate
-}
-
-apply_powersave()
-{
- # may be override
- mutate "300000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "300000" /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
-
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "0" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "0" /dev/stune/top-app/schedtune.boost
- mutate "0" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1200000 6:1000000" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "400" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # limit the usage of big cluster
- lock_val "1" /sys/devices/system/cpu/cpu6/core_ctl/enable
- mutate "0" /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
-}
-
-apply_balance()
-{
- # may be override
- mutate "300000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "300000" /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
-
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "0" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "0" /dev/stune/top-app/schedtune.boost
- mutate "0" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1200000 6:1000000" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "400" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # limit the usage of big cluster
- lock_val "1" /sys/devices/system/cpu/cpu6/core_ctl/enable
- mutate "1" /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
-}
-
-apply_performance()
-{
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "1" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "10" /dev/stune/top-app/schedtune.boost
- mutate "1" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1200000 6:1500000" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "2000" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu0/core_ctl/enable
- lock_val "0" /sys/devices/system/cpu/cpu6/core_ctl/enable
- mutate "2" /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
-}
-
-apply_fast()
-{
- # may be override
- mutate "576000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "1500000" /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
-
- # easier to boost
- mutate "40" /proc/sys/kernel/sched_downmigrate
- mutate "60" /proc/sys/kernel/sched_upmigrate
- mutate "40" /proc/sys/kernel/sched_downmigrate
-
- # avoid being the bottleneck
- mutate "1344000000" /sys/class/devfreq/soc:qcom,cpu0-cpu-l3-lat/min_freq
- mutate "1344000000" /sys/class/devfreq/soc:qcom,cpu6-cpu-l3-lat/min_freq
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "1" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "20" /dev/stune/top-app/schedtune.boost
- mutate "1" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:0 6:1500000" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "2000" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu0/core_ctl/enable
- lock_val "0" /sys/devices/system/cpu/cpu6/core_ctl/enable
- mutate "2" /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
-}
-
-# $1: power_mode
-apply_power_mode()
-{
- case "${1}" in
- "powersave")
- stop_qti_perfd
- apply_common
- apply_powersave
- update_qti_perfd powersave
- start_qti_perfd
- echo "Applying powersave done."
- ;;
- "balance")
- stop_qti_perfd
- apply_common
- apply_balance
- update_qti_perfd balance
- start_qti_perfd
- echo "Applying balance done."
- ;;
- "performance")
- stop_qti_perfd
- apply_common
- apply_performance
- update_qti_perfd performance
- start_qti_perfd
- echo "Applying performance done."
- ;;
- "fast")
- stop_qti_perfd
- apply_common
- apply_fast
- update_qti_perfd fast
- start_qti_perfd
- echo "Applying fast done."
- ;;
- *)
- action="balance"
- stop_qti_perfd
- apply_common
- apply_balance
- update_qti_perfd balance
- start_qti_perfd
- echo "Applying balance done."
- ;;
- esac
-}
-
-# suppress stderr
-(
-
-echo ""
-
-# we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
-while [ ! -e ${panel_path} ]
-do
- touch ${panel_path}
- sleep 2
-done
-
-if [ ! -n "$action" ]; then
- # default option is balance
- action="balance"
- # load default mode from file
- default_action=`read_cfg_value default_mode`
- if [ "${default_action}" != "" ]; then
- action=${default_action}
- fi
-fi
-
-# perform hotfix
-apply_power_mode ${action}
-
-# save mode for automatic applying mode after reboot
-echo "" > ${panel_path}
-echo "Perfd-opt https://github.com/yc9559/perfd-opt/" >> ${panel_path}
-echo "Author: Matt Yang" >> ${panel_path}
-echo "Platform: sm6150" >> ${panel_path}
-echo "Version: v1 (20190727)" >> ${panel_path}
-echo "" >> ${panel_path}
-echo "[status]" >> ${panel_path}
-echo "Power mode: ${action}" >> ${panel_path}
-echo "Last performed: `date '+%Y-%m-%d %H:%M:%S'`" >> ${panel_path}
-echo "" >> ${panel_path}
-echo "[settings]" >> ${panel_path}
-echo "# Available mode: balance powersave performance fast" >> ${panel_path}
-echo "default_mode=${action}" >> ${panel_path}
-
-echo "${panel_path} has been updated."
-
-echo ""
-
-# suppress stderr
-) 2> /dev/null
-
-exit 0
diff --git a/profiles/sdm675_730/system/vendor/bin/powercfg_once.sh b/profiles/sdm675_730/system/vendor/bin/powercfg_once.sh
deleted file mode 100644
index 51ea152..0000000
--- a/profiles/sdm675_730/system/vendor/bin/powercfg_once.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Author: Matt Yang
-# Platform: sm6150
-# Version: v1 (20190727)
-
-# Runonce after boot, to speed up the transition of power modes in powercfg
-
-# $1:value $2:file path
-lock_val()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- chmod 0444 ${2}
- fi
-}
-
-# $1:task_name $2:cgroup_name $3:"cpuset"/"stune"
-change_task_cgroup()
-{
- temp_pids=`ps -Ao pid,cmd | grep "${1}" | awk '{print $1}'`
- for temp_pid in ${temp_pids}
- do
- for temp_tid in `ls /proc/${temp_pid}/task/`
- do
- echo ${temp_tid} > /dev/${3}/${2}/tasks
- done
- done
-}
-
-# suppress stderr
-(
-
-# 580M for empty apps
-lock_val "18432,23040,27648,51256,122880,150296" /sys/module/lowmemorykiller/parameters/minfree
-
-# treat crtc_commit as display
-change_task_cgroup "crtc_commit" "display" "cpuset"
-
-# avoid display preemption on big
-lock_val "0-5" /dev/cpuset/display/cpus
-
-# fix laggy bilibili feed scrolling
-change_task_cgroup "servicemanager" "top-app" "cpuset"
-change_task_cgroup "servicemanager" "foreground" "stune"
-change_task_cgroup "android.phone" "top-app" "cpuset"
-change_task_cgroup "android.phone" "foreground" "stune"
-
-# fix laggy home gesture
-change_task_cgroup "system_server" "top-app" "cpuset"
-change_task_cgroup "system_server" "foreground" "stune"
-
-# reduce render thread waiting time
-change_task_cgroup "surfaceflinger" "top-app" "cpuset"
-change_task_cgroup "surfaceflinger" "foreground" "stune"
-
-# unify schedtune misc
-lock_val "0" /dev/stune/background/schedtune.sched_boost_enabled
-lock_val "1" /dev/stune/background/schedtune.sched_boost_no_override
-lock_val "0" /dev/stune/background/schedtune.boost
-lock_val "0" /dev/stune/background/schedtune.prefer_idle
-lock_val "0" /dev/stune/foreground/schedtune.sched_boost_enabled
-lock_val "1" /dev/stune/foreground/schedtune.sched_boost_no_override
-lock_val "0" /dev/stune/foreground/schedtune.boost
-lock_val "0" /dev/stune/foreground/schedtune.prefer_idle
-lock_val "0" /dev/stune/top-app/schedtune.sched_boost_no_override
-
-# CFQ io scheduler takes cgroup into consideration
-lock_val "cfq" /sys/block/sda/queue/scheduler
-# Flash doesn't have back seek problem, so penalty is as low as possible
-lock_val "1" /sys/block/sda/queue/iosched/back_seek_penalty
-# slice_idle = 0 means CFQ IOP mode, https://lore.kernel.org/patchwork/patch/944972/
-lock_val "0" /sys/block/sda/queue/iosched/slice_idle
-# UFS 2.0+ hardware queue depth is 32
-lock_val "16" /sys/block/sda/queue/iosched/quantum
-# lower read_ahead_kb to reduce random access overhead
-lock_val "128" /sys/block/sda/queue/read_ahead_kb
-
-# adreno default settings
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_no_nap
-lock_val "1" /sys/class/kgsl/kgsl-3d0/bus_split
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_bus_on
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_clk_on
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_rail_on
-
-# zram doesn't need much read ahead(random read)
-lock_val "4" /sys/block/zram0/queue/read_ahead_kb
-
-# suppress stderr
-) 2> /dev/null
diff --git a/profiles/sdm675_730/system/vendor/etc/perf/commonresourceconfigs.xml b/profiles/sdm675_730/system/vendor/etc/perf/commonresourceconfigs.xml
index c600900..9837d8a 100644
--- a/profiles/sdm675_730/system/vendor/etc/perf/commonresourceconfigs.xml
+++ b/profiles/sdm675_730/system/vendor/etc/perf/commonresourceconfigs.xml
@@ -1,210 +1,210 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
index 016b975..859a65b 100644
--- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
+++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
@@ -16,25 +16,25 @@
-
+
-
+
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
@@ -71,59 +71,59 @@
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF" />
+ Resources="0x40804000, 1500, 0x40800000, 1000, 0x40800100, 1000, 0x40C18000, 1, 0x40C3C000, 127, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 1700, 0x40800000, 1000, 0x40800100, 1000, 0x40C18000, 1, 0x40C3C000, 127, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1000, 0x40800100, 1000, 0x40C18000, 1, 0x41000100, 6, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40800000, 1000, 0x40800100, 1000, 0x40C18000, 1, 0x41000100, 6, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
index b5b38dd..2a350d2 100644
--- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
+++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
@@ -16,25 +16,25 @@
-
+
-
+
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
@@ -71,59 +71,59 @@
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF" />
+ Resources="0x40804000, 1700, 0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 30, 0x40C3C000, 127, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 1900, 0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 30, 0x40C3C000, 127, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 30, 0x41000100, 6, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 30, 0x41000100, 6, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
index 065b785..595a19d 100644
--- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
+++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
@@ -53,7 +53,7 @@
CpufreqGov="1" />
-
+
diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
index 1f3b512..2a350d2 100644
--- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
+++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
@@ -16,25 +16,25 @@
-
+
-
+
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
@@ -71,59 +71,59 @@
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF" />
+ Resources="0x40804000, 1700, 0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 30, 0x40C3C000, 127, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 1900, 0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 30, 0x40C3C000, 127, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 30, 0x41000100, 6, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 30, 0x41000100, 6, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
index 97ba4bf..c886389 100644
--- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
+++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
@@ -1,129 +1,129 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/profiles/sdm675_730/system/vendor/etc/perf/targetresourceconfigs.xml b/profiles/sdm675_730/system/vendor/etc/perf/targetresourceconfigs.xml
index 76acda3..a9f1437 100644
--- a/profiles/sdm675_730/system/vendor/etc/perf/targetresourceconfigs.xml
+++ b/profiles/sdm675_730/system/vendor/etc/perf/targetresourceconfigs.xml
@@ -35,8 +35,6 @@ as anyway perflock calls of these resources would fail. -->
-
-
diff --git a/profiles/sdm710/powercfg_modes.sh b/profiles/sdm710/powercfg_modes.sh
new file mode 100644
index 0000000..06ab186
--- /dev/null
+++ b/profiles/sdm710/powercfg_modes.sh
@@ -0,0 +1,118 @@
+#!/system/bin/sh
+# Platform Power Modes
+# Perfd-opt https://github.com/yc9559/perfd-opt/
+# Author: Matt Yang
+# Platform: sdm710
+# Version: v3 (20200222)
+
+BASEDIR="$(dirname "$0")"
+. $BASEDIR/pathinfo.sh
+. $BASEDIR/libpowercfg.sh
+
+PLATFORM_NAME="sdm710"
+BWMON_CPU_LLC="soc:qcom,cpubw"
+BWMON_LLC_DDR="soc:qcom,cpubw"
+BIG_L3_LAT="soc:qcom,l3-cpu6"
+BIG_DDR_LAT="soc:qcom,memlat-cpu6"
+STUNE_BG_CPUS="0-5"
+STUNE_FG_CPUS="0-7"
+
+apply_common()
+{
+ set_governor_param "scaling_governor" "0:schedutil 6:schedutil"
+ set_governor_param "schedutil/hispeed_load" "0:90 6:90"
+ set_governor_param "schedutil/hispeed_freq" "0:998400 6:1536000"
+ set_cpufreq_max "0:9999000 6:9999000"
+ set_cpufreq_dyn_max "0:9999000 6:9999000"
+ lock_val "bw_hwmon" $DEVFREQ/$BWMON_CPU_LLC/governor
+ lock_val "bw_hwmon" $DEVFREQ/$BWMON_LLC_DDR/governor
+ mutate "0" $DEVFREQ/$BWMON_CPU_LLC/min_freq
+ mutate "0" $DEVFREQ/$BWMON_LLC_DDR/min_freq
+ lock_val "8000" $DEVFREQ/$BIG_L3_LAT/mem_latency/ratio_ceil
+ lock_val "800" $DEVFREQ/$BIG_DDR_LAT/mem_latency/ratio_ceil
+ mutate "0" $LPM/lpm_prediction
+ mutate "0" $LPM/sleep_disabled
+}
+
+apply_powersave()
+{
+ set_cpufreq_min "0:300000 6:300000"
+ set_cpufreq_max "0:1708800 6:1843200"
+ set_sched_migrate "95" "95" "140" "100"
+ set_corectl_param "min_cpus" "0:4 6:1"
+ set_governor_param "schedutil/pl" "0:0 6:0"
+ lock_val "0:998400 6:1132800" $CPU_BOOST/input_boost_freq
+ lock_val "800" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "0" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "6000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "6000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "25" $LPM/bias_hyst
+}
+
+apply_balance()
+{
+ set_cpufreq_min "0:576000 6:652800"
+ set_cpufreq_max "0:1708800 6:2016000"
+ set_sched_migrate "95" "95" "140" "100"
+ set_corectl_param "min_cpus" "0:4 6:2"
+ set_governor_param "schedutil/pl" "0:0 6:0"
+ lock_val "0:998400 6:1132800" $CPU_BOOST/input_boost_freq
+ lock_val "800" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "0" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "6000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "6000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "25" $LPM/bias_hyst
+}
+
+apply_performance()
+{
+ set_cpufreq_min "0:576000 6:652800"
+ set_cpufreq_max "0:1708800 6:2208000"
+ set_sched_migrate "80" "80" "100" "90"
+ set_corectl_param "min_cpus" "0:6 6:2"
+ set_governor_param "schedutil/pl" "0:0 6:1"
+ lock_val "0:998400 6:1536000" $CPU_BOOST/input_boost_freq
+ lock_val "2000" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "10" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "7000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "7000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "100" $LPM/bias_hyst
+}
+
+apply_fast()
+{
+ set_cpufreq_min "0:576000 6:1536000"
+ set_cpufreq_max "0:1708800 6:2016000"
+ set_sched_migrate "80" "80" "100" "90"
+ set_corectl_param "min_cpus" "0:6 6:2"
+ set_governor_param "schedutil/pl" "0:1 6:1"
+ lock_val "0:998400 6:1536000" $CPU_BOOST/input_boost_freq
+ lock_val "2000" $CPU_BOOST/input_boost_ms
+ lock_val "1" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "30" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "7000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "7000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "1000" $LPM/bias_hyst
+}
+
+apply_once()
+{
+ mutate "$STUNE_FG_CPUS" /dev/cpuset/foreground/cpus
+ lock_val "$STUNE_BG_CPUS" /dev/cpuset/restricted/cpus
+ lock_val "$STUNE_BG_CPUS" /dev/cpuset/display/cpus
+ set_corectl_param "enable" "0:1 6:1"
+ set_corectl_param "busy_down_thres" "0:20 6:20"
+ set_corectl_param "busy_up_thres" "0:40 6:40"
+ set_corectl_param "offline_delay_ms" "0:100 6:100"
+}
diff --git a/profiles/sdm710/system/vendor/bin/powercfg.sh b/profiles/sdm710/system/vendor/bin/powercfg.sh
deleted file mode 100644
index 33841d5..0000000
--- a/profiles/sdm710/system/vendor/bin/powercfg.sh
+++ /dev/null
@@ -1,284 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Author: Matt Yang
-# Platform: sdm710
-# Version: v1 (20190727)
-
-module_dir="/data/adb/modules/perfd-opt"
-panel_path="/sdcard/powercfg_panel.txt"
-
-# target power mode
-action=$1
-
-# $1:value $2:file path
-lock_val()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- chmod 0444 ${2}
- fi
-}
-
-# $1:value $2:file path
-mutate()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- fi
-}
-
-# stop before updating cfg
-stop_qti_perfd()
-{
- stop perf-hal-1-0
-}
-
-# start after updating cfg
-start_qti_perfd()
-{
- start perf-hal-1-0
-}
-
-# $1:mode(such as balance)
-update_qti_perfd()
-{
- rm /data/vendor/perfd/default_values
- cp -af ${module_dir}/system/vendor/etc/perf/perfd_profiles/${1}/* ${module_dir}/system/vendor/etc/perf/
-}
-
-# $1:key $return:value(string)
-read_cfg_value()
-{
- value=""
- if [ -f ${panel_path} ]; then
- value=`grep "^${1}=" "${panel_path}" | tr -d ' ' | cut -d= -f2`
- fi
- echo ${value}
-}
-
-apply_common()
-{
- # prevent foreground using big cluster, may be override
- mutate "0-5" /dev/cpuset/foreground/cpus
-
- # tend to online more cores to balance parallel tasks
- mutate "15" /sys/devices/system/cpu/cpu6/core_ctl/busy_up_thres
- mutate "5" /sys/devices/system/cpu/cpu6/core_ctl/busy_down_thres
- mutate "100" /sys/devices/system/cpu/cpu6/core_ctl/offline_delay_ms
-
- # unify scaling_min_freq, may be override
- mutate "576000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "652800" /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
-
- # unify scaling_max_freq, may be override
- mutate "1708800" /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
- mutate "2208000" /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq
-
- # unify group_migrate, may be override
- mutate "110" /proc/sys/kernel/sched_group_upmigrate
- mutate "100" /proc/sys/kernel/sched_group_downmigrate
-}
-
-apply_powersave()
-{
- # may be override
- mutate "300000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "300000" /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
-
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "0" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "0" /dev/stune/top-app/schedtune.boost
- mutate "0" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1209660 6:1132800" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "400" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # limit the usage of big cluster
- lock_val "1" /sys/devices/system/cpu/cpu6/core_ctl/enable
- mutate "0" /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
-}
-
-apply_balance()
-{
- # may be override
- mutate "300000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "300000" /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
-
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "0" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "0" /dev/stune/top-app/schedtune.boost
- mutate "0" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1209660 6:1132800" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "400" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # limit the usage of big cluster
- lock_val "1" /sys/devices/system/cpu/cpu6/core_ctl/enable
- mutate "1" /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
-}
-
-apply_performance()
-{
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "1" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "10" /dev/stune/top-app/schedtune.boost
- mutate "1" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1209600 6:1843200" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "2000" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu0/core_ctl/enable
- lock_val "0" /sys/devices/system/cpu/cpu6/core_ctl/enable
- mutate "2" /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
-}
-
-apply_fast()
-{
- # may be override
- mutate "576000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "1536000" /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq
-
- # easier to boost
- mutate "40" /proc/sys/kernel/sched_downmigrate
- mutate "60" /proc/sys/kernel/sched_upmigrate
- mutate "40" /proc/sys/kernel/sched_downmigrate
-
- # avoid being the bottleneck
- mutate "1344000000" /sys/class/devfreq/soc:qcom,cpu0-cpu-l3-lat/min_freq
- mutate "1344000000" /sys/class/devfreq/soc:qcom,cpu6-cpu-l3-lat/min_freq
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "1" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "20" /dev/stune/top-app/schedtune.boost
- mutate "1" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:0 6:1843200" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "2000" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu0/core_ctl/enable
- lock_val "0" /sys/devices/system/cpu/cpu6/core_ctl/enable
- mutate "2" /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
-}
-
-# $1: power_mode
-apply_power_mode()
-{
- case "${1}" in
- "powersave")
- stop_qti_perfd
- apply_common
- apply_powersave
- update_qti_perfd powersave
- start_qti_perfd
- echo "Applying powersave done."
- ;;
- "balance")
- stop_qti_perfd
- apply_common
- apply_balance
- update_qti_perfd balance
- start_qti_perfd
- echo "Applying balance done."
- ;;
- "performance")
- stop_qti_perfd
- apply_common
- apply_performance
- update_qti_perfd performance
- start_qti_perfd
- echo "Applying performance done."
- ;;
- "fast")
- stop_qti_perfd
- apply_common
- apply_fast
- update_qti_perfd fast
- start_qti_perfd
- echo "Applying fast done."
- ;;
- *)
- action="balance"
- stop_qti_perfd
- apply_common
- apply_balance
- update_qti_perfd balance
- start_qti_perfd
- echo "Applying balance done."
- ;;
- esac
-}
-
-# suppress stderr
-(
-
-echo ""
-
-# we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
-while [ ! -e ${panel_path} ]
-do
- touch ${panel_path}
- sleep 2
-done
-
-if [ ! -n "$action" ]; then
- # default option is balance
- action="balance"
- # load default mode from file
- default_action=`read_cfg_value default_mode`
- if [ "${default_action}" != "" ]; then
- action=${default_action}
- fi
-fi
-
-# perform hotfix
-apply_power_mode ${action}
-
-# save mode for automatic applying mode after reboot
-echo "" > ${panel_path}
-echo "Perfd-opt https://github.com/yc9559/perfd-opt/" >> ${panel_path}
-echo "Author: Matt Yang" >> ${panel_path}
-echo "Platform: sdm710" >> ${panel_path}
-echo "Version: v1 (20190727)" >> ${panel_path}
-echo "" >> ${panel_path}
-echo "[status]" >> ${panel_path}
-echo "Power mode: ${action}" >> ${panel_path}
-echo "Last performed: `date '+%Y-%m-%d %H:%M:%S'`" >> ${panel_path}
-echo "" >> ${panel_path}
-echo "[settings]" >> ${panel_path}
-echo "# Available mode: balance powersave performance fast" >> ${panel_path}
-echo "default_mode=${action}" >> ${panel_path}
-
-echo "${panel_path} has been updated."
-
-echo ""
-
-# suppress stderr
-) 2> /dev/null
-
-exit 0
diff --git a/profiles/sdm710/system/vendor/bin/powercfg_once.sh b/profiles/sdm710/system/vendor/bin/powercfg_once.sh
deleted file mode 100644
index 48dee68..0000000
--- a/profiles/sdm710/system/vendor/bin/powercfg_once.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Author: Matt Yang
-# Platform: sdm710
-# Version: v1 (20190727)
-
-# Runonce after boot, to speed up the transition of power modes in powercfg
-
-# $1:value $2:file path
-lock_val()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- chmod 0444 ${2}
- fi
-}
-
-# $1:task_name $2:cgroup_name $3:"cpuset"/"stune"
-change_task_cgroup()
-{
- temp_pids=`ps -Ao pid,cmd | grep "${1}" | awk '{print $1}'`
- for temp_pid in ${temp_pids}
- do
- for temp_tid in `ls /proc/${temp_pid}/task/`
- do
- echo ${temp_tid} > /dev/${3}/${2}/tasks
- done
- done
-}
-
-# suppress stderr
-(
-
-# 580M for empty apps
-lock_val "18432,23040,27648,51256,122880,150296" /sys/module/lowmemorykiller/parameters/minfree
-
-# treat crtc_commit as display
-change_task_cgroup "crtc_commit" "display" "cpuset"
-
-# avoid display preemption on big
-lock_val "0-5" /dev/cpuset/display/cpus
-
-# fix laggy bilibili feed scrolling
-change_task_cgroup "servicemanager" "top-app" "cpuset"
-change_task_cgroup "servicemanager" "foreground" "stune"
-change_task_cgroup "android.phone" "top-app" "cpuset"
-change_task_cgroup "android.phone" "foreground" "stune"
-
-# fix laggy home gesture
-change_task_cgroup "system_server" "top-app" "cpuset"
-change_task_cgroup "system_server" "foreground" "stune"
-
-# reduce render thread waiting time
-change_task_cgroup "surfaceflinger" "top-app" "cpuset"
-change_task_cgroup "surfaceflinger" "foreground" "stune"
-
-# unify schedtune misc
-lock_val "0" /dev/stune/background/schedtune.sched_boost_enabled
-lock_val "1" /dev/stune/background/schedtune.sched_boost_no_override
-lock_val "0" /dev/stune/background/schedtune.boost
-lock_val "0" /dev/stune/background/schedtune.prefer_idle
-lock_val "0" /dev/stune/foreground/schedtune.sched_boost_enabled
-lock_val "1" /dev/stune/foreground/schedtune.sched_boost_no_override
-lock_val "0" /dev/stune/foreground/schedtune.boost
-lock_val "0" /dev/stune/foreground/schedtune.prefer_idle
-lock_val "0" /dev/stune/top-app/schedtune.sched_boost_no_override
-
-# CFQ io scheduler takes cgroup into consideration
-lock_val "cfq" /sys/block/sda/queue/scheduler
-# Flash doesn't have back seek problem, so penalty is as low as possible
-lock_val "1" /sys/block/sda/queue/iosched/back_seek_penalty
-# slice_idle = 0 means CFQ IOP mode, https://lore.kernel.org/patchwork/patch/944972/
-lock_val "0" /sys/block/sda/queue/iosched/slice_idle
-# UFS 2.0+ hardware queue depth is 32
-lock_val "16" /sys/block/sda/queue/iosched/quantum
-# lower read_ahead_kb to reduce random access overhead
-lock_val "128" /sys/block/sda/queue/read_ahead_kb
-
-# adreno default settings
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_no_nap
-lock_val "1" /sys/class/kgsl/kgsl-3d0/bus_split
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_bus_on
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_clk_on
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_rail_on
-
-# zram doesn't need much read ahead(random read)
-lock_val "4" /sys/block/zram0/queue/read_ahead_kb
-
-# suppress stderr
-) 2> /dev/null
diff --git a/profiles/sdm710/system/vendor/etc/perf/commonresourceconfigs.xml b/profiles/sdm710/system/vendor/etc/perf/commonresourceconfigs.xml
index c600900..9837d8a 100644
--- a/profiles/sdm710/system/vendor/etc/perf/commonresourceconfigs.xml
+++ b/profiles/sdm710/system/vendor/etc/perf/commonresourceconfigs.xml
@@ -1,210 +1,210 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
index 28c1e54..7b4ea18 100644
--- a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
+++ b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
@@ -16,20 +16,20 @@
-
+
-
+
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 1747,0x40800100, 1516, 0x40400000, 0x1, 0x42804000, 0x2" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
@@ -61,31 +61,31 @@
+ Resources="0x40804000, 1800, 0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 1, 0x40C40000, 15, 0x41800000, 25" />
+ Resources="0x41800000, 25" />
+ Resources="0x41800000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 1, 0x41000100, 6, 0x41800000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1600, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
index e0224a4..3da300a 100644
--- a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
+++ b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
@@ -1,7 +1,7 @@
-
+
-
+
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 1747,0x40800100, 1516, 0x40400000, 0x1, 0x42804000, 0x2" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
@@ -61,31 +61,31 @@
+ Resources="0x40804000, 2000, 0x40800000, 1500, 0x40800100, 1000, 0x40C18000, 30, 0x40C40000, 15, 0x41800000, 25" />
+ Resources="0x41800000, 25" />
+ Resources="0x41800000, 25" />
+ Resources="0x40800000, 1500, 0x40800100, 1000, 0x40C18000, 30, 0x41000100, 6, 0x41800000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1600, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
index a65ef2a..3da300a 100644
--- a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
+++ b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
@@ -1,7 +1,7 @@
-
+
-
+
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 1747,0x40800100, 1516, 0x40400000, 0x1, 0x42804000, 0x2" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
@@ -61,31 +61,31 @@
+ Resources="0x40804000, 2000, 0x40800000, 1500, 0x40800100, 1000, 0x40C18000, 30, 0x40C40000, 15, 0x41800000, 25" />
+ Resources="0x41800000, 25" />
+ Resources="0x41800000, 25" />
+ Resources="0x40800000, 1500, 0x40800100, 1000, 0x40C18000, 30, 0x41000100, 6, 0x41800000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1600, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
index 0d05081..79c9a54 100644
--- a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
+++ b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
@@ -1,91 +1,91 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
index d6352a8..750b7e4 100644
--- a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
+++ b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
@@ -53,7 +53,7 @@
CpufreqGov="1" />
-
+
diff --git a/profiles/sdm710/system/vendor/etc/perf/targetresourceconfigs.xml b/profiles/sdm710/system/vendor/etc/perf/targetresourceconfigs.xml
index a7ee6a0..f8f0fab 100644
--- a/profiles/sdm710/system/vendor/etc/perf/targetresourceconfigs.xml
+++ b/profiles/sdm710/system/vendor/etc/perf/targetresourceconfigs.xml
@@ -35,8 +35,6 @@ as anyway perflock calls of these resources would fail. -->
-
-
diff --git a/profiles/sdm845/powercfg_modes.sh b/profiles/sdm845/powercfg_modes.sh
new file mode 100644
index 0000000..8d3323c
--- /dev/null
+++ b/profiles/sdm845/powercfg_modes.sh
@@ -0,0 +1,118 @@
+#!/system/bin/sh
+# Platform Power Modes
+# Perfd-opt https://github.com/yc9559/perfd-opt/
+# Author: Matt Yang
+# Platform: sdm845
+# Version: v3 (20200222)
+
+BASEDIR="$(dirname "$0")"
+. $BASEDIR/pathinfo.sh
+. $BASEDIR/libpowercfg.sh
+
+PLATFORM_NAME="sdm845"
+BWMON_CPU_LLC="soc:qcom,cpubw"
+BWMON_LLC_DDR="soc:qcom,llccbw"
+BIG_L3_LAT="soc:qcom,l3-cpu4"
+BIG_DDR_LAT="soc:qcom,memlat-cpu4"
+STUNE_BG_CPUS="0-3"
+STUNE_FG_CPUS="0-6"
+
+apply_common()
+{
+ set_governor_param "scaling_governor" "0:schedutil 4:schedutil"
+ set_governor_param "schedutil/hispeed_load" "0:90 4:90"
+ set_governor_param "schedutil/hispeed_freq" "0:1132800 4:1612800"
+ set_cpufreq_max "0:9999000 4:9999000"
+ set_cpufreq_dyn_max "0:9999000 4:9999000"
+ lock_val "bw_hwmon" $DEVFREQ/$BWMON_CPU_LLC/governor
+ lock_val "bw_hwmon" $DEVFREQ/$BWMON_LLC_DDR/governor
+ mutate "0" $DEVFREQ/$BWMON_CPU_LLC/min_freq
+ mutate "0" $DEVFREQ/$BWMON_LLC_DDR/min_freq
+ lock_val "8000" $DEVFREQ/$BIG_L3_LAT/mem_latency/ratio_ceil
+ lock_val "800" $DEVFREQ/$BIG_DDR_LAT/mem_latency/ratio_ceil
+ mutate "0" $LPM/lpm_prediction
+ mutate "0" $LPM/sleep_disabled
+}
+
+apply_powersave()
+{
+ set_cpufreq_min "0:300000 4:300000"
+ set_cpufreq_max "0:1766400 4:1996800"
+ set_sched_migrate "95" "95" "140" "100"
+ set_corectl_param "min_cpus" "0:4 4:1"
+ set_governor_param "schedutil/pl" "0:0 4:0"
+ lock_val "0:1132800 4:1286400" $CPU_BOOST/input_boost_freq
+ lock_val "800" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "0" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "9500" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "6000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "25" $LPM/bias_hyst
+}
+
+apply_balance()
+{
+ set_cpufreq_min "0:576000 4:825600"
+ set_cpufreq_max "0:1766400 4:2476800"
+ set_sched_migrate "95" "95" "140" "100"
+ set_corectl_param "min_cpus" "0:4 4:2"
+ set_governor_param "schedutil/pl" "0:0 4:0"
+ lock_val "0:1132800 4:1286400" $CPU_BOOST/input_boost_freq
+ lock_val "800" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "0" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "9500" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "6000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "25" $LPM/bias_hyst
+}
+
+apply_performance()
+{
+ set_cpufreq_min "0:576000 4:825600"
+ set_cpufreq_max "0:1766400 4:2803200"
+ set_sched_migrate "80" "80" "100" "90"
+ set_corectl_param "min_cpus" "0:4 4:4"
+ set_governor_param "schedutil/pl" "0:0 4:1"
+ lock_val "0:1132800 4:1612800" $CPU_BOOST/input_boost_freq
+ lock_val "2000" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "10" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "11000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "7000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "100" $LPM/bias_hyst
+}
+
+apply_fast()
+{
+ set_cpufreq_min "0:576000 4:1612800"
+ set_cpufreq_max "0:1766400 4:2476800"
+ set_sched_migrate "80" "80" "100" "90"
+ set_corectl_param "min_cpus" "0:4 4:4"
+ set_governor_param "schedutil/pl" "0:1 4:1"
+ lock_val "0:1132800 4:1612800" $CPU_BOOST/input_boost_freq
+ lock_val "2000" $CPU_BOOST/input_boost_ms
+ lock_val "1" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "30" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "11000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "7000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "1000" $LPM/bias_hyst
+}
+
+apply_once()
+{
+ mutate "$STUNE_FG_CPUS" /dev/cpuset/foreground/cpus
+ lock_val "$STUNE_BG_CPUS" /dev/cpuset/restricted/cpus
+ lock_val "$STUNE_BG_CPUS" /dev/cpuset/display/cpus
+ set_corectl_param "enable" "0:1 4:1"
+ set_corectl_param "busy_down_thres" "0:20 4:20"
+ set_corectl_param "busy_up_thres" "0:40 4:40"
+ set_corectl_param "offline_delay_ms" "0:100 4:100"
+}
diff --git a/profiles/sdm845/system/vendor/bin/powercfg.sh b/profiles/sdm845/system/vendor/bin/powercfg.sh
deleted file mode 100644
index 0516d36..0000000
--- a/profiles/sdm845/system/vendor/bin/powercfg.sh
+++ /dev/null
@@ -1,280 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Author: Matt Yang
-# Platform: sdm845
-# Version: v1 (20190727)
-
-module_dir="/data/adb/modules/perfd-opt"
-panel_path="/sdcard/powercfg_panel.txt"
-
-# target power mode
-action=$1
-
-# $1:value $2:file path
-lock_val()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- chmod 0444 ${2}
- fi
-}
-
-# $1:value $2:file path
-mutate()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- fi
-}
-
-# stop before updating cfg
-stop_qti_perfd()
-{
- stop perf-hal-1-0
-}
-
-# start after updating cfg
-start_qti_perfd()
-{
- start perf-hal-1-0
-}
-
-# $1:mode(such as balance)
-update_qti_perfd()
-{
- rm /data/vendor/perfd/default_values
- cp -af ${module_dir}/system/vendor/etc/perf/perfd_profiles/${1}/* ${module_dir}/system/vendor/etc/perf/
-}
-
-# $1:key $return:value(string)
-read_cfg_value()
-{
- value=""
- if [ -f ${panel_path} ]; then
- value=`grep "^${1}=" "${panel_path}" | tr -d ' ' | cut -d= -f2`
- fi
- echo ${value}
-}
-
-apply_common()
-{
- # prevent foreground using big cluster, may be override
- mutate "0-3" /dev/cpuset/foreground/cpus
-
- # turn off hotplug to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu0/core_ctl/enable
- # tend to online more cores to balance parallel tasks
- mutate "15" /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres
- mutate "5" /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres
- mutate "100" /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms
-
- # unify scaling_min_freq, may be override
- mutate "576000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "825600" /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
-
- # unify scaling_max_freq, may be override
- mutate "1766400" /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
- mutate "2803200" /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq
-
- # unify group_migrate, may be override
- mutate "110" /proc/sys/kernel/sched_group_upmigrate
- mutate "100" /proc/sys/kernel/sched_group_downmigrate
-}
-
-apply_powersave()
-{
- # may be override
- mutate "300000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "300000" /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
-
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "0" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "0" /dev/stune/top-app/schedtune.boost
- mutate "0" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1209600 4:1036800" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "400" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # limit the usage of big cluster
- lock_val "1" /sys/devices/system/cpu/cpu4/core_ctl/enable
- mutate "0" /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
-}
-
-apply_balance()
-{
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "0" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "0" /dev/stune/top-app/schedtune.boost
- mutate "0" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1209600 4:1036800" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "400" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # limit the usage of big cluster
- lock_val "1" /sys/devices/system/cpu/cpu4/core_ctl/enable
- mutate "2" /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
-}
-
-apply_performance()
-{
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90" /proc/sys/kernel/sched_downmigrate
- mutate "90" /proc/sys/kernel/sched_upmigrate
- mutate "90" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "1" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "10" /dev/stune/top-app/schedtune.boost
- mutate "1" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1228800 4:1612800" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "2000" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu4/core_ctl/enable
- mutate "4" /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
-}
-
-apply_fast()
-{
- # may be override
- mutate "576000" /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- mutate "1612800" /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
-
- # easier to boost
- mutate "40" /proc/sys/kernel/sched_downmigrate
- mutate "60" /proc/sys/kernel/sched_upmigrate
- mutate "40" /proc/sys/kernel/sched_downmigrate
-
- # avoid being the bottleneck
- mutate "1401600000" /sys/class/devfreq/soc:qcom,l3-cpu0/min_freq
- mutate "1401600000" /sys/class/devfreq/soc:qcom,l3-cpu4/min_freq
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "1" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "20" /dev/stune/top-app/schedtune.boost
- mutate "1" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:0 4:1996800" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "2000" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu4/core_ctl/enable
- mutate "4" /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
-}
-
-# $1: power_mode
-apply_power_mode()
-{
- case "${1}" in
- "powersave")
- stop_qti_perfd
- apply_common
- apply_powersave
- update_qti_perfd powersave
- start_qti_perfd
- echo "Applying powersave done."
- ;;
- "balance")
- stop_qti_perfd
- apply_common
- apply_balance
- update_qti_perfd balance
- start_qti_perfd
- echo "Applying balance done."
- ;;
- "performance")
- stop_qti_perfd
- apply_common
- apply_performance
- update_qti_perfd performance
- start_qti_perfd
- echo "Applying performance done."
- ;;
- "fast")
- stop_qti_perfd
- apply_common
- apply_fast
- update_qti_perfd fast
- start_qti_perfd
- echo "Applying fast done."
- ;;
- *)
- action="balance"
- stop_qti_perfd
- apply_common
- apply_balance
- update_qti_perfd balance
- start_qti_perfd
- echo "Applying balance done."
- ;;
- esac
-}
-
-# suppress stderr
-(
-
-echo ""
-
-# we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
-while [ ! -e ${panel_path} ]
-do
- touch ${panel_path}
- sleep 2
-done
-
-if [ ! -n "$action" ]; then
- # default option is balance
- action="balance"
- # load default mode from file
- default_action=`read_cfg_value default_mode`
- if [ "${default_action}" != "" ]; then
- action=${default_action}
- fi
-fi
-
-# perform hotfix
-apply_power_mode ${action}
-
-# save mode for automatic applying mode after reboot
-echo "" > ${panel_path}
-echo "Perfd-opt https://github.com/yc9559/perfd-opt/" >> ${panel_path}
-echo "Author: Matt Yang" >> ${panel_path}
-echo "Platform: sdm845" >> ${panel_path}
-echo "Version: v1 (20190727)" >> ${panel_path}
-echo "" >> ${panel_path}
-echo "[status]" >> ${panel_path}
-echo "Power mode: ${action}" >> ${panel_path}
-echo "Last performed: `date '+%Y-%m-%d %H:%M:%S'`" >> ${panel_path}
-echo "" >> ${panel_path}
-echo "[settings]" >> ${panel_path}
-echo "# Available mode: balance powersave performance fast" >> ${panel_path}
-echo "default_mode=${action}" >> ${panel_path}
-
-echo "${panel_path} has been updated."
-
-echo ""
-
-# suppress stderr
-) 2> /dev/null
-
-exit 0
diff --git a/profiles/sdm845/system/vendor/bin/powercfg_once.sh b/profiles/sdm845/system/vendor/bin/powercfg_once.sh
deleted file mode 100644
index e722352..0000000
--- a/profiles/sdm845/system/vendor/bin/powercfg_once.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Author: Matt Yang
-# Platform: sdm845
-# Version: v1 (20190727)
-
-# Runonce after boot, to speed up the transition of power modes in powercfg
-
-# $1:value $2:file path
-lock_val()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- chmod 0444 ${2}
- fi
-}
-
-# $1:task_name $2:cgroup_name $3:"cpuset"/"stune"
-change_task_cgroup()
-{
- temp_pids=`ps -Ao pid,cmd | grep "${1}" | awk '{print $1}'`
- for temp_pid in ${temp_pids}
- do
- for temp_tid in `ls /proc/${temp_pid}/task/`
- do
- echo ${temp_tid} > /dev/${3}/${2}/tasks
- done
- done
-}
-
-# suppress stderr
-(
-
-# 580M for empty apps
-lock_val "18432,23040,27648,51256,122880,150296" /sys/module/lowmemorykiller/parameters/minfree
-
-# treat crtc_commit as display
-change_task_cgroup "crtc_commit" "display" "cpuset"
-
-# avoid display preemption on big
-lock_val "0-3" /dev/cpuset/display/cpus
-
-# fix laggy bilibili feed scrolling
-change_task_cgroup "servicemanager" "top-app" "cpuset"
-change_task_cgroup "servicemanager" "foreground" "stune"
-change_task_cgroup "android.phone" "top-app" "cpuset"
-change_task_cgroup "android.phone" "foreground" "stune"
-
-# fix laggy home gesture
-change_task_cgroup "system_server" "top-app" "cpuset"
-change_task_cgroup "system_server" "foreground" "stune"
-
-# reduce render thread waiting time
-change_task_cgroup "surfaceflinger" "top-app" "cpuset"
-change_task_cgroup "surfaceflinger" "foreground" "stune"
-
-# unify schedtune misc
-lock_val "0" /dev/stune/background/schedtune.sched_boost_enabled
-lock_val "1" /dev/stune/background/schedtune.sched_boost_no_override
-lock_val "0" /dev/stune/background/schedtune.boost
-lock_val "0" /dev/stune/background/schedtune.prefer_idle
-lock_val "0" /dev/stune/foreground/schedtune.sched_boost_enabled
-lock_val "1" /dev/stune/foreground/schedtune.sched_boost_no_override
-lock_val "0" /dev/stune/foreground/schedtune.boost
-lock_val "0" /dev/stune/foreground/schedtune.prefer_idle
-lock_val "0" /dev/stune/top-app/schedtune.sched_boost_no_override
-
-# CFQ io scheduler takes cgroup into consideration
-lock_val "cfq" /sys/block/sda/queue/scheduler
-# Flash doesn't have back seek problem, so penalty is as low as possible
-lock_val "1" /sys/block/sda/queue/iosched/back_seek_penalty
-# slice_idle = 0 means CFQ IOP mode, https://lore.kernel.org/patchwork/patch/944972/
-lock_val "0" /sys/block/sda/queue/iosched/slice_idle
-# UFS 2.0+ hardware queue depth is 32
-lock_val "16" /sys/block/sda/queue/iosched/quantum
-# lower read_ahead_kb to reduce random access overhead
-lock_val "128" /sys/block/sda/queue/read_ahead_kb
-
-# adreno default settings
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_no_nap
-lock_val "1" /sys/class/kgsl/kgsl-3d0/bus_split
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_bus_on
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_clk_on
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_rail_on
-
-# zram doesn't need much read ahead(random read)
-lock_val "4" /sys/block/zram0/queue/read_ahead_kb
-
-# prefer to use cpu4 & cpu5
-lock_val "0 0 0 1" /sys/devices/system/cpu/cpu4/core_ctl/not_preferred
-
-# suppress stderr
-) 2> /dev/null
diff --git a/profiles/sdm845/system/vendor/etc/perf/commonresourceconfigs.xml b/profiles/sdm845/system/vendor/etc/perf/commonresourceconfigs.xml
index c600900..9837d8a 100644
--- a/profiles/sdm845/system/vendor/etc/perf/commonresourceconfigs.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/commonresourceconfigs.xml
@@ -1,210 +1,210 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
index 2abc761..a30c4a1 100644
--- a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
@@ -16,44 +16,44 @@
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
+ Resources="0x40804000, 2000, 0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 1, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1000, 0x40C18000, 1, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1600, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml
index 5b3c861..73a56ba 100644
--- a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml
@@ -53,7 +53,7 @@
CpufreqGov="1" />
-
+
diff --git a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
index 6db5cfb..468bf43 100644
--- a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
@@ -16,44 +16,44 @@
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
+ Resources="0x40804000, 2400, 0x40800000, 1600, 0x40800100, 1000, 0x40C18000, 30, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1600, 0x40800100, 1000, 0x40C18000, 1, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1600, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
index 11602be..538a3cd 100644
--- a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
@@ -53,7 +53,7 @@
CpufreqGov="1" />
-
+
diff --git a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
index 9f0e7f6..468bf43 100644
--- a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
@@ -16,44 +16,44 @@
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60" />
+ Resources="0x40804000, 2400, 0x40800000, 1600, 0x40800100, 1000, 0x40C18000, 30, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1600, 0x40800100, 1000, 0x40C18000, 1, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40800000, 2000, 0x40800100, 1500" />
+ Resources="0x40800000, 1600, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
index b38f891..6421877 100644
--- a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
@@ -1,59 +1,59 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
index 1304520..d0fed31 100644
--- a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
@@ -53,7 +53,7 @@
CpufreqGov="1" />
-
+
diff --git a/profiles/sdm845/system/vendor/etc/perf/targetresourceconfigs.xml b/profiles/sdm845/system/vendor/etc/perf/targetresourceconfigs.xml
index eccae7c..6a29ece 100644
--- a/profiles/sdm845/system/vendor/etc/perf/targetresourceconfigs.xml
+++ b/profiles/sdm845/system/vendor/etc/perf/targetresourceconfigs.xml
@@ -35,8 +35,6 @@ as anyway perflock calls of these resources would fail. -->
-
-
diff --git a/profiles/sdm855/powercfg_modes.sh b/profiles/sdm855/powercfg_modes.sh
new file mode 100644
index 0000000..9c287ee
--- /dev/null
+++ b/profiles/sdm855/powercfg_modes.sh
@@ -0,0 +1,121 @@
+#!/system/bin/sh
+# Platform Power Modes
+# Perfd-opt https://github.com/yc9559/perfd-opt/
+# Author: Matt Yang
+# Platform: sdm855
+# Version: v3 (20200222)
+
+BASEDIR="$(dirname "$0")"
+. $BASEDIR/pathinfo.sh
+. $BASEDIR/libpowercfg.sh
+
+PLATFORM_NAME="sdm855"
+BWMON_CPU_LLC="soc:qcom,cpu-cpu-llcc-bw"
+BWMON_LLC_DDR="soc:qcom,cpu-llcc-ddr-bw"
+BIG_L3_LAT="soc:qcom,cpu4-cpu-l3-lat"
+BIG_DDR_LAT="soc:qcom,cpu4-llcc-ddr-lat"
+STUNE_BG_CPUS="0-3"
+STUNE_FG_CPUS="0-6"
+
+apply_common()
+{
+ lock_val "15" $SCHED/sched_min_task_util_for_boost
+ lock_val "1000" $SCHED/sched_min_task_util_for_colocation
+ lock_val "700000" $SCHED/sched_little_cluster_coloc_fmin_khz
+ set_governor_param "scaling_governor" "0:schedutil 4:schedutil 7:schedutil"
+ set_governor_param "schedutil/hispeed_load" "0:90 4:90 7:80"
+ set_governor_param "schedutil/hispeed_freq" "0:1113600 4:1286400 7:1612800"
+ set_cpufreq_max "0:9999000 4:9999000 7:9999000"
+ set_cpufreq_dyn_max "0:9999000 4:9999000 7:9999000"
+ lock_val "bw_hwmon" $DEVFREQ/$BWMON_CPU_LLC/governor
+ lock_val "bw_hwmon" $DEVFREQ/$BWMON_LLC_DDR/governor
+ mutate "0" $DEVFREQ/$BWMON_CPU_LLC/min_freq
+ mutate "0" $DEVFREQ/$BWMON_LLC_DDR/min_freq
+ lock_val "8000" $DEVFREQ/$BIG_L3_LAT/mem_latency/ratio_ceil
+ lock_val "800" $DEVFREQ/$BIG_DDR_LAT/mem_latency/ratio_ceil
+ mutate "0" $LPM/lpm_prediction
+ mutate "0" $LPM/sleep_disabled
+}
+
+apply_powersave()
+{
+ set_cpufreq_min "0:300000 4:710400 7:825600"
+ set_cpufreq_max "0:1785600 4:1612800 7:2419200"
+ set_sched_migrate "95 85" "95 60" "140" "100"
+ set_corectl_param "min_cpus" "0:4 4:1 7:0"
+ set_governor_param "schedutil/pl" "0:0 4:0 7:0"
+ lock_val "0:1113600 4:1056000 7:0" $CPU_BOOST/input_boost_freq
+ lock_val "800" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "0" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "15000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "6000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "25" $LPM/bias_hyst
+}
+
+apply_balance()
+{
+ set_cpufreq_min "0:576000 4:710400 7:825600"
+ set_cpufreq_max "0:1785600 4:2016000 7:2649600"
+ set_sched_migrate "95 85" "95 60" "140" "100"
+ set_corectl_param "min_cpus" "0:4 4:2 7:0"
+ set_governor_param "schedutil/pl" "0:0 4:0 7:0"
+ lock_val "0:1113600 4:1056000 7:0" $CPU_BOOST/input_boost_freq
+ lock_val "800" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "0" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "15000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "6000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "25" $LPM/bias_hyst
+}
+
+apply_performance()
+{
+ set_cpufreq_min "0:576000 4:710400 7:825600"
+ set_cpufreq_max "0:1785600 4:2419100 7:2841600"
+ set_sched_migrate "80 80" "80 60" "100" "90"
+ set_corectl_param "min_cpus" "0:4 4:3 7:1"
+ set_governor_param "schedutil/pl" "0:0 4:1 7:1"
+ lock_val "0:1113600 4:1286400 7:0" $CPU_BOOST/input_boost_freq
+ lock_val "2000" $CPU_BOOST/input_boost_ms
+ lock_val "2" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "10" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "16000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "8000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "100" $LPM/bias_hyst
+}
+
+apply_fast()
+{
+ set_cpufreq_min "0:576000 4:1286400 7:1286400"
+ set_cpufreq_max "0:1785600 4:2016000 7:2745600"
+ set_sched_migrate "80 80" "80 60" "100" "90"
+ set_corectl_param "min_cpus" "0:4 4:3 7:1"
+ set_governor_param "schedutil/pl" "0:1 4:1 7:1"
+ lock_val "0:1113600 4:1612800 7:1612800" $CPU_BOOST/input_boost_freq
+ lock_val "2000" $CPU_BOOST/input_boost_ms
+ lock_val "1" $CPU_BOOST/sched_boost_on_input
+ mutate "1" $ST_TOP/schedtune.sched_boost_enabled
+ mutate "30" $ST_TOP/schedtune.boost
+ mutate "1" $ST_TOP/schedtune.prefer_idle
+ mutate "16000" $DEVFREQ/$BWMON_CPU_LLC/max_freq
+ mutate "8000" $DEVFREQ/$BWMON_LLC_DDR/max_freq
+ mutate "1000" $LPM/bias_hyst
+}
+
+apply_once()
+{
+ mutate "$STUNE_FG_CPUS" /dev/cpuset/foreground/cpus
+ lock_val "$STUNE_BG_CPUS" /dev/cpuset/restricted/cpus
+ lock_val "$STUNE_BG_CPUS" /dev/cpuset/display/cpus
+ set_corectl_param "enable" "0:1 4:1 7:1"
+ set_corectl_param "busy_down_thres" "0:20 4:20 7:20"
+ set_corectl_param "busy_up_thres" "0:40 4:40 7:40"
+ set_corectl_param "offline_delay_ms" "0:100 4:100 7:100"
+}
diff --git a/profiles/sdm855/system/vendor/bin/powercfg.sh b/profiles/sdm855/system/vendor/bin/powercfg.sh
deleted file mode 100644
index c4f375c..0000000
--- a/profiles/sdm855/system/vendor/bin/powercfg.sh
+++ /dev/null
@@ -1,311 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Original repo: https://github.com/yc9559/sdm855-tune/
-# Author: Matt Yang
-# Platform: sdm855
-# Version: v1 (20190727)
-
-module_dir="/data/adb/modules/perfd-opt"
-panel_path="/sdcard/powercfg_panel.txt"
-
-# target power mode
-action=$1
-
-# $1:value $2:file path
-lock_val()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- chmod 0444 ${2}
- fi
-}
-
-# $1:value $2:file path
-mutate()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- fi
-}
-
-# stop before updating cfg
-stop_qti_perfd()
-{
- stop perf-hal-1-0
-}
-
-# start after updating cfg
-start_qti_perfd()
-{
- start perf-hal-1-0
-}
-
-# $1:mode(such as balance)
-update_qti_perfd()
-{
- rm /data/vendor/perfd/default_values
- cp -af ${module_dir}/system/vendor/etc/perf/perfd_profiles/${1}/* ${module_dir}/system/vendor/etc/perf/
-}
-
-# $1:key $return:value(string)
-read_cfg_value()
-{
- value=""
- if [ -f ${panel_path} ]; then
- value=`grep "^${1}=" "${panel_path}" | tr -d ' ' | cut -d= -f2`
- fi
- echo ${value}
-}
-
-apply_common()
-{
- # prevent foreground using big cluster, may be override
- mutate "0-3" /dev/cpuset/foreground/cpus
-
- # task_util(p) = p->ravg.demand_scaled <= sysctl_sched_min_task_util_for_boost
- mutate "12" /proc/sys/kernel/sched_min_task_util_for_boost
- mutate "96" /proc/sys/kernel/sched_min_task_util_for_colocation
- # normal colocation util report
- mutate "1000000" /proc/sys/kernel/sched_little_cluster_coloc_fmin_khz
-
- # turn off hotplug to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu0/core_ctl/enable
- # tend to online more cores to balance parallel tasks
- mutate "15" /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres
- mutate "5" /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres
- mutate "100" /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms
- mutate "3" /sys/devices/system/cpu/cpu4/core_ctl/task_thres
- # task usually doesn't run on cpu7
- mutate "15" /sys/devices/system/cpu/cpu7/core_ctl/busy_up_thres
- mutate "10" /sys/devices/system/cpu/cpu7/core_ctl/busy_down_thres
- mutate "100" /sys/devices/system/cpu/cpu7/core_ctl/offline_delay_ms
-
- # unify scaling_min_freq, may be override
- mutate "576000" /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
- mutate "710400" /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
- mutate "825600" /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freq
-
- # unify scaling_max_freq, may be override
- mutate "1785600" /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
- mutate "2419100" /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freq
- mutate "2841600" /sys/devices/system/cpu/cpufreq/policy7/scaling_max_freq
-
- # unify group_migrate, may be override
- mutate "110" /proc/sys/kernel/sched_group_upmigrate
- mutate "100" /proc/sys/kernel/sched_group_downmigrate
-}
-
-apply_powersave()
-{
- # may be override
- mutate "300000" /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
- mutate "710400" /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
- mutate "825600" /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freq
-
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90 60" /proc/sys/kernel/sched_downmigrate
- mutate "90 85" /proc/sys/kernel/sched_upmigrate
- mutate "90 60" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "0" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "0" /dev/stune/top-app/schedtune.boost
- mutate "0" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1113600 4:825600 7:0" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "400" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # limit the usage of big cluster
- lock_val "1" /sys/devices/system/cpu/cpu4/core_ctl/enable
- mutate "0" /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
- # task usually doesn't run on cpu7
- lock_val "1" /sys/devices/system/cpu/cpu7/core_ctl/enable
- mutate "0" /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
-}
-
-apply_balance()
-{
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90 60" /proc/sys/kernel/sched_downmigrate
- mutate "90 85" /proc/sys/kernel/sched_upmigrate
- mutate "90 60" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "0" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "0" /dev/stune/top-app/schedtune.boost
- mutate "0" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1113600 4:825600 7:0" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "400" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # limit the usage of big cluster
- lock_val "1" /sys/devices/system/cpu/cpu4/core_ctl/enable
- mutate "2" /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
- # task usually doesn't run on cpu7
- lock_val "1" /sys/devices/system/cpu/cpu7/core_ctl/enable
- mutate "0" /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
-}
-
-apply_performance()
-{
- # 1708 * 0.95 / 1785 = 90.9
- # higher sched_downmigrate to use little cluster more
- mutate "90 60" /proc/sys/kernel/sched_downmigrate
- mutate "90 85" /proc/sys/kernel/sched_upmigrate
- mutate "90 60" /proc/sys/kernel/sched_downmigrate
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "1" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "10" /dev/stune/top-app/schedtune.boost
- mutate "1" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:1209600 4:1612800 7:0" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "2000" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu4/core_ctl/enable
- mutate "3" /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
- # task usually doesn't run on cpu7
- lock_val "1" /sys/devices/system/cpu/cpu7/core_ctl/enable
- mutate "0" /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
-}
-
-apply_fast()
-{
- # may be override
- mutate "576000" /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
- mutate "1401600" /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
- mutate "1401600" /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freq
-
- # easier to boost
- mutate "16" /proc/sys/kernel/sched_min_task_util_for_boost
- mutate "16" /proc/sys/kernel/sched_min_task_util_for_colocation
- mutate "40 40" /proc/sys/kernel/sched_downmigrate
- mutate "40 60" /proc/sys/kernel/sched_upmigrate
- mutate "40 40" /proc/sys/kernel/sched_downmigrate
-
- # avoid being the bottleneck
- mutate "1440000000" /sys/class/devfreq/soc:qcom,cpu0-cpu-l3-lat/min_freq
- mutate "1440000000" /sys/class/devfreq/soc:qcom,cpu4-cpu-l3-lat/min_freq
- mutate "1440000000" /sys/class/devfreq/soc:qcom,cpu7-cpu-l3-lat/min_freq
-
- # do not use lock_val(), libqti-perfd-client.so will fail to override it
- mutate "1" /dev/stune/top-app/schedtune.sched_boost_enabled
- mutate "20" /dev/stune/top-app/schedtune.boost
- mutate "1" /dev/stune/top-app/schedtune.prefer_idle
-
- lock_val "0:0 4:1804800 7:1804800" /sys/module/cpu_boost/parameters/input_boost_freq
- lock_val "2000" /sys/module/cpu_boost/parameters/input_boost_ms
- lock_val "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
-
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu4/core_ctl/enable
- mutate "3" /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
- # turn off core_ctl to reduce latency
- lock_val "0" /sys/devices/system/cpu/cpu7/core_ctl/enable
- mutate "1" /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
-}
-
-# $1: power_mode
-apply_power_mode()
-{
- case "${1}" in
- "powersave")
- stop_qti_perfd
- apply_common
- apply_powersave
- update_qti_perfd powersave
- start_qti_perfd
- echo "Applying powersave done."
- ;;
- "balance")
- stop_qti_perfd
- apply_common
- apply_balance
- update_qti_perfd balance
- start_qti_perfd
- echo "Applying balance done."
- ;;
- "performance")
- stop_qti_perfd
- apply_common
- apply_performance
- update_qti_perfd performance
- start_qti_perfd
- echo "Applying performance done."
- ;;
- "fast")
- stop_qti_perfd
- apply_common
- apply_fast
- update_qti_perfd fast
- start_qti_perfd
- echo "Applying fast done."
- ;;
- *)
- action="balance"
- stop_qti_perfd
- apply_common
- apply_balance
- update_qti_perfd balance
- start_qti_perfd
- echo "Applying balance done."
- ;;
- esac
-}
-
-# suppress stderr
-(
-
-echo ""
-
-# we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
-while [ ! -e ${panel_path} ]
-do
- touch ${panel_path}
- sleep 2
-done
-
-if [ ! -n "$action" ]; then
- # default option is balance
- action="balance"
- # load default mode from file
- default_action=`read_cfg_value default_mode`
- if [ "${default_action}" != "" ]; then
- action=${default_action}
- fi
-fi
-
-# perform hotfix
-apply_power_mode ${action}
-
-# save mode for automatic applying mode after reboot
-echo "" > ${panel_path}
-echo "Perfd-opt https://github.com/yc9559/perfd-opt/" >> ${panel_path}
-echo "Author: Matt Yang" >> ${panel_path}
-echo "Platform: sdm855" >> ${panel_path}
-echo "Version: v1 (20190727)" >> ${panel_path}
-echo "" >> ${panel_path}
-echo "[status]" >> ${panel_path}
-echo "Power mode: ${action}" >> ${panel_path}
-echo "Last performed: `date '+%Y-%m-%d %H:%M:%S'`" >> ${panel_path}
-echo "" >> ${panel_path}
-echo "[settings]" >> ${panel_path}
-echo "# Available mode: balance powersave performance fast" >> ${panel_path}
-echo "default_mode=${action}" >> ${panel_path}
-
-echo "${panel_path} has been updated."
-
-echo ""
-
-# suppress stderr
-) 2> /dev/null
-
-exit 0
diff --git a/profiles/sdm855/system/vendor/bin/powercfg_once.sh b/profiles/sdm855/system/vendor/bin/powercfg_once.sh
deleted file mode 100644
index 18db633..0000000
--- a/profiles/sdm855/system/vendor/bin/powercfg_once.sh
+++ /dev/null
@@ -1,92 +0,0 @@
-#! /vendor/bin/sh
-# Perfd-opt https://github.com/yc9559/perfd-opt/
-# Original repo: https://github.com/yc9559/sdm855-tune/
-# Author: Matt Yang
-# Platform: sdm855
-# Version: v1 (20190727)
-
-# Runonce after boot, to speed up the transition of power modes in powercfg
-
-# $1:value $2:file path
-lock_val()
-{
- if [ -f ${2} ]; then
- chmod 0666 ${2}
- echo ${1} > ${2}
- chmod 0444 ${2}
- fi
-}
-
-# $1:task_name $2:cgroup_name $3:"cpuset"/"stune"
-change_task_cgroup()
-{
- temp_pids=`ps -Ao pid,cmd | grep "${1}" | awk '{print $1}'`
- for temp_pid in ${temp_pids}
- do
- for temp_tid in `ls /proc/${temp_pid}/task/`
- do
- echo ${temp_tid} > /dev/${3}/${2}/tasks
- done
- done
-}
-
-# suppress stderr
-(
-
-# 580M for empty apps
-lock_val "18432,23040,27648,51256,122880,150296" /sys/module/lowmemorykiller/parameters/minfree
-
-# treat crtc_commit as display
-change_task_cgroup "crtc_commit" "display" "cpuset"
-
-# avoid display preemption on big
-lock_val "0-3" /dev/cpuset/display/cpus
-
-# fix laggy bilibili feed scrolling
-change_task_cgroup "servicemanager" "top-app" "cpuset"
-change_task_cgroup "servicemanager" "foreground" "stune"
-change_task_cgroup "android.phone" "top-app" "cpuset"
-change_task_cgroup "android.phone" "foreground" "stune"
-
-# fix laggy home gesture
-change_task_cgroup "system_server" "top-app" "cpuset"
-change_task_cgroup "system_server" "foreground" "stune"
-
-# reduce render thread waiting time
-change_task_cgroup "surfaceflinger" "top-app" "cpuset"
-change_task_cgroup "surfaceflinger" "foreground" "stune"
-
-# unify schedtune misc
-lock_val "0" /dev/stune/background/schedtune.sched_boost_enabled
-lock_val "1" /dev/stune/background/schedtune.sched_boost_no_override
-lock_val "0" /dev/stune/background/schedtune.boost
-lock_val "0" /dev/stune/background/schedtune.prefer_idle
-lock_val "0" /dev/stune/foreground/schedtune.sched_boost_enabled
-lock_val "1" /dev/stune/foreground/schedtune.sched_boost_no_override
-lock_val "0" /dev/stune/foreground/schedtune.boost
-lock_val "0" /dev/stune/foreground/schedtune.prefer_idle
-lock_val "0" /dev/stune/top-app/schedtune.sched_boost_no_override
-
-# CFQ io scheduler takes cgroup into consideration
-lock_val "cfq" /sys/block/sda/queue/scheduler
-# Flash doesn't have back seek problem, so penalty is as low as possible
-lock_val "1" /sys/block/sda/queue/iosched/back_seek_penalty
-# slice_idle = 0 means CFQ IOP mode, https://lore.kernel.org/patchwork/patch/944972/
-lock_val "0" /sys/block/sda/queue/iosched/slice_idle
-# UFS 2.0+ hardware queue depth is 32
-lock_val "16" /sys/block/sda/queue/iosched/quantum
-# lower read_ahead_kb to reduce random access overhead
-lock_val "128" /sys/block/sda/queue/read_ahead_kb
-
-# adreno default settings
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_no_nap
-lock_val "1" /sys/class/kgsl/kgsl-3d0/bus_split
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_bus_on
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_clk_on
-lock_val "0" /sys/class/kgsl/kgsl-3d0/force_rail_on
-
-# zram doesn't need much read ahead(random read)
-lock_val "4" /sys/block/zram0/queue/read_ahead_kb
-
-# suppress stderr
-) 2> /dev/null
diff --git a/profiles/sdm855/system/vendor/etc/perf/commonresourceconfigs.xml b/profiles/sdm855/system/vendor/etc/perf/commonresourceconfigs.xml
index d3ffb9e..9837d8a 100644
--- a/profiles/sdm855/system/vendor/etc/perf/commonresourceconfigs.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/commonresourceconfigs.xml
@@ -51,7 +51,7 @@ need to be added just before the end of it's major group. -->
-
+
diff --git a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
index cd1a0bf..5b591c1 100644
--- a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml
@@ -16,52 +16,52 @@
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60,0x40C20200, 40, 0x40C1C200, 60" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60,0x40C20200, 40, 0x40C1C200, 60, 0x42C10000, 1,0x40800200, 1600, 0x40800000, 1600, 0x40800100, 1200, 0x41800000, 80, 0x43000000, 58, 0x43400000, 14000" />
+ Resources="0x40804000, 1900, 0x40804200, 2200, 0x40800000, 1000, 0x40800100, 1000, 0x40C18000, 1, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1500, 0x41800000, 80, 0x43000000, 40" />
+ Resources="0x40800000, 1000, 0x40800100, 1000, 0x40C18000, 1, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40804200, 0xFFF, 0x40800000, 2000, 0x40800100, 1500, 0x40800200, 2000" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml
index e0ff56c..de97b7c 100644
--- a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml
@@ -53,8 +53,8 @@
CpufreqGov="1" />
-
-
+
+
diff --git a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
index 8a16450..08f51f5 100644
--- a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml
@@ -16,52 +16,52 @@
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60,0x40C20200, 40, 0x40C1C200, 60" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60,0x40C20200, 40, 0x40C1C200, 60, 0x42C10000, 1,0x40800200, 1600, 0x40800000, 1600, 0x40800100, 1200, 0x41800000, 80, 0x43000000, 58, 0x43400000, 14000" />
+ Resources="0x40804000, 2200, 0x40804200, 2500, 0x40800000, 1600, 0x40800100, 1000, 0x40C18000, 30, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1500, 0x41800000, 80, 0x43000000, 40" />
+ Resources="0x40800000, 1600, 0x40800100, 1000, 0x40C18000, 30, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40804200, 0xFFF, 0x40800000, 2000, 0x40800100, 1500, 0x40800200, 2000" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
index 5275e1c..003e4f8 100644
--- a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml
@@ -53,8 +53,8 @@
CpufreqGov="1" />
-
-
+
+
diff --git a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
index dbc5973..08f51f5 100644
--- a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml
@@ -16,52 +16,52 @@
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60,0x40C20200, 40, 0x40C1C200, 60" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60,0x40C20200, 40, 0x40C1C200, 60, 0x42C10000, 1,0x40800200, 1600, 0x40800000, 1600, 0x40800100, 1200, 0x41800000, 80, 0x43000000, 58, 0x43400000, 14000" />
+ Resources="0x40804000, 2200, 0x40804200, 2500, 0x40800000, 1600, 0x40800100, 1000, 0x40C18000, 30, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1500, 0x41800000, 80, 0x43000000, 40" />
+ Resources="0x40800000, 1600, 0x40800100, 1000, 0x40C18000, 30, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40804200, 0xFFF, 0x40800000, 2000, 0x40800100, 1500, 0x40800200, 2000" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml
index a30b30c..9f54cd1 100644
--- a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml
@@ -54,7 +54,7 @@
-
+
diff --git a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
index 5ab7478..b9897c6 100644
--- a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml
@@ -16,52 +16,52 @@
-
+
-
+
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60,0x40C20200, 40, 0x40C1C200, 60" />
+ Resources="0x40C58000, 45, 0x40C54000, 65, 0x40408000, 99, 0x40C20000, 40, 0x40C1C000, 60,0x40C20200, 40, 0x40C1C200, 60, 0x42C10000, 1,0x40800200, 1600, 0x40800000, 1600, 0x40800100, 1200, 0x41800000, 80, 0x43000000, 58, 0x43400000, 14000" />
+ Resources="0x40804000, 1600, 0x40804200, 2000, 0x40800000, 800, 0x40800100, 1200, 0x40C40000, 15, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x43000000, 25" />
+ Resources="0x40800000, 1200, 0x40800100, 1500, 0x41800000, 80, 0x43000000, 40" />
+ Resources="0x40800000, 800, 0x40800100, 1200, 0x41800000, 80, 0x43000000, 25" />
+ Resources="0x40804000, 0xFFF, 0x40804100, 0xFFF, 0x40804200, 0xFFF, 0x40800000, 2000, 0x40800100, 1500, 0x40800200, 2000" />
+ Resources="0x40800000, 1200, 0x40800100, 1500" />
+ Resources="0x40800100, 1100, 0x4280C000, 500" />
diff --git a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
index 4bfdae5..1028be3 100644
--- a/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml
@@ -54,7 +54,7 @@
-
+
diff --git a/profiles/sdm855/system/vendor/etc/perf/targetresourceconfigs.xml b/profiles/sdm855/system/vendor/etc/perf/targetresourceconfigs.xml
index de45617..0f59c8c 100644
--- a/profiles/sdm855/system/vendor/etc/perf/targetresourceconfigs.xml
+++ b/profiles/sdm855/system/vendor/etc/perf/targetresourceconfigs.xml
@@ -35,8 +35,6 @@ as anyway perflock calls of these resources would fail. -->
-
-
diff --git a/script/libcommon.sh b/script/libcommon.sh
new file mode 100644
index 0000000..3420605
--- /dev/null
+++ b/script/libcommon.sh
@@ -0,0 +1,118 @@
+#!/system/bin/sh
+# Basic Tool Library
+# https://github.com/yc9559/
+# Author: Matt Yang
+# Version: 20200217
+
+BASEDIR="$(dirname "$0")"
+. $BASEDIR/pathinfo.sh
+
+###############################
+# Basic tool functions
+###############################
+
+# $1:value $2:file path
+lock_val()
+{
+ if [ -f "$2" ]; then
+ chmod 0666 "$2" 2> /dev/null
+ echo "$1" > "$2"
+ chmod 0444 "$2" 2> /dev/null
+ fi
+}
+
+# $1:value $2:file path
+mutate()
+{
+ if [ -f "$2" ]; then
+ chmod 0666 "$2" 2> /dev/null
+ echo "$1" > "$2"
+ fi
+}
+
+# $1:value $2:list
+has_val_in_list()
+{
+ for item in $2; do
+ if [ "$1" == "$item" ]; then
+ echo "true"
+ return
+ fi
+ done
+ echo "false"
+}
+
+###############################
+# Config File Operator
+###############################
+
+# $1:key $return:value(string)
+read_cfg_value()
+{
+ local value=""
+ if [ -f "$PANEL_FILE" ]; then
+ value="$(grep "^$1=" "$PANEL_FILE" | head -n 1 | tr -d ' ' | cut -d= -f2)"
+ fi
+ echo "$value"
+}
+
+# $1:content
+write_panel()
+{
+ echo "$1" >> "$PANEL_FILE"
+}
+
+clear_panel()
+{
+ true > "$PANEL_FILE"
+}
+
+wait_until_login()
+{
+ # whether in lock screen, tested on Android 7.1 & 10.0
+ # in case of other magisk module remounting /data as RW
+ while [ "$(dumpsys window policy | grep mInputRestricted=true)" != "" ]; do
+ sleep 2
+ done
+ # we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
+ while [ ! -f "$PANEL_FILE" ]; do
+ touch "$PANEL_FILE"
+ sleep 2
+ done
+}
+
+###############################
+# Cgroup functions
+###############################
+
+# $1:task_name $2:cgroup_name $3:"cpuset"/"stune"
+change_task_cgroup()
+{
+ # avoid matching grep itself
+ # ps -Ao pid,args | grep kswapd
+ # 150 [kswapd0]
+ # 16490 grep kswapd
+ local ps_ret
+ ps_ret="$(ps -Ao pid,args)"
+ for temp_pid in $(echo "$ps_ret" | grep "$1" | awk '{print $1}'); do
+ for temp_tid in $(ls "/proc/$temp_pid/task/"); do
+ echo "$temp_tid" > "/dev/$3/$2/tasks"
+ done
+ done
+}
+
+# $1:task_name $2:hex_mask(0x00000003 is CPU0 and CPU1)
+change_task_affinity()
+{
+ # avoid matching grep itself
+ # ps -Ao pid,args | grep kswapd
+ # 150 [kswapd0]
+ # 16490 grep kswapd
+ local ps_ret
+ ps_ret="$(ps -Ao pid,args)"
+ for temp_pid in $(echo "$ps_ret" | grep "$1" | awk '{print $1}'); do
+ for temp_tid in $(ls "/proc/$temp_pid/task/"); do
+ taskset -p "$2" "$temp_tid"
+ done
+ done
+}
diff --git a/script/libpowercfg.sh b/script/libpowercfg.sh
new file mode 100644
index 0000000..712637f
--- /dev/null
+++ b/script/libpowercfg.sh
@@ -0,0 +1,133 @@
+#!/system/bin/sh
+# Powercfg Library
+# https://github.com/yc9559/
+# Author: Matt Yang
+# Version: 20200216
+
+BASEDIR="$(dirname "$0")"
+. $BASEDIR/pathinfo.sh
+. $BASEDIR/libcommon.sh
+
+###############################
+# PATHs
+###############################
+
+PERFCFG_REL="./system/vendor/etc/perf"
+
+###############################
+# Abbreviations
+###############################
+
+SCHED="/proc/sys/kernel"
+CPU="/sys/devices/system/cpu"
+CPU_BOOST="/sys/module/cpu_boost/parameters"
+KSGL="/sys/class/kgsl/kgsl-3d0"
+DEVFREQ="/sys/class/devfreq"
+LPM="/sys/module/lpm_levels/parameters"
+MSM_PERF="/sys/module/msm_performance/parameters"
+ST_TOP="/dev/stune/top-app"
+ST_FORE="/dev/stune/foreground"
+ST_BACK="/dev/stune/background"
+SDA_Q="/sys/block/sda/queue"
+
+###############################
+# Powermodes helper functions
+###############################
+
+# $1:keyword $2:nr_max_matched
+get_package_name_by_keyword()
+{
+ echo "$(pm list package | grep "$1" | head -n "$2" | cut -d: -f2)"
+}
+
+# $1:"0:576000 4:710400 7:825600"
+set_cpufreq_min()
+{
+ mutate "$1" $MSM_PERF/cpu_min_freq
+ local key
+ local val
+ for kv in $1; do
+ key=${kv%:*}
+ val=${kv#*:}
+ mutate "$val" $CPU/cpu$key/cpufreq/scaling_min_freq
+ done
+}
+
+# $1:"0:576000 4:710400 7:825600"
+set_cpufreq_max()
+{
+ mutate "$1" $MSM_PERF/cpu_max_freq
+}
+
+# $1:"0:576000 4:710400 7:825600"
+set_cpufreq_dyn_max()
+{
+ local key
+ local val
+ for kv in $1; do
+ key=${kv%:*}
+ val=${kv#*:}
+ mutate "$val" $CPU/cpu$key/cpufreq/scaling_max_freq
+ done
+}
+
+# $1:"schedutil/pl" $2:"0:4 4:3 7:1"
+set_governor_param()
+{
+ local key
+ local val
+ for kv in $2; do
+ key=${kv%:*}
+ val=${kv#*:}
+ mutate "$val" $CPU/cpu$key/cpufreq/$1
+ done
+}
+
+# $1:"min_cpus" $2:"0:4 4:3 7:1"
+set_corectl_param()
+{
+ local key
+ local val
+ for kv in $2; do
+ key=${kv%:*}
+ val=${kv#*:}
+ mutate "$val" $CPU/cpu$key/core_ctl/$1
+ done
+}
+
+# $1:upmigrate $2:downmigrate $3:group_upmigrate $4:group_downmigrate
+set_sched_migrate()
+{
+ mutate "$2" $SCHED/sched_downmigrate
+ mutate "$1" $SCHED/sched_upmigrate
+ mutate "$2" $SCHED/sched_downmigrate
+ mutate "$4" $SCHED/sched_group_downmigrate
+ mutate "$3" $SCHED/sched_group_upmigrate
+ mutate "$4" $SCHED/sched_group_downmigrate
+}
+
+###############################
+# QTI perf framework functions
+###############################
+
+# stop before updating cfg
+stop_qti_perfd()
+{
+ stop perf-hal-1-0
+ stop perf-hal-2-0
+ usleep 500
+}
+
+# start after updating cfg
+start_qti_perfd()
+{
+ start perf-hal-1-0
+ start perf-hal-2-0
+}
+
+# $1:mode(such as balance)
+update_qti_perfd()
+{
+ rm /data/vendor/perfd/default_values
+ cp -af "$MODULE_PATH/$PERFCFG_REL/perfd_profiles/$1"/* "$MODULE_PATH/$PERFCFG_REL/"
+}
diff --git a/script/pathinfo.sh b/script/pathinfo.sh
new file mode 100644
index 0000000..5820086
--- /dev/null
+++ b/script/pathinfo.sh
@@ -0,0 +1,10 @@
+#!/system/bin/sh
+# Module Path Header
+# https://github.com/yc9559/
+# Author: Matt Yang
+
+SCRIPT_DIR="/script"
+BIN_DIR="/bin"
+MODULE_PATH="$(dirname $(readlink -f "$0"))"
+MODULE_PATH="${MODULE_PATH%$SCRIPT_DIR}"
+PANEL_FILE="/sdcard/Android/panel_powercfg.txt"
diff --git a/script/powercfg.sh b/script/powercfg.sh
new file mode 100644
index 0000000..ba82367
--- /dev/null
+++ b/script/powercfg.sh
@@ -0,0 +1,69 @@
+#!/system/bin/sh
+# Perfd-opt https://github.com/yc9559/perfd-opt/
+# Original repo: https://github.com/yc9559/sdm855-tune/
+# Author: Matt Yang
+# Platform: sdm855
+# Version: v3 (20200222)
+
+BASEDIR="$(dirname "$0")"
+. $BASEDIR/libcommon.sh
+. $BASEDIR/libpowercfg.sh
+. $BASEDIR/powercfg_modes.sh
+
+# $1: power_mode
+apply_power_mode()
+{
+ stop_qti_perfd
+ apply_common
+ eval apply_$1
+ update_qti_perfd "$1"
+ start_qti_perfd
+ echo "Applying $1 done."
+}
+
+# $1: power_mode
+verify_power_mode()
+{
+ case "$1" in
+ "powersave"|"balance"|"performance"|"fast") echo "$1";;
+ *) echo "balance" ;;
+ esac
+}
+
+save_panel()
+{
+ clear_panel
+ write_panel ""
+ write_panel "Perfd-opt"
+ write_panel "https://github.com/yc9559/perfd-opt/"
+ write_panel "Author: Matt Yang"
+ write_panel "Platform: $PLATFORM_NAME"
+ write_panel "Version: v3 (20200222)"
+ write_panel "Last performed: $(date '+%Y-%m-%d %H:%M:%S')"
+ write_panel ""
+ write_panel "[current status]"
+ write_panel "Power mode: $action"
+ write_panel ""
+ write_panel "[settings]"
+ write_panel "# Available mode: balance powersave performance fast"
+ write_panel "default_mode=$default_mode"
+}
+
+wait_until_login
+
+# 1. target from exec parameter
+action="$1"
+# 2. target from panel
+default_mode="$(read_cfg_value default_mode)"
+[ "$action" == "" ] && action="$default_mode"
+# 3. target from default(=balance)
+action="$(verify_power_mode "$action")"
+default_mode="$(verify_power_mode "$default_mode")"
+
+# perform hotfix
+apply_power_mode "$action"
+
+# save mode for automatic applying mode after reboot
+save_panel
+
+exit 0
diff --git a/script/powercfg_once.sh b/script/powercfg_once.sh
new file mode 100644
index 0000000..8861bbd
--- /dev/null
+++ b/script/powercfg_once.sh
@@ -0,0 +1,78 @@
+#!/system/bin/sh
+# Perfd-opt https://github.com/yc9559/perfd-opt/
+# Original repo: https://github.com/yc9559/sdm855-tune/
+# Author: Matt Yang
+# Platform: sdm855
+# Version: v3 (20200222)
+
+# Runonce after boot, to speed up the transition of power modes in powercfg
+
+BASEDIR="$(dirname "$0")"
+. $BASEDIR/libcommon.sh
+. $BASEDIR/libpowercfg.sh
+. $BASEDIR/powercfg_modes.sh
+
+# prefer to use prev cpu, decrease jitter from 0.5ms to 0.3ms with lpm settings
+lock_val "15000000" $SCHED/sched_migration_cost_ns
+
+# OnePlus opchain pins UX threads on the big cluster
+lock_val "0" /sys/module/opchain/parameters/chain_on
+
+# unify schedtune misc
+# android 10 doesn't have schedtune.sched_boost_enabled exposed, default = true
+lock_val "0" $ST_BACK/schedtune.sched_boost_enabled
+lock_val "0" $ST_BACK/schedtune.sched_boost_no_override
+lock_val "0" $ST_BACK/schedtune.boost
+lock_val "0" $ST_BACK/schedtune.prefer_idle
+lock_val "0" $ST_FORE/schedtune.sched_boost_enabled
+lock_val "0" $ST_FORE/schedtune.sched_boost_no_override
+lock_val "0" $ST_FORE/schedtune.boost
+lock_val "1" $ST_FORE/schedtune.prefer_idle
+lock_val "0" $ST_TOP/schedtune.sched_boost_no_override
+
+# CFQ io scheduler takes cgroup into consideration
+lock_val "cfq" $SDA_Q/scheduler
+# Flash doesn't have back seek problem, so penalty is as low as possible
+lock_val "1" $SDA_Q/iosched/back_seek_penalty
+# slice_idle = 0 means CFQ IOP mode, https://lore.kernel.org/patchwork/patch/944972/
+lock_val "0" $SDA_Q/iosched/slice_idle
+# UFS 2.0+ hardware queue depth is 32
+lock_val "16" $SDA_Q/iosched/quantum
+# lower read_ahead_kb to reduce random access overhead
+lock_val "128" $SDA_Q/read_ahead_kb
+
+# Reserve 90% IO bandwith for foreground tasks
+lock_val "1000" /dev/blkio/blkio.weight
+lock_val "1000" /dev/blkio/blkio.leaf_weight
+lock_val "100" /dev/blkio/background/blkio.weight
+lock_val "100" /dev/blkio/background/blkio.leaf_weight
+
+# save ~100mw under light 3D workload
+lock_val "0" $KSGL/force_no_nap
+lock_val "1" $KSGL/bus_split
+lock_val "0" $KSGL/force_bus_on
+lock_val "0" $KSGL/force_clk_on
+lock_val "0" $KSGL/force_rail_on
+
+# treat crtc_commit as background, avoid display preemption on big
+change_task_cgroup "crtc_commit" "background" "cpuset"
+
+# fix laggy bilibili feed scrolling
+change_task_cgroup "servicemanager" "top-app" "cpuset"
+change_task_cgroup "servicemanager" "foreground" "stune"
+change_task_cgroup "android.phone" "top-app" "cpuset"
+change_task_cgroup "android.phone" "foreground" "stune"
+
+# fix laggy home gesture
+change_task_cgroup "system_server" "top-app" "cpuset"
+change_task_cgroup "system_server" "foreground" "stune"
+
+# reduce render thread waiting time
+change_task_cgroup "surfaceflinger" "top-app" "cpuset"
+change_task_cgroup "surfaceflinger" "foreground" "stune"
+
+# reduce big cluster wakeup, eg. android.hardware.sensors@1.0-service
+change_task_affinity ".hardware." "0f"
+
+# platform specific
+apply_once
diff --git a/script/settings_override.sh b/script/settings_override.sh
new file mode 100644
index 0000000..6c50a84
--- /dev/null
+++ b/script/settings_override.sh
@@ -0,0 +1,10 @@
+#!/system/bin/sh
+# Perfd-opt https://github.com/yc9559/perfd-opt/
+# Original repo: https://github.com/yc9559/sdm855-tune/
+# Author: Matt Yang
+# Platform: sdm855
+# Version: v3 (20200222)
+
+# smoother oneplus launcher gesture animation, not relying on window_animation_scale
+# /vendor/bin/sh: settings: inaccessible or not found
+# settings put global animator_duration_scale 1.15
diff --git a/common/vtools-powercfg-base.sh b/script/vtools-powercfg.sh
similarity index 96%
rename from common/vtools-powercfg-base.sh
rename to script/vtools-powercfg.sh
index 726b0c8..8b4a45f 100644
--- a/common/vtools-powercfg-base.sh
+++ b/script/vtools-powercfg.sh
@@ -5,4 +5,3 @@
# powercfg wrapper for com.omarea.vtools
# MAKE SURE THAT THE MAGISK MODULE "Perfd-opt" HAS BEEN INSTALLED
-exit 0