aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]rootdir/etc/init.qcom.post_boot.sh38
1 files changed, 24 insertions, 14 deletions
diff --git a/rootdir/etc/init.qcom.post_boot.sh b/rootdir/etc/init.qcom.post_boot.sh
index c381d3b..e548373 100644..100755
--- a/rootdir/etc/init.qcom.post_boot.sh
+++ b/rootdir/etc/init.qcom.post_boot.sh
@@ -340,13 +340,21 @@ function configure_zram_parameters() {
# Zram disk - 75% for Go devices.
# For 512MB Go device, size = 384MB, set same for Non-Go.
# For 1GB Go device, size = 768MB, set same for Non-Go.
- # For >=2GB Non-Go devices, size = 50% of RAM size. Limit the size to 4GB.
+ # For 2GB Go device, size = 1536MB, set same for Non-Go.
+ # For >2GB Non-Go devices, size = 50% of RAM size. Limit the size to 4GB.
# And enable lz4 zram compression for Go targets.
- RamSizeGB=`echo "($MemTotal / 1048576 ) + 1" | bc`
- zRamSizeBytes=`echo "$RamSizeGB * 1024 * 1024 * 1024 / 2" | bc`
- if [ $zRamSizeBytes -gt 4294967296 ]; then
- zRamSizeBytes=4294967296
+ let RamSizeGB="( $MemTotal / 1048576 ) + 1"
+ diskSizeUnit=M
+ if [ $RamSizeGB -le 2 ]; then
+ let zRamSizeMB="( $RamSizeGB * 1024 ) * 3 / 4"
+ else
+ let zRamSizeMB="( $RamSizeGB * 1024 ) / 2"
+ fi
+
+ # use MB avoid 32 bit overflow
+ if [ $zRamSizeMB -gt 4096 ]; then
+ let zRamSizeMB=4096
fi
if [ "$low_ram" == "true" ]; then
@@ -357,13 +365,17 @@ function configure_zram_parameters() {
if [ -f /sys/block/zram0/use_dedup ]; then
echo 1 > /sys/block/zram0/use_dedup
fi
- if [ $MemTotal -le 524288 ]; then
- echo 402653184 > /sys/block/zram0/disksize
- elif [ $MemTotal -le 1048576 ]; then
- echo 805306368 > /sys/block/zram0/disksize
- else
- echo $zRamSizeBytes > /sys/block/zram0/disksize
+ echo "$zRamSizeMB""$diskSizeUnit" > /sys/block/zram0/disksize
+
+ # 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
@@ -455,11 +467,9 @@ if [ "$ProductName" == "msmnile" ] || [ "$ProductName" == "kona" ] || [ "$Produc
echo 100 > /proc/sys/vm/swappiness
else
arch_type=`uname -m`
- MemTotalStr=`cat /proc/meminfo | grep MemTotal`
- MemTotal=${MemTotalStr:16:8}
# Set parameters for 32-bit Go targets.
- if [ $MemTotal -le 1048576 ] && [ "$low_ram" == "true" ]; then
+ if [ "$low_ram" == "true" ]; then
# Disable KLMK, ALMK, PPR & Core Control for Go devices
echo 0 > /sys/module/lowmemorykiller/parameters/enable_lmk
echo 0 > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk