[Galaxy S II General] droidphile:
Misc Faqs on Kernel Stuffs

Kernel users ask a lot of questions - be it development thread or discussion thread. With this post, i hope to aggregate many such questions and even more questions along with answers. I have arranged them randomly - in no particular order. There will be basic and advanced questions. Some answers may be short some may be too long. Try "ctrl+F" in your browser and search for a keyword. You may find the answer you're looking for.

1) "Is it possible to have different default governors for recovery and rom?"

A. Yes.

2) "Governor in recovery?"

A. Ondemand. Not changeable from userspace.

3) "Is there a separate I/O sheduler in recovery? Can it be diff from rom default?"

A. Yes, it can. To support huge amount of writes to sdcard (for ex: with dual boot options), devs may use a different i/o scheduler in recovery. Noop would be apt.

4) "Governor while charging phone when it's off?"

A. The governor is virtually powersave. Because while phone is off and is on charging - device and kernel is ON but there's no background processes running. So frequency will be locked to 200/100 mhz - depending on your lowest frequency.

Also, charging when device is on in airplane mode is almost equal to charging when device is off. Except cell radio, other background processes in airplane mode shouldn't be hogging CPU too much.

5) "Why is resetting extweaks profile recommended sometimes after a kernel flash?"

A. Your profiles are stored under /data/.siyah with ".profile" extension. ".active.profile" file under the same directory stores the name of your active profile. Contents in profiles are in the format "parameter"="<default_value> format. Sometimes there will be change in extweaks interface :-

i) Some new tunables were added

ii) Some tunables were removed

iii) Transposition of some tunables

iv) Default value of some tunable was changed.

When such a change occurs, your profiles should know it too so that it can contain all the parameters. That's why you have to reset profiles after a new kernel flash if it changes something in extweaks.

Resetting simply copies .profile files from /res/customconfig to /data/.siyah . You can do it manually using a file manager to avoid a reboot to recovery and back to rom. From recent versions, Gokhan auto detect changes in extweaks configuration between your existing & new kernel version to auto reset extweaks profile. The check is achieved by md5 sum checks between existing /res/customconfig/customconfig.xml and new one.

6) "How to change mount point for NTFS-sticks from /mnt/ntfs to another location for NTFS usb disks?"

A. Mounting ntfs sticks are managed by /sbin/hotplug script which is called on every plugging and unplugging operations and it includes usb sticks.

We can have an initd script which mounts rootfs in rw and replace that script to modify the location. Script should

1. mount -o remount,rw /

2. rm /sbin/hotplug

3. echo some lines to /sbin/hotplug to create the string you have prepared

4. chmod 755 /sbin/hotplug

7) "What happens if i set single/dual core mode and is on pegasusq?"

A. At the moment, pegausq override the setting and force system to dynamic hotplug mode. Anyhow, it is supposed to respect single core/dual core mode setup and behave like pure ondemand. Dev may make changes in the governor soon.

8) "I feel brightness is still high even at lowest brightness level while reading in dark?"

A. Reduce gamma using extweaks.

9)" Which hotplug logic is used with pegasusq?"

A. Stand hotplug which was introduced on ics which is multi thread aware. (Other hotplug logic is legacy hotplug which is default on gingerbread and is also available in ICS)

10) "Bln and testmode was working perfectly until a new kernel flash. Now there seems to be a problem."

A. Open extweaks. Disable bln - apply changes, enable bln - apply changes, reboot.

11) "What exactly is smooth scaling?"

A. Ondemand governor jumps straight to max frequency a little too often. We can control this by setting a smooth scaling frequency to which the CPU will scale to first before scaling to maximum frequency. A little power saving is the target here. Note that CPU driver does smooth scaling - not governor. When CPU driver is requested by governor to scale up to max frequency, it first scales to smooth frequency, and only in the next sampling to highest frequency. Smooth scaling atm is active for ondemand and pegasusq.

12) "What happens if i set smooth scaling freq to more than my scaling max frequency?"

A. Cpu driver will jump freq to that before scaling to max freq. So make sure you set it below max freq.

13) "How to insert a module that's available in /system/lib/modules?"

A. Safe to be root. In terminal or adb

su

insmod /lib/modules/<module_name.ko>

14) "How to know which modules are pre-loaded by kernel?"

A. Terminal or adb:

lsmod

15) "Why do i feel there's more wake up lag with ICS compared to gingerbread?"

A. ICS kernels has a resume time of 1000ms (one second) compared to 650ms in gingerbread. This time is just to resume the kernel from deep sleep. Note that a little more time is required to resume other background processes.

16) "I'm finding it difficult to underclock to below 800 mhz. Why?"

A. Frequency on GS2 is locked to 800mhz while entering and exiting deep sleep. Boot-loader resumes at 800mhz. Configuring this frequency at kernel level to something lower could cause a lot of SODs on many devices. Anyhow - your underclocking frequency shouldn't be below 800 mhz because of the mentioned reason.

17) "What is screen touch frequency?"

A. It's the frequency the CPU driver jumps CPU to when the screen is touched. Open voltage control/setcpu. Touch the screen and don't take off the finger. You can see CPU at 500mhz. This is the default in most of the custom kernels. Samsung default was 1000 mhz.

18) "Can i change touch screen frequency?"

A. Yes. With kmemhelper interface on supported kernels like Siyah.

You need to lower the frequency. Ideally to your scaling minimum frequency whether it's 100 or 200mhz. First find the level number of frequency from your freq table. Example: if you use 18 steps frequency table, L0=1600 L1=1500 L2=1400..... L14=200mhz L15=100mhz

Put this line in one of your init.d scripts

TF=`cat /proc/kallsyms|grep " level\."|awk '{print $3}'`;kmemhelper -n $TF -t int 14

Replace the last parameter - 14 with the level number of frequency you want to set. After executing this line, open voltage control again, touch screen and hold. You will see frequency did not jump and stayed at 200mhz.

19) "What are the basic things i should take care of when i echo my custom frequency steps to scaling_available_frequencies table?"

A. 1) Valid frequencies are 1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25 in Mhz.

2) Valid frequency is a multiple of four

3) If you're undervolting via an app or script,make sure you set proper voltages and enough voltage steps depending on your frequency step count. Wrongly parsed voltages may result in a non-booting device.

4) ExTweaks settings are applied only during initial boot stage. Any settings that uses frequency level numbers - L0, L1, etc etc should be properly configured to work with your new frequency steps. Best examples are Smooth Scaling parameters and governor settings (like lulzactive screen_off_min_step. Value is 5 in a 7 Step freq table points to a max cap of 500 mhz and max cap of 800mhz in a 9 step table.

5) You can not skip frequencies - 500, 800 and 1000 when you're echoing custom frequency steps.

20) "Why should Not we use high thresholds for hotplugging unlike we did on gingerbread"?

A.We have multiple hotplugging logics on ICS. One is Stand Hotplug (default in most of the ICS kernels) another one is Legacy Hotplug (this was also the logic in gingerbread).

In legacy hotplug (remember loadh, loadl, load_scroff, loadl_scroff etc on GB), the thresholds directly mapped to the current load percentages. At any frequency, if load on CPU is greater than loadh, second core will kick in.

But equations are different in stand hotplug. Stand hotplug aims to calculate load using current load and current frequency. It will make more sense looking at the load calculation equation.

Average Load = (current_frequency * load) / max_performance [where max_performance = max_frequency * no_of_cpus]

Ex: Assume current frequency = 500 mhz load = 70% and max frequency = 1200 mhz

=> average_load = (500*70) / (1200*2) = 23%.

From this it's obvious that second core would kick-in at a 70% load on CPU running at 500mhz only if load_h is set to 23% or less.

Let's calculate theoretically what's the max value for load_h that's valid.

To calculate highest average load, current frequency should be maximum (it should equal max freq) and load should be max (100%).

Highest Average Load = (MaxFreq*100) / (MaxFreq*2) = 50%. So theoretically, load_h can have a max value of 50%. You set anything above, second core won't turn on and the setup will work like single core mode. Practically, the values should be even lesser. I recommend using load_h= 25% and load_l = 10%.

21) "I don't see an init.d folder in my rom. I wanna create some initd scripts. What to do?"

A. Using a root explorer create init.d directory under /system/etc. Set perm 777.

22) "Difference between tar and cwm versions of kernels?"

A. No significant difference. Tar just has the raw kernel image - zimage which you can flash using cwm app/recovery/even adb. Zip has the same zimage with installation script that writes raw image to kernel partition.

23) "After flashing a new kernel i see there are some stuffs missing from extweaks"

A. Either the support for those missing tunables were removed or just the extweaks interface was removed. The parameters might still be accessible through scripts. Check the file path to make sure.

24) "How to know which hotplugging logic is used in the current kernel build?"

A. Navigate to /sys/module using a file explorer. If you find stand_hotplug directory, Stand Hotplug logic is used. If you find pm_hotplug directory instead, Legacy Hotplug is used.

Many more questions to come......