From 20bc13de0e6fb3964263954b5d5425770bd6c475 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Wed, 11 Dec 2019 15:52:05 -0800 Subject: [PATCH] post_boot: Ensure SLAB_STORE_USER is disabled for zram kmem_caches ZRAM compression uses the linux slub allocator its internal data structures. If these internal data structure consume a lot of memory, ZRAM compression may increase memory usage, rather than decrease it as expected. Decrease the chance of this occuring by ensuring the SLAB_STORE_USER debug option is disabled. Change-Id: I4684feda94b7bebacb6218b7f979c95771b0ee10 Signed-off-by: Patrick Daly --- rootdir/bin/init.qcom.post_boot.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rootdir/bin/init.qcom.post_boot.sh b/rootdir/bin/init.qcom.post_boot.sh index f38fe2e5..1dca6f78 100755 --- a/rootdir/bin/init.qcom.post_boot.sh +++ b/rootdir/bin/init.qcom.post_boot.sh @@ -392,6 +392,16 @@ function configure_zram_parameters() { else echo $zRamSizeBytes > /sys/block/zram0/disksize fi + + # ZRAM may use more memory than it saves if SLAB_STORE_USER + # debug option is enabled. + if [ -e /sys/kernel/slab/zs_handle ]; then + echo 0 > /sys/kernel/slab/zs_handle/store_user + fi + if [ -e /sys/kernel/slab/zspage ]; then + echo 0 > /sys/kernel/slab/zspage/store_user + fi + mkswap /dev/block/zram0 swapon /dev/block/zram0 -p 32758 fi