Advertisement
Guest User

MyPersonalTweaks

a guest
Jun 27th, 2016
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.46 KB | None | 0 0
  1. #!/system/bin/sh
  2. #
  3. # Device            : Xiaomi Redmi Note 3 Pro (kenzo)
  4. # Android Version   : CyanogenMod 13.1 (Android 6.0.1-MOB30M)
  5. # Tweaks & Mods     : MOVZX (http://forum.xda-developers.com/member.php?u=4460588)
  6. #
  7. #
  8. # I'm using non-generic busybox binary which is specifically build for arm64, because I need fstrim and some other commands.
  9. # I also enabled init.d support by editing /system/etc/init.qcom.post_boot.sh, adding this (below) command to the last line of the file (init.qcom.post_boot.sh) to enable init.d:
  10. #
  11. # busybox run-parts /system/etc/init.d
  12. #
  13. # So, to fully install busybox into the system, I run this install command (after mounting /system partition to rw: mount -o remount,rw /system) via ADB:
  14. #
  15. # /system/xbin/busybox --install /system/xbin
  16. #
  17. # This is my personal tweaks for every ROM/Kernel made for Xiaomi Redmi Note 3 Pro (kenzo), I prefer my phone to run fast but also still maintaining better battery life.
  18. #
  19.  
  20. # Definitions
  21. CPU_LITTLE_CLUSTER=`ls -d /sys/devices/system/cpu/cpu0`;
  22. CPU_BIG_CLUSTER=`ls -d /sys/devices/system/cpu/cpu4`;
  23. CPU_LITTLE_CLUSTER_FREQ=`ls -d /sys/devices/system/cpu/cpu0/cpufreq`;
  24. CPU_BIG_CLUSTER_FREQ=`ls -d /sys/devices/system/cpu/cpu4/cpufreq`;
  25. VIRTUAL_MEMORY=`ls -d /proc/sys/vm`;
  26. IO_SCHEDULER=`ls -d /sys/block/mmcblk0/queue`;
  27. KERNEL=`ls -d /proc/sys/kernel`;
  28. LMK=`ls -d /sys/module/lowmemorykiller/parameters`;
  29. KSM=`ls -d /sys/kernel/mm/ksm`;
  30. NETWORKING=`ls -d /proc/sys/net/ipv4`;
  31. LOG_FILE="/sdcard/MyPersonalTweaks.log";
  32.  
  33. # Logging
  34. if [ -e $LOG_FILE ]; then
  35.     rm $LOG_FILE;
  36. fi;
  37. echo "Starting Metal Droid Tweaks at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
  38. echo "" | tee -a $LOG_FILE;
  39.  
  40. # CPU Tweaks
  41. echo "CPU Tweaks" | tee -a $LOG_FILE;
  42. #
  43. # Disable Core Control
  44. echo "    Disable Core Control" | tee -a $LOG_FILE;
  45. #
  46. echo "0" > /sys/module/msm_thermal/core_control/enabled;
  47. for mode in /sys/devices/soc.0/qcom,bcl.*/mode; do
  48.     echo -n disable > $mode;
  49. done
  50. for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask; do
  51.     bcl_hotplug_mask=`cat $hotplug_mask`;
  52.     echo "0" > $hotplug_mask;
  53. done
  54. for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask; do
  55.     bcl_soc_hotplug_mask=`cat $hotplug_soc_mask`;
  56.     echo "0" > $hotplug_soc_mask;
  57. done
  58. for mode in /sys/devices/soc.0/qcom,bcl.*/mode; do
  59.     echo -n enable > $mode;
  60. done
  61. #
  62. # Little
  63. echo "    Set CPU Little Cluster" | tee -a $LOG_FILE;
  64. #
  65. for l in $CPU_LITTLE_CLUSTER; do
  66.     # CPU idle load threshold
  67.     echo "30" > $l/sched_mostly_idle_load;
  68.     # CPU idle nr run threshold
  69.     echo "3" > $l/sched_mostly_idle_nr_run;
  70.     # CPU prefer idle
  71.     echo "0" > $l/sched_prefer_idle;
  72.     # Enable sched guided freq control
  73.     echo "1" > $l/cpufreq/interactive/use_sched_load;
  74.     echo "1" > $l/cpufreq/interactive/use_migration_notif;
  75. done
  76. for l in $CPU_LITTLE_CLUSTER_FREQ; do
  77.     echo "interactive" > $l/scaling_governor;
  78.     echo "400000" > $l/scaling_min_freq;
  79.     echo "99 400000:75 691200:80 806400:85 1017600:90 1305600:95 1401600:99" > $l/interactive/target_loads;
  80.     echo "10000" > $l/interactive/above_hispeed_delay;
  81.     echo "691200" > $l/interactive/hispeed_freq;
  82.     echo "99" > $l/interactive/go_hispeed_load;
  83.     echo "10000" > $l/interactive/timer_rate;
  84.     echo "10000" > $l/interactive/min_sample_time;
  85.     echo "10000" > $l/interactive/timer_slack;
  86.     echo "0" > $l/interactive/boost;
  87.     echo "0" > $l/interactive/io_is_busy;
  88.     echo "10000" > $l/interactive/max_freq_hysteresis;
  89.     echo "10000" > $l/interactive/boostpulse_duration;
  90. done
  91. #
  92. # Big
  93. echo "    Set CPU Big Cluster" | tee -a $LOG_FILE;
  94. #
  95. for b in $CPU_BIG_CLUSTER; do
  96.     # CPU idle load threshold
  97.     echo "50" > $b/sched_mostly_idle_load;
  98.     # CPU idle nr run threshold
  99.     echo "5" > $b/sched_mostly_idle_nr_run;
  100.     # CPU prefer idle
  101.     echo "0" > $b/sched_prefer_idle;
  102.     # Enable sched guided freq control
  103.     echo "1" > $b/cpufreq/interactive/use_sched_load;
  104.     echo "1" > $b/cpufreq/interactive/use_migration_notif;
  105. done
  106. for b in $CPU_BIG_CLUSTER_FREQ; do
  107.     echo "interactive" > $b/scaling_governor;
  108.     echo "400000" > $b/scaling_min_freq;
  109.     echo "99 400000:75 883200:80 1056000:85 1305600:90 1612800:95 1804800:99" > $b/interactive/target_loads;
  110.     # echo "90 400000:41 883200:84 940800:85 998400:85 1056000:85 1113600:84 1190400:86 1248000:86 1305600:85 1382400:77 1612800:83 1747200:90" > $b/interactive/target_loads;
  111.     echo "10000" > $b/interactive/above_hispeed_delay;
  112.     echo "883200" > $b/interactive/hispeed_freq;
  113.     echo "99" > $b/interactive/go_hispeed_load;
  114.     echo "10000" > $b/interactive/timer_rate;
  115.     echo "10000" > $b/interactive/min_sample_time;
  116.     echo "10000" > $b/interactive/timer_slack;
  117.     echo "0" > $b/interactive/boost;
  118.     echo "0" > $b/interactive/io_is_busy;
  119.     echo "10000" > $b/interactive/max_freq_hysteresis;
  120.     echo "10000" > $b/interactive/boostpulse_duration;
  121. done
  122. #
  123. # Re-Enable Core Control
  124. echo "    Re-Enable Core Control" | tee -a $LOG_FILE;
  125. #
  126. echo "1" > /sys/module/msm_thermal/core_control/enabled;
  127. for mode in /sys/devices/soc.0/qcom,bcl.*/mode; do
  128.     echo -n disable > $mode;
  129. done
  130. for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask; do
  131.     echo $bcl_hotplug_mask > $hotplug_mask;
  132. done
  133. for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask; do
  134.     echo $bcl_soc_hotplug_mask > $hotplug_soc_mask;
  135. done
  136. for mode in /sys/devices/soc.0/qcom,bcl.*/mode; do
  137.     echo -n enable > $mode;
  138. done
  139.  
  140. # GPU Tweaks
  141. echo "GPU Tweaks" | tee -a $LOG_FILE;
  142. #
  143. # For battery life!
  144. echo "simple_ondemand" > /sys/class/kgsl/kgsl-3d0/devfreq/governor
  145.  
  146. # VM Tweaks
  147. echo "VM Tweaks" | tee -a $LOG_FILE;
  148. #
  149. for v in $VIRTUAL_MEMORY; do
  150.     echo "0" > $v/swappiness;
  151.     echo "500" > $v/dirty_writeback_centisecs;
  152.     echo "300" > $v/dirty_expire_centisecs;
  153. done
  154.  
  155. # I/O Scheduler Tweaks
  156. echo "I/O Scheduler Tweaks" | tee -a $LOG_FILE;
  157. #
  158. for s in $IO_SCHEDULER; do
  159.     # echo "noop" > $s/scheduler;
  160.     echo "fiops" > $s/scheduler;
  161.     echo "128" > $s/read_ahead_kb;
  162. done
  163.  
  164. # Entropy Tweaks
  165. echo "Entropy Tweaks" | tee -a $LOG_FILE;
  166. #
  167. for e in $KERNEL; do
  168.     echo "512" > $e/random/read_wakeup_threshold;
  169.     echo "1024" > $e/random/write_wakeup_threshold;
  170. done
  171.  
  172. # KSM Tweaks
  173. echo "KSM Tweaks" | tee -a $LOG_FILE;
  174. #
  175. for k in $KSM; do
  176.     # I disabled KSM for battery life, also because I own XRN3Pro with 3GB of RAM, so Free-RAM is not a problem for me.
  177.     echo "0" > $k/run;
  178.     # echo "89" > $k/pages_to_scan;
  179.     # echo "55" > $k/sleep_millisecs;
  180. done
  181.  
  182. # Minfree Tweaks
  183. echo "Minfree Tweaks" | tee -a $LOG_FILE;
  184. #
  185. for m in $LMK; do
  186.     echo "0,1,2,7,14,15" > $m/adj;
  187.     echo "2560,4096,6144,7168,8192,9216" > $m/minfree;
  188. done
  189.  
  190. # Networking Tweaks
  191. echo "Networking Tweaks" | tee -a $LOG_FILE;
  192. #
  193. for n in $NETWORKING; do
  194.     echo "1" > $n/tcp_timestamps;
  195.     echo "1" > $n/tcp_sack;
  196.     echo "1" > $n/tcp_window_scaling;
  197. done
  198.  
  199. # FSTrim
  200. echo "FSTrim" | tee -a $LOG_FILE;
  201. #
  202. echo "    Trimming CACHE Partition" | tee -a $LOG_FILE;
  203. fstrim /cache;
  204. echo "    Trimming CUST Partition" | tee -a $LOG_FILE;
  205. fstrim /cust;
  206. echo "    Trimming DATA Partition" | tee -a $LOG_FILE;
  207. fstrim /data;
  208. echo "    Trimming DSP Partition" | tee -a $LOG_FILE;
  209. fstrim /dsp;
  210. echo "    Trimming PERSIST Partition" | tee -a $LOG_FILE;
  211. fstrim /persist;
  212. echo "    Trimming SYSTEM Partition" | tee -a $LOG_FILE;
  213. fstrim /system;
  214.  
  215. # Cleaning VM Cache
  216. echo "Cleaning VM Cache" | tee -a $LOG_FILE;
  217. #
  218. for v in $VIRTUAL_MEMORY; do
  219.     sync;
  220.     echo "3" > $v/drop_caches;
  221.     sleep 1;
  222.     echo "0" > $v/drop_caches;
  223. done
  224.  
  225. echo "" | tee -a $LOG_FILE;
  226. echo "Metal Droid Tweaks finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
  227. echo "" | tee -a $LOG_FILE;
  228.  
  229. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement