• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

[GUIDE][Kernel] Comprehensive Guide to Kernels. [UPDATE:21.12.16]

Was this guide helpful to you?

  • Yes

    Votes: 111 95.7%
  • No

    Votes: 5 4.3%

  • Total voters
    116
Search This thread

Kyuubi10

Senior Member
Feb 21, 2014
726
542
If I answer the question of "what is a kernel" it wouldn't tell you much, besides there are enough other threads on XDA and other websites to answer this question.
The best question is "Why to use a custom Kernel?", which answers not only what it is, but also what it can do.

I like the way its explained here:
http://www.makeuseof.com/tag/consider-using-custom-android-kernel/

The next most important thing you need besides the custom kernel is an app to manage it.
Yes, you can change the code directly, but for most non-nerds an app tends to be best, providing a nice GUI to facilitate tuning.
And since I am aiming for this guide to be N00b proof, I am gonna provide as much information as possible.

There aren't many apps which give you control over all features of the kernel and, personally, I hate having to download multiple apps to control every feature of the kernel.
So these are my top 3 recommendations:
  1. The original app from the kernel's dev. You know, the one made specifically for use with that Kernel?
  2. Device Control [root] by Alexander Martinz (Not gonna explain why, just go and test it for yourself or at least look at the play store page)
  3. Kernel Adiutor by Willi Ye (It has a nice material GUI, + Extra features such as tweaking low memory killer, sysctl & sysfs)
What I most found lacking in other kernel guides was a well organised and comprehensive list of things custom kernels can offer. And since there is so much a Kernel could offer I'm going to try to provide it in categories with a couple examples so you get a good idea.

If I there is anything not accounted for, you are welcome to reply to this post and I will be checking every day to expand with any new info.

So without any further ado:

Feature List
General Settings:
These are things which do not fall within any of the other categories to follow. They are things which are usually classed separately in the App used to control the kernel. Examples include but are not limited to Fast Charge, Gesture (Knock on, Swipe2Wake), Color Calibration, Vibration Strength.​

Advanced Settings:
These are similar to the general settings, but as the name suggests they are a bit more advanced and require a bit more knowledge/research to use effectively.
This includes Entropy (if you have no idea what this is look for Seeder App. The description of the App explains this very well.), Voltage Control (Ever heard of UnderVolting?), TCP Congestion Control (As a Networking Student I had no trouble understanding the technical documents about this, but knowing many who will be reading aren't knowledgeable of technical jargon I have included a nice link.)
http://androidmodguide.blogspot.co.uk/p/tcp-algorithms.html

As I know that there will probably be things I'm missing here, if you find anything which I have not explained, a quick google might be very helpful. Otherwise you are welcome to post a reply to this thread (even including the results of your Google if you need someone to explain it to you in a simple way.)

UPDATE 21/12/16: After getting my new HTC 10 I begun doing some research to understand the big.LITTLE configuration. It turns out that there are in fact some tweakable tunables for this. I won't be providing any recommended settings, since currently I am using a modded PnP which dynamically manages Kernel tunables for me, and as far as I know this is a feature unique to HTC.
But for those interested in finding out more here is a guide you could look through, if you want to learn more. The tunables are at the very end.
https://android.googlesource.com/ke...llow-dr/Documentation/scheduler/sched-hmp.txt


CPU Settings:
This is what you're most likely here for, this is the home of Over (and Under) Clocking.
But it also provides other very useful settings which might not look so simple at first. Here you can select a CPU governor (No guys, I will not list and explain what each one is, there are just too many and too many with stupid names. Instead I will leave you guys with a link to another guide specific about CPU Govs.)
http://androidmodguide.blogspot.co.uk/p/blog-page.html

While we're still talking about CPU Governors, there is a further option that you have if your app supports it. You can tune the specific tunables for each specific Governor, to get the best result possible and most suited to you. Whether you want more performance or battery savings from that specific governor.

Here you can also find toggles for HotPlugging or its counter part CPUquiet (Available only for NVIDIA CPUs I believe.) Hotplugging is simply the technology which decides when and which cores to turn off. CPUquiet is similar but rather than turning off the cores it simply makes the idle. The advantage is debated but the possibility is still there.

GPU Settings:
This one doesn't have many features (That I know of), it allows you to Over/UnderClock your GPU and also change its Governor.​

Memory Settings:
(EDIT: I have included a Memory settings after doing a bit more of research about it, since its slightly more complicated compared to the other settings. Although most of these settings are available in both custom or stock kernels they can be tweaked to experience performance and battery improvements. So I'll try to cover as much as I can.)

Here you can tweak anything related to RAM and Cache. For tweaking these settings I suggest using the app Kernel Adiutor which I recommended earlier.
Things which you can find in all kernels are Low Memory Killer (Out of memory killer function on Android.) There is no need for me to explain it, what it does is self explanatory, to better understand the tunables I will provide this link:
http://forum.xda-developers.com/showthread.php?t=622666

You can also find tunables for Virtual Memory (Caching parameters), which is part of "sysctl" in the kernel. Tweaking this improves cache management, helping improve load times of cached apps, battery saving by emptying cache less often etc...
Here is a link which will give you a description for each parameter: https://www.kernel.org/doc/Documentation/sysctl/vm.txt

But there are also things which are not active or part of all kernels. zRAM is part of stock, and some custom kernels disable it. While KSM (Kernel Samepage Merging) can be added by some customs.

zRAM is just compressed RAM space. So you can store more in RAM by compressing the data you can fit more data inside your RAM.
Now obviously it is slower than actual normal RAM (since you have to encrypt and decrypt the data), but apparently it still is faster than using swap (which is in your internal memory rather than RAM). The principle works based on that Android prefers to keep data stored as much as possible in RAM to keep recently used apps running quickly. The more you use an app the more priority it has, therefore will stay in normal RAM, things you use sometimes but not very often are kept in zRAM (regardless of how full your actual RAM is), but since you don't use this very often you don't notice the performance hiccup of decrypting that data.
Then last case scenario things you barely use are kept in swap.
For you IT enthusiasts you should have realised already that "z" is the technology prefix for Compression. So it shouldn't come as a surprise that zRAM is compressed RAM.

KSM (Kernel Samepage Merging), this is simple, but it requires knowledge of some terminology. I will try to explain as simple as possible.
It allows the system to merge/share identical memory pages in RAM from different Applications/Processes. Thus it frees up RAM memory.
The only drawback to this is that it's up to your CPU to perform this task, therefore while it will increase performance it will also use up battery. But this is negligibly small (In my experience).
Therefore my recommendation is that if your Kernel offers this keep it turned on.

File System Settings:
The most desired setting available here is I/O schedulers. Again, I will not specify each scheduler since there are enough guides on the interbebs to give you all the info you need. On the other hand, I will leave you with my favourite of those guides.
http://androidmodguide.blogspot.co.uk/p/io-schedulers.html

The next most interesting settings is Read Ahead Buffer, this simply lets you choose how much data to load the buffer cache with. According to most benchmarks/tests the best value for this is 3 mb aka 3072 kb. This link gives you a better idea of it: https://broodplank.net/?p=788

Thermal Driver:
Here you can find toggles to manage overheating of the CPU and GPU. An example of which is MSM-Thermal and Core Control. I'm not gonna go into detail about these, since they are pretty self explanatory, and in my experience they both had descriptions beneath the toggles.
The most important thing to keep note of here is that only one should be on at any given time. If you turn 2 or more of these on together it may give you some issues. (It did with me.)

Tips & Recommendations
This is where as usual the writer gets to voice his opinion :)
Don't hate if you don't agree, just reply with your own opinion!! :D
I believe that any good custom Kernel should consistently provide some common settings.
We could say the minimum required to be considered a good custom Kernel.

Here is my list of basics:
  • General Settings:
    • Knock On (AKA double tap to wake)
    • Fast Charge
  • Advanced Settings:
    • Entropy
    • TCP Congestion Control
  • CPU Settings, all of it.
  • File System Settings, all of it.

Also my recommendation and tips for ideal CPU tuning and I/O schedulers.

FIrstly, CPU governors can be tuned to improve performance or battery saving. I found a good guide which explains the tunables:
http://forum.xda-developers.com/galaxy-s2/general/ref-kernel-governors-modules-o-t1369817

My recommendations will not take into account all the possible governors, but obviously if you take into account my recommendations and swap my choice of governor for an improved version of the same, or a similar one, then it should be even better.
While regarding the I/O schedulers, they are extremely under documented in comparison to CPU governors. And I have not managed to find a guide on how to best tune the tunables for the schedulers, so I will not cover this. If any one reading has any idea about this, please feel free to share your knowledge with us lowly humans!! :D
Actual testing reports and comparisons among schedulers are extremely difficult to find. So I will only recommend ones which I have found enough articles for or ones which I have tested myself.

Now for my list of recommendations:
  • Ideal CPU Governor
    • For general use, with a battery saving focus I would recommend the Conservative governor. And if you need a bit more of performance then it can be tuned to provide such.
    • For performance I would use Wheatley. If unavailable, then Elemental X or Interactive will be fine.

    N/B: I added wheatley as an update after using it for a couple months, it has a double focus on both performance and battery saving. It follows the idea of "race to idle", that since idle saves the most battery then dealing with processes quicker means more time spent in idle. Therefore it will scale up to higher frequencies than ondemand and interactive, and it will try to deal with all processes in as quick a time as possible.
    But it also focuses on battery, and if a process queue is taking long it will resort to scaling down the frequency to save battery while still getting work done.
    In my experience I have not felt it glitch, and its very stable. It has improved my battery life (not as much as conservative), but it also has allowed me to use my device at full power.
    But as with anything, there's always a downfall, which for wheatley is that it is a rare governor to find in most kernels. Currently I only have it on skydragon kernel. Most other kernels do not feature this governor.


    EDIT 29/02/2016: I have learned of a new way to tune the parameters for Interactive governor, for optimum efficiency, when wheatley governor is unavailable. Since Interactive is always available - it is one of the stock governors.
    In short it is tuning the parameters to use and spend more time in efficient frequency steps, in order to save battery while keeping the performance as high as possible. Using the fastest frequency steps before a huge jump in voltage consumption.
    The links which helped me do it are the following:
    http://forum.xda-developers.com/showthread.php?t=2769899
    https://vjnaik.wordpress.com/2015/06/25/kernel-tweak-interactive-governor-paramaters-rooted-phone/


  • Ideal I/O Scheduler
    • For general use of your phone or tablet I would recommend using ZEN. It can provide good performance and better than average multitasking while having an average battery consumption. Being considerably better than ROW while at only slightly more battery intensive.
      Obviously ROW is second choice, but if both of the above are unavailable, then B] FIOPS[/B] is a good replacement, ensuring an above average visual experience, good battery saving, at the expense of multitasking capabilities.
      If battery isn't an issue, or you stream a lot of videos, then BFQ appears to provide similar experience to FIOPS plus excellent multitasking, at the expense of battery.
    • For Gaming, this was hard to find since there weren't any specific articles focusing on this, but from the descriptions and certain comments it appears that SIO provides a good experience. Others mentioned BFQ since it reduces lag.
      For gaming you should absolutely avoid ROW and FIOPS since both have reported to increase lag during gaming.
    • For best battery saving the recommendation is definitely FIOPS. While it isn't the most battery saving scheduler (Noop is), it will provide the most battery saving while also efficiently giving you a great user experience.
    • For general multitasking the best one is BFQ. It will provide the best transfer rates (aka copy paste and install kind of thing), best for streaming & watching HD videos, and great for keeping loads of apps open at the same time.

    N/B: I added ZEN to the list after using it for a couple months. At the time I first released this guide I could not find a kernel which offered this scheduler to test it. But after a while it started becoming more popular, and now it is easily accessible through most major kernels.
    In my experience with it it has improved my multitasking slightly, while also reducing lag on general use. Battery increase unnoticeable.


  • Virtual Memory tuning
    This one is a bit more complicated, and I have heard a whole bunch of stuff... Which is why I decided to test it myself and then come back to give you guys a report for it. The effects of VM tuning are not obvious at first glance and but affects the overall feel of the device. (Whether it feels like new, or sluggish etc...)
    The main tunables you need to worry about are: Dirty Ratio, Dirty Background Ratio, Overcommit Ratio and Swappiness.
    The guide I added above under "Memory Settings" will explain what each of these are.

    • Dirty Ratio & Dirty Background Ratio - Most people say that these need to be high, so that more stuff is stored in Cache. This will make your phone quick. Because cache is quick. But in reality this is only good advice if all you need to load on your phone is the system UI. Because as soon as you start loading different apps this cache fills quickly, and whenever you want to open an app/file/webpage that is not in cache, your CPU is tasked with both emptying whatever is filling up cache memory and load your new app into cache. Thus making multitasking a nightmare within the first day. A simple reboot of the phone is not enough, nor is clearing RAM (Note: Cache is not RAM).
      Often the only solution to speed up your device is to Wipe Cache and Dalvik Cache from recovery every day. And for people with 150+ Apps installed which need to be optimized on boot, this means a lot of time is wasted.
      My personal recommendation is to keep Dirty Ratio at around 40, which is double the stock value. Thus you have enough room before your phone freezes to free up cache. While Dirty Background Ration at 10, so that in the background without freezing the app you're currently in the kernel is constantly clearing cache. Allowing enough space for whatever you need to load.

    • Overcommit Ratio - While increasing allows more multitasking, I recommend leaving this at 0. It keeps RAM from completely filling up, thus avoiding "app xxx not responding" issues.

    • Swappiness - You have three kinds of fast memory on your phone, from quickest to slowest: Cache, RAM, Swap.
      Swap is the last resort for your phone's memory. It is usually used when your RAM is nearly full. Swap is used for app data which is not currently being used, but part of the group of apps you use the most. (This is related to the Low memory killer, so for more information check that link. )
      Since app data stored in Swap is stuff you don't use often it doesn't affect your phone greatly. But the more data kept in RAM, rather than Swap, the better.
      Therefore after loads of try and testing I found that 40 is the perfect sweet spot. Allowing higher performance while keeping some data rather than completely deleting it when RAM is full.


This is my Guide to Kernels, if you find that it has helped you and would like to thank me remember to press thanks.
If you have any questions please do ask them, I'll answer the best I can.
If you would like to add more, dispute any of the things I said, give extra info on any specific thing which you believe deserves a more thorough breakdown, then go ahead, fell free to comment below.

Thank you for reading this Guide.


 
Last edited:

luke!

Senior Member
May 6, 2015
220
203
Very useful guide :D

Just a question: would it be possible gathering info about the "power suspend mode" that is often found in Kernel Adiutor?
Fpu6E49.jpg
What are the differences among the available options?
Thanks again for your guide ;)
 

Kyuubi10

Senior Member
Feb 21, 2014
726
542
Very useful guide :D

Just a question: would it be possible gathering info about the "power suspend mode" that is often found in Kernel Adiutor?
Fpu6E49.jpg
What are the differences among the available options?
Thanks again for your guide ;)

It took me ages to research, because initially when I did I found nothing. Whenever I searched this I would only find stuff about wakelocks. The wakelock system is more important to developers than actual users, so it was of no use to me.
But after a bit of research I THINK I found the original source code for this feature...I will put a couple links at the bottom for the enthusiasts to see.
(N.B. I will keep researching as I get more time to see if I can find more info on this, because it puzzles me also.)

Before I explain anything you must understand what the suspend state is, usually it is called sleep.
I usually cba to explain anything...since I am awful at explaining stuff in written form...I usually like to explain verbally. So I will leave you with a couple links:

Power suspend in Linux - http://unix.stackexchange.com/questions/162886/what-does-pm-suspend-hybrid-do

Power suspend in Android - http://bamboopuppy.com/android-suspend-a-brief-overview/

How it interacts with the hardware - https://source.android.com/devices/sensors/suspend-mode.html

Now for this kernel feature... I seems from what I have read that it is not activating or deactivating suspend mode....instead it is simply deciding on what "metric" to use.
Generally you could say that suspend state would be achieved on request by the kernel. But what if you want to automate the process so that it uses less requests, and thus goes to sleep quicker and more efficiently?
You make it so it bases on something else's output in order to initiate the count down.

This could be screen on/off (LCD panel), idle time (autosleep function), hybrid (autosleep & LCD panel whichever comes first), or userspace (defined by user.)

In all honesty, how it all works in detail I have no idea. But that is the basic idea.

I also have no idea why it keeps locking to userspace, as if it was default.
It seems that this function is not fully functional yet, or maybe it needs some fixing.

The gerrit page for the source code says that this project was abandoned by the main devs.
Gerrit page - https://gerrit.omnirom.org/#/c/9137/2

In summary, from other things I have read they say that Hybrid is the best one for battery life. But for me it never stays on Hybrid, it keeps resetting to userspace. Therefore I am unable to give you any further information about this.

I hope I helped.
 

billysam

Senior Member
Oct 3, 2014
551
298
Thank you, thank you, thank you, for putting this up so organized, the only problem on xda is proper guides, I can understand how much time and energy you have put into finding and putting up this guide, and the best part you have given links to the original author and not just copied their hard work and spread their knowledge combined. Well Done mate. That's a real example of how member of xda should be. this will help a lot of people. will share links to this thread. :)

Edit: added your thread link in my signature, hope you don't mind. I thought it would be better this way for people to see.
 
Last edited:
  • Like
Reactions: jabia and Kyuubi10

Kyuubi10

Senior Member
Feb 21, 2014
726
542
Very useful guide :D

Just a question: would it be possible gathering info about the "power suspend mode" that is often found in Kernel Adiutor?
Fpu6E49.jpg
What are the differences among the available options?
Thanks again for your guide ;)

I have some new info about this, I don't remember specifics of where I got this, but it was in a thread about custom kernels.
A lost of people were asking why the setting was stuck.
And if I remember correctly it seems that this feature is a left-over stub from a failed project, which now has been superseded by Doze on Marshmallow.
It works exactly as I described, with the exception of Userspace, which rather than being defined by user it is defined by app. e.g. when app x says it's time to sleep phone will sleep. The other options are automated, and hybrid is the default option and we as users have no way to change it. It's been this way for a while, idk why Adiutor still has the option available.

Also finally understood fully why wakelocks kept popping up when I searched for this...it's because apps can set wakelocks to prevent the "power suspend" from happening, or even to wake the phone from a "power suspend" in order to not stop the app from running. This would be things like facebook, or other messenger apps which want to have a constant running service.
This created huge battery drains in KK and Lollipop, but now in Marshmallow Doze is a bit tougher to get around. Simple wakelocks won't do anymore.


Thank you, thank you, thank you, for putting this up so organized, the only problem on xda is proper guides, I can understand how much time and energy you have put into finding and putting up this guide, and the best part you have given links to the original author and not just copied their hard work and spread their knowledge combined. Well Done mate. That's a real example of how member of xda should be. this will help a lot of people. will share links to this thread. :)

Edit: added your thread link in my signature, hope you don't mind. I thought it would be better this way for people to see.

It's honestly been a pleasure.
I have been learning even more and soon I will re-update this thread with a lot of new info I have found.
I'm glad you liked this Guide, it did take me time and it's good that it has been recognized. You've made my day :D

This brings to mind the fact that I have been thinking on a new guide to newcomers into rooting and XDA, just explaining all that which is possible in a short but well organized guide :).

Feel free to copy the link and share however you would like, it is honestly a huge help!
 

Kyuubi10

Senior Member
Feb 21, 2014
726
542
hello dude can i get your screenshot your setting on your kernel adiutor for daily, power save, and Gaming

Unfortunately I don't keep presents.
I change on the fly as needed.

It just works better for testing rather than having specific presets to use, because I am constantly changing the actual values I use, also as apps get updated and their RAM usage increase or decrease, the values are always very fluid for me. I just keep changing until I find a comfortable value.

If there is anything specific you would like to know ask, and I'll advise you accordingly.
 

bearthing

Senior Member
Feb 15, 2014
149
13
thanks for this thread bro...
i have zero knowledge about kernel issues
and im so curious about how it work's and what it did
to our mobile phone's. but now i found your thread.
thanks for specific and detailed explanation..:D

even though i did understand only a little part of it
only the specific settings. I didn't know exactly how to use by changing
the number's of each settings under each codes and how it will
response to the performance of the device ..
i hope i will get it soon..:D thanks again for putting this thread
it is very helpful in the likes of me newbie with zero knowledge
but willing to learn and understand how it is..
very big thanks bro...:highfive::good:
 

Kyuubi10

Senior Member
Feb 21, 2014
726
542
Thermal Driver:

Here you can find toggles to manage overheating of the CPU and GPU. An example of which is MSM-Thermal and Core Control. ...

Is there a way to manually set a temperature at which the CPU is clocked down to a specific MHz?

For example:
Temperature rises to 38 ° C = CPU clocks not higher than 800Mhz

Unfortunately I don't know if that is even possible, you might have to mess with source code and add your own patches.
Good luck finding this out!
If and when you do share the knowledge with the community! :D
 

Kyuubi10

Senior Member
Feb 21, 2014
726
542
thanks for this thread bro...
i have zero knowledge about kernel issues
and im so curious about how it work's and what it did
to our mobile phone's. but now i found your thread.
thanks for specific and detailed explanation..:D

even though i did understand only a little part of it
only the specific settings. I didn't know exactly how to use by changing
the number's of each settings under each codes and how it will
response to the performance of the device ..
i hope i will get it soon..:D thanks again for putting this thread
it is very helpful in the likes of me newbie with zero knowledge
but willing to learn and understand how it is..
very big thanks bro...:highfive::good:

Dude, it's an absolute pleasure. It's mainly for people like you that I have made this guide.
I was like you too, and i didnt find a straightforward guide to help me out in the beginning...
There was a wealth of information but it was all over the place. A bit here a bit there.

I urge you to keep researching and keep learning. If ever you find that something you need doesn't exist, then make your own research and create that which you needed so that others who follow after you don't have to go through the same struggle! :)
 
  • Like
Reactions: bearthing

bearthing

Senior Member
Feb 15, 2014
149
13
Dude, it's an absolute pleasure. It's mainly for people like you that I have made this guide.
I was like you too, and i didnt find a straightforward guide to help me out in the beginning...
There was a wealth of information but it was all over the place. A bit here a bit there.

I urge you to keep researching and keep learning. If ever you find that something you need doesn't exist, then make your own research and create that which you needed so that others who follow after you don't have to go through the same struggle! :)

some device not supported the tuning like my lg g4 h818p the noop doesn't tunable and cubic? thanks again bro
 

bearthing

Senior Member
Feb 15, 2014
149
13
it's not the device, but the Kernel.
If the developer of the kernel adds support for certain features you will be able to use them.
You need to search and find the custom Kernel which has the features you are looking for.

any kernel is compatible to my g4 h818p? or
i search for specific kernel that compatible to my device?
thanks bro
 

Top Liked Posts

  • There are no posts matching your filters.
  • 101
    If I answer the question of "what is a kernel" it wouldn't tell you much, besides there are enough other threads on XDA and other websites to answer this question.
    The best question is "Why to use a custom Kernel?", which answers not only what it is, but also what it can do.

    I like the way its explained here:
    http://www.makeuseof.com/tag/consider-using-custom-android-kernel/

    The next most important thing you need besides the custom kernel is an app to manage it.
    Yes, you can change the code directly, but for most non-nerds an app tends to be best, providing a nice GUI to facilitate tuning.
    And since I am aiming for this guide to be N00b proof, I am gonna provide as much information as possible.

    There aren't many apps which give you control over all features of the kernel and, personally, I hate having to download multiple apps to control every feature of the kernel.
    So these are my top 3 recommendations:
    1. The original app from the kernel's dev. You know, the one made specifically for use with that Kernel?
    2. Device Control [root] by Alexander Martinz (Not gonna explain why, just go and test it for yourself or at least look at the play store page)
    3. Kernel Adiutor by Willi Ye (It has a nice material GUI, + Extra features such as tweaking low memory killer, sysctl & sysfs)
    What I most found lacking in other kernel guides was a well organised and comprehensive list of things custom kernels can offer. And since there is so much a Kernel could offer I'm going to try to provide it in categories with a couple examples so you get a good idea.

    If I there is anything not accounted for, you are welcome to reply to this post and I will be checking every day to expand with any new info.

    So without any further ado:

    Feature List
    General Settings:
    These are things which do not fall within any of the other categories to follow. They are things which are usually classed separately in the App used to control the kernel. Examples include but are not limited to Fast Charge, Gesture (Knock on, Swipe2Wake), Color Calibration, Vibration Strength.​

    Advanced Settings:
    These are similar to the general settings, but as the name suggests they are a bit more advanced and require a bit more knowledge/research to use effectively.
    This includes Entropy (if you have no idea what this is look for Seeder App. The description of the App explains this very well.), Voltage Control (Ever heard of UnderVolting?), TCP Congestion Control (As a Networking Student I had no trouble understanding the technical documents about this, but knowing many who will be reading aren't knowledgeable of technical jargon I have included a nice link.)
    http://androidmodguide.blogspot.co.uk/p/tcp-algorithms.html

    As I know that there will probably be things I'm missing here, if you find anything which I have not explained, a quick google might be very helpful. Otherwise you are welcome to post a reply to this thread (even including the results of your Google if you need someone to explain it to you in a simple way.)

    UPDATE 21/12/16: After getting my new HTC 10 I begun doing some research to understand the big.LITTLE configuration. It turns out that there are in fact some tweakable tunables for this. I won't be providing any recommended settings, since currently I am using a modded PnP which dynamically manages Kernel tunables for me, and as far as I know this is a feature unique to HTC.
    But for those interested in finding out more here is a guide you could look through, if you want to learn more. The tunables are at the very end.
    https://android.googlesource.com/ke...llow-dr/Documentation/scheduler/sched-hmp.txt


    CPU Settings:
    This is what you're most likely here for, this is the home of Over (and Under) Clocking.
    But it also provides other very useful settings which might not look so simple at first. Here you can select a CPU governor (No guys, I will not list and explain what each one is, there are just too many and too many with stupid names. Instead I will leave you guys with a link to another guide specific about CPU Govs.)
    http://androidmodguide.blogspot.co.uk/p/blog-page.html

    While we're still talking about CPU Governors, there is a further option that you have if your app supports it. You can tune the specific tunables for each specific Governor, to get the best result possible and most suited to you. Whether you want more performance or battery savings from that specific governor.

    Here you can also find toggles for HotPlugging or its counter part CPUquiet (Available only for NVIDIA CPUs I believe.) Hotplugging is simply the technology which decides when and which cores to turn off. CPUquiet is similar but rather than turning off the cores it simply makes the idle. The advantage is debated but the possibility is still there.

    GPU Settings:
    This one doesn't have many features (That I know of), it allows you to Over/UnderClock your GPU and also change its Governor.​

    Memory Settings:
    (EDIT: I have included a Memory settings after doing a bit more of research about it, since its slightly more complicated compared to the other settings. Although most of these settings are available in both custom or stock kernels they can be tweaked to experience performance and battery improvements. So I'll try to cover as much as I can.)

    Here you can tweak anything related to RAM and Cache. For tweaking these settings I suggest using the app Kernel Adiutor which I recommended earlier.
    Things which you can find in all kernels are Low Memory Killer (Out of memory killer function on Android.) There is no need for me to explain it, what it does is self explanatory, to better understand the tunables I will provide this link:
    http://forum.xda-developers.com/showthread.php?t=622666

    You can also find tunables for Virtual Memory (Caching parameters), which is part of "sysctl" in the kernel. Tweaking this improves cache management, helping improve load times of cached apps, battery saving by emptying cache less often etc...
    Here is a link which will give you a description for each parameter: https://www.kernel.org/doc/Documentation/sysctl/vm.txt

    But there are also things which are not active or part of all kernels. zRAM is part of stock, and some custom kernels disable it. While KSM (Kernel Samepage Merging) can be added by some customs.

    zRAM is just compressed RAM space. So you can store more in RAM by compressing the data you can fit more data inside your RAM.
    Now obviously it is slower than actual normal RAM (since you have to encrypt and decrypt the data), but apparently it still is faster than using swap (which is in your internal memory rather than RAM). The principle works based on that Android prefers to keep data stored as much as possible in RAM to keep recently used apps running quickly. The more you use an app the more priority it has, therefore will stay in normal RAM, things you use sometimes but not very often are kept in zRAM (regardless of how full your actual RAM is), but since you don't use this very often you don't notice the performance hiccup of decrypting that data.
    Then last case scenario things you barely use are kept in swap.
    For you IT enthusiasts you should have realised already that "z" is the technology prefix for Compression. So it shouldn't come as a surprise that zRAM is compressed RAM.

    KSM (Kernel Samepage Merging), this is simple, but it requires knowledge of some terminology. I will try to explain as simple as possible.
    It allows the system to merge/share identical memory pages in RAM from different Applications/Processes. Thus it frees up RAM memory.
    The only drawback to this is that it's up to your CPU to perform this task, therefore while it will increase performance it will also use up battery. But this is negligibly small (In my experience).
    Therefore my recommendation is that if your Kernel offers this keep it turned on.

    File System Settings:
    The most desired setting available here is I/O schedulers. Again, I will not specify each scheduler since there are enough guides on the interbebs to give you all the info you need. On the other hand, I will leave you with my favourite of those guides.
    http://androidmodguide.blogspot.co.uk/p/io-schedulers.html

    The next most interesting settings is Read Ahead Buffer, this simply lets you choose how much data to load the buffer cache with. According to most benchmarks/tests the best value for this is 3 mb aka 3072 kb. This link gives you a better idea of it: https://broodplank.net/?p=788

    Thermal Driver:
    Here you can find toggles to manage overheating of the CPU and GPU. An example of which is MSM-Thermal and Core Control. I'm not gonna go into detail about these, since they are pretty self explanatory, and in my experience they both had descriptions beneath the toggles.
    The most important thing to keep note of here is that only one should be on at any given time. If you turn 2 or more of these on together it may give you some issues. (It did with me.)

    Tips & Recommendations
    This is where as usual the writer gets to voice his opinion :)
    Don't hate if you don't agree, just reply with your own opinion!! :D
    I believe that any good custom Kernel should consistently provide some common settings.
    We could say the minimum required to be considered a good custom Kernel.

    Here is my list of basics:
    • General Settings:
      • Knock On (AKA double tap to wake)
      • Fast Charge
    • Advanced Settings:
      • Entropy
      • TCP Congestion Control
    • CPU Settings, all of it.
    • File System Settings, all of it.

    Also my recommendation and tips for ideal CPU tuning and I/O schedulers.

    FIrstly, CPU governors can be tuned to improve performance or battery saving. I found a good guide which explains the tunables:
    http://forum.xda-developers.com/galaxy-s2/general/ref-kernel-governors-modules-o-t1369817

    My recommendations will not take into account all the possible governors, but obviously if you take into account my recommendations and swap my choice of governor for an improved version of the same, or a similar one, then it should be even better.
    While regarding the I/O schedulers, they are extremely under documented in comparison to CPU governors. And I have not managed to find a guide on how to best tune the tunables for the schedulers, so I will not cover this. If any one reading has any idea about this, please feel free to share your knowledge with us lowly humans!! :D
    Actual testing reports and comparisons among schedulers are extremely difficult to find. So I will only recommend ones which I have found enough articles for or ones which I have tested myself.

    Now for my list of recommendations:
    • Ideal CPU Governor
      • For general use, with a battery saving focus I would recommend the Conservative governor. And if you need a bit more of performance then it can be tuned to provide such.
      • For performance I would use Wheatley. If unavailable, then Elemental X or Interactive will be fine.

      N/B: I added wheatley as an update after using it for a couple months, it has a double focus on both performance and battery saving. It follows the idea of "race to idle", that since idle saves the most battery then dealing with processes quicker means more time spent in idle. Therefore it will scale up to higher frequencies than ondemand and interactive, and it will try to deal with all processes in as quick a time as possible.
      But it also focuses on battery, and if a process queue is taking long it will resort to scaling down the frequency to save battery while still getting work done.
      In my experience I have not felt it glitch, and its very stable. It has improved my battery life (not as much as conservative), but it also has allowed me to use my device at full power.
      But as with anything, there's always a downfall, which for wheatley is that it is a rare governor to find in most kernels. Currently I only have it on skydragon kernel. Most other kernels do not feature this governor.


      EDIT 29/02/2016: I have learned of a new way to tune the parameters for Interactive governor, for optimum efficiency, when wheatley governor is unavailable. Since Interactive is always available - it is one of the stock governors.
      In short it is tuning the parameters to use and spend more time in efficient frequency steps, in order to save battery while keeping the performance as high as possible. Using the fastest frequency steps before a huge jump in voltage consumption.
      The links which helped me do it are the following:
      http://forum.xda-developers.com/showthread.php?t=2769899
      https://vjnaik.wordpress.com/2015/06/25/kernel-tweak-interactive-governor-paramaters-rooted-phone/


    • Ideal I/O Scheduler
      • For general use of your phone or tablet I would recommend using ZEN. It can provide good performance and better than average multitasking while having an average battery consumption. Being considerably better than ROW while at only slightly more battery intensive.
        Obviously ROW is second choice, but if both of the above are unavailable, then B] FIOPS[/B] is a good replacement, ensuring an above average visual experience, good battery saving, at the expense of multitasking capabilities.
        If battery isn't an issue, or you stream a lot of videos, then BFQ appears to provide similar experience to FIOPS plus excellent multitasking, at the expense of battery.
      • For Gaming, this was hard to find since there weren't any specific articles focusing on this, but from the descriptions and certain comments it appears that SIO provides a good experience. Others mentioned BFQ since it reduces lag.
        For gaming you should absolutely avoid ROW and FIOPS since both have reported to increase lag during gaming.
      • For best battery saving the recommendation is definitely FIOPS. While it isn't the most battery saving scheduler (Noop is), it will provide the most battery saving while also efficiently giving you a great user experience.
      • For general multitasking the best one is BFQ. It will provide the best transfer rates (aka copy paste and install kind of thing), best for streaming & watching HD videos, and great for keeping loads of apps open at the same time.

      N/B: I added ZEN to the list after using it for a couple months. At the time I first released this guide I could not find a kernel which offered this scheduler to test it. But after a while it started becoming more popular, and now it is easily accessible through most major kernels.
      In my experience with it it has improved my multitasking slightly, while also reducing lag on general use. Battery increase unnoticeable.


    • Virtual Memory tuning
      This one is a bit more complicated, and I have heard a whole bunch of stuff... Which is why I decided to test it myself and then come back to give you guys a report for it. The effects of VM tuning are not obvious at first glance and but affects the overall feel of the device. (Whether it feels like new, or sluggish etc...)
      The main tunables you need to worry about are: Dirty Ratio, Dirty Background Ratio, Overcommit Ratio and Swappiness.
      The guide I added above under "Memory Settings" will explain what each of these are.

      • Dirty Ratio & Dirty Background Ratio - Most people say that these need to be high, so that more stuff is stored in Cache. This will make your phone quick. Because cache is quick. But in reality this is only good advice if all you need to load on your phone is the system UI. Because as soon as you start loading different apps this cache fills quickly, and whenever you want to open an app/file/webpage that is not in cache, your CPU is tasked with both emptying whatever is filling up cache memory and load your new app into cache. Thus making multitasking a nightmare within the first day. A simple reboot of the phone is not enough, nor is clearing RAM (Note: Cache is not RAM).
        Often the only solution to speed up your device is to Wipe Cache and Dalvik Cache from recovery every day. And for people with 150+ Apps installed which need to be optimized on boot, this means a lot of time is wasted.
        My personal recommendation is to keep Dirty Ratio at around 40, which is double the stock value. Thus you have enough room before your phone freezes to free up cache. While Dirty Background Ration at 10, so that in the background without freezing the app you're currently in the kernel is constantly clearing cache. Allowing enough space for whatever you need to load.

      • Overcommit Ratio - While increasing allows more multitasking, I recommend leaving this at 0. It keeps RAM from completely filling up, thus avoiding "app xxx not responding" issues.

      • Swappiness - You have three kinds of fast memory on your phone, from quickest to slowest: Cache, RAM, Swap.
        Swap is the last resort for your phone's memory. It is usually used when your RAM is nearly full. Swap is used for app data which is not currently being used, but part of the group of apps you use the most. (This is related to the Low memory killer, so for more information check that link. )
        Since app data stored in Swap is stuff you don't use often it doesn't affect your phone greatly. But the more data kept in RAM, rather than Swap, the better.
        Therefore after loads of try and testing I found that 40 is the perfect sweet spot. Allowing higher performance while keeping some data rather than completely deleting it when RAM is full.


    This is my Guide to Kernels, if you find that it has helped you and would like to thank me remember to press thanks.
    If you have any questions please do ask them, I'll answer the best I can.
    If you would like to add more, dispute any of the things I said, give extra info on any specific thing which you believe deserves a more thorough breakdown, then go ahead, fell free to comment below.

    Thank you for reading this Guide.


    6
    Nice guide and thanks for linking to my website ;)

    gsstudios
    5
    Hi @Kyuubi10,

    I have Phone idle drain consuming more battery for nothing (in android battery usage). So I googled and came across this article: http://www.hackmyandroid.com/fix-battery-drain-stock-sony-devices/9763

    Do you think those values really help to fix idle drain ? Can you suggest me values for virtual memory or kernel settings to Z5/Z4 which has 3GB ram ? I am using 7.0.

    Thanks

    Well, there's soooo much I could say about this.
    It's going to be a bit long... But don't be disheartened. Read on, and learn!

    1. Android battery usage is unreliable.
    It calculates based on proportion, rather than absolutes.
    Example:
    If your idle battery drain is 10% because of an app...
    It will show 70% battery consumption "app", 30% "phone idle".
    But if you uninstall the app, and your idle battery drain is reduced to 3%.
    Battery usage will now show 100% "phone idle".

    So in short, your idle drain might have actually fallen from 10% to 3%....but the proportion of "phone idle" within that 3% has risen.
    Therefore, a higher phone idle percentage doesn't mean that you are getting a higher idle drain. It just means the phone idle contributed to a higher proportion of that drain.

    2. If you are having unusual battery drains while phone is idle, there are much better ways to handle it (maybe you're already using them).
    Making use of Doze on nougat is going to be your best friend.

    Dowload Greenify, and select any app which have high background usage, and also select aggressive doze within settings.
    This will keep battery draining apps from running in the background, and will make sure doze starts faster.

    Another great app, which integrates with greenify, is wakelock detector.... It helps you visualise which apps are keeping your phone awake, or waking up your phone from deep sleep.
    Once you find the problem app it gives you a link to greenify it.

    This will give you a much better result than messing with Virtual Memory.

    3. About the article, I see what they are trying to do.
    And it does work, if improving battery drain is all you are trying to achieve.
    I'd imagine you'd also struggle to play high intensity games without having a healthy amount of lag.
    I'll be surprised if you can actually game with those settings.

    My personal opinion is that the battery gains of those settings (which are real), don't justify the performance drawbacks they cause.

    But each user focuses on their own thing... Some like to optimise for battery, others optimise for throughput, others optimise for latency (me).

    Therefore... My best advice to you, is after understanding step 1 and 2 from this post....
    Read step 3 and be inspired to make your own mind up... Decide what matters most to you.

    Then use the knowledge of this thread to come up with your own values :)

    Good luck!
    Let us know how it goes!
    4
    Very useful guide :D

    Just a question: would it be possible gathering info about the "power suspend mode" that is often found in Kernel Adiutor?
    Fpu6E49.jpg
    What are the differences among the available options?
    Thanks again for your guide ;)

    It took me ages to research, because initially when I did I found nothing. Whenever I searched this I would only find stuff about wakelocks. The wakelock system is more important to developers than actual users, so it was of no use to me.
    But after a bit of research I THINK I found the original source code for this feature...I will put a couple links at the bottom for the enthusiasts to see.
    (N.B. I will keep researching as I get more time to see if I can find more info on this, because it puzzles me also.)

    Before I explain anything you must understand what the suspend state is, usually it is called sleep.
    I usually cba to explain anything...since I am awful at explaining stuff in written form...I usually like to explain verbally. So I will leave you with a couple links:

    Power suspend in Linux - http://unix.stackexchange.com/questions/162886/what-does-pm-suspend-hybrid-do

    Power suspend in Android - http://bamboopuppy.com/android-suspend-a-brief-overview/

    How it interacts with the hardware - https://source.android.com/devices/sensors/suspend-mode.html

    Now for this kernel feature... I seems from what I have read that it is not activating or deactivating suspend mode....instead it is simply deciding on what "metric" to use.
    Generally you could say that suspend state would be achieved on request by the kernel. But what if you want to automate the process so that it uses less requests, and thus goes to sleep quicker and more efficiently?
    You make it so it bases on something else's output in order to initiate the count down.

    This could be screen on/off (LCD panel), idle time (autosleep function), hybrid (autosleep & LCD panel whichever comes first), or userspace (defined by user.)

    In all honesty, how it all works in detail I have no idea. But that is the basic idea.

    I also have no idea why it keeps locking to userspace, as if it was default.
    It seems that this function is not fully functional yet, or maybe it needs some fixing.

    The gerrit page for the source code says that this project was abandoned by the main devs.
    Gerrit page - https://gerrit.omnirom.org/#/c/9137/2

    In summary, from other things I have read they say that Hybrid is the best one for battery life. But for me it never stays on Hybrid, it keeps resetting to userspace. Therefore I am unable to give you any further information about this.

    I hope I helped.
    4
    Hi guys...will have an update coming up in the next couple of weeks.
    I've been working as part of Team Helix working on an EAS Kernel.

    This is very interesting as it is at the very forefront of Kernel development, some parts of it are still experimental but it's stable enough for testing.
    I might consider putting an explanation and guide about EAS as a separate guide.
    But I will update this thread with as much relevant detail I can find.