Temperature hacks on the Tab (battery, and the other sensor) - Galaxy Tab Android Development

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

Related

How to configure the standard kernel scheduler (CFS) to behave more like BFS

First an introduction (sorry, if this got a little long, just wanted to make clear for everybody what we are talking about).
What is a scheduler?
The scheduler is a built-in part of the Linux kernel. It is that part of the kernel which decides how the available cpu power is divided among all running processes. As the cpu can only work for one process at any given time, the scheduler is responsible to assign cpu time-slices fairly to running processes.
Because of this the scheduler (among other things) plays an essential role on how responsive a system "feels" for the user. That's because responsiveness depends among other things on the time how long it takes from user input until the cpu handles the input (i.e. until "your" task/process gets cpu-cycles).
Current state of the art:
The standard Linux kernel uses the so called "Completely Fair Scheduler" (CFS) since some time (October 2007) now and seems to be useful for most use-cases (server, desktop, smartphone..).
As you may have already heard, since August 2009 there is a new player on the field, namely the "Brain **** Scheduler" (BFS). BFS promises some better latency behaviour on smaller platforms with fewer cpu-cores and mobile devices. Altough it wasn't accepted into the official Linux kernel tree, it was used by cyanogen and also adopted by Google into the mainline Android kernel (and as we are having kernel sources now, I'm sure you will see some more BFS-enabled kernels for the Hero, too).
But back to topic:
So, what I am going to talk about applies to those of you who DON'T have a kernel with the BSF scheduler (i.e. which have the standard CFS scheduler) which should be the majority of ROMs at the moment.
Tuning the CFS scheduler:
Even it's said that BFS may be better for small devices it's also possible to configure CFS for our needs:
While searching around I learned that the behaviour of the CFS scheduler can be influenced at runtime by a few parameters. All these settings can be applied at runtime and will be gone after a reboot. So it is safe to play around a little bit.
One interesting parameter I found was "NO_NEW_FAIR_SLEEPERS". As stated by some people on the Linux kernel mailinglist :
NO_NEW_FAIR_SLEEPERS is something that will turn the scheduler into a more classic fair scheduler (like BFS is too)
Click to expand...
Click to collapse
If this is true, maybe it will let the CFS behave better optimized for small devices.
But let's try it out! Let's see if it gives us some improvements.
How to to this:
Code:
# Step 1: Mount debugfs (which is a virtual filesystem like /proc/ or /sys/)
mount -t debugfs none /sys/kernel/debug
# Step 2 (optional): Display the current scheduler flags
cat /sys/kernel/debug/sched_features
# Step 3: Set the flag NO_NEW_FAIR_SLEEPERS
echo "NO_NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features
# Step 4: Unmount debugfs again
umount /sys/kernel/debug
As said before: These changes are NOT PERMANENT. They will be gone after a reboot. But therefore it's safe to play around here.
Testing:
Tuning the scheduler will not give you plain speed improvements, so testing with Linpack is useless here. Instead it changes the way how the system reacts if there is a lot of multi-tasking.
So when you have changed the settings try testing around a little bit when the system is under load (like playing music while doing CPU intensive stuff or things like that) and report if it behaves better/worse than with default settings.
How to undo the setting:
Simple reboot your phone.
Or redo the steps above and replace the command in Step 3 with this one (note that the prefix "NO_" is ommited here):
Code:
echo "NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features
Feel free to test and share your findings!
I guess I can copy paste the lines and use GScript to run them.
Any way to make this permanent? Put something in init.d maybe?
Geochelone said:
I guess I can copy paste the lines and use GScript to run them.
Click to expand...
Click to collapse
Of course. You will find 2 scripts for gscript in the attached zip-file:
enable_CFS_tweak.sh
disable_CFS_tweak.sh
So you can simply switch for easy testing.
For those who don't know GScript: It's an app from the market to easily execute scripts on your phone. Pretty handy if you are testing things before you add them to an init-script.
Instructions:
Install "GScript Lite" from the market
Unzip the 2 scripts and place it on the sd-card into the folder gscript
Launch GScript Lite, press "Menu" -> "Add script" -> "Load file" and select the scripts you just placed into "gscript" folder.
Make sure the "Need SU?" checkbox is checked and press "Save"
Tap on the script to launch it.
Geochelone said:
Any way to make this permanent? Put something in init.d maybe?
Click to expand...
Click to collapse
Correct. You would need to place the commands into an init script, which are located in "/system/etc/init.d" on most ROMs.
Hard to test..
I underclocked my Hero to 245Mhz, started the music player, launched NeoCore benchmark and via adb launched 10 instances of "md5sum /dev/urandom".
Music still not choppy. No matter whether the tweak is enabled or disabled.
The scheduler seems too good to exploit it..
[edit]
just got a NeoCore benchmark if 02.8 FPS Yeahh, that's stresstesting..
[/edit]
is there a way to make this by default in the source?
maybe add the option to the .config file?
MaXo64 said:
is there a way to make this by default in the source?
maybe add the option to the .config file?
Click to expand...
Click to collapse
Yes, you can edit kernel/sched_features.h
and replace
Code:
SCHED_FEAT(NEW_FAIR_SLEEPERS, 1)
with
Code:
SCHED_FEAT(NEW_FAIR_SLEEPERS, 0)
thanks mate, compiling right away..
what is the test result?
Just so you guys know we are basically doing this now on the Eris... via some cool scripts:
http://forum.xda-developers.com/showthread.php?t=784089&page=7
Thanks for the tip will definitively check it out
Wow! Thanks for the tip. After reading it sparked my curiosity in the Linux kernel so I went hunting on the web for more detailed info on this particular parameter (NEW_FAIR_SLEEPERS) but I found no useful info as to what exactly it is or what it does. unfortunately, the name doesnt give too much away either (to the layman).
Anyway eventually I came across a site that a couple of other SLEEPER parameters are mentioned. and it claimed that tweaking these as well as changing the sched_latency and sched_granulairty parameters will enhance android phone performance. Again I searched for explanations of these parameters but to no avail (im obviously not very good at searching!). In the end I thought id just apply the tweaks and see what happened. and voila! the phone is the smoothest I have ever felt it!
As I said I dont know which tweak is responsible for the smoothness or if its just a combination of all three but my phone is really nice to use now. I can scroll long lists and actually see scrolling instead of a stutter from start to finish! I am running elelinux 1.8 and flykernel10a at 528MHz and its smoother than i've had it when running at > 600MHz.
I have no idea what implications the changes have on the overall performance of the phone but its smooth and not overclocked! cant be bad??
so heres the changes I applied: (from ./adb shell or terminal emulator on phone)
$ su
# mount -o remount,rw /system
# echo 'kernel.sched_latency_ns = 600000' >> /etc/sysctl.conf
# echo 'kernel.sched_min_granularity_ns = 400000' >> /etc/sysctl.conf
# echo 'kernel.sched_features = 24188' >> /etc/sysctl.conf
# mount -o remount,ro /system
# sysctl -p
kernel.sched_latency_ns = 600000
kernel.sched_min_granularity_ns = 400000
kernel.sched_features = 24188
# exit
$ exit
the 24188 parameter disables a couple of sleepers and the other two change some timings in the kernel. The changes are supposedly ONLY suitable for non-BFS kernels. but they are supposed to make the CFS kernel behave more like the BFS kernel in general.
Anyway try it and see if you want and report back if it makes your phone any better or worse. Or if there are any Linux gurus maybe you can shed more light on what these parameters actually do.
I know this thread is a little old, but I wanted to report that those settings worked great on my MyTouch Slide! I'm also overclocked/underclocked to 825/245 and using the autokiller memory optimizer, with the settings you suggest my phone is amazingly fast!
I did a little research on these settings as well, and will report back as I do some more testing to see what works best with the specs in this specific phone. At that time I will post a link to a new thread on this in the section for my specific phone.
Thanks for the great tips!

activity manager cpu 100%

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

[SCRIPT/DISCUSSION] Loopy Smoothness Tweak (Android's priorities) [02-02-2013]

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

keeping NoRefreshToggle running after epd_disable

I have created 2 bash scripts for Gscript that allows NoRefreshToggle to get turned on every time epd gets disabled for more than 150ms [edit 0 ms].
It's nice to have a non-stop experience with NoRefreshToggle but the solution is quite dirty and it uses 10-20% cpu.
Does anyone have any other idea how to prevent NoRefreshToggle from turning off every time you switch to other application?
1. ON
input keyevent 4
input keyevent 4
killall nl.rogro.GScript
echo 350 > /sys/class/graphics/fb0/epd_disable
while true
do
val=$(cat /sys/class/graphics/fb0/epd_disable)
if [[ "$val" -gt 0 ]]
then
sleep 1s
am start -n com.eink.norefresh/.A2Activity
sleep 2s
fi
done
Click to expand...
Click to collapse
2. OFF
killall sh
Click to expand...
Click to collapse
EDIT :
fixed obvious error
Sometimes apk stops EPD for 150 ms.. i'll check whether the 0 threshold works better than 150.
Also, I need to observe the behaviour of epd_refresh.
EDIT 2:
- yes it does. Now NoRefresh starts after you open and close the 'quicknav' bar
- 'epd_refresh' does not help in any way
here are my other scripts
http://forum.xda-developers.com/showpost.php?p=35362768&postcount=105

[KERNEL] Bricked-Kernel Hammerhead | Sweep2wake | KnockKnock/Dt2w

Welcome to the most customizable N5 kernel on xda
Bricked-Kernel Nexus 5 (hammerhead)​
Features:
* Based upon Google's msm 3.4 source
* Various fixes, improvements and optimizatios (look @ github)
* Compiled with gcc4.7.2 toolchain (linaro 09.12)
* -O3+ optimized
* Snapdragon & CortexA15 optimizations
* replaced qcom's hotplug binary with msm_mpdecision (IN-KERNEL, better battery life + performance)
* Extensive sysfs interface for mpdecision with all the tuneables you want (/sys/kernel/msm_mpdecision/)
* replaced qcom's thermal binary with my IN-KERNEL solution. (/sys/kernel/msm_thermal/)
* export krait version to: /sys/kernel/debug/krait_variant
* Allow OC up to 2,5Ghz
* Allow UC to 96Mhz
* Undervolting (faux123)
* F2FS Support
* Multirom Support
* KCAL (savoca) & Gamma Control (faux123)
* Sound Control (faux123)
* Default clocks: 300 Mhz min & 2265,6 Mhz max
Zip features:
*** ON-THE-FLY-RAMDISK EDITS!
*** THIS KERNEL USES YOUR RAMDISK, it will just modify it on the fly while flashing. These changes are not creating any incompatibilities with roms/other kernels.
* removes min freq overrides from the ramdisk
* removes governor overrides from the ramdisk
* adds init.d support to your ramdisk (if not already supported)
* modifies stock ondemand settings
* add module insertion
Check the compare links for the rest ​
Where is tha Changelog???
There will be no more changelogs.
Instead the download pages were outfitted with compare links to github for each download.​
What is sweep2wake?
Disabled as default, activate through an app like KControl or over sysfs: echo 1 > /sys/android_touch/sweep2wake​
What is doubletap2wake / knock knock?
Disabled as default, activate through an app like KControl or over sysfs: echo 1 > /sys/android_touch/doubletap2wake​
How to install?
Flash through recovery. #done.​
How to uninstall?
Flash this:
http://bricked.de/downloads/kernel/hammerhead/bricked_uninstaller_hammerhead.zip
You are done. Bye.​
Where to complain about errors/bugs?
Please use the Issuetracker for bugs/errors/feature wishes!
Issuetracker @ https://github.com/showp1984/bricked-hammerhead/issues
[email protected]
IRC Chat: Freenode IRC #bricked​
Download:
No Guarantees! If it kills your grandmother or your device, I am NOT responsible! If you understand this:
(If you download, please hit Thanks below my post! Thank you!)
>>> DOWNLOAD <<<​
Donation Hall-of-Fame:​
> Hall of fame <
Thank you very much!​
Stock 4.4 Nexus5 boot.img - flash this if you come from another kernel coming with it's own ramdisk (eg: zip contains a *.img file) ONLY FLASH ON 4.4
Source:
​
What is msm_thermal?
Kernel based 3-phase thermal control!
This replaces your /system/bin/thermal-engine-hh binary which is renamed by the installer to thermal-engine-hh_bck.
It will throttle your cpu speed to keep it cool and unleash it if the cpu has cooled down enough. (3 phases: low, mid and high)
Check /sys/kernel/msm_thermal/conf/ for the thermal configuration
allowed_max_high = highest threshold (phase 3)
allowed_max_low = remove the throttling if we cooled down to this (clr_thrshold)
allowed_max_freq = max frequency if throttled (limit)
[...]mid[...] = same as above, just for phase 2
[...]low[...] = Lowest threshold (phase 1)
check_interval_ms = how often shall we check? (sampling rate)
shutdown_temp = if we reach this shut down the device!
If you want to see msm_thermal doing it's job:
Code:
adb shell
cat /proc/kmsg | grep 'thermal'
What is msm_mpdecision?
100% kernel based multi core decision! (should cpu1/2/3 be online or not?)
This replaces your /system/bin/mpdecision binary which is renamed by the installer to mpdecision_bck.
Check /sys/kernel/msm_mpdecision/conf/ for the configuration.
startdelay = time until mpdecision starts doing it's magic (20000)
delay = time between checks (130)
pause = if something else plugs in the cpu, fall asleep for 10000ms (10 secs)
scroff_single_core = if the screen is off, don't plug in cpu1/2/3. Additionally: Unplug all cpus except cpu0 when screen is turned off (1)
enabled = enable(1) or disable(0) mpdecision. This does not affect scroff_single_core!
min_cpus = min cpus to be online, cannot be < 1. Default: 1
max_cpus = max cpus to be online, cannot be > 4. (if you set it to 2 and min_cpus to 1 you will basically have a dualcore) Default: 4
idle_freq = a value against that will be checked if a core +/- is requested. (499200)
If cpu0 is below that value and a core up of another cpu is requested, nothing will happen.
If any other cpu is above that value and a core down of that cpu is requested, nothing will happen. (otherwise it would now put down that cpu even though it is still working, which isn't what we want)
Hot plug thresholds (aka now it gets 'complicated')
This small formula calculates which value will be used: (number_of_cpus_online - 1) * 2
The result of this formula will be the nwns_threshold where a new cpu is hotplugged.
The result of this formula + 1 will be the nwns_threshold where a cpu is unplugged.
nwns_threshold_x = runqueue threshold, if this is reached cpuX will be hot/unplugged
twts_threshold_x = time threshold, this amount of time must have passed for the related action to be taken (hot/unplug)
Example:
One cpu is online.
(1 - 1) * 2 = 0 ergo:
nwns_threshold_0 = cpu1 will be hotplugged at this value
((1 - 1) * 2) + 1 = 1
nwns_threshold_1 = cpu0 will be unplugged at this value
Since we can't unplug cpu0 this is '0'.
Two cpus are online.
(2 - 1) * 2 = 2 ergo:
nwns_threshold_2 = cpu2 will be hotplugged at this value
((2 - 1) * 2) + 1 = 3
nwns_threshold_3 = cpu1 will be unplugged at this value
etc...
Some values are:
NwNs_Threshold: 12, 0, 25, 20, 32, 28, 0, 35
TwTs_Threshold: 140, 0, 140, 190, 140, 190, 0, 190
Where the position and function of the number equals the result of the above explained formula.
(all times are in ms)
If you want to see the mpdecision magic happening:
Code:
adb shell
cat /proc/kmsg | grep 'MPDEC'
mpdecision's input event boost, aka project butter
This will boost your min cpu speed if you touch the screen or press a button and gives you full control.
In those events the min cpu freq will be risen to a predefined value (look below) on every online cpu. This boosts overall reaction times and smoothness a lot. (works similar to the qcom mpdecision binary)
Configuration files:
[email protected]:/sys/kernel/msm_mpdecision/conf # ls | grep boost
boost_enabled
boost_freqs
boost_time
All of them work like the usual sysfs files, except one special case:
boost_freqs will list all frequencies from cpu 0 to cpu x. Cpu 3 and any following cpu will share one frequency.
To change those frequencies echo the cpu number + the frequency in khz.
Example: To change the boost freq of cpu3 (and 4,5,6,7,8, etc) the echo would look as follows:
Code:
echo "3 960000" > /sys/kernel/msm_mpdecision/conf/boost_freqs
for cpu0:
Code:
echo "0 960000" > /sys/kernel/msm_mpdecision/conf/boost_freqs
Defaults:
Code:
cat /sys/kernel/msm_mpdecision/conf/boost_freqs
960000
960000
729600
576000
Why do I have no WLAN?
Due to this kernels very high optimization settings it is too big for our boot.img with WLAN included into the kernel, so it is built as a module. That means it needs to be inserted into the kernel upon boot up, which needs to be automated for maximum comfort.
The zip adds module insertion to your ramdisk, if that fails for some reason the wlan module cannot be inserted.
if
Code:
adb shell lsmod
doesn't show this:
Code:
tun 14701 0 - Live 0x00000000
cifs 275399 0 - Live 0x00000000
bcmdhd 2964650 0 - Live 0x00000000 (C)
Then something went horribly wrong.
Chances are that I broke it and this should never happen.
One post in the issue tracker will probably fix it with the next release
You can restore wlan for your current bootup by executing:
Code:
adb shell
su
insmod /system/lib/modules/bcmdhd.ko
Is there an app available to customize this pure bodacious and awesome kernel?
Yes there is: KControl. It's in the Google Playstore.
​
A few benchmark results:
Vellamo Metal:
http://vellamo2.quicinc.com/api/v2/app/plot/Metal/submission/PEE3B604B-8C49-69F5-001E-6BCA76DF491D
(usually ranges from 11xx-12xx. Depending on system background load, thermal status, air pressure, weather, world hunger, etc...)
Antutu:
https://plus.google.com/u/0/108262968419038009038/posts/VJbxpMoFJPN
(usually ranges from 28.xxx - 30.xxx. Depending on system background load, thermal status, air pressure, weather, world hunger, etc...)
3DMark Icestorm unlimited: (the others are maxed out)
https://plus.google.com/u/0/108262968419038009038/posts/N24t9ssoBcL
(17xxx)
FIRST! o yes!!! mwhahahah!! and so it begins
Finally a Bricked thread! :victory: No more F5 spamming the kernel website
Good stuff, you've finally joined the party.
Sent from my Nexus 5 using Tapatalk
Woot! first page!
+1
10 char
Ngo93 said:
Finally a Bricked thread! :victory: No more F5 spamming the kernel website
Click to expand...
Click to collapse
If you are familiar with rss, all kernel download pages have a little rss symbol, if you click it you get here:
http://bricked.de/kernelrss.php?action=krss&device=hammerhead&release=stable&type=aosp
Just something to consider instead of spamming F5
unforgivenmercy said:
Good stuff, you've finally joined the party.
Click to expand...
Click to collapse
If you take a look at the dates on my homepage you might notice that the party ended about 2 days ago. The after party on the other hand starts now!
faux123 said:
Woot! first page!
Click to expand...
Click to collapse
Indeed! Well the thread isn't that old yet
OBI ONE is here aweseome !!! Always a pleasure to hang around in ur threads
n3ocort3x said:
OBI ONE is here aweseome !!! Always a pleasure to hang around in ur threads
Click to expand...
Click to collapse
left something on github for you
I saw, many thanks for that, but i think i have to ask u a bit about this, already in bed now, but tomorrow is another day 5star and subscribed as always
show-p1984 said:
left something on github for you
Click to expand...
Click to collapse
In the op it just says to install. So no wiping of cache or D cache correct? Sorry just re assuring
Sent from my Nexus 5 using Tapatalk
Wiping cache is redundant and you don't have to do it with kernels.
Sent from my Nexus 5 using Tapatalk
Carbajal3009 said:
In the op it just says to install. So no wiping of cache or D cache correct? Sorry just re assuring
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
The zip does it for you.
However, if it gives you a warm and fuzzy feeling you are free to do it again (so twice then ^^).
Wow, finally it is here. Flashing now.
Has anyone actually demonstrated (scientifically or otherwise) anything wrong with the qcom mpdecision binary? Im not taking anything away from kernel developers who write their own mpdecision (especially those who also provides sources), but I am curious as to whether they are actually better than those provided by qcom. Surely they know more about the capabilities of their own cpus better than anyone no?
jazzor said:
Has anyone actually demonstrated (scientifically or otherwise) anything wrong with the qcom mpdecision binary? Im not taking anything away from kernel developers who write their own mpdecision (especially those who also provides sources), but I am curious as to whether they are actually better than those provided by qcom. Surely they know more about the capabilities of their own cpus better than anyone no?
Click to expand...
Click to collapse
A fair question, I imagine there is something sacrificed using either or.
Sent from my Nexus 5 using XDA Premium 4 mobile app
jazzor said:
Has anyone actually demonstrated (scientifically or otherwise) anything wrong with the qcom mpdecision binary? Im not taking anything away from kernel developers who write their own mpdecision (especially those who also provides sources), but I am curious as to whether they are actually better than those provided by qcom. Surely they know more about the capabilities of their own cpus better than anyone no?
Click to expand...
Click to collapse
It's not that complicated (there is no black voodoo magic), that's why bricked kernel was the first to introduce this feature back on the pyramid.
CPUs need to be plugged in / unplugged based on load, there is nothing more qcom can know that we can't also see inside of the kernel.
There is one HUGE thing that is wrong with qcom's mpdecision: It's closed. It's a black box. We don't have any idea what is going on in there. Literally, none. It's not even configurable. It could contain secret nsa code, or send dirty sms to your girlfriend (who might actually enjoy that, idk...)
If we would have source, hell, awesome. I wouldn't have spent over a year (first commit: Date: Thu, 21 Jun 2012 06:06:47 +0200, see here) to get my msm_mpdecision solution to the point where it is a) awesome and b) a lot better than the binary. It can be configured in any way you might need to. It features statistics on how often and how long a cpu is hotplugged. It has the input event boost. It's the full package deal.
If you compare my kernel with the stock kernel you will see huge performance improvements and battery savings on bricked. Those are not only because of my msm_mpdecision but certainly related. Furthermore: we can completely customize it, over sysfs, on a running kernel, without reflashing.
That's what I would have expected from qcom in the first place.
Another thing wrong with qcom's binary: It's static. Meaning: If you change your min freq on stock it will always reset back to defaults. Same with their thermal binary. That's just annoying.
msm_mpdecision will notice it if you change your min frequency and dynamically work with that from there on. It will also prevent hotplug wars between apps and it: eg: an app plugs in cpus to grab some cpu data (like frequencies, etc. That is only available if the cpu is plugged in). Qcom's mpdecision would now raise hell to keep that cpu unplugged, my msm_mpdecision just sits back and chills for 10 seconds to avoid those wars. (again, even that delay is fully configurable)
There are also a bunch of boring advantages as to why it is better to let something crucial to the system run in kernel space and not in user space, but that would most certainly explode the context of this thread by the factor of 4.
My solution is not inferior to that binary in any way, in fact it has been vastly superior in my testing up until now, otherwise I would a) improve it or b) ditch it. I don't keep around bad stuff just for the point of having it or because I wrote it. If it sucks I will say that and act accordingly.
Thanks for the very informative post. I suppose there are advantages in avoiding qcom's mpdecision. Though i'd like to point out that the Android framework (msm power HAL) does use some of the interfaces provided by the binary (see hardware/qcom/power/). With the nexus 4, this will spam a lot of stuff to logcat if you are missing this interface, not sure if this is the same with the nexus 5, but judging by the sources it seems it will. Maybe you could provide some notification about this side effect.
Similarly, this could apply to the thermal side of things as well.

Categories

Resources