IMPORTANT: As notified in due time, my CM10.2 kernels do NOT support proprietary Custom Rom frameworks anymore. So if your Custom Rom did not implement the generic framework class framework-2.jar but his own naming convention, you may get a boot loop. Do not whine about this here but advise your Custom ROM dev to fix this. I will not change this ever again.The most prominent custom kernels for CM will follow the same approach (aligned between AndiP, Googy, Teufel, Psndna, Temasek and me).

Before proceding, please consider learning from Garfield :

(Thanx to MuertoKo for this educational image)

I have spend numerous hours coding, merging ... and writing this OP, so please have the decency to at least read it before asking questions.

Disclaimer

FIRST OF ALL, do a Nandroid backup before flashing !

By flashing this kernel you agree to do this at your very own risk ! I will and can not beheld responsible for whatever may happen as a consequence of using this kernel / script generator.This software is made available to you as is, no waranties can be given.

If you do not agree to these terms, then please use your browser's back key.

ROMCompatibility

This kernel is based on CyanogenMod CM10 kernel sources, so it is intended only to be used on CM10 based ROMs.

The kernel has been tested on the following Android 4.1.x AOSP/CM ROMs :

The kernel has been tested on the following Android 4.2.x AOSP/CM ROMs :

[url="http://forum.xda-developers.com/showthread.php?t=1745003"]Paranoid Android[/url] all 4.2.2 by gokussjx

SuperNexus 2.0

CM10.1 Nightly

SlimBeam 4.2.2

BeanStalk 4.2.2

JellyBam 7.5.0

SentinelRom

... (you tell me )

It won't work on Samsung JB (nor ICS) ROMs...

WhatToExpectUsingThisKernel

First of all, the main reason this kernel even exists is because I make it for my own personal use. As some users started using it as well (link in my signature), which was absolutely fine by me, I decided to start a thread for it rather than reply to PMs, as I added one or the other feature upon request by a user even if I don't use that feature personnally (e.g. zram support).

Main objectives for this kernel :

be as stable as possible to be usable as a perfect daily kernel (conservative approach)

give a good battery life while being snappy

give users an easy and safe way to customize settings

be and stay as close to stock CM10 as possible

allow only for moderate CPU OC (up to 1.6GHz)

include some standard Linux features missing in stock kernel (e.g. swap support)

include interesting commits by other devs (giving proper credit, of course !)

updated to kernel.org Linux

WhatNOTToExpectUsingThisKernel

experimental modifications

cutting edge development

thrive to be the first, fastest, best, most advanced ... kernel ever !

I just suspect there is a public for genuine slightly modified kernels that are a no fuzz to use, and which are aimed towards "standard power users" as opposed to "hungry beta testers and debuggers" (been there, done that, fun time in my HD2 times helping as I could on Dorimanx kernel). But I need my S3 on a daily bases, privately and for work, so my S3 just has to work.

This is the most important bit of them all, a small place to pay tribute to all those who have helped me making this kernel :

Faux123

Thanx for helping me get started, out of an almost 20 years break on Linux kernel compiling (at the time it was Linux 0.47 if I remember well), helping me build my compile box(es), upfront getting my first Android kernel compiled, making mods, merging sources, using github in general ... and always taking the time to explain and help out !

Corrsea

Huge thanx for thorough testing and usefull advice, since my first steps on Android, at the time we were both running Tytung's Nexus HD2 on our initially WinMo device, chasing any possible bugs there were to iron out.

MuertoKo

Thanx for pushing me here and there to go further with my kernels, and for testing them on your daily and reporting back.

uberto.costanzo & F3nr1s

Thanx for your support, for testing the kernel and reporting back.

Amarullz

And last but nowhere least, huge thanx to Amarullz for giving us such a great tool, without Aroma Installer flashing kernels / ROMs would still be stone-age kind of voodoo magic, now it has become a proper user experince, giving everybody an easy way to customize whatever is being flashed !

------------------------------------

Kernel Cleanup Script, to be flashed when going to a different kernel :

===========================================================I ask one simple and single thing in return for you to use my work for free,

DO NOT POST MIRRORS OF MY KERNELS ANYWHERE !

You can post as many links to this thread as you want, but no uploading ofmy work on file sharing servers or attaching them to posts on otherforums !You can post as many links to this thread as you want, but no uploading ofmy work on file sharing servers or attaching them to posts on otherforums !

Only exception : Discussing my work or sharing Links to here on Android-Hilfe.deis hereby expressly unwanted ! They have no respect for devs and I don't wantany contribution from me on their forum, neither directly nor indirectly !

added CPU-idle and sched_mc_power_savings options in Aroma (requested by janres155)

compiler flags updated to generate Position Independent Code

updated to kernel.org Linux 3.0.101 [EOL]

updated ramfs to latest CM10.2 (20131022)

IMPORTANT: As notified in due time, my CM10.2 kernels do NOT support proprietary Custom Rom frameworks anymore. So if your Custom Rom did not implement the generic framework class framework-2.jar but his own naming convention, you may get a boot loop. Do not whine about this here but advise your Custom ROM dev to fix this. I will not change this ever again.The most prominent custom kernels for CM will follow the same approach (aligned between AndiP, Googy, Teufel, Psndna, Temasek and me).

removed fixed scaling lookup tables and use the system frequency table instead changed scaling logic accordingly for this modification (thx and credits to Yank555)

reduced new hotplug logic loop to a minimum

again try to fix stuck issues by using seperate hotplug functions out of dbs_check_cpu (credits to ktoonesz)

added support for 2 and 8 core systems and added automatic detection of cores were it is needed (for setting the different core modes you can use the macro 'MAX_CORES'. possible values are: 2,4 or 8, default are 4 cores) reduced core threshold defaults to only one up/down default and use an array to hold all threshold values

fixed some mistakes in 'frequency tuneables' (Yank555):

stop looping once the frequency has been found

return invalid error if new frequency is not found in the frequency table

Big thanks to Faux123 for most of the above, which I found in various of his repos !

Please consider using zzmoove optimized when using my settings, I changed it to yank-battery in CM10.1 kernel only, but I reverted back to optimized myself (and all 4 other kernels), it's just snappier.

Main reason for releasing 1.5f was the reintroduction of the Android 4.1.x (aka. CM10) kernel, so I could have both inline on the same levels. Only difference being the fact that CM10 kernel still has the old mali drivers and CM10 ramfs, whereas CM10.1 kernel comes with updated mali drivers and updated CM10.1 ramfs

Please bear in mind when setting the standby max CPU freq.that Samsung uses 1.4GHz by default, so it's not about beatingany kind of record, as going too low may result in a sleep of death !!Battery pull or long power key will be necessary to get out if it ratherunproperly I might add !

Completely neutralized mic_mode to avoid any interference to related registers when not used (fix for call issues with certain firmwares) by not doing any actions until mic_mode is enabled + using cached registers when restoring default mode back

mic_mode is now exclusive and not "intelligent" anymore. If you want to make calls, switch mic_mode back to default first

Safety-net introduced to avoid writing empty mic register cache values back to the registers in any case (thx to Yank555 for this idea)

fix reported issue about boeffla sound starting up in enabled mode is causing a boot loop

removed mic setting from Aroma completely, no need to change set it during boot

updated to Boeffla-Sound: Engine 1.4.6 (AndiP71)removed an optimisation in the call detection routine that was identified to cause timing issues in combination with some roms which in the end lead to improper handling of mic mode settings

Here is a list with explanations about the several options you have in Aroma installer :

CPU frequency settings

CPU Governor

PegasusQ

This is the stock governor provided by Samsung to control the exynos CPU frequencies and cores hotplugging (switching cores on and off).

PegasusQ-IO

Still the same stock governor at work, but this will set the governor's "io is busy" property to either 1 (= yes) or 0 (= no). If set to yes, this means that if the CPU is waiting for io's to complete, it the governor will consider this as load, and continue to throttle up the CPU freq. If on the other hand it is set to no, in this case, the governor considers this as not being a load, and CPU freq. will start throttling down.

I like to keep this to yes, as I'm a convinced "race to idle" theory fan, which means best battery drain is achieved if we do what we have to do as fast as possible (higher CPU clock) so we can put cores to sleep sooner and save juice. There are also others that say better battery is achieved by keeping the CPUs on low freqs. but taking longer.

Don't expect the difference to be huge, and whatever your oppinion on this, I'd rather provided you with the choice, so it's up to you what you consider being the "truth"

YankasusQ

This is a PegasusQ governor with a few modifications of my own. It will have the "io is busy" set to 1 by default (see above for details) and has the hotplug parameters changed (thresholds for frequencies and run queue) so as to try to have as little cores online as possible at any given time.

So far, we're still in a stock Pegasus environment.

I've also added 4 more parameters that now allow to set the CPU max. frequency for any of the core setups, so you get a CPU max. frequency for single core mode, for dual-core mode, for 3-core mode and for quad-core mod.

As well, the latest update added a screen off max frequency, which can be set in Aroma. This should keep the freq. low when the phone must is woken up during screen off.

IMPORTANT

Please bear in mind when setting the standby max CPU freq. that Samsung uses 1.4GHz by default, so it's not about beating any kind of record, as going too low may result in a sleep of death !! Battery pull or long power key will be necessary to get out if it rather unproperly I might add !

LulzactiveQ

This is a different governor that has been ported to the SGS3 and adapted from dual core to quad core. It will scale up and down the CPU frequencies more aggressively and also hotplug faster (switch cores on sooner but also switch them off sooner).

The result is a better responsiveness, but at the cost of a little battery.

zzmoove (explanations by zanezam, author of the governor, thanx !!)

Basically this is the ported SGS1 version of the well known "smoove" governor from the good old midnight kernel from Michael Weingaertner (mialwe) with a modified CPU hotplug implementation of the ktoonservative governor from ktoonesz. The original implementation from ktoonesz worked well but I observed that on idle most of the time only one cpu was going to sleep. Well that was not enough for me so I made a modification to put the other cpu's also to sleep (except cpu0). That means that this governor uses more often only one cpu on idle and as a consequence of that it needs less energy. Depending on System load and governor settings all 4 cores will be instantly up again if it is needed.

So what you can expect now from this thingy is a battery-friendly behaving hotplug conservative governor which uses a frequency lookup table for faster upscaling (so called "smooth scaling"). So this is more a energy-saving than a performer.

IDLE - Clock is gated but power on CPU core remains (static power consumption still active)

AFTR - Clock is gated, power on CPU cores removed and L2 cache power remains. Static power consumption mostly eliminated.

LPA - Cache power removed.

AFTR or LPA cannot be entered if second core is active.

Multicore power saving :

Significance: Increases multi-core awareness!?

Sched_mc aims to schedule tasks between multiple cores in the CPU. Sched_mc can be a) OFF (value 0), b) load balance (value 2) the cores by keeping the load even between them or c) power-save balance (value 1) by loading first core until it's 100% loaded. Hotplugging does load balancing already by taking care of thresholds, run queues, process priorities, cut-off frequency, etc. So there's no use of sched_mc = 1. Powersave balancing which overloads first core will increase the time to relieve first core (as compared to same task balanced between both the cores). This will cause delay to hit deep-idle states, since only first core can enter AFTR/LPA states.Disable sched_mc. There could be only one situation where load balancing or weird-overloading of first core can be useful - when we use dual core mode. Sched_mc is valid only when both cores are online. If someone uses dual-core mode sched_mc is worth a try to handle task-loads across cores.

I'd say this one's pretty selfexplaining, it will let you chose at what maximum frequency you want to limit your CPUs. Stock is 1.4GHz, so allowing (up to 1.6GHz) more means you're overclocking the CPUs (expect better perfomance, but to the cost of a slightly higher battery drain !), restricting this to anything lower than 1.4GHz means you're underclocking the CPUs (you can expect to save some battery juice, but to the cost of lesser performance.)

Since our S3 has quite a powerfull CPU, if you use your S3 for basic tasks only (browing, texting, calling, reading emails...) you may use lower freqs. and not feel any real loss in speed, but if you're gaming etc. expect to feel the difference.

NB: You will se a different list of options if you chose YankasusQ governor, as it will allow for more frequencies as explained above.

MMC I/O Settings

These settings will be applied only 2 minutes after boot is completed, as we need to wait that the external sd card has become ready in the system before applying this.

MMC readahead buffer

This will set how much more of a file the system will read than an app actually asks for, so that when the app asks for the next data, it is already available, thus winning the time to go get it on internal / external memory.

Sounds nice, first reflex, put it to the max. As you can see, I've limited the choices to 4Kb max, that is not a technical limit, but more of a failsafe against this very same reflex.

While reading files sequentially, e.g. from the beginning to the end like on MP3s or movies, more is better since we are going to read what's next in the file anyway, we want to listen to the rest of that song, watch the rest of that movie, if on the other hand the app reads randomly within a file, like a database would do, e.g. your satnav reading the map for you, it will jump reading from here to there, what is the point of reading too much ahead in this case ? Well none, you'll have your system read loads of data that the app is never going to ask for, so it's counterproductive.

As so often in life, you need to find the perfect balance, but this balance may be different depending on what you do more...

MMC I/O Scheduler

I'll keep this one short, have a look here, considering that we only have "noop, dealine, cfq, sio and row" in this kernel. I couldn't tell you more about this anyway

Just a few words about the latest addition, ROW, since that one is not explained in the linked thread. ROW has been specifically designed for flash memory storage (e.g. our internal / external memory). It will handle READ operations with higher priority, while delaying WRITE opterations to when there's time for it, but at some point, writes will have to be done anyway, so they won't be delayed forever, obviously.

It makes the device really feel more responsive and to be honest, it's the only scheduler I ever really actually "felt" a difference.

Low Memory Killer Presets

All the apps you run are put into different categories (as a degree of importance or a kind of service they provide).

Memory is divided into memory blocks that apps can use. In Android one memory block has 4096 bytes. Each category will have a number of memory pages limit, which as soon as free memory drops below of that limit, will make LMK start killing tasks of that category.

So the higher the limits, the sooner it will start its blood bath and kill away, or put otherwise, the higher the limit, the more free memory you will have at any given time.

ALMK is your guardian of free memory if you will.

Again, balance is key, too high, and you'll end up not having any multitasking at all, but loads of free memory that's not used, bad idea, too low, you might run out of memory, which induces lag and might even trigger Linux's OOM (out of memory killer), which will shot a sight without looking what it's shooting at (more or less), so you don't want to wake that monster either.

Plus depending on the use of swap and what kind of swap, these settings will also have an indirect impact.

Virtual memory

Perfect transition to swap

As I just said, memory is divided into memory blocks of 4096 bytes. Each memory block holds also the information when it has been used for the last time.

Considering this, one single app will be using many blocks. Some of those the app will be using a lot, some it won't. Take a simple card game. When you're playing, you're not using the app's settings menu, thus not using any of the blocks that hold those parts of the app.

Swap is a process that is used in most of modern operating systems. The virtual memory management system (that's swap !) will swap out all the blocks that were not used for a certain time, this "certain time" is influenced by swappiness and a few other parameters that we can change.

The plus is that the memory blocks that have been swapped out will free up RAM to be used by other apps, thus allowing for more apps to run at the same time.

On the other hand, if you need a swapped out block, that will cost extra time, since it's not located in memory any more but on the swap partition, so it will need to be reloaded into RAM (possibly by swapping out another block to make room for this).

That should give you a glimpse on the benefits and the costs of using swap. There's that damn balance once again...

That should also give you an idea of why LMK settings matter, since if almost no free ram is available, a swap in will generally cost a swap out first then the swap in !

Consider swap as a way to have only part of the apps in RAM instead of having all of it, and as such allowing for more apps to run at the same time.

BTW, it does not add RAM, you can only add RAM by actually adding physical RAM, anyone telling you otherwise is either lying or does not know what she/he's talking about

Hardswap

My favorite, since it adds virtual memory, without taking anything for it, swapped out memory pages are stored on a separate partition on the external SD card. The drawback is it's actually slower than using internal memory, but I don't like that, wearing internal memory is kind of bricking the phone, where wearing out an SD card just means replacing it, much cheaper. And it's much slower than zram, but ... read ahead ...

zram

The one I don't like that much. It's fast, yes. It will take less RAM than it will give swap in return, still true as it uses compression to store the swapped out memory pages, so you'll be fitting more pages in swap than swap actually uses pages to store them.

But, there's always a but, you now understand that swap is not RAM, so taking RAM away to use as swap, is removing RAM from running apps. The more zram, the more RAM you take from your apps to acutally run.

But again, since it's the fastest, maybe it's going to fit your need better than hardswap, so you need to try, and with Aroma, that's real easy to do

As a sidenote, it might be interesting to read the FAQ in my hardswap thread if you want to know some more about this.

Fast charge

My favorite first kernel mod, the one that gave me the courage to go the whole way to compiling a kernel as I just needed to port it on my Sensation at the time.

This is the S3 flavour of the mod, it has a few options :

Substitute

This is the classic fast charge mod, which just tells the device to charge on a USB port as if it were an AC charger. It's a but simplistic, but back in the days (that's just a few months back actually) it was fine.

I've kept the logic, since there are apps on Play Store that allow to enable / disable this mode from an app/widget.

But I consider this deprecated.

Custom current

Now the S3's hardware allows for something quite nicer, we can actually set the charging rate as we wish ! In this mode, well you just chose at what rate you would like to charge your battery when connected to a USB port (475mA/h is default) or an AC wall charger (1000mA/h is default).

Be aware that you may fry your USB port if you draw too much and it overheats, but if it's a port that fully complies to the standard, it should shut down (stop giving current) if you draw too much from it.

Also, charging at higher rate than 1000mA/h (= wall charger rate) you may shorten the life of your battery, so it's up to you to use this, again, with balance

Dynamic fsync settings

This is a goodie by faux123, so all credits go to him for creating this unique feature !

Many kernels just disable synchronous writes to file to speed up system. While this works neatly, it is also dangerous as processes believe that file writes are actually sync'ed to disk (or mmc media in our case) while this is not yet true !

The gain is a noticably smoother user experience, but the risk of doing so is to have a corrupted filesystem if the device crashes, user pulls battery, battery fully depleats ... so that the device is turned off unexpectedly.

To allow for the benefit, but to minimize the risk, faux123 created dynamic fsync, which while the screen is on, will defer file sync temporarily, but when screen gets turned off, a flush is called to synchronize all outstanding writes keeping your data safe.

Now it's up to you to either use this unique feature (that has been enabled by default up until v2.2) or choose to stay stock by disabling it, thus writes being done synchronously, which is safer but also slower.

Boeffla Sound Engine by AndiP

First off, huge thanks to Andi for offering me to incluse his amazing sound engine !!

This engine allows to control the hardware sound processor, as such it's not a software implementation that consumes CPU power and other resources, it "only" chnages the hardware settings that our hardware is capable of and which Samsung didn't allow us to use, why ever...

don't set - use this if you intend to use the APP the control the Sound Engine or if you're rather into implementing your own init.d script to set it up

Speaker - Output level

This feature is the same that I previously implemented in my Sound Level Mod, it allows to make the speaker louder, but be careful not to blow the speaker !!

Headphones - Output level

This feature is also the same that I previously implemented in my Sound Level Mod, it allows to make the headphones louder, but be careful not to blow your ears !!

Headphones - Equalizer Mode

sat.prev. - enable hardware equalizer with saturation prevention (will compress sound if the output is too high to prevent distortions)

enabled - enable hardware equalizer without saturation prevention

disabled - keep the hardware equalizer off (stock behaviour)

Headphones - Equalizer Setting

These are a few presets for the hardware equalizer, while standard will keep all bands at 0, you'll just need to test the other presets for yourselves (eargasm, pleasant4ears, bass-extreme, Yankgasm).

Headphones - Privacy Mode

This setting causes the speaker to be completely muted for notification sounds, phone ring signals etc. as long as a headphone is plugged in. This avoids people looking at you when you are wearing headphones and receive a notification, which is by standard played via both speaker and headphones. Now, nobody will notice anymore when you get alerts while wearing headphones.

But that means, the speaker will not work as long as you have your headphones plugged in !!

Headphones - DAC direct

By switching DAC direct to on, you will bypass the output mixer in the signal path and connect the DAC directly to the headphone amplifier.

This setting changes the FLL configuration of the Wolfson WM1811 audio hub.

Expected impact: Better sound quality when using headphones.

Microphone - Sensitivity mode

By this setting you can configure the microphone mode when you want to record videos etc. in very loud and noisy environments. Ever tried it and your audio was completely distorted and over-saturated? By this setting, you can avoid this in future.

Note: Of course this setting is automatically disabled as soon as you use your phone for a call.

Expected impact: You can record also in very loud environments and audio is not distorted.

Kernel modules

I've made these supports as kernel modules, I see no need to have it in the kernel if you don't need them.

CIFS network filesystem support

This will load the kernel modules for CIFS support at boot time. Apps like CIFS Manager can do that for you, but if you are keen to use CIFS shares from your S3 like I do, preloading them at boot is a good idea.

NFS network filesystem support

This will load the kernel modules for NFS v3 support at boot time.

NTFS filesystem support

This will load the kernel modules for NTFS support at boot time, which will allow to mount NTFS partitions on SD cards or external harddrives.

Please note that the kernel only provides the modules, mounting the partitions will not be done automatically, you will have to do this either yourself or using some kind of app.

ISO 9660 filesystem support

This will load the kernel modules for ISO 9600 filesystem support at boot time, which is used on CDs or DVDs.

Please note that the kernel only provides the modules, mounting the partitions will not be done automatically, you will have to do this either yourself or using some kind of app.

UDF filesystem support

This will load the kernel modules for UDF filesystem support at boot time, which is used on CDs or DVDs.

Please note that the kernel only provides the modules, mounting the partitions will not be done automatically, you will have to do this either yourself or using some kind of app.

XBOX 360 gamepad support

This was a user request which was quite easy to implement, but again, I did it as a kernel module as, for instance I don't use it, and I suppose quite a few won't, so only those that really use their Xbox gamepad to play should preload the module on boot.

This only works if you connect the gamepad to your S3 using an USB OTG cable ! It won't work wirelessly.

init.d script support

The hardest to explain :rolleyes:

Let me try it this way. Most mods will change settings, and to do this so that those settings stick, they need to do it everytime your device boots.

To do so, there is a folder called init.d, it's actually located in "/system/etc/init.d" and it will hold scripts which will be executed everytime your device boots.

Well and this "will be executed" is the thing we need to focus on here. This can be either handled by the kernel (or rather ramdisk to be more precise, which comes with the kernel), or it can be handled by the ROM (like this is the case in mike's ARHD ROMs).

So depending on the ROM you have, you either need the ramdisk to handle this, or the opposite just don't want it to take care of that, since if both do, the scripts will be executed twice, which may be fine, but may also be a problem...

So you need to know what your ROM does here, and according to what the ROM does, have or not have the ramdisk do it.

So to make this as easy as possible, ask in your ROM thread if the ROM handles init.d.

Are exFAT formated sd cards supported ? or Now I flashed this kernel my sdcard is not detected anymore ?

So far, no, there's no exFAT support.

exFAT is a Microsoft proprietary format for which we don't have sources. There is a way to force the kernel to load the module, but since 64Gb sdcards can be formated in FAT32 as well (not in Windows, though), I so far didn't see the need to include that hack. It's against my open source religion.

Blame Microsoft for making exFAT closed source and balme Google way more for using it anyway

Does this kernel support undervolting, are there plans to add support ?

I have no undervolting in the kernel, and no plans to include it either, as it makes no measurable battery life difference whatsoever.

At best, it keeps the device a little cooler, but I never had temp issues.

I've done my fair share of testing back then on the htc Sensation, undervolting as low as -100mV, without any noticable battery life increase, at -125mV all I got was occasional random reboots.

So what it will bring most certainly is instability and that will flood the kernel thread with hotreboot and freeze posts because most users tend to just exagerate and use more UV than their device in fact can handle.

It may seem stable at first, but may not stay so as frequency is throttled up, you'd need to finetune every step to do it properly... a lot of work for a mere placebo effect, so for me absolutely not worth adding it.

Anyway, that's just my oppinion on the topic, I don't pretend to own the BIG TRUTH on that, this is just based on my observations.

My kernels, though, will be made according to my oppinion obviously

Is there a way to remove this kernels configuration scripts when going for another kernel ?

All leftovers are passive, e.g. they won't get executed by any other kernel as I created a file of my own and have an own entry in init.rc to execute it. New kernel = new ramdisk = new init.rc = no execution.

The files are :

/system/etc/init.kernel.sh

/system/etc/init.hardswap.sh (only if you chose hardswap = yes)

/data/kernel-boot.log

/data/kernel-script.log

/data/hardswap.log (only if you chose hardswap = yes)

/data/swap.*.log (only if you chose hardswap = yes)

I've made a flashable kernel cleanup zip that will remove everything in preparation to flash a different kernel, so your system becomes perfectly clean again, as if my kernel never had been there.