[Huawei Ascend P7] Kostyan_nsk:
Ascend P6S / P7 K-Tuned Kernel​

Hello! Finally I decided to make a new thread for kernel with description of all features.

So, here they are:

CPU Governors:

PegasusQ

AbyssplugV2

Optdemand

Interactive

Impulse

Pwrctrl_hotplug default

I/O Schedulers:

CFQ

Deadline

ROW

Noop

FIOPS default

TCP Congestion:

HTCP

Reno

BIC

CUBIC

Westwood+ default

Upstreamed to 3.0.101 version

SELinux permissive for 5.1.1

LZ4 kernel & ramdisk compression

Backport random from kernel 4.0 branch

ExFAT version updated from 1.2.5 to 1.2.9

F2FS support

Fixed 5.1.1 GPU performance regression bug

USB Fast Charge

Intelli-Plug

Asynchronous Fsync

CPU overclock: enabled 1996MHz CPU frequency and 1795MHz for P6S

CPU undervolting

GPU overclock: enabled 700MHz GPU frequency for P6S

GPU undervolting

Adjusted stock CPU & GPU governor thresholds for better performance

DoubleTap2Wake

Sweep2Sleep

init.d support

set_immutable binary removed from ramdisk for 4.4.2

Speed up system startup

Now more detail about some features:

Governors

PegasusQ

Governor from Samsung with hotplug support. Perhaps, the most tunable and flexible one.

Parameters description:

sampling_rate: the interval with which governor will be carried out. Less value - better responsiveness, but at the same time, more load for CPU by governor itself.

sampling_down_factor: amount of iterations governor will stay at highest frequency before go down.

up_threshold: load threshold in % above which CPU frequency will be increased.

up_threshold_at_min_freq, freq_for_responsiveness: at frequency lower than freq_for_responsiveness will be used up_threshold_at_min_freq threshold - provided for better responsiveness.

down_threshold: load threshold in % below which CPU frequency will be decreased.

freq_step: step of frequency encrease in % from maximum frequency.

hotplug_freq_*: high and low frequency thresholds for making decision about hotplug of each core.

For clarity, it looks like this:

static int hotplug_freq[4][2] = {
{0, 1596000},
{208000, 1795000},
{416000, 1996000},
{624000, 0}
};

In this array left column is frequency at which core will be disabled; right column - frequency at which will be enabled next core.

hotplug_rq_*: analogous parameters set (array), defining queue task length for making decision about hotplug of each core.

static int hotplug_rq[4][2] = {{0, 50}, {50, 100}, {100, 150}, {150, 0}};

For example, second core will be disabled after reaching 208MHz frequency and amount of tasks must be less than 50;

third core will be enabled after reaching 1795MHz frequency by second core and amount of tasks more than 100.

cpu_up_rate: amount of governor iterations cpu should stay at defined frequency for enabling next core.

cpu_down_rate: amount of governor iterations cpu should stay at defined frequency for disabling last active core.

down_differential: defines load in % which must be less than up_threshold to go to lower frequency.

hotplug_lock: lock amount of active cores.

min_cpu_lock: limits min value of enabled cores.

max_cpu_lock: limits max value of enabled cores.

up_nr_cpus: defines how many cores to enable at a time.

AbyssplugV2

Based on Conservative, has hotplug support. Pluses: pretty simple, hence doesn't load CPU by himself. Frequency increases sequentally, after reaching max frequency - enables next core. And vice versa. Minuses: often enables / disables cores (what in itself is energy intensive).

Distinctive parameters:

up_threshold_hotplug: load threshold in % above which will be enabled next core.

down_threshold_hotplug: load threshold in % below which will be disabled last active core.

boost: load threshold above which frequency will be increased through step (for exaample., from 208000 immediately on 624000)

Optdemand

Governor by Hisilicon, based on Ondemand. Backported from Honor 4X/4C. Distinctive feature is each frequency has its own thresholds to go to higher or lower frequency.

Distinctive parameters:

go_hispeed_load, hispeed_freq: after exceeding go_hispeed_load threshold, CPU goes immediately to hispeed_freq frequency.

up_thresholds, down_thresholds: above and below load thresholds for each frequency. For clarity:

static unsigned int operating_points[7][3] = {
/* kHz up_threshold down_threshold */
{208000, 60, 0},
{416000, 60, 30},
{624000, 70, 40},
{798000, 80, 50},
{1196000, 85, 50},
{1596000, 90, 60},
{1795000, 95, 70},
{1996000, 100, 80},
};

For example, for frequency 624MHz, if load will go below 30%, will be calculated new lower frequency according to new load value; if load will go above 70% - frequency will be increased.

boost: frequency will be increased to hispeed_freq

bostpulse_duration: duration of boost in microseconds.

Interactive

Google's gold standard governor. Updated to 3.4 kernel branch

Impulse

Based on Interactive governor. Good responsiveness.

USB Fast Charge

Increases charge current when connected to USB. It has sense only when connected to USB 3.0

Can be enabled by writing "1" into /sys/kernel/fast_charge/force_fast_charge file or by third party applications.

Disabled by default

Intelli-Plug

Hotplug driver for governors not supporting hotplug.

Activated and deactivated automatically depending on chosen governor.

Parameters are in /sys/module/intelli_plug/parameters

nr_possible_cores: max cores affected by driver.

nr_run_profile_sel: has several profiles :

0: balance default

1: performance

2: conservative

3: eco

4: eco extreme

screen_off_max: max frequency at screen off.

touch_boost_active: enables additional core at screen touch disabled by default

CPU undervolting

Undervolting values can be set for each frequency individually. Regulator has step 8mV starting from 700mV. I've got such stable values:

View attachment 3712992

But you should start from higher values. I've made a test: CPU locked at frequency 1795MHz, RAR creates archive with 4 threads in 10 minutes. Average CPU temperature during this time was 56.124 degrees, with undervolting average temperature became 51.119 degrees. I.e. average temperature became lower for 5 degrees which means less power consumption.

Comparative graph:

View attachment 3712997

GPU undervolting

Since I couldn't find any common used sysfs interface and applications supporting it, you can make it using script (see init.d spoiler).

My stable values are:

160: 860 -> 700
266: 860 -> 732
355: 876 -> 764
533: 956 -> 860
700: 1052 -> 924

But most probable, you will have troubles with such values, try to find suitable for your own.

3DMark Ice Storm Extreme showed average temperature decrease from 61.587 to 55.502 degrees.

Comparative grapth:

View attachment 3712998

DoubleTap2Wake

Screen on by double tap on it. Has two parameters in /sys/android_touch

doubletap2wake: enables dt2w. Possible values are:

0: disabled default

1: active at all screen

2: active at top half

3: active at bottom half

4: active at navbar

dt2w_duration: Since I couldn't implement waking up device from deep sleep by irq from touch panel, so kernel doesn't go to deep sleep when dt2w is active, I added parameter defining how long dt2w stays active after screen off. After this duration dt2w becomes inactive and kernel can go into deep sleep.

Sweep2Sleep

Swipe on navbar for screen off. Can be enabled by writing "1" into /sys/android_touch/sweep2sleep file. Disabled by default.

s2s_length: swipe length in dots. By default, equal to 25% of screen width.

init.d

For executing scripts at startup, put them in /system/etc/init.d folder and set permissions to 0755

Several scripts examples (doubletap2wake, sweep2sleep, fast_charge, gpu_undervolting): View attachment 3713003

Scores

View attachment 3713004

For correct governors switching I recommend to use Kernel Adiutor

It also lets to manage IO schedulers, TCP congestion, fast charge, CPU undervolting.

Requirements:

Unlocked bootloader

TWRP

Installation:

Just install zip-archive from TWRP

Download:

View attachment 3922542

View attachment 3922543

Source: Github

Updates:

31.10.2016

CVE-2016-5195 "Dirty COW" fixed.

Now CPU voltage values take effect right after frequency changes.

30.07.2016

Adjusted voltages for overclocked frequencies due to cases of appearing stability issues on some devices.

15.05.2016

Removed GPU undervolting applying at booting due to some users had stability issues. Now for GPU undervolting use init.d script individually.

Adjusted governor thresholds.

Reduced min online CPUs from 3 to 2 when screen is on for stock pwrctrl_hotplug governor.

Regards,

Kostyan_nsk