moddingg33k
Ambitioniertes Mitglied
- 40
Achtung: Für FORTGESCHRITTENE!
Hatte mir ursprünglich ein init.d-Skript geschrieben, dass die Paramter des OnDemand-Governors beim Booten festlegen sollte. Musste aber leider feststellen, dass meine Werte jedes mal überschrieben wurden, sobald der Bildschirm ausging. Das liegt an einem Kerneltreiber (mpdecision), der als Service im Hintergrund mitläuft und, abhängig davon ob das Display an/aus ist, die CPU-Kernel steuert, sowie deren Paramter festlegt.
Bin dann im Netz auf ein interessantes Skript gestoßen und habe es mir für mein Y300 ein wenig angepasst.
- FUNKTION
Reguliert in Abhängigkeit davon, ob das Display AN oder AUS ist:
- CPU-Frequenz (min & max)
- CPU-Governor
- CPU-Governor Parameter
- kann den 2. Kernel deaktivieren (sollte sowieso der Fall sein, wenn das Display ausgeht. Der zweite Kernel wird außerdem eh nur bei Bedarf zugeschalten)
- optimiert ein paar VM-Einstellungen zugunsten des Akkuverbrauchs
- INSTALLATION
Vorausgesetzt wird, dass eure ROM init.d unterstützt.
Einfach die anghängte Datei mit einem UNIX-Editor euren Vorstellungen nach anpassen und ins init.d-Verzeichnis eures Telefon kopieren.
Einfach die anghängte Datei mit einem UNIX-Editor euren Vorstellungen nach anpassen und ins init.d-Verzeichnis eures Telefon kopieren.
- SCRIPT
Rote Texstellen: können ausgeklammert (#) oder entfernt werden, falls nicht gewünscht
Blaue Textstellen: diese Werte sollten euren Vorlieben entsprechend angepasst werden.
Blaue Textstellen: diese Werte sollten euren Vorlieben entsprechend angepasst werden.
Code:
#!/system/bin/sh
#
# Kernel_Governors - switch CPU frequency governor on screen state change
# florian.schaefer@gmail.com (FloHimself)
#
# modifications by zacharias.maladroit and Jimbo77
# modifications & ideas taken from: ckMod SSSwitch by voku1987 and "battery tweak" (collin_ph@xda)
#
# 01.06.2013: modificated and tweaked for the Huawei Y300-100 by Balthasar aka m0ddingg33k (v0.3a)
#
#
# =============
# DESCRIPTION
# =============
#
# for uncommenting settings remove the preceding diamond/rhomb-sign (#) at the
# beginning of the line and remember to comment the other settings otherwise they
# will fight with each other and you might see inconsistent results
#
#
# ==========================
# DESCRIPTION OF GOVERNORS
# ==========================
#
# VISIT: http://forum.xda-developers.com/showthread.php?t=1736168
#
#[color=blue]
########################################################
# #
# // CONFIGURE SETTINGS BELOW TO YOUR LIKINGS // #
# #
########################################################
#
# ==============================================================
# STEP [ 1 ] : CHOOSE AWAKE GOVERNOR WHILE SCREEN IS ON
# ==============================================================
#
# ONLY KEEP O N E GOVERNOR UNCOMMENTED AT A TIME !!!
#
# ==============================================================
#
# AWAKE_GOVERNOR="conservative";
# AWAKE_GOVERNOR="ondemand";
AWAKE_GOVERNOR="interactive";
# AWAKE_GOVERNOR="powersave"; # [NOT recommended]
# AWAKE_GOVERNOR="performance";
# AWAKE_GOVERNOR="userspace"; # [NOT recommended]
#
#
# ==============================================================
# STEP [ 2 ] : CHOOSE SLEEP GOVERNOR WHILE SCREEN IS OFF
# ==============================================================
#
# ONLY KEEP O N E GOVERNOR UNCOMMENTED AT A TIME !!!
#
# ==============================================================
#
# SLEEP_GOVERNOR="conservative";
# SLEEP_GOVERNOR="ondemand";
# SLEEP_GOVERNOR="interactive"; # [NOT recommended]
SLEEP_GOVERNOR="powersave";
# SLEEP_GOVERNOR="performance"; # [NOT recommended]
# SLEEP_GOVERNOR="userspace"; # [NOT recommended]
#
#
# ==============================================================
# STEP [ 3 ] : CHOOSE GOVERNOR BEHAVIOUR
# ==============================================================
#
# =========
# AWAKE
# =========
#
# Available Frequencys: 196608 - 320000 - 480000 - 700800 - 1008000
#
AWAKE_CPU1_ONLINE="1"
AWAKE_SCALING_MAX_FREQ="1008000"
AWAKE_SCALING_MIN_FREQ="100000"
AWAKE_UP_THRESHOLD="90"
AWAKE_SAMPLING_RATE="45000"
AWAKE_SAMPLING_DOWN_FACTOR="1"
AWAKE_IGNORE_NICE_LOAD="1"
#
AWAKE_IO_IS_BUSY="0"; # ONDEMAND ONLY
AWAKE_DOWN_DIFFERENTIAL="5"; # ONDEMAND ONLY
AWAKE_POWERSAVE_BIAS="150"; # ONDEMAND ONLY
#
AWAKE_DOWN_THRESHOLD="50"; # CONSERVATIVE ONLY
AWAKE_FREQ_STEP="25"; # CONSERVATIVE ONLY
#
AWAKE_ABOVE_HISPEED_DELAY="30000"; # INTERACTIVE ONLY
AWAKE_BOOST="0"; # INTERACTIVE ONLY
AWAKE_GO_HISPEED_LOAD="95"; # INTERACTIVE ONLY
AWAKE_HISPEED_FREQ="1008000"; # INTERACTIVE ONLY
AWAKE_INPUT_BOOST="0"; # INTERACTIVE ONLY
AKWAE_MIN_SAMPLE_TIME="30000"; # INTERACTIVE ONLY
AWAKE_TIMER_RATE="20000"; # INTERACTIVE ONLY
#
# ==========
# SLEEPING
# ==========
#
# Available Frequencys: 196608 - 320000 - 480000 - 700800 - 1008000
#
SLEEP_CPU1_ONLINE="0"
SLEEP_SCALING_MAX_FREQ="320000"
SLEEP_SCALING_MIN_FREQ="196608"
SLEEP_SAMPLING_DOWN_FACTOR="1"
SLEEP_IO_IS_BUSY="0"; # ONDEMAND ONLY
SLEEP_IGNORE_NICE_LOAD="1"
SLEEP_DOWN_DIFFERENTIAL="1"; # ONDEMAND ONLY
SLEEP_POWERSAVE_BIAS="500"; # ONDEMAND ONLY
SLEEP_UP_THRESHOLD="95"
SLEEP_DOWN_THRESHOLD="75"; # CONSERVATIVE ONLY
SLEEP_SAMPLING_RATE="200000"
SLEEP_FREQ_STEP="10"; # CONSERVATIVE ONLY
#
#
######################################
# #
# // END OF CONFIGURATION // #
# #
######################################
#[/color]
#
#
# ==============================================================
# ==============================================================
# [ SCREENSTATE SCALING LOOP ]
# ==============================================================
# ==============================================================
#
LAST_FLUSH=`date +%s`;
RENICE_DONE="0";
#
(while [ 1 ];
do
##################################################################
# #
# ============================================================== #
# #
# [ SCREEN: ON ] #
# #
# ============================================================== #
# #
##################################################################
#
AWAKE=`cat /sys/power/wait_for_fb_wake`;
if [ $AWAKE = "awake" ]; then
chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
echo $AWAKE_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
#
# ==============================================================
# Ondemand
# ==============================================================
#
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ]; then
echo $AWAKE_UP_THRESHOLD > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold;
echo $AWAKE_IO_IS_BUSY > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy;
echo $AWAKE_IGNORE_NICE_LOAD > /sys/devices/system/cpu/cpufreq/ondemand/ignore_nice_load;
echo $AWAKE_POWERSAVE_BIAS > /sys/devices/system/cpu/cpufreq/ondemand/powersave_bias;
echo $AWAKE_DOWN_DIFFERENTIAL > /sys/devices/system/cpu/cpufreq/ondemand/down_differential;
echo $AWAKE_SAMPLING_DOWN_FACTOR > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor;
echo $AWAKE_SAMPLING_RATE > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate;
fi;
#
# ==============================================================
# Conservative
# ==============================================================
#
if [ -e /sys/devices/system/cpu/cpufreq/conservative/up_threshold ]; then
echo $AWAKE_UP_THRESHOLD > /sys/devices/system/cpu/cpufreq/conservative/up_threshold;
echo $AWAKE_DOWN_THRESHOLD > /sys/devices/system/cpu/cpufreq/conservative/down_threshold; # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
echo $AWAKE_FREQ_STEP > /sys/devices/system/cpu/cpufreq/conservative/freq_step; # more aggressive ramping up (50) # screen off: # 10
echo $AWAKE_SAMPLING_DOWN_FACTOR > /sys/devices/system/cpu/cpufreq/conservative/sampling_down_factor;
echo $AWAKE_SAMPLING_RATE > /sys/devices/system/cpu/cpufreq/conservative/sampling_rate;
echo $AWAKE_IGNORE_NICE_LOAD > /sys/devices/system/cpu/cpufreq/conservative/ignore_nice_load;
fi;
#
# ==============================================================
# Interactive
# ==============================================================
#
if [ -e /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load ]; then
echo $AWAKE_ABOVE_HISPEED_DELAY > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay;
echo $AWAKE_BOOST > /sys/devices/system/cpu/cpufreq/interactive/boost;
echo $AWAKE_GO_HISPEED_LOAD > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load;
echo $AWAKE_HISPEED_FREQ > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq;
echo $AWAKE_INPUT_BOOST > /sys/devices/system/cpu/cpufreq/interactive/input_boost;
echo $AKWAE_MIN_SAMPLE_TIME > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time;
echo $AWAKE_TIMER_RATE > /sys/devices/system/cpu/cpufreq/interactive/timer_rate;
fi;
#
# ==============================================================
# Limiting max/min frequencies
# ==============================================================
#
chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 644 /sys/devices/system/cpu/cpu1/online
echo $AWAKE_SCALING_MAX_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo $AWAKE_SCALING_MIN_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo $AWAKE_CPU1_ONLINE > /sys/devices/system/cpu/cpu1/online
chmod 444 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 444 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
#[color=red]
# ==============================================================
# dirty_ratio & vfs_cache_pressure: too high (dirty_ratio) and too low values (vfs_cache_pressure) might fill up the RAM too much and end up triggering the OOM killer
#
# http://www.cyrius.com/debian/nslu2/linux-on-flash/
# http://doc.opensuse.org/documentation/html/openSUSE/opensuse-tuning/cha.tuning.memory.html
# ==============================================================
#
# /* flushing caches every 24h...
CURRENT_TIME=`date +%s`;
if [ $(expr $CURRENT_TIME - $LAST_FLUSH) -gt 86400 ];
then
sync;
sysctl -w vm.drop_caches=3;
sysctl -w vm.drop_caches=0;
LAST_FLUSH=`date +%s`;
RENICE_DONE="0";
fi;
# ...done flushing */
sysctl -w vm.dirty_expire_centisecs=2000;
sysctl -w vm.dirty_writeback_centisecs=2000;
sysctl -w vm.dirty_background_ratio=60;
sysctl -w vm.dirty_ratio=80;
sysctl -w vm.vfs_cache_pressure=10;
#
# ==============================================================
# [ RENICING PROCESSES ]
# ==============================================================
# credits to lpy:
# -> http://forum.xda-developers.com/showthread.php?t=1137554
# ==============================================================
#
if [ $RENICE_DONE == 0 ]; then
### Phone Dialer APP ###
renice -15 `pidof com.android.phone`;
### Text Messaging APP ##
renice -15 `pidof com.android.mms`;
### Launcher APP ###
renice -10 `pidof com.anddoes.launcher`; # APEX Launcher
### System APPs ###
renice -10 `pidof com.google.android.inputmethod.latin`; # Keyboard
renice -6 `pidof com.sec.android.app.controlpanel`; # Taskmanager
renice -6 `pidof com.android.systemui`; # Statusbar
renice -6 `pidof com.android.settings`; # Settingsmenu
renice -6 `pidof com.android.contacts`; # Contacts
renice -6 `pidof com.sec.android.app.camera`; # CameraApp
renice -6 `pidof android.process.acore`;
RENICE_DONE="1";
fi;
#[/color]
#log -p i -t screenstate_scaling "*** awake ***: switching CPU frequency governor to -> $AWAKE_GOVERNOR"
AWAKE=;
fi;
##################################################################
# #
# ============================================================== #
# #
# [ SCREEN: OFF ] #
# #
# ============================================================== #
# #
##################################################################
#
SLEEPING=`cat /sys/power/wait_for_fb_sleep`;
if [ $SLEEPING = "sleeping" ]; then
chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
echo $SLEEP_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
#
# ==============================================================
# Ondemand
# ==============================================================
#
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ]; then
echo $SLEEP_UP_THRESHOLD > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold;
echo $SLEEP_IO_IS_BUSY > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy;
echo $SLEEP_IGNORE_NICE_LOAD > /sys/devices/system/cpu/cpufreq/ondemand/ignore_nice_load;
echo $SLEEP_POWERSAVE_BIAS > /sys/devices/system/cpu/cpufreq/ondemand/powersave_bias;
echo $SLEEP_DOWN_DIFFERENTIAL > /sys/devices/system/cpu/cpufreq/ondemand/down_differential;
echo $SLEEP_SAMPLING_DOWN_FACTOR > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor;
echo $SLEEP_SAMPLING_RATE > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate;
fi;
#
# ==============================================================
# Conservative
# ==============================================================
#
if [ -e /sys/devices/system/cpu/cpufreq/conservative/up_threshold ]; then
echo $SLEEP_UP_THRESHOLD > /sys/devices/system/cpu/cpufreq/conservative/up_threshold;
echo $SLEEP_DOWN_THRESHOLD > /sys/devices/system/cpu/cpufreq/conservative/down_threshold; # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
echo $SLEEP_FREQ_STEP > /sys/devices/system/cpu/cpufreq/conservative/freq_step; # more aggressive ramping up (50) # screen off: # 10
echo $SLEEP_SAMPLING_DOWN_FACTOR > /sys/devices/system/cpu/cpufreq/conservative/sampling_down_factor;
echo $SLEEP_SAMPLING_RATE > /sys/devices/system/cpu/cpufreq/conservative/sampling_rate;
echo $SLEEP_IGNORE_NICE_LOAD > /sys/devices/system/cpu/cpufreq/conservative/ignore_nice_load;
fi;
#
# ==============================================================
# Limiting max/min frequencies
# ==============================================================
#
chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 644 /sys/devices/system/cpu/cpu1/online
echo $SLEEP_SCALING_MAX_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo $SLEEP_SCALING_MIN_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo $SLEEP_CPU1_ONLINE > /sys/devices/system/cpu/cpu1/online
chmod 444 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 444 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
#[color=red]
# ==============================================================
# dirty_ratio & vfs_cache_pressure: too high (dirty_ratio) and too low values (vfs_cache_pressure) might fill up the RAM too much and end up triggering the OOM killer
#
# http://www.cyrius.com/debian/nslu2/linux-on-flash/
# http://doc.opensuse.org/documentation/html/openSUSE/opensuse-tuning/cha.tuning.memory.html
# ==============================================================
#
sysctl -w vm.dirty_expire_centisecs=6000;
sysctl -w vm.dirty_writeback_centisecs=6000;
sysctl -w vm.dirty_background_ratio=70;
sysctl -w vm.dirty_ratio=90;
sysctl -w vm.vfs_cache_pressure=1;
#[/color]
# log -p i -t screenstate_scaling "*** sleeping ***: switching CPU frequency governor to -> $SLEEP_GOVERNOR"
SLEEPING=;
fi;
done &);
Anhänge
Zuletzt bearbeitet: