diff --git a/magisk/README.md b/magisk/README.md deleted file mode 100644 index f084ba7..0000000 --- a/magisk/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Uperf - - -## Requirements - -1. Android >= 8.0 -2. Rooted -3. Magisk >= 17.0 - -## Installation - -1. Download zip in [Release Page](https://github.com/yc9559/uperf/releases) -2. Flash in Magisk manager -3. Reboot -4. Check whether `/sdcard/Android/panel_uperf.txt` exists - -## Switch modes - -### Switching on boot - -1. Open `/sdcard/Android/panel_uperf.txt` -2. Edit line `default_mode=balance`, where `balance` is the default mode applied at boot -3. Reboot - -### Switching after boot - -Option 1: -Exec `sh /data/powercfg.sh balance`, where `balance` is the mode you want to switch. - -Option 2: -Install [vtools](https://www.coolapk.com/apk/com.omarea.vtools) and bind APPs to power mode. - -## Credit - -```plain -``` diff --git a/magisk/initsvc_uperf.sh b/magisk/initsvc_uperf.sh index 27e8b17..3200b17 100755 --- a/magisk/initsvc_uperf.sh +++ b/magisk/initsvc_uperf.sh @@ -9,11 +9,15 @@ BASEDIR="$(dirname $(readlink -f "$0"))" wait_until_login() { # we doesn't have the permission to rw "/sdcard" before the user unlocks the screen - while [ ! -d "/sdcard/Android" ]; do - sleep 2 + local test_file + test_file="/sdcard/Android/$(mktemp -u XXXXXXXX)" + while [ ! -f "$test_file" ]; do + touch "$test_file" + sleep 1 done + rm "$test_file" } wait_until_login -sleep 60 +# do not sleep 60, may causing MIUI 12 launcher freezed by sfanalysis sh $BASEDIR/run_uperf.sh diff --git a/magisk/module.prop b/magisk/module.prop index d87f954..74049d7 100644 --- a/magisk/module.prop +++ b/magisk/module.prop @@ -1,6 +1,6 @@ id=uperf name=Uperf -version=DEV 20200507 +version=DEV 20200513 versionCode=1 author=Matt Yang description=Userspace performance controller for android. Repo: https://github.com/yc9559/uperf/ diff --git a/magisk/run_uperf.sh b/magisk/run_uperf.sh index 4f7cd60..8ccbb12 100755 --- a/magisk/run_uperf.sh +++ b/magisk/run_uperf.sh @@ -16,6 +16,6 @@ chmod 755 /data/powercfg-base.sh # powercfg path provided by magisk module echo "sh $SCRIPT_DIR/powercfg_main.sh \"\$1\"" >> /data/powercfg.sh -# not relying on executable permissions +sh $SCRIPT_DIR/start_sfanalysis.sh sh $SCRIPT_DIR/powercfg_main.sh sh $SCRIPT_DIR/powercfg_once.sh diff --git a/magisk/script/libcommon.sh b/magisk/script/libcommon.sh index 03a88b1..d2c5f71 100644 --- a/magisk/script/libcommon.sh +++ b/magisk/script/libcommon.sh @@ -2,7 +2,7 @@ # Basic Tool Library # https://github.com/yc9559/ # Author: Matt Yang -# Version: 20200507 +# Version: 20200513 BASEDIR="$(dirname "$0")" . $BASEDIR/pathinfo.sh @@ -70,9 +70,13 @@ clear_panel() wait_until_login() { # we doesn't have the permission to rw "/sdcard" before the user unlocks the screen - while [ ! -d "/sdcard/Android" ]; do - sleep 2 + local test_file + test_file="/sdcard/Android/$(mktemp -u XXXXXXXX)" + while [ ! -f "$test_file" ]; do + touch "$test_file" + sleep 1 done + rm "$test_file" } ############################### diff --git a/magisk/script/libuperf.sh b/magisk/script/libuperf.sh index 93dc33f..db67eb7 100644 --- a/magisk/script/libuperf.sh +++ b/magisk/script/libuperf.sh @@ -20,7 +20,7 @@ UPERF_NAME="uperf" ############################### uperf_config_path="$MODULE_PATH/config/cfg_uperf.json" -uperf_log_path="/sdcard/Android/log_uperf.log" +uperf_log_path="/sdcard/Android/log_uperf.txt" uperf_powermode_node="/data/uperf_powermode" # $1:mode_name @@ -52,6 +52,10 @@ uperf_start() lock_val "131072" /proc/sys/fs/inotify/max_user_watches lock_val "1024" /proc/sys/fs/inotify/max_user_instances + # cleanup + rm /sdcard/Android/log_uperf.log + rm /sdcard/Android/log_uperf.log.bak + # start uperf "$MODULE_PATH/$UPERF_REL/$UPERF_NAME" -o "$uperf_log_path" "$uperf_config_path" 2>> "$uperf_log_path" # waiting for uperf initialization diff --git a/magisk/script/powercfg_main.sh b/magisk/script/powercfg_main.sh index 1c84dbc..7cacaf1 100644 --- a/magisk/script/powercfg_main.sh +++ b/magisk/script/powercfg_main.sh @@ -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 20200507" + write_panel "Version: DEV 20200513" write_panel "Last performed: $(date '+%Y-%m-%d %H:%M:%S')" write_panel "" write_panel "[Uperf status]" diff --git a/magisk/script/powercfg_once.sh b/magisk/script/powercfg_once.sh index e132ccf..858487e 100644 --- a/magisk/script/powercfg_once.sh +++ b/magisk/script/powercfg_once.sh @@ -8,7 +8,6 @@ BASEDIR="$(dirname "$0")" . $BASEDIR/libcommon.sh . $BASEDIR/libpowercfg.sh . $BASEDIR/libuperf.sh -. $BASEDIR/libsfanalysis.sh # unify schedtune misc # android 10 doesn't have schedtune.sched_boost_enabled exposed, default = true @@ -71,20 +70,20 @@ change_thread_cgroup "system_server" "android.ui" "top-app" "stune" # ...and pin HeapTaskDaemon on LITTLE change_thread_cgroup "system_server" "HeapTaskDaemon" "background" "cpuset" -# # reduce big cluster wakeup, eg. android.hardware.sensors@1.0-service -# change_task_cgroup ".hardware." "background" "cpuset" -# change_task_affinity ".hardware." "0f" -# # ...but exclude fingerprint&camera&display service for speed -# change_task_cgroup ".hardware.biometrics.fingerprint" "" "cpuset" -# change_task_cgroup ".hardware.camera.provider" "" "cpuset" -# change_task_cgroup ".hardware.display" "" "cpuset" -# change_task_affinity ".hardware.biometrics.fingerprint" "ff" -# change_task_affinity ".hardware.camera.provider" "ff" -# change_task_affinity ".hardware.display" "ff" +# reduce big cluster wakeup, eg. android.hardware.sensors@1.0-service +change_task_cgroup ".hardware." "background" "cpuset" +change_task_affinity ".hardware." "0f" +# ...but exclude fingerprint&camera&display service for speed +change_task_cgroup ".hardware.biometrics.fingerprint" "" "cpuset" +change_task_cgroup ".hardware.camera.provider" "" "cpuset" +change_task_cgroup ".hardware.display" "" "cpuset" +change_task_affinity ".hardware.biometrics.fingerprint" "ff" +change_task_affinity ".hardware.camera.provider" "ff" +change_task_affinity ".hardware.display" "ff" # provide best performance for fingerprint service -change_task_cgroup ".hardware.biometrics.fingerprint" "rt" "stune" -change_task_nice ".hardware.biometrics.fingerprint" "-20" +change_task_cgroup ".hardware.biometrics." "rt" "stune" +change_task_nice ".hardware.biometrics." "-20" mutate "100" $ST_RT/schedtune.boost mutate "1" $ST_RT/schedtune.prefer_idle @@ -141,9 +140,10 @@ lock_val "0" /sys/module/cpu_input_boost/parameters/flex_boost_freq_hp lock_val "0" /sys/module/cpu_input_boost/parameters/flex_boost_freq_lp lock_val "0" /sys/module/devfreq_boost/parameters/input_boost_duration -# stop qualcomm perfd +# try to disable all other userspace performance daemon +# Qualcomm perfd stop perfd -# stop qualcomm perfd +# Qualcomm perfhal perfhal_stop # brain service maybe not smart stop oneplus_brain_service @@ -154,12 +154,37 @@ stop oneplus_brain_service # stop vendor.power-hal-1-2 # 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 +lock_val "0" /sys/devices/virtual/misc/mako_hotplug_control/enabled +lock_val "0" /sys/module/autosmp/parameters/enabled +lock_val "0" /sys/kernel/zen_decision/enabled # bring all cores online for i in 0 1 2 3 4 5 6 7 8 9; do mutate "1" $CPU/cpu$i/online @@ -225,9 +250,6 @@ lock_val "1" $LPM/lpm_prediction lock_val "0" $LPM/sleep_disabled lock_val "25" $LPM/bias_hyst -# start surfaceflinger analysis -sfa_start - # start uperf once only uperf_stop uperf_start diff --git a/magisk/script/libsfanalysis.sh b/magisk/script/start_sfanalysis.sh similarity index 93% rename from magisk/script/libsfanalysis.sh rename to magisk/script/start_sfanalysis.sh index 3d77c99..3ccc73a 100644 --- a/magisk/script/libsfanalysis.sh +++ b/magisk/script/start_sfanalysis.sh @@ -2,7 +2,7 @@ # Surfaceflinger Analysis Library # https://github.com/yc9559/ # Author: Matt Yang -# Version: 20200507 +# Version: 20200513 BASEDIR="$(dirname "$0")" . $BASEDIR/pathinfo.sh @@ -43,3 +43,5 @@ sfa_start() 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 } + +[ -f "$MODULE_PATH/enable_sfanalysis" ] && sfa_start diff --git a/magisk/setup_uperf.sh b/magisk/setup_uperf.sh index 660d6e2..26efe59 100755 --- a/magisk/setup_uperf.sh +++ b/magisk/setup_uperf.sh @@ -2,7 +2,7 @@ # Uperf Setup # https://github.com/yc9559/ # Author: Matt Yang & cjybyjk (cjybyjk@gmail.com) -# Version: 20200507 +# Version: 20200513 BASEDIR="$(dirname $(readlink -f "$0"))" @@ -109,6 +109,15 @@ _get_sdm865_type() fi } +_get_sdm76x_type() +{ + if [ "$(cat /sys/devices/soc0/revision)" == "2.0" ]; then + echo "sdm768" + else + echo "sdm765" + fi +} + _get_msm8916_type() { case "$(_get_socid)" in @@ -258,7 +267,7 @@ _get_cfgname() "kona") ret="$(_get_sdm865_type)" ;; "msmnile") ret="sdm855" ;; "sdm845") ret="sdm845" ;; - "lito") ret="sdm765" ;; + "lito") ret="$(_get_sdm76x_type)" ;; "sm6150") ret="$(_get_sm6150_type)" ;; "sdm710") ret="sdm710" ;; "msm8916") ret="$(_get_msm8916_type)" ;; @@ -290,7 +299,7 @@ uperf_print_banner() echo "" echo "* Uperf https://github.com/yc9559/uperf/" echo "* Author: Matt Yang" - echo "* Version: DEV 20200507" + echo "* Version: DEV 20200513" echo "" } @@ -340,6 +349,9 @@ sfa_install() _set_perm "$target_lib_path/libsfanalysis.so" 0 0 0644 u:object_r:system_lib_file:s0 # in case of set_perm_recursive is broken chmod 0755 $BASEDIR/bin/* + + # create sfanalysis enable flag + touch $BASEDIR/enable_sfanalysis } powerhal_stub_install() diff --git a/magisk/system/vendor/etc/powerhint.json.override b/magisk/system/vendor/etc/powerhint.json.override deleted file mode 100644 index 5c5330e..0000000 --- a/magisk/system/vendor/etc/powerhint.json.override +++ /dev/null @@ -1,105 +0,0 @@ -{ - "Nodes": [ - { - "Name": "PMQoSCpuDmaLatency", - "Path": "/dev/cpu_dma_latency", - "Values": [ - "44", - "1000" - ], - "HoldFd": true - } - ], - "Actions": [ - { - "PowerHint": "SUSTAINED_PERFORMANCE", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "INTERACTION", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "LAUNCH", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "CAMERA_LAUNCH", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "CAMERA_STREAMING", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "CAMERA_STREAMING_60FPS", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "CAMERA_STREAMING_4K", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "CAMERA_STREAMING_SECURE", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "CAMERA_SHOT", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "AUDIO_STREAMING", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "AUDIO_LOW_LATENCY", - "Node": "PowerHALAudioState", - "Duration": 0, - "Value": "AUDIO_LOW_LATENCY" - }, - { - "PowerHint": "AUDIO_LOW_LATENCY", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "EXPENSIVE_RENDERING", - "Node": "PowerHALRenderingState", - "Duration": 0, - "Value": "EXPENSIVE_RENDERING" - }, - { - "PowerHint": "EXPENSIVE_RENDERING", - "Node": "PMQoSCpuDmaLatency", - "Duration": 0, - "Value": "1000" - }, - { - "PowerHint": "TPU_BOOST", - "Node": "PMQoSCpuDmaLatency", - "Duration": 2000, - "Value": "44" - } - ] -} \ No newline at end of file