• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Editing init.d (Tweaking smartassV2 and other governors)

I wanted to adjust the voltage for 806 MHz to 1025 vdd from 1050 vdd. I tried adjusting it with AnTuTu CPU Master, but the setting would not stick past reboot. I found this guide by LeeDroid which taught me how you do it by editing the init.d file.

Open /system/etc/init.d/01sysctl with a text editor and this is what I the contents of the file are

#!/system/bin/sh
# - sysctl - p -
I edited the file to read:

#!/system/bin/sh
# - sysctl - p -
#CONFIG_CPU_FREQ_VDD_LEVELS

echo '806400 1025' > /sys/devices/system/cpu/cpu0/cpufreq/vdd_levels

On reboot, 860 MHz is set to 1025 vdd :)

A bit confused about this line:

# - sysctl - p -

This is supposed to load settings from /etc/sysctl.conf

But I cannot find /etc/sysctl.conf on my device. Maybe a junk line left from some app I installed? If I remember correctly, entries behind a # are ignored.

I really gotta learn more about what else I can edit init.d to do :D

Next project would be how to enable a governor and configure it from init.d.
 
This is how my init.d file now looks like:

#!/system/bin/sh
# - sysctl - p -
#CONFIG_CPU_FREQ_VDD_LEVELS

echo '806400 1025' > /sys/devices/system/cpu/cpu0/cpufreq/vdd_levels

#CONFIG_CPU_GOVERNOR

echo 'smartassV2' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

The lines #CONFIG_CPU_FREQ_VDD_LEVELS and #CONFIG_CPU_GOVERNOR are not necessary.

Why do it? Rather than have your Androrid boot up on performance, and than set smartassV2, Android will not boot up with smartassV2 by default.

I think I would to do this so that I can configure smartassV2 via init.d. I want to read up more on smartassV2 before going any further. But I was thinking of these settings:

echo "100000" > /sys/devices/system/cpu/cpufreq/smartass/ramp_up_step

Current is 200000 but given the available speeds are 245-368-768-806-1024 maybe 100000 would be better since 768 and 806 are pretty close together?

echo "700000" > /sys/devices/system/cpu/cpufreq/smartass/sleep_wakeup_freq

Current is 99999999 which does not make sense to me. With 700000 the phone should wake up at 708 MHz?

Am a bit over my head here... but I do have a Nandroid backup. Any advice would be appreciated.
 
Upvote 0
Okay, editing the init.d file will allow me to change SmartassV2 settings and make it stick. A little planning is in order.

General info:

SmartassV2 "has an 'ideal' frequency which it will quickly ramp up to, then more slowly ramp up once past it, and vice-versa for down-ramping. A separate "ideal" frequency is used when the screen is off." (Source)

The most important tunable is the "ideal" frequency: this governor will aim for this frequency, in the sense that it will ramp towards this frequency much more aggresively than beyond it - both when ramping up from below this frequency and when ramping down from above this frequency. Still, note, that when load is low enough the governor should choose the lowest available frequency regardless of the ideal frequency and similarly when load is consistently high enough the highest available frequency will be used.

Smartass also tracks the state of the screen, and when screen is off (a.k.a sleep or suspended in the terms of this governor) a different ideal frequency is used. This is the only difference between the screen on and screen off states. Proper tuning of the awake_ideal_freq and sleep_ideal_freq should allow both high responsiveness when screen is on and utilizing the low frequency range when load is low, especially when screen is off (Source).

Tunables (Source)

awake_ideal_freq

The "ideal" frequency to use when awake. The governor will ramp up faster towards the ideal frequency and slower after it has passed it. Similarly, lowering the frequency towards the ideal frequency is faster than below it.

sleep_ideal_freq

The "ideal" frequency to use when suspended. When set to 0, the governor will not track the suspended state (meaning that practically when sleep_ideal_freq =0 the awake_ideal_freq is used also when suspended).

sleep_wakeup_freq

The frequency to set when waking up from sleep.When sleep_ideal_freq=0 this will have no effect.

ramp_up_step

Frequency delta when ramping up above the ideal frequency. Zero disables and causes to always jump straight to max frequency. When below the ideal frequency we always ramp up to the ideal freq.

ramp_down_step

Frequency delta when ramping down below the ideal freqeuncy. Zero disables and will calculate ramp down according to load heuristic. When above the ideal freqeuncy we always ramp down to the ideal freq.

max_cpu_load

CPU freq will be increased if measured load > max_cpu_load;

min_cpu_load

CPU freq will be decreased if measured load < min_cpu_load;

up_rate_us

The minimum amount of time to spend at a frequency before we can ramp up. Notice we ignore this when we are below the ideal frequency.

down_rate_us

The minimum amount of time to spend at a frequency before we can ramp down. Notice we ignore this when we are above the ideal frequency.

sample_rate_jiffies

Sampling rate, I highly recommend to leave it at 2.
 
Upvote 0
My current ROM (Blackout ICS v3.1.0) has the following frequencies enabled:

245 - 368 -768 -806 -1024

ROM SmartassV2 settings are:

awake_ideal_freq - 800000

sleep_ideal_freq - 200000

sleep_wakeup_freq - 99999999

ramp_up_step - 200000

ramp_down_step - 300000

max_cpu_load - 55

min_cpu_load - 25

up_rate_us - 48000

down_rate_us - 99000

sample_rate_jiffies - 2

I gather this is how all this works:

Phone wakes from sleep ---> sleep_wakeup_freq ---> Unknown (9999999 setting allows governor decide what frequency to wake at as per @cstayton of Team Blackout)

The processor goes 'ideal' frequency ---> awake_ideal_frequency ---> 806 Mhz (800000)

If needed it will ramp up to at steps of 200MHz (ramp_up_step). Needed being defined by max_cpu_load which is now a 55%. Basically from 806 MHz to 1024MHz.

When load is low (min_cpu_load) the processor ramps down in 300 MHz steps. Load is low when cpu usage is below 25% (min_cpu_load). From 1024 MHz to 768 MHz (less than a 300MHz ramp down) than to 368 MHz and finally 245 MHz.
 
Upvote 0
Details: Governor is smartassv2 with default clock speeds and settings except vdd for 806 MHz is reduced to 1025.

10pzv9s.png


Given the preferred wake speed is 800 MHz it appears that the other settings do not allow it to stay at the preferred default wake speed.

Images of time in state and battery use for reference:

2mz9n5u.png


2h5tb9e.png


I was thinking of making the following changes SmartassV2 settings are:

awake_ideal_freq - 768000
sleep_ideal_freq - 245760
sleep_wakeup_freq - 99999999
ramp_up_step - 100000 - To allow a 245 to 368 MHz change.
ramp_down_step - 256000 - For the 1024 to 768 MHz ramp down.
max_cpu_load - 75 - Slow to ramp up.
min_cpu_load - 35 - A bit faster to ramp down.
up_rate_us - 48000
down_rate_us - 99000
sample_rate_jiffies - 2
 
Upvote 0
All this may be moot soon. I cannot find /system/etc/init.d/01sysctl or vdd_levels in Android 4.1.1 :thinking:

im pretty boring when it comes to changing kernels,and modifying build.prop,init.d,or other system files.

LOL... I am an old man. I never really trust GUI's and using a console to modify Android is above my head. On the other hand, Notepad and the Registry... been hacking Windows with those since Win95.
 
Upvote 0
Found an post on governors and with suggested tweaks for Smartassv2. So decided to revise my settings based on them:

echo '800000' > /sys/devices/system/cpu/cpufreq/smartass/sleep_wakeup_freq

Screen wakes up at this speed.

echo '85' > /sys/devices/system/cpu/cpufreq/smartass/max_cpu_load

echo '70' > /sys/devices/system/cpu/cpufreq/smartass/min_cpu_load

echo '200000' > /sys/devices/system/cpu/cpufreq/smartass/ramp_down_step

echo '49000' > /sys/devices/system/cpu/cpufreq/smartass/down_rate_us


This makes the processor scale up slower than default settings.

izt384.png


With these settings the phone makes more use of the 384/768/806 clock speeds.
 
Upvote 0
Having got the phone to make more use of the middle clock speeds (384-806) I enabled the 1200 MHz clock speed which after some testing I managed to run at 1100 vdd (that is 100 vdd less than the default of 1024 MHz @ 1200 vdd).

I was expecting the phone to make use of both 1024 MHz and 1200 MHz. But that was not the case.

snkjex.png


It seems to just blow past 1024 MHz. I tried lowering the ramp_up_rate from 200000 to 100000. This did not result in any significant increase in the use of the 1024 GHz clock speeds. It does seem to keep the phone using the lower 284-384 clock speeds more.

2ztd1d5.png
 
  • Like
Reactions: scotty85
Upvote 0
... It seems to just blow past 1024 MHz. I tried lowering the ramp_up_rate from 200000 to 100000. This did not result in any significant increase in the use of the 1024 GHz clock speeds. It does seem to keep the phone using the lower 284-384 clock speeds more. .

Mine's OCd to 1382GHz and if I check BeterBatteryStats for the CPU history it shows a similar pattern to yours. that is, lots at the bottom and at the top of the CPU speed range. Can't really be bothered to check out why as it seems to work fine (On IceColdSandwich 8.6.1).

Dave
 
Upvote 0
I think I am done testing and have settled with these settings:

awake_ideal_freq - 800000
sleep_ideal_freq - 200000
sleep_wakeup_freq - 800000

max_cpu_load - 95
min_cpu_load - 70

ramp_up_step - 100000
ramp_down_stwp - 200000

up_rate_us - 48000
down_rate_us - 49000

In theory, it should be more conservative battery wise. I myself, well I have not noticed a substantial difference across all these settings.

2117yxd.png
 
Upvote 0
It's a Saturday!

#!/system/bin/sh
# - sysctl -p

#CONFIG_CPU_FREQ_SCALING

#echo '1200000' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

#CONFIG_CPU_FREQ_VDD_LEVELS

echo '806400 1025' > /sys/devices/system/cpu/cpu0/cpufreq/vdd_levels

echo '1200000 1100' > /sys/devices/system/cpu/cpu0/cpufreq/vdd_levels

#CONFIG_CPU_GOVERNOR

echo 'Lionheart' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
 
Upvote 0
I realized made a mistake with my max and min cpu load settings. These two.

echo '85' > /sys/devices/system/cpu/cpufreq/smartass/max_cpu_load

echo '70' > /sys/devices/system/cpu/cpufreq/smartass/min_cpu_load


This will work fine for ROM's with clock speeds stepping's 100MHz or so apart. But not with the Blackout ROM with its default kernel.

To recap I only have the following frequencies to work with:

1024 MHz - 806 MHz - 768 MHz - 368 MHz - 245 MHz

So when the average load of the processor is 70% or below, the cpu ramps down from 1024 MHz - 806 MHz or 768 MHz.

70% load at 1024 MHz could be > 85% load at 806 or 768 MHz which would cause the cpu to ramp up again.

It gets worse below this. 70% load at 806 or 768 MHz will be greater > 85% load at 368 which would cause the cpu to ramp up again.

To prevent all this unnecessary ramping up and down I need greater separation on min and max cpu load.

echo '85' > /sys/devices/system/cpu/cpufreq/smartass/max_cpu_load

echo '35' > /sys/devices/system/cpu/cpufreq/smartass/min_cpu_load


Basically, 35% of 806 MHz < 85% of 368 MHz.

Something as low as:

echo '75' > /sys/devices/system/cpu/cpufreq/smartass/max_cpu_load

echo '30' > /sys/devices/system/cpu/cpufreq/smartass/min_cpu_load


... should be fine too.

b480td.jpg


Sorry for the bad settings.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones