Skip to content

Commit

Permalink
v3 (20200217)
Browse files Browse the repository at this point in the history
新增:关闭一加固定UI线程在大核的opchain,与其他平台统一
新增:使用prefer_idle+boost方案固定topapp在大核,放弃colocate与sched_boost方案
新增:所有性能模式启用top-app的prefer_idle,在小核都有进程占用的情况唤醒任务到大核
新增:调整C-state降低UiBench渲染抖动40%,C0与C3在低频率未见显著功耗差异
新增:滑动时提升cpullccbw/cpubw的最小频率避免成为瓶颈
新增:调整不同性能模式的llcc带宽和ddr带宽限制,降低一点DDR功耗
新增:降低大核访存缓存命中率降低时提升DDR频率的阈值,减少小掉帧(90fps)
新增:使用blkio保留90%的IO带宽给前台进程
新增:限制传感器服务相关线程在小核集群,减少唤醒大核集群
新增:同步qti-mem-opt的libcommon,libpowercfg,path header
改进:panel的default_mode不会随着热切换而改变了
改进:各个性能模式频率范围调整,见项目连接内的readme
改进:滑动时foreground分组只使用小核
改进:执行脚本不再依赖于sh文件可执行权限
改进:读取目标性能模式的逻辑更加通顺
改进:加大一点二段式app启动boost的时长
改进:全部去除QTI Boost Framework对sched_boost的设置,改用其他方式实现类似效果
修复:在Android 10没有sched_boost_enabled,改用其他方式实现类似效果
修复:最大频率限制不再只靠targetconfig,补上mem_performance频率范围设置
修复:补上cpuset/restricted分组的cpu限制
修复:减少perf框架的一些报警

Signed-off-by: Matt Yang <yccy@outlook.com>
  • Loading branch information
yc9559 committed Feb 22, 2020
1 parent e368bc8 commit 32b4f6e
Show file tree
Hide file tree
Showing 57 changed files with 2,119 additions and 2,761 deletions.
69 changes: 27 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
24 changes: 18 additions & 6 deletions common/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 0 additions & 18 deletions common/vtools-powercfg.sh

This file was deleted.

54 changes: 28 additions & 26 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion module.prop
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
138 changes: 138 additions & 0 deletions profiles/sdm675_730/powercfg_modes.sh
Original file line number Diff line number Diff line change
@@ -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"
}
Loading

0 comments on commit 32b4f6e

Please sign in to comment.