TLDR: in Oct 2016, the patch has been merged into official Cyanogenmod / Lineage kernel sources: https://github.com/LineageOS/androi...mmit/0e899ff2828df771b524dc52f19f29c0c5cd5842
-------------------------------------------------------------------------
There has been much discussion on UI freezes / lags with CM13 on the Droid 4 in another thread which turned out to be related to some quarrel between Android lowmemorykiller (LMK), ZRAM and kswapd direct reclaim...
As a workaround, increasing extra_free_kbytes (to 75000 in my case) turned out to reduce lags a great deal. (This can be done e.g. with Kernel Adiutor Mod)
Now, I made a small kernel patch adapted from 3.4 kernel which makes LMK account for swap memory, i.e. LMK does only consider memory pages as free which won't require swapping:
Code:
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 86d5195..d4e4513 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -34,6 +34,7 @@
#include <linux/mm.h>
#include <linux/oom.h>
#include <linux/sched.h>
+#include <linux/swap.h>
#include <linux/notifier.h>
static uint32_t lowmem_debug_level = 2;
@@ -90,7 +91,7 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
int selected_tasksize = 0;
int selected_oom_adj;
int array_size = ARRAY_SIZE(lowmem_adj);
- int other_free = global_page_state(NR_FREE_PAGES);
+ int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
int other_file = global_page_state(NR_FILE_PAGES) -
global_page_state(NR_SHMEM);
If you want to try, just flash the following zip file via safestrap recovery over existing CM13 (both - kernel and ramdisk.img - are included): cm13_lmkpatch_v1.zip
I am not sure yet, if extra_free_kbytes can be reduced now (seemingly not, I'm still at 75000), nor if LMK watermarks can be lowered (maybe yes, I have set it to Kernel Adiutor's Agressive Profile)....
....but I'm very much interested in your findings!
If this turns out to be an improvement, I'll commit a change request to review.cyanogenmod.org
Last edited: