From f96b6fd622f3e1c38c5a618fdd6803e637614745 Mon Sep 17 00:00:00 2001 From: moddingg33k Date: Tue, 19 Aug 2014 18:13:51 +0200 Subject: [PATCH] assets/run: improve zram intialization if zram is build into kernel Sometimes ZRAM is built into the kernel itself rather than being shipped as loadable module. In this case the number of available ZRAM devices doesn't always have to match with the number of CPUs. We should take care of that. Signed-off-by: moddingg33k --- assets/run | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/assets/run b/assets/run index c74d8e4..d6b7849 100644 --- a/assets/run +++ b/assets/run @@ -21,6 +21,19 @@ local val=$2; local v=$(( val/cpus )); local ncpus=$(( cpus - 1 )); +local devices=`ls /dev/block/zram*`; +local ndevices=0; + +for j in $devices; do + ndevices=$(( ndevices + 1 )); +done + +# override values in case ZRAM is built into kernel +if [ $ndevices -gt 0 ]; then + v=$(( val/ndevices )); + ncpus=$(( ndevices - 1 )); +fi; + if busybox [ -f /system/lib/modules/zram.ko ]; then if busybox [ -z "`busybox lsmod | busybox grep zram`" ]; then busybox insmod /system/lib/modules/zram.ko;