Skip to content

Commit

Permalink
v1 (20200516)
Browse files Browse the repository at this point in the history
uperf:修复定时器回调导致死锁,使用独立延时任务线程
uperf:恢复进入overlay类型hint之前的base类型hint,如果还在base类型hint的时间范围内
uperf:推测发生解锁屏幕这一方法存在少量漏检,因此在屏幕熄灭时收到渲染滞后通知也作为`AndroidAM`事件处理
uperf:如果负载真的特别低(30% idleload),应该立即退出重负载
配置文件生成器:因为允许sflag->androidam,必须设置对应动作的最小频率
配置文件生成器:略微提升heavyload目标阈值
once:当SfAnalysis注入失败后设置SELinux为permissive后,再次尝试注入
makefile:uperf提供32/64位双版本
readme:完成初版文档

Signed-off-by: Matt Yang <[email protected]>
  • Loading branch information
yc9559 committed May 16, 2020
1 parent fdbf037 commit 2019ea5
Show file tree
Hide file tree
Showing 19 changed files with 587 additions and 78 deletions.
579 changes: 546 additions & 33 deletions README.md

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions magisk/initsvc_uperf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ BASEDIR="$(dirname $(readlink -f "$0"))"
wait_until_login()
{
# we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
local test_file
test_file="/sdcard/Android/$(mktemp -u XXXXXXXX)"
while [ ! -d "/sdcard/Android" ]; do
sleep 1
done

local test_file="/sdcard/Android/.PERMISSION_TEST"
touch "$test_file"
while [ ! -f "$test_file" ]; do
touch "$test_file"
sleep 1
Expand Down
4 changes: 2 additions & 2 deletions magisk/makezip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ python3 make_configs.py
cd ..

echo "Copy files from project..."
cp uperf magisk/bin/
cp -r build/uperf magisk/uperf/
cp -r build/configs/ magisk/config

echo "Make flashable magisk package..."
Expand All @@ -22,7 +22,7 @@ rm "$zipname"
zip "$zipname" -q -9 -r . -x makezip.sh

echo "Cleanup..."
rm bin/uperf
rm -r uperf
rm -r config

echo "Make zip done."
2 changes: 1 addition & 1 deletion magisk/module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=uperf
name=Uperf
version=DEV 20200513
version=v1 (20200516)
versionCode=1
author=Matt Yang
description=Userspace performance controller for android. Repo: https://github.com/yc9559/uperf/
Expand Down
10 changes: 7 additions & 3 deletions magisk/script/libcommon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Basic Tool Library
# https://github.com/yc9559/
# Author: Matt Yang
# Version: 20200513
# Version: 20200516

BASEDIR="$(dirname "$0")"
. $BASEDIR/pathinfo.sh
Expand Down Expand Up @@ -70,8 +70,12 @@ clear_panel()
wait_until_login()
{
# we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
local test_file
test_file="/sdcard/Android/$(mktemp -u XXXXXXXX)"
while [ ! -d "/sdcard/Android" ]; do
sleep 1
done

local test_file="/sdcard/Android/.PERMISSION_TEST"
touch "$test_file"
while [ ! -f "$test_file" ]; do
touch "$test_file"
sleep 1
Expand Down
2 changes: 1 addition & 1 deletion magisk/script/powercfg_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ save_panel()
write_panel ""
write_panel "Uperf https://github.com/yc9559/uperf/"
write_panel "Author: Matt Yang"
write_panel "Version: DEV 20200513"
write_panel "Version: v1 (20200516)"
write_panel "Last performed: $(date '+%Y-%m-%d %H:%M:%S')"
write_panel ""
write_panel "[Uperf status]"
Expand Down
27 changes: 2 additions & 25 deletions magisk/script/powercfg_once.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ lock_val "0" $KSGL/force_bus_on
lock_val "0" $KSGL/force_clk_on
lock_val "0" $KSGL/force_rail_on

# # cleanup top-app cpuset
# for p in $(cat /dev/cpuset/top-app/tasks); do
# echo "$p" > /dev/cpuset/foreground/tasks
# done

# treat crtc_commit as background, avoid display preemption on big
change_task_cgroup "crtc_commit" "background" "cpuset"

Expand Down Expand Up @@ -82,8 +77,8 @@ change_task_affinity ".hardware.camera.provider" "ff"
change_task_affinity ".hardware.display" "ff"

# provide best performance for fingerprint service
change_task_cgroup ".hardware.biometrics." "rt" "stune"
change_task_nice ".hardware.biometrics." "-20"
change_task_cgroup ".hardware.biometrics.fingerprint" "rt" "stune"
change_task_nice ".hardware.biometrics.fingerprint" "-20"
mutate "100" $ST_RT/schedtune.boost
mutate "1" $ST_RT/schedtune.prefer_idle

Expand Down Expand Up @@ -155,30 +150,12 @@ stop oneplus_brain_service
# stop vendor.power-hal-1-3

# try to disable all hotplug
# Qualcomm Battery Current Limit
for mode in /sys/devices/soc.0/qcom,bcl.*/mode; do
echo -n "disable" > $mode
done
for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask; do
lock_val "0" $hotplug_mask
done
for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask; do
lock_val "0" $hotplug_soc_mask
done
for mode in /sys/devices/soc.0/qcom,bcl.*/mode; do
echo -n "enable" > $mode
done
# Exynos hotplug
mutate "0" /sys/power/cpuhotplug/enabled
mutate "0" $CPU/cpuhotplug/enabled
# turn off msm_thermal
lock_val "0" /sys/module/msm_thermal/core_control/enabled
lock_val "N" /sys/module/msm_thermal/parameters/enabled
# maybe CAF
lock_val "0" /proc/sys/kernel/hotplug
lock_val "1" $CPU/cpu0/rq-stats/hotplug_disable
# AllWinner H6
lock_val "1" /sys/kernel/autohotplug/boost_all
# 3rd
lock_val "0" /sys/kernel/intelli_plug/intelli_plug_active
lock_val "0" /sys/module/blu_plug/parameters/enabled
Expand Down
14 changes: 9 additions & 5 deletions magisk/script/start_sfanalysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Surfaceflinger Analysis Library
# https://github.com/yc9559/
# Author: Matt Yang
# Version: 20200513
# Version: 20200516

BASEDIR="$(dirname "$0")"
. $BASEDIR/pathinfo.sh
Expand Down Expand Up @@ -35,13 +35,17 @@ sfa_start()
fi

# fallback to standlone mode
if [ ! -f "$lib_path" ]; then
lib_path="$MODULE_PATH/$lib_path"
# setenforce 0
fi
[ ! -f "$lib_path" ] && lib_path="$MODULE_PATH/$lib_path"

echo "$(date '+%Y-%m-%d %H:%M:%S')" > /cache/injector.log
"$MODULE_PATH/$SFA_REL/$SFA_NAME" "/system/bin/surfaceflinger" "$lib_path" >> /cache/injector.log

# injection failed. Retry after setting SELinux to permissive
if [ "$?" != "0" ]; then
setenforce 0
echo "Retry after setting SELinux to permissive." >> /cache/injector.log
"$MODULE_PATH/$SFA_REL/$SFA_NAME" "/system/bin/surfaceflinger" "$lib_path" >> /cache/injector.log
fi
}

[ -f "$MODULE_PATH/enable_sfanalysis" ] && sfa_start
19 changes: 13 additions & 6 deletions magisk/setup_uperf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Uperf Setup
# https://github.com/yc9559/
# Author: Matt Yang & cjybyjk ([email protected])
# Version: 20200513
# Version: 20200516

BASEDIR="$(dirname $(readlink -f "$0"))"

Expand Down Expand Up @@ -299,7 +299,7 @@ uperf_print_banner()
echo ""
echo "* Uperf https://github.com/yc9559/uperf/"
echo "* Author: Matt Yang"
echo "* Version: DEV 20200513"
echo "* Version: v1 (20200516)"
echo ""
}

Expand All @@ -318,14 +318,21 @@ uperf_install()
if [ "$cfgname" != "unsupported" ]; then
echo "- The platform name is $target. Use $cfgname.json"
_setup_platform_file "$cfgname"
_set_perm_recursive $BASEDIR 0 0 0755 0644
_set_perm_recursive $BASEDIR/bin 0 0 0755 0755
# in case of set_perm_recursive is broken
chmod 0755 $BASEDIR/bin/*
else
_abort "! [$target] not supported."
fi

if [ "$(_is_aarch64)" == "true" ]; then
cp "$BASEDIR/uperf/arm64-v8a/uperf" "$BASEDIR/bin"
else
cp "$BASEDIR/uperf/armeabi-v7a/uperf" "$BASEDIR/bin"
fi

_set_perm_recursive $BASEDIR 0 0 0755 0644
_set_perm_recursive $BASEDIR/bin 0 0 0755 0755
# in case of set_perm_recursive is broken
chmod 0755 $BASEDIR/bin/*

echo "- Uperf installation was successful."
}

Expand Down
Binary file modified magisk/sfanalysis/arm64-v8a/injector
Binary file not shown.
Binary file modified magisk/sfanalysis/armeabi-v7a/injector
Binary file not shown.
Binary file added media/adjusted_demand_capacity_relation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/alipay-qr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/android_am.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/fingerprint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/render_restart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/render_stop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sflag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/wechat_resume.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2019ea5

Please sign in to comment.