[Galaxy S 4 i9506 Android Development] papete:
Scripts to control some of De Hawk's Kernel parameters (without Faux's app or any other app)

These scripts are for both insecured KitKat kernels, I guess it should work on the Lollipop insecured kernels but I'm not sure.

The values on this guide match my personal preferences, and may differ from yours...

I don't use all the scripts in this guide as many of the options I use are the default values, the ones I use are with a (+) sign next to the title

Some of them have my personal comments (with a *) on why I use or don't use them, those are personal comments, and in no way means that they should apply to you, neglect the work of others, mean you should kill anyone, etc, etc...

# Set the governor

echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Change Scheduler and readahead size for eMMC and SDCard (+)

echo "row" > /sys/block/mmcblk0/queue/scheduler
echo "256" > /sys/block/mmcblk0/queue/read_ahead_kb
echo "row" > /sys/block/mmcblk1/queue/scheduler
echo "1024" > /sys/block/mmcblk1/queue/read_ahead_kb

*Higher sequential read is better for audio and video so it is a good idea to have a big number for external SD card, a small number is better for random memory reading, which is what you usually need for the rest of operations.

# Clear VFS Cache After Boot (+)

echo "3" > /proc/sys/vm/drop_caches

* May not be necessary, but it does no harm

# Auto FS Writeback delay mode on (+)

echo "0" > /proc/sys/vm/laptop_mode

*Laptop mode is made with Hard Disk drives in mind, delaying the flushing of cache on a single point in time to "fire up" the HD, flush, and then turn it off again to save energy. I think it makes no sense to have this active on Android Phones. Having it activated will possibly harm performance.

# Swapiness (our devices use a form of ZRAM by default, set it to 60-100) (+)

echo "0" > /proc/sys/vm/swappiness

* If you have deactivated VNSWAP swapiness (my case) should be 0, if not 60-100 is my recommended value.

# VFS Cache Pressure (+)

echo "60" > /proc/sys/vm/vfs_cache_pressure

# Dirty Radio (+)

echo "35" > /proc/sys/vm/dirty_ratio

# Dirty Background Ratio (+)

echo "10" > /proc/sys/vm/dirty_background_ratio

# TCP Congestion Control (+)

echo "westwood" > /proc/sys/net/ipv4/tcp_congestion_control

# Disable VNSWAP (+)

swapoff /dev/block/vnswap0

Intelliplug: the following scripts are useful to activate (echo 1) or deactivate (echo 0) intelliplug, and change its parameters. I use this personally as I use the mpdecision driver normally (as it is the most battery friendly), but use intelliplug when I want a little more performance (if activating intelliplug via scripts ALWAYS deactivate mpdecision first)

To stop mpdecision

stop mpdecision

To activate and change intelliplug settings

echo "1" > /sys/module/intelli_plug/parameters/intelli_plug_active
echo "3" > /sys/module/intelli_plug/parameters/nr_run_profile_sel
echo "4" > /sys/module/intelli_plug/parameters/nr_run_hysteresis
echo "192" > /sys/module/intelli_plug/parameters/cpu_nr_run_threshold
echo "300000" > /sys/module/intelli_plug/parameters/screen_off_max

To activate (echo 1), deactivate (echo 0) the C0, C1, C2 and C3 states (not tested as I keep all of them enabled all the time):

C0 (WFI) - Shallowest Sleep

echo 1 > /sys/module/msm_pm/modes/cpu0/wfi/idle_enable

C1 (Retention) - slightly deeper sleep

echo 1 > /sys/module/msm_pm/modes/cpu0/retention/idle_enable

C2 (Stand Alone Power Collapse) - deeper sleep

echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enable

C3 (Power Collapse) - deepest sleep

echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enable

All the parameters above can be set via an init.d script or by executing the code via terminal, tasker or any other.

- How can I add a init.d script?: Simple, I am uploading a sample init.d script, you can edit it with notepad++, change the values, add the ones you want and delete the ones you don't. Once you are done put the file in the following folder: /etc/init.d and make sure you set the proper permissions for the file (0755) (see the attached image).

BTW, I had a 00SETVAR file there already, I deleted it.