Related
Can we underclock with undervolt our CPU like Desire, Nexus,...?
lynx2k50 said:
Can we underclock with undervolt our CPU like Desire, Nexus,...?
Click to expand...
Click to collapse
You can underclock with SetCPU app. Never heard about undervolt so. Maybe you ment Underworld with Kate Beckinsale ?
yeah that wud be excellent.. i know it makes a huge difference on the wattage wasted on pc's.. dunno how much it'll help battery life with so many components on a phone.. n it'll be near impossible to fiddle with all the voltages
Hehe no i mean undervolt. One Nexus one and Desire there are allready kernel. The Kernel reduces the cpu voltage so we save battery.
lynx2k50 said:
Hehe no i mean undervolt. One Nexus one and Desire there are allready kernel. The Kernel reduces the cpu voltage so we save battery.
Click to expand...
Click to collapse
Change your CPUFREQ_MIN and change IDLE_TO_SLEEP timeout to a lesser value. Also set NO_SLEEP_LIMIT and FULL SLEEP (power down suspend), and there's no need to undervolt.
Battery lasts forever.
adwinp said:
Change your CPUFREQ_MIN and change IDLE_TO_SLEEP timeout to a lesser value. Also set NO_SLEEP_LIMIT and FULL SLEEP (power down suspend), and there's no need to undervolt.
Battery lasts forever.
Click to expand...
Click to collapse
Thnx for the quick reply.. ur fix wud be luvly only if i understood how to do that
red4 said:
Thnx for the quick reply.. ur fix wud be luvly only if i understood how to do that
Click to expand...
Click to collapse
Me too!
no need to go to the kernel source..
adding this line in a "init.d" script really help:
Code:
echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
MaXo64 said:
no need to go to the kernel source..
adding this line in a "init.d" script really help:
Code:
echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
Click to expand...
Click to collapse
Does that really work?? is it that easy to get the battery usage very low?
and does it still play music with this line added?
ybinnenweg said:
Does that really work?? is it that easy to get the battery usage very low?
and does it still play music with this line added?
Click to expand...
Click to collapse
i'm using it with both aHero and HeroDroid, and everything works perfectly even when Screen is off..
MaXo64 said:
i'm using it with both aHero and HeroDroid, and everything works perfectly even when Screen is off..
Click to expand...
Click to collapse
and what exactly does that line in the script do? doubt it's undervolt.
MaXo64 said:
i'm using it with both aHero and HeroDroid, and everything works perfectly even when Screen is off..
Click to expand...
Click to collapse
wow, well, then i'm going to ADB rightnow, and add that line!!
just use the ADB from the SDK right??
interesting! how do we do this? do we just go into adb shell and type that command?
Ya just open up an adb shell and paste that line
It'll create a file called powersave_bias with the value of "1" inside.
I'm testing it out today we'll see how it does.
VR 10 had mobile network always on so it killed my battery in 12 hours last night, normally it's around 50% after 12 hours, so we'll see if turning off always on and turning powersave on helps.
petsasj said:
and what exactly does that line in the script do? doubt it's undervolt.
Click to expand...
Click to collapse
it doesn't undervolt but it makes the CPU works much less when idle.
see this, page 26: http://kernel.org/pub/linux/kernel/people/lenb/acpi/doc/OLS2006-ondemand-presentation.pdf
ybinnenweg said:
wow, well, then i'm going to ADB rightnow, and add that line!!
just use the ADB from the SDK right??
Click to expand...
Click to collapse
you can use it temporary by executing this command in adb:
Code:
adb shell echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
but it's gone after reboot..
djdavis said:
interesting! how do we do this? do we just go into adb shell and type that command?
Click to expand...
Click to collapse
yup..
kool, so how would one make this permenant?
djdavis said:
kool, so how would one make this permenant?
Click to expand...
Click to collapse
i get a "the system cannot find the path specified" error in cmd, when typing
Code:
adb shell echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
correct command (thanks to kendon)
Code:
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
running a bogomips returned the exact same value in mhz as i've set for in setcpu (352mhz). so what does this do essentially? drop mhz? how does it lower workload?
so does this make it permanent?
petsasj said:
i get a "the system cannot find the path specified" error in cmd, when typing
Code:
adb shell echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
correct command (thanks to kendon)
Code:
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
running a bogomips returned the exact same value in mhz as i've set for in setcpu (352mhz). so what does this do essentially? drop mhz? how does it lower workload?
Click to expand...
Click to collapse
Are you sure that command from kendon is correct? From what I can tell, that should simply tell you what is in that file (thats what cat does).
djdavis said:
so does this make it permanent?
Click to expand...
Click to collapse
don't know, but my guess is no.
why would you want to make something permanent if you haven't tested it for a few days?
Hey guys, sorry if this has been covered elsewhere, I've been searching but haven't been able to find anything. If it has, I'd appreciate a link to the thread, thanks
I'm sure I'm not the first to want this, but I'd like to throttle my Droid Incredible's CPU based on the currently open application. I'd like to do it one of two ways.
The first way is perhaps by using Tasker and the Execute plugin for Locale that I have installed for Tasker. The problem is, I don't know what commands to use in order to set my CPU minimum speed, maximum speed, and scaling type (performance, ondemand, etc.). Do I need to use an external script or program to do that? Or is there something built right into Android that I can use via Terminal / the Execute plugin for Tasker?
The other method would be through a profile built into SetCPU. I know I can just email the dev of SetCPU, but I figured he's gotten the question from someone here already, and perhaps they could pass the info along. Has anyone already asked if he plans on integrating application-based profiles in the future? Or is it possible to set SetCPU's parameters through Terminal somehow?
Thanks
Great question. I've seen some clocking scripts, but haven't tried them out. Here's one link: http://forum.cyanogenmod.com/topic/595-alternative-setcpu-script/
And also, here are clockup/down scripts that I found somewhere, saved on my phone, but never actually used...
clock up:
Code:
#!/system/bin/sh
if [ "$(id -u)" == "0" ]; then
CUR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`
COUNT=30;
until [ $CUR -lt 1000000 ] || [ $COUNT -lt 1 ];
do
sleep 1;
CUR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`
COUNT=$((COUNT-1));
done;
echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
else
echo -e "Getting root priveleges\n"
su<$0
fi
clock down:
Code:
#!/system/bin/sh
SPEED=200000
if [ "$(id -u)" == "0" ]; then
CUR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`
until [ $CUR -le $SPEED ];
do
sleep 1;
CUR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`
done;
echo $SPEED > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
else
echo -e "Getting root priveleges\n"
su<$0
fi
What I'd personally love to see are the action intents needed to manipulate SetCPU itself from Tasker. The only reason I haven't used the above scripts is that I worry slightly about trying to actively manipulate the CPU both through SetCPU while simultaneously through separate scripts. I worry that the two will step on each others' feet and I won't have a clear idea of what's going on with my CPU. That's why I'd like to see a solution that manipulates SetCPU itself.
chameleon131 said:
Hey guys, sorry if this has been covered elsewhere, I've been searching but haven't been able to find anything. If it has, I'd appreciate a link to the thread, thanks
I'm sure I'm not the first to want this, but I'd like to throttle my Droid Incredible's CPU based on the currently open application. I'd like to do it one of two ways.
The first way is perhaps by using Tasker and the Execute plugin for Locale that I have installed for Tasker. The problem is, I don't know what commands to use in order to set my CPU minimum speed, maximum speed, and scaling type (performance, ondemand, etc.). Do I need to use an external script or program to do that? Or is there something built right into Android that I can use via Terminal / the Execute plugin for Tasker?
The other method would be through a profile built into SetCPU. I know I can just email the dev of SetCPU, but I figured he's gotten the question from someone here already, and perhaps they could pass the info along. Has anyone already asked if he plans on integrating application-based profiles in the future? Or is it possible to set SetCPU's parameters through Terminal somehow?
Thanks
Click to expand...
Click to collapse
Have you considered a kernel that does processor throttling for you, rather than doing it yourself? King has them for AOSP and Sense ROMs. Take a look - those kernels do some amazing stuff, with little to no user input (ie settings or tasker tweaks) needed.
smtom said:
Have you considered a kernel that does processor throttling for you, rather than doing it yourself? King has them for AOSP and Sense ROMs. Take a look - those kernels do some amazing stuff, with little to no user input (ie settings or tasker tweaks) needed.
Click to expand...
Click to collapse
How does the kernel know that when I read on my phone using kindle, I really don't care how fast the page turns, but when I play a game I do care? Or maybe with angry birds, I don't care, because there's no real time component, but with Doom I do care?
How does it know that I'll get to a charger in 2 hours, so at the rate things are going, I don't need to conserve power? Or maybe that I'll get to the next charger in two days, so I need to conserve power maximally?
I wish to do this as well.
Solved!
Good news everyone! Tasker has recently added this to its very very long list of features. Kudos to the dev, and thank you for your amazing program!
chameleon131 said:
Good news everyone! Tasker has recently added this to its very very long list of features. Kudos to the dev, and thank you for your amazing program!
Click to expand...
Click to collapse
If it helps, I've had a go at setting up the CPU Profiles here
It was trial and error, so let me know what you all think!
First of all, I needed SetCPU to detect the battery temperature on my overclocked Galaxy Tab (to switch profile when overheating), so I modified my home-brewed kernel with this small patch:
http://forum.xda-developers.com/showthread.php?p=11454036#post11454036
This is fine, but on my JMI ROM (even with the correct /system/lib/hw/sensors.default.so library), applications like "SensorTest" were not displaying the temperature from the AK8973B sensor. I found a way to fix this.
Basically, I compiled this open-source driver (or alternatively, this one), which provides a custom sensors.default.so library and akmd service executable. The former is actually not needed, only the latter needs to be run on the Tab (because the standard /dev/akm8973_daemon device node is used, via ioctl to update the /dev/input values for compass, etc.).
First, I stopped the default /system/bin/akmd2 service. I then launched the custom akm daemon, which showed wrongly-calibrated values for the compass and orientation sensors (because I entered random digital and analog gain values), but the correct temperature was displayed (actually higher than the battery one !). I then stopped akmd, and re-launched akmd2...and magic: the temperature is now picked-up correctly !
Note that the gyroscope and accelerometer sensors are *not* affected these AKM modifications (they are effectively different hardware, with different drivers). The ambient light and proximity sensors are also different hardware (the latter isn't enabled on the Tab, by the way...I suspect we need to compile/install a driver for it).
I will do more testing with akmd and akmd2, and I will probably modify my init.rc to launch the service accordingly (in my custom initramfs).
I hope this helps.
Cheers, Dan
--- EDIT ---
Mhmmm, here's an interesting update:
There is no need to compile the open-source AKM daemon ! Instead, you just need to kill the /system/bin/akmd2 process, and restart it.
Well, actually it's not that simple: it only really works when the temperature sensor is polled (for example, when the SensorTest or Elixir app is displaying current values). Oh, and the temperature sensor only spits-out results when the compass sensor is also polled at the same time ! (Elixir is useful to test this, because sensors can be selectively activated)
I tried to reverse-engineer the values coming out of /dev/input/event4 (which corresponds to the compass sensor, as shown by the getevent command). I used shell commands similar to that (note the automatic conversion from hexadecimal to decimal values):
Code:
getevent | grep "/dev/input/event4:" | sed 's/ffffff//g' | awk '{print $2 " " $3 " " ("0x"$4)+0 ">" $4}'
Unfortunately my time ran out before I could make sense out the stream of values.
By the way, here is the script I used to stop+restart the AKM daemon in init.d/ :
Code:
get_akmd_pid()
{
ps -w | grep akmd2 | grep -v grep | awk '{print $1}'
}
pid=`get_akmd_pid`
echo "Killing /system/bin/akmd2 (PID: ${pid}) ..."
kill -9 $pid
pid=`get_akmd_pid`
echo "Checking that /system/bin/akmd2 process has been terminated: now PID = [${pid}] (should be empty)"
echo "Restarting /system/bin/akmd2..."
/system/bin/akmd2 &
pid=`get_akmd_pid`
echo "Checking that /system/bin/akmd2 process has been restarted: now PID = [${pid}] (should NOT be empty)"
What temperature do you consider too hot on your tab? I currently have my set to underclock from 1.4 ghz to 800 mhz whenever it reaches 90 degrees Fahrenheit (I am a worry-wart), but it reaches that a lot, so I was wondering what you have the maximum temperature set to before you bring the clock speed down.
Thanks
caveman999 said:
What temperature do you consider too hot on your tab?
Click to expand...
Click to collapse
I'm not sure yet. The battery temperature is lower than the one indicated by the AK8973 sensor. As it stands, SetCPU switches profiles based on the battery temperature, so personally I use conservative values (at the moment, 35 degrees Celcius).
By the way, the original post has been updated to reflect new findings.
Cheers, Daniel
my temp sensor is stuck at 30 c after flashing a kernel how do i get it to work. what you posted did not work. im actually stuck in a boot loop
nev310 said:
my temp sensor is stuck at 30 c after flashing a kernel how do i get it to work. what you posted did not work. im actually stuck in a boot loop
Click to expand...
Click to collapse
Same here, stuck on 30 degrees C. Any fix would be appreciated.
Any updates on this
Hi
i have a weird thing , dont know if its rom related but defenetly noticed it after rooting my device and installing cosutm roms. well i only used ARHD since 2.0.09 and i love it.
but , what happens is that suddenly and out of nothing (after like hours/days and the rom running smooth and ultra fast) , system cpu usage jumps to 100% and never bugs off only through a restart, and this seems to happen with all the different versions of ARHD i had, even though i install most of them with full wipes. but this i don't understand and it annoyes me cos it uses this cpu amount and drains battery and it happens suddenly and randomly , dunno what triggers it, and no matter how i tried to track it to see the error but couldn't find a thing.
i just hope u can help me by taking a look at this log i saved from android systeminfo app registering some errors (3 min log and it drained 14% battery ) , it shows something about "activity manager", im not a developer and i know nothing about those codes, but would be awesome if someone helps me out with any tip please.
thank you.
I am not a DEV but i don't think your log file includes any clue of what is causing your problem. Do you have sense account on? or any types of account that let you track your phone?
Activate usb debugging
Seems to be the bug with the .init process.
Sent from my Desire HD using Tapatalk
thank you for the replies , i already have usb debugging on. dunno what is causing this, its totally random and its driving me nuts.
can you see a process that uses 100% cpu in android system info? If yes, try to kill it and look at your cpu usage.
CPUNotify is a great tool. It shows cpu usage in the notification bar
Sent from my Desire HD using Tapatalk
the process showing 100% cpu usage (not always but randomly, no idea what triggers it ) is system , and u can't force close or end that task
Hmm strange... i can't even find a process called activity manager on my phone...
Well i don't know but maybe it's related to the DroidDream malware. Some apps in the market were infected with this virus. And i've read that the virus gains root access and can download other apps in the background.
Here's a link: http://forum.xda-developers.com/showthread.php?t=977154
I really don't know if it's related to this but it just came to my mind
Sent from my Desire HD using Tapatalk
thx for the help mate , but i dont think its related to droidream cos ive been having this issue since a while (long time before droidream was up )
im still monitoring to find out what is causing this issue.
i have the same issue since going to a rooted ROM (HD rev 2.0.12). tried every build up to 3.0 and i have the same issue. it seems to be randomly triggered (i've seen it trigger after playing "robo defense", playing music, making a call etc).
i have no sense account and dont have malware and have usb debugging on
I fix/hack it this way..open adb shell
type
chmod 700 /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
ie disallow anything (even system_server) from reading this file.
in fact i automate this command to run every 15 mins using an app called phone prioritizer. as soon as you type the chmod..your logcat will stop spinning and all will be well (iove not seen any side effects yet).
ps. you have to run this every time you open setcpu, as it will reset the permission on this file to 777/666 depending on the version of setcpu you have.
Activate usb debugging
Seems to be the bug with the .init process.
Click to expand...
Click to collapse
nope that totally different. that problem shows itself in "top -m 5" as init taking all the cpu ..this will show as system_server.
the "bug" manifests itself in this kernel file:
goto url github.com/android/platform_frameworks_base/blob/master/services/java/com/android/server/ProcessStats.java#L157
it spins on getCpuSpeedTimes() where it reads time_in_state..why it does this i dont know..it looks like mBuffer is corrupt as nosuchelementException would indicate that the buffer didnt have 2 words per line of the file yet the real file looks fine if you cat it (readFile seems not to initialise this on reading it to null first (but i'm not a java expert..maybe ".read" does this) so perhaps it has junk in it on certain conditions..any java guys out there can explain why they made this a glbal variable? it seems like it should be a local one)
by chmodding the file i cause an IOException to throw in readFile (which is then ignored and the return is gracefully set as null..this then skips the infinate loop).
you can see this issue in a few bugs like android issue 9733..oxygen rom issue 507 etc.
wow , cheers mate for the help , sounds a bit complicated for me but at least we know what it is now and how to get over it.
but how come mike1986 doesnt know about this bug and its fix ? he could incorporate this into his next build so it saves us that command run every 15 mins. or it cant be incorporated ?
someone should tell him to be honest
but cheers for explanation mate, thank you
Is Apache14 informed about this? Maybe he can solve it in next Kernelversion.
walda said:
Is Apache14 informed about this? Maybe he can solve it in next Kernelversion.
Click to expand...
Click to collapse
i have no idea about that , if he does then im sure he will fix it
As I read in mikes 3.0 thread, he is informed. Fine...
sent from my DHD via Tapatalk
further to this.
in ProcessStats.java (im not sure if this is a kernel file or if it sits just outside the kernel).
mBuffer looks to me to be the main problem.
1. in apaches rom, which is overclocked he defines 23 CPU speeds..ProcessStats.java only allows 20
Code:
private long[] getCpuSpeedTimes(long[] out) {
long[] tempTimes = out;
long[] tempSpeeds = mCpuSpeeds;
final int MAX_SPEEDS = 20;
if (out == null) {
tempTimes = new long[MAX_SPEEDS]; // Hopefully no more than that
tempSpeeds = new long[MAX_SPEEDS];
this is a minor issue..as this overflow is trapped in the loop anyway:
Code:
if (speed == MAX_SPEEDS) break; // No more
however, the definition of mBuffer is too small:
Code:
private byte[] mBuffer = new byte[256];
my file at the moment is 300 bytes. the readFile reads only once instead of looping until end of file:
Code:
int len = is.read(mBuffer);
is.close();
so only the first 256 bytes are ever read.
My assumption is that IF the files first 256 bytes ends up cutting off the last read line (and that line lies in the first MAX_SPEEDS lines of the file) before the speed time element..this causes a NoSuchElementException to throw..as the last line will be like
921600 255
960000 750
998400 8042
10368
ie the line
1036800 3089
was cut off too soon and this code
Code:
long val = Long.parseLong(token);
tempSpeeds[speed] = val;
token = st.nextToken(); <-- here
val = Long.parseLong(token);.
in getCpuSpeedTimes() fails as it cant see the timing?
would then fail on the second nextToken().
the big question is who owns that code in our custom ROM? is it the same as the original android code so we are at the mercy of Google to fix it or is this something Mike / Apache will be able to patch up ..assuming i'm making sense
the only workaround is as i said before: to chmod this file to 700 and ensure it stays there (avoid using setcpu as it changes the permissions).
You can probably also reduce this by limiting the CPU frequency range your phone uses (ie keep the filesize smaller)..if you have profiles that span 200mhz to 1.2ghz then you will probably hit this sooner
i did a test.
1. rebooted my phone..ensured time_in_state had permissions -r--r--r--
2. manipulated CPU frequency using cpu tuner to make all frequencies have at least 5 bytes per line.
once the first 20 lines were > 256 bytes and the 256nd byte sat between <cpu speed> and <time spent at that speed> i get the loop.
eg just before the issue arose i saw:
Code:
# cat time_in_state
cat time_in_state
245000 200030
422400 12676
460800 11929
499200 10333
537600 37021
576000 10685
614400 13672
652800 10646
691200 14864
729600 13956
768000 12662
806400 15025
844800 22094
883200 26741
921600 10389
960000 9937
998400 17606
1036800 6864
1075200 1560
1113600 1296
1152000 2158
1190400 2540
1228800 2463
i had my cpu pinned to 960 mhz.
the 256 at this point lies here:
Code:
1075200 1560
1113600 1
ie line 20 is cut off after 1..this is still "valid" in terms of the data in mBuffer..but once 960 rolled into five digits
Code:
# cat time_in_state
cat time_in_state
245000 200030
422400 12676
460800 11929
499200 10333
537600 37021
576000 10685
614400 13672
652800 10646
691200 14864
729600 13956
768000 12662
806400 15025
844800 22094
883200 26741
921600 10389
960000 10288
998400 17606
1036800 6864
1075200 1560
1113600 1296
1152000 2158
1190400 2540
1228800 2463
the 256 byte now meant the last line shifts to:
Code:
1036800 6864
1075200
the 2nd word is now totally missing!
as soon as this happened..my logcat started issuing
Code:
Unexpected exception collecting process stats
java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenizer.java:272)
at com.android.server.ProcessStats.getCpuSpeedTimes(ProcessStats.java:596)
at com.android.server.ProcessStats.getLastCpuSpeedTimes(ProcessStats.java:568)
at com.android.server.am.ActivityManagerService.updateCpuStatsNow(ActivityManagerService.java:1657)
at com.android.server.am.ActivityManagerService$4.run(ActivityManagerService.java:1583)
errors.
something later on then causes this behavior to go into a full tight loop (as once the issue starts..it just issues this every few seconds..so most uses wont notice it).
didnt mike fixed it with his latest release (ARHD 3.1) ?
Goodm7sn said:
didnt mike fixed it with his latest release (ARHD 3.1) ?
Click to expand...
Click to collapse
mike changed the file permission to 700 to get around it. the bug is still there in the code though. also im not sure if hes scheduling it to make it stay at 700..if not then users with setcpu installed may still get the problem (as setcpu changes the file permission back to 777/666 when you open the gui).
DazzaL said:
i have the same issue since going to a rooted ROM (HD rev 2.0.12). tried every build up to 3.0 and i have the same issue. it seems to be randomly triggered (i've seen it trigger after playing "robo defense", playing music, making a call etc).
i have no sense account and dont have malware and have usb debugging on
I fix/hack it this way..open adb shell
type
chmod 700 /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
ie disallow anything (even system_server) from reading this file.
in fact i automate this command to run every 15 mins using an app called phone prioritizer. as soon as you type the chmod..your logcat will stop spinning and all will be well (iove not seen any side effects yet).
ps. you have to run this every time you open setcpu, as it will reset the permission on this file to 777/666 depending on the version of setcpu you have.
nope that totally different. that problem shows itself in "top -m 5" as init taking all the cpu ..this will show as system_server.
the "bug" manifests itself in this kernel file:
goto url github.com/android/platform_frameworks_base/blob/master/services/java/com/android/server/ProcessStats.java#L157
it spins on getCpuSpeedTimes() where it reads time_in_state..why it does this i dont know..it looks like mBuffer is corrupt as nosuchelementException would indicate that the buffer didnt have 2 words per line of the file yet the real file looks fine if you cat it (readFile seems not to initialise this on reading it to null first (but i'm not a java expert..maybe ".read" does this) so perhaps it has junk in it on certain conditions..any java guys out there can explain why they made this a glbal variable? it seems like it should be a local one)
by chmodding the file i cause an IOException to throw in readFile (which is then ignored and the return is gracefully set as null..this then skips the infinate loop).
you can see this issue in a few bugs like android issue 9733..oxygen rom issue 507 etc.
Click to expand...
Click to collapse
Thanks mate, your solution is really effective on my DHD with revolution 3.0.
I am going to reflash with revolution 3.1, hopefully 3.1 will cure the cpu 100% usage
im on android revolution HD and i can confirm this , 100% system cpu of death is still here, didnt get fixed , had to change setcpu frequency and it stopped
meh phone cant last 12 hrs without a restart, frustrating.
DazzaL said:
mike changed the file permission to 700 to get around it. the bug is still there in the code though. also im not sure if hes scheduling it to make it stay at 700..if not then users with setcpu installed may still get the problem (as setcpu changes the file permission back to 777/666 when you open the gui).
Click to expand...
Click to collapse
if setcpu changed the range once the gui is opened , what do u recommend us to use for overclocking ? something safer
thx for helping
I read that it happens with CPU tuner and even without anything also!
The only solution I see is to fix the frequency file.
sent from my DHD via Tapatalk
LATEST UPDATE: 02.02.2013
A question that I'm often asked is:
"Can I have your permission to use your script in my ROM etc...?"
That answer to that is:
"Yes it is ok to use the code. I don't really believe it's useful anymore, but if you can find a use, and possibly improve the code to make it work better, go for it."
Version 1.0.2
Download available for ClockworkMod: requires Root (Superuser/Busybox), and a kernel that supports "init.d" scripts (script files that are stored in /system/etc/init.d/).
Always have a backup before installing any modification. Even though this script is rather simple, I can't guarantee it will work on every ROM! It appears to freeze custom ROMs such as CM, I don't know why. Maybe someone else knows.
NOTE: This script appears to be less and less useful as newer ROMs and phones become more sophisticated in dealing with any sort of lag. Tested on I9000XWJW9 and it doesn't seem to help. This ROM is quite smooth anyway.
What this script hopes to achieve:
- Entering your PIN with minimal/no delay/lag
- Minimising delay with lock screen pattern/unlock (not the time it takes to wakeup, but the touchscreen response lag)
- Having smoother notifications on the status bar, and smoother pulldown menu response
- Minimising Launcher lag while Media Scanner is running (can scroll through screens without heavy pauses)
- Minimising lag when scrolling through the market while icons are still loading
- Installing/Uninstalling apps while continuing other tasks
- Minimising/eliminating intermittent lag spikes in gaming
- No delay in being able to answer phone calls
... you get the idea
#!/system/bin/sh
#
# Loopy Smoothness Tweak v1.0.2 - 02/02/2013 (http://forum.xda-developers.com/showthread.php?t=1137554).
#
# An attempt at keeping the UI running a little smoother.
# Optimised for Galaxy S1 stock ROM, but can be modded for other Android devices. Backup recommended before running scripts.
# Not recommended for custom ROMs, such as CM. The "sleep" command appears to halt the OS, rendering the script useless.
# Feel free to edit how you wish, but please leave at least the first comment above as is.
# Any editing must be saved in UNIX (LF) format. Google "text editor unix lf" to read more.
#
Click to expand...
Click to collapse
However, as phones get faster, this script will probably have less of an effect.
Even with 2.3.6 and ext4, RAM scripts, governor tweaks, other tweaks, etc. the occasional lag still appears to be there, especially noticable when installing/unistalling, gaming, or even just scrolling through the launcher screens and menus. I decided to investigate. Being a linux newbie, I had to also source the appropriate commands.
The following has been discussed a little here and there on other Android forums, but surprisingly I couldn't find anything about it in the I9000 section...
Thinking of how processes in Windows can be run with six different priorities (Low, Below Normal, Normal, Above Normal, High, Realtime), I investigated to see what the deal was with Linux/Android. Turns out there are forty settings, ranging from -20 (Highest) to 0 (Default) to 19 (Lowest).
The next step was to see which process was causing the CPU bottleneck as it was happening. The top command is handy for this. I used this in adb shell (these tests were performed quite some time after reboot when there was craploads of stuff in the memory - the impact is not very noticeable after a fresh boot, or with very few apps installed/running.
UPDATE: The reason behind the majority of the kswapd0 issue was due to modified code of a custom kernel I was once using. I do however still find the script of benefit to me, and maybe you will too. You can still read below if you wish, but it may be irreverent.
Code:
adb shell
top -n 1
At the top of the list was:
18 16% R 1 0K 0K fg root kswapd0
Click to expand...
Click to collapse
kswapd0 is a kernel thread responsible for managing the memory.
I know Angry Birds can show a little lag from time to time, so I performed a little testing while playing that.
To change the priority of a running process, I used the renice command as such:
Code:
su
renice -20 `pidof kswapd0`
where -20 equals highest priority and `pidof kswapd0` returns the PID of the process, which is required by renice. In this case, 18.
To confirm the change, the ps command will give you what you need to know. Interesting to note "krfcommd" with a value of -10, and "mediaserver", -8.
Code:
ps -p kswapd0
If you enter "ps -p" all processes in memory are shown, along with their "nice" value.
It shouldn't take long before the game becomes barely playable at times (for a split second), as kswapd0 completely takes over the CPU until it performs its task. Setting the priority to
Code:
renice 0 `pidof kswapd0`
returns kswapd0 back to its default, and Angry Birds with the seldom lag. Let's go the other way now with
Code:
renice 19 `pidof kswapd0`
setting kswapd0 to its lowest priority, it should now have barely any impact on the game, if at all. Will this have negative impact on Android, though? Not sure yet.
We can even go one better and give Angry Birds all the CPU it needs via
Code:
renice -20 `pidof com.rovio.angrybirds`
With these settings in place, you could virtually play this all day, and your battery would probably be flat way before any lag becomes noticeable.
One problem though, when you close and reopen the game - assuming it's left the memory - it will have a new PID and the priority is set back to 0 (default).
Now, with my very limited knowledge of Linux/Android/Busybox, I'm not sure if there's a way to tell an app to open with a priority other than 0. Well, there is the nice command, but I couldn't get that working.
A common problem is the phone dialer app taking too long to popup when someone calls. Luckily, processes such as this one enter the memory from boot and seem to remain there. Setting its priority to -20 will basically tell the CPU to hold everything with less priority and open the phone dialer ASAP so you can take that call. And it works. I was on Angry Birds when a call came in, and was able to answer it on the first ring. I tried then calling myself without the -20 phone or the 19 kswapd0 settings, and there was an extra 2-3 second delay before I was able to answer. A few other apps that usually never leave the memory are default launcher (in my case, ADW Launcher EX), SMS/MMS app, Swype, Status Bar, and some others.
Even with apps launching at the default priority, with kswapd0 at 19, it still allows them more CPU, and may just be enough to combat this lag that people have tried to rid of with RAM scripts, Overclocking, and what not.
The script shown below is not the current init.d download script.
And the result (still a work in progress):
Code:
#!/system/bin/sh
###### Loopy Smoothness Tweak for Galaxy S (Experimental) #######
sleep 3
renice 18 `pidof kswapd0` # please give credit and thanks to loopy for this line if it works
##### Set nice levels for smoothness loop BEGIN #####
### Let's loop this in the background for a bit
for i in {1..20}
do
sleep 5
### Phone dialer app ###
renice -20 `pidof com.android.phone`
### Launcher apps ###
renice -19 `pidof com.sec.android.app.twlauncher` # TouchWiz Launcher
renice -19 `pidof org.adwfreak.launcher` # ADW Launcher Ex
renice -19 `pidof org.zeam.core` # Zeam launcher
### System apps ###
renice -19 `pidof com.android.mms` # Text message app
renice -19 `pidof com.swype.android.inputmethod` # Swype keyboard
renice -15 `pidof com.sec.android.app.controlpanel` # Task manager
renice -15 `pidof com.android.systemui` # Status bar
renice -9 `pidof com.android.settings` # Settings menu
renice -9 `pidof com.android.browser` # Browser app
renice -9 `pidof com.android.vending` # Market app
renice -6 `pidof com.sec.android.app.camera` # Camera app
renice -6 `pidof com.sec.android.app.fm` # FM Radio app
renice -6 `pidof com.google.android.youtube` # YouTube app
renice -6 `pidof com.google.android.apps.maps` # Maps
renice -3 `pidof android.process.acore`
renice -3 `pidof android.process.media`
### Memory management kernel thread ###
renice 19 `pidof kswapd0` # please give credit and thanks to loopy for this line if it works
done
##### Set nice levels for smoothness loop END #####
What would be ideal is if programs such as launchers (TouchWiz Launcher etc..) had the ability to set its "nice" level upon launch, and have kswapd0 set real low, assuming it's safe to do so. If Android isn't doing this, why not? This isn't a good idea? Maybe it's only Samsung? If so, then... well, I won't ask why not...
NOTE: These commands/parameters vary depending on the su/busybox version installed.
Common SGS1 apk's:
com.android.phone # Phone
com.sec.android.app.dialertab # Dialer
com.sec.android.app.twlauncher # TouchWiz Launcher
com.android.mms # Messaging
com.swype.android.inputmethod # Swype keyboard
com.sec.android.app.controlpanel # Task manager
com.android.systemui # Status bar
com.android.settings # Settings menu
com.android.browser # Internet Browser
com.android.vending # Google Play
com.sec.android.app.camera # Camera
com.sec.android.app.fm # FM Radio
com.google.android.youtube # YouTube
com.google.android.apps.maps # Google Maps
com.android.phone # Phone
Common SGS3 apk's:
com.android.phone
com.android.contacts
com.sec.android.app.controlpanel
com.android.browser
com.android.mms
com.android.vending
com.android.settings
mediaserver
com.sec.android.app.camera
com.sec.android.app.videoplayer
com.sec.android.app.myfiles
com.android.browser
com.sec.android.app.camera
Click to expand...
Click to collapse
Quick FAQ:
I wanna see how it works without it again, how do I remove the script?
To remove, delete the file /system/etc/init.d/S00loopyst. If using Root Explorer, use Mount R/W before you attempt to delete. For adb, use the commands at the DOS prompt:
Code:
C:\>adb root
restarting adbd as root
C:\>adb remount
remount succeeded
Code:
[SIZE=2][SIZE=2]C:\>adb shell rm /system/etc/init.d/[/SIZE][/SIZE][SIZE=2]S00loopyst
[/SIZE][SIZE=2]
[/SIZE][SIZE=2]C:\>
[/SIZE]
For the Test versions (prior to v1.0.0):
Code:
[SIZE=2][SIZE=2]C:\>adb shell rm /system/etc/init.d/S_loopy_smoothness_tweak[/SIZE][/SIZE][SIZE=2]
[/SIZE][SIZE=2]
[/SIZE][SIZE=2]C:\>
[/SIZE]
How can I make this script run first/last?
Scripts in the init.d are run in alphabetical/numerical order, following the letter "S". For example, script "S_ramboost" would run AFTER "S00loopyst", because "r" is after "l". Renaming it to "S_1ramboost" will now run that script BEFORE "S00loopyst".
How do I edit the script and add apps I use?
Open the .zip file and extract the file S00loopyst from /system/etc/init.d/. Alternatively, if installed, you can edit the file directly from the phone's init.d folder. File must be saved in UNIX format.
So I can just edit the script and add apps I use?
You can, but there is no guarantee this will actually work. Very few processes remain in memory...there is a lot of chopping and changing going on in the background. You could alter the script's timing variables, but even then results are unpredictable with anything other than what I call the resident system processes. If you're able to improve the script in any way, let us know.
Will this work on a custom ROM such as CM/MIUI?
Probably not. The "sleep" command within the screen appears to run in the foreground as opposed to the background in a stock ROM, hence making the script useless. Not to mention it may prevent anything else loading.
Are the settings permanant?
Usually. Most apps remain in the memory, although some do come and go. If you use the Task Manager to clear apps from the memory, or use the "Clear memory" option, the apps will have lose their priority when removed from the memory.
Changelog:
v1.0.2a:
Added option for "low priority" tasks.
Early script finish if 2nd loop is complete before "number of checks" is complete.
More detailed log file.
v1.0.1:
Cleaned up some invalid code.
Tested OK on rooted Samsung GT-I9000 2.3.6 ROM.
Tested OK on rooted Samsung GT-I9305T 4.1.1 ROM.
Tested NOT OK on CM 9.1 GT-I9000 ROM. Phone freezes on boot until loop is complete.
v1.0.0:
User friendly - a lot easier to configure.
Total number of processes automatically calculated (used to shorten 1st loop if all apps are in memory).
Debug file created for troubleshooting (includes "renice" pass or fail test) - can be saved to /data partition or sdcard.
Simple "Aggressive" option to increase priority of resident and other apps.
In addition to kswapd0 checking before continuing, launcher app is also checked in a loop before continuing (usually no more than ~15 seconds after start-up).
oom_adj & oom_score settings for launcher to remain resident (doesn't seem to work too well... settings don't appear to "stick").
T2:
"Smarter" script.
Checks for kswapd0 every 3 seconds until found, and then 'nice' level is set.
1st loop: checks for apps 60 times, at an interval of 3 seconds. Once an app is found in memory, 'nice' level is set, and it is not checked again during the loop. (Some apps enter and then leave the memory, which ain't helpful.)
2nd loop: checks again 6 times at an interval of 5 seconds and sets 'nice' level.
Settings are a little more user-friendly.
Debug option (if kernel stores a log file).
T1:
Sets kswapd0 'nice' level after 3 seconds.
Pauses for 15 seconds, sets 'nice' levels for other apps (many of which don't remain in memory).
Download:
Download file and transfer to SD card
Enter ClockworkMod Recovery via Vol+Up/Menu/Power button combo
Select zip and install (remove any "Test" versions before using Version 1 or above)
I'm not a Linux/Android master myself, but this actually is food for thought. I'll try and do some reading, and i would really like to hear more experienced users's opinion about it.
Thanks for the explanatory post.
Very interesting idea
Sent from my GT-I9000 using XDA Premium App
Thanks for the feedback so far. I too would like to hear what more experienced users have to say, as I've only been using linux for a few days now and have quite a lot to learn.
The other good thing about this is, if it turns out to be a good idea, I'm guessing it can be used on basically any Android device.
this is something to be looked at
interesting
I'd personally like to see more discussion on this and input from more experienced people as well so...
BUMP
A good place to start from...
Will take a look more....i am very interested on this and if u need help in scripts i can help u....
Sent from my GT-I9000 using XDA Premium App
interesting approach lpy !
FYI:
looping should be fine since it is also done, e.g. on the Galaxy Spica and CM7
but with different parameters
I have some ideas back in the back of my mind that might help with this issue (kernel-patches and other stuff)
Thanks !
edit:
related:
On Saturday, May 07, 2011 09:35:48 PM Ali Ahsan wrote:
> Hi All
>
> I have xeon server with 16 Gb Ram and no Swap memory.I am running
> cassandra server on two node in cluster.When there is high load on
> server kswapd0 kicks inn and take 100% cpu and make machine very slow
> and we need to restart out cassandra server.I have latest kernel
> 2.6.18-238.9.1.el5.Please let me know how can i fix this issue .Its
> hurting us badly this our production server any quick help will be
> appreciated.
There is more than one bug that causes this behaviour. A few related memory
managent situations (possibly responsible) may actually be avoided if you add
some swap (even if it's not used). My suggestion would be to add some swap,
set swappiness to 0 and see what happens.
/Peter
_______________
Click to expand...
Click to collapse
http://www.linux-archive.org/centos/523508-kswapd-taking-100-cpu-no-swap-system.html
Tried the script with go contacts,go sms, go launcher (edited ofcourse)
it seems to make them open instantly even when they aren't running in the background..
if some1 could make an app which make the app you use as -20 or something and if you close it or move to another one make it back to 0..
It would be really interesting to see this being controlled at Kernel level (if possible.)
I know that it contains the govenors to control the CPU and UV settings (smartass, conservative, etc.), but wouldn't it be awesome if you could determine a priority level for apps installed on your phone so that it removed a load of junk from memory?
I mean I know app developers would all start setting their apps "attention level" to -20, but if there could be an intelligent manager for this, it would make things alot faster I would think.
lttldvl said:
It would be really interesting to see this being controlled at Kernel level (if possible.)
I know that it contains the govenors to control the CPU and UV settings (smartass, conservative, etc.), but wouldn't it be awesome if you could determine a priority level for apps installed on your phone so that it removed a load of junk from memory?
I mean I know app developers would all start setting their apps "attention level" to -20, but if there could be an intelligent manager for this, it would make things alot faster I would think.
Click to expand...
Click to collapse
that s the goal , ultimately all these task killers try to achieve problem as of today is it usually creates more problems then it solves ..
having a script in init.d folder or using gsript (market app ) to run script manually on a regular basis to ensure your apk have the proper level ..
@ OP : good thread
that's really interesting approach but it has also some drawbacks. With nice you give a process more CPU time and in case that the application is not written properly you could end up with frozen system.
looping this script will eat my battery? i see it like a permament recursive process running in background.
phone will sleep properly after? cpu usage?
Indeed there is a speedup if I use parts of your script. This is an interresting approach to gain your most important task faster. I often recognized a large latency if I opened phone or sms/mms. Is their a way to preload this apps and prevent its swapping out of ram?
Edit: recognized a reliable process when updating a lot of apps at once -> no update failed message any more
using scripts should be fine and the resource consumption should not be a problem, if it is used properly
while using nice/renice will gain some benefits in controlling the priorities (i use nice too in some cases), i doubt the effectiveness if all thoese processes are set to low priorities
also, on my phone, the kswapd0 only consumes very little resources and it's not even in the top 10 in the top results but somewhere near 20
All good responses so far, and definitely making a lot of sense.
@simone201 many thanks re the script offer. There is no doubt this script can be improved, for example, having an 'if ... then' condition where once an app enters the memory, the "`pidof" changes from 0 (false) to a PID (true), and then the nice value can be set.
matematic said:
that's really interesting approach but it has also some drawbacks. With nice you give a process more CPU time and in case that the application is not written properly you could end up with frozen system.
Click to expand...
Click to collapse
Very true. -20 can be quite a dangerous setting if an app decides to play up.
lttldvl said:
I mean I know app developers would all start setting their apps "attention level" to -20, but if there could be an intelligent manager for this, it would make things alot faster I would think.
Click to expand...
Click to collapse
haha. I can see "priority wars" happening between developers and apps.
If Android doesn't take advantage of nice, I don't see why we can't. It's possible that in 12 months from now when many phones are dual core (or more?), this may have little impact, but for now this should prove very handy.
ykk_five said:
using scripts should be fine and the resource consumption should not be a problem, if it is used properly
while using nice/renice will gain some benefits in controlling the priorities (i use nice too in some cases), i doubt the effectiveness if all thoese processes are set to low priorities
also, on my phone, the kswapd0 only consumes very little resources and it's not even in the top 10 in the top results but somewhere near 20
Click to expand...
Click to collapse
I agree with all that, however, I don't really see it as a matter of "how much" it uses in terms of resources, but rather "when". My example with Angry Birds and a stock ROM, you will notice little glitches here and there, due to the work kswapd0 does. Lowering its priority still enables it to complete its task/s, but without interfering with real-time action.
Here are examples of some improvements I've noticed:
- Entering your PIN minimal/no delay
- Minimising delay with lock screen pattern/unlock (not the time it takes to wakeup, but the touchscreen response lag)
- Having smoother notifications on the status bar, and smoother pulldown menu response
- Minimising Launcher lag while Media Scanner is running (can scroll through screens without heavy pauses)
- Minimising lag when scrolling through the market while icons are still loading
- Installing/Uninstalling apps while continuing other tasks
- Minimising/eliminating intermittent lagging in gaming
- you get the idea..
The way I see it, at the very least, lowering the priority of kswapd0 already helps with the way everything runs. Setting an app's nice/renice value (if managed in a practical way) will be a bonus.
Just a quick note (uncertain if this is even related):
A couple of kernels ago (yes, i switch a lot) i noticed a large battery consumption by "Android System". This was running JVP, and DarkCore 2.7.3 i think... But it wasn't until I read this thread that I remembered that the reason I switched kernels was because of a "laggy" system. After a while the phone seemed a lot slower, and I had to reboot to get the initial speed.
Now with Galaxian kernel I have an extremely snappy phone, and the "Android System" drain is gone aswell....
How do you get the process name of an application (to edit the script)?
Edit\\ open app in app manager (astro)
I think this is an important topic, but don't see much feedback from developers.
My question as a non developer is:
is there a way for me to use this? seems like the script is already there, so it could be possible to have a flashable zip or a tutorial because different apps/versions require a different script.
Cool thing. I remember something very similar to this when I was having HTC Dream. There was scheduling app which runs similar script like this Will try it and post my opinion