Kernel V4.4 New _ Improvements and optimizations. - LGE-G5-G6-V20/msm8996_lge_kernel GitHub Wiki

Improvements already done prior to this page's creation

Some improvements were already made a while back, both ported from the older source, and backported from newer kernels, such as EAS support (many commits from this to this); lots, lots, and lots of kgsl improvements; support for LZ4 ramdisk; support for lz4 on ZRAM as well as updates for its compressor and decompressor modules, with added support for it in the crypto subsystem; not one, but two CAF tag merges to get it on the bleeding edge of caf-4.4; memory management optimizations; and also some config updates such as ARCH_HAS_FAST_MULTIPLIER and compiler optimization flag adjustments, also for clang.

Swan2000 also had some exclusive additions, namely KCAL control; usb fast charge mode; addition of an extra clock step for 8996pro; GPU/CPU/M4M undervolts; A new README with more specific info on that custom branch and build steps.

So with all that in mind, let's go over what can be added later to help optimize things further, separated by kernel type (stable branch for LOS compatibility, and Swan2000 being the fully custom kernel).

Stable branch adjustments (which also goes into Swan2000)

  • Move some driver probes to async mode, slightly improving boot times. - Done

Commits: A few examples are: icnss, msm_ion and mdss.

  • Pull in some CFQ I/O Scheduler patches, we could use a better scheduler to help the storage's overall performance. - Done, upstreaming the kernel by merging lineage's qcom_msm8998/lineage-20 branch brought many improvements to CFQ and other I/O Schedulers.

  • Improve the charging curve. It's way slower than 3.18 and stock for now, even on smaller batteries. Seems to trigger somewhere around 50%, where it goes from fast charging to slow charging. - Done, it's not faster per se, just... different. Seems we can't go all the way up to 3000mA max, but we managed to devise a custom charging code for smb's driver on LGE that's a lot faster than what's provided by QCOM and SoMC's defaults. Related commits(these span multiple branches, as some were done post-upstream):

dts: lge: Tweak some battery temp and hysteresis props. ,

drivers: power: qcom: Implement a way of tweaking LGE charge speeds

dts: lge: Increase G5's SoMC typec max_curr to 2500mA to match smb

drivers: power: qcom: Add a new LGE_CUSTOM_CHARGE_RATES config

drivers: power: qcom: Tweak the rates a bit for V20 and G5

drivers: power: qcom: Tweak rates and add batt temp compensation

drivers: power: qcom: Keep default icl_ma values for LGE devices.

dts: lge: Clean up SoMC's thermal-engine props.

"power: qcom:" + "dts: lge:" Tweak charge rates a bit more.

"power: qcom:" + "dts: lge:" Rework charging and temp readings.

  • Fix G5's charging speeds. According to some logs, the current seldom goes beyond 500mA on a wall charger.

  • Introduce support for VDSO32 (slightly improves performance and battery life on ARM64, and was also supported on LGE 3.18 kernels) - Done

Commits: Basically everything from this one to this one Those commits aren't valid anymore, since VDSO32 came as part of 4.4-new's upstream to 4.4-302 by merging Lineage's qcom_msm8998/lineage-19.1 branch.

  • Get improved memory and string subroutines from arm's optimized routines to prevent having to backport and extensively test those from newer kernels for newer SoCs. - Done.

Commits: From this to this.

  • More to come...

Swan2000-exclusive adjustments (which includes things that conflict with LOS's guidelines)

  • Update the undervolt curve of the CPU and GPU and add the possibility of toggling unsafe undervolts through a kernel CONFIG. - Done in this commit.

  • Add some ARM routine optimizations, such as the ones from xiaomi vayu. - No need, the optimized routines and general backports we got from xiaomi's custom 4.4 8996/8998 kernels don't need much extra porting and are far safer to use because of that. Here's a list of them:

ashmem backport from 4.19

ashmem build fix for 4.4

optimized strncmp

optimized strlen

optimized strcmp

optimized memcmp

prefetch on memmove and copy_template

NEON optimized memchr

NEON optimized strrchr

NEON optimized strchr

NEON glue layer to enable the commits behind this one

  • Cherry-pick certain performance-improving commits known to be stable from kerneltoast, with some examples being this, this and this. Some general improvements were already cherry-picked, but not these ones... yet, as they need some backporting. - Done, although only one of those has tangible benefits for our platform.

  • Try backporting some of the commits from this V40 source. - Done, though only a small subset of commits could be added, most of the others required a big restructuring. Here's most of what could be brought over:

pagevec optimization

parallel kgsl initialization

selinux perf improvements

use kthread buffers on stack instead of heap

use kmem_cache_pool on kernfs open_node/file structs

use kmem_cache_pool on sdcardfs sdcardfs_file_info

  • More to come...