From 28e54cf75557ca1c55ea7d21aac8c95c2c910676 Mon Sep 17 00:00:00 2001 From: Divyanand Rangu Date: Tue, 31 Mar 2020 19:35:33 +0530 Subject: [PATCH] post_boot: updating post_boot for <=2 GB devices Removing the check of 1GB RAM while enabling low_ram target specific configurations to enable them for 2GB RAM targets as well. Updating ZRAM size to 75% of RAM for <2GB devices Change-Id: I8d5341a4397cd20f2c59e7396801fcbea7fe5b73 --- rootdir/bin/init.qcom.post_boot.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/rootdir/bin/init.qcom.post_boot.sh b/rootdir/bin/init.qcom.post_boot.sh index deb53dc7..9147696e 100644 --- a/rootdir/bin/init.qcom.post_boot.sh +++ b/rootdir/bin/init.qcom.post_boot.sh @@ -546,12 +546,19 @@ 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` - zRamSizeMB=`echo "$RamSizeGB * 1024 / 2" | bc` + if [ $RamSizeGB -le 2 ]; then + zRamSizeBytes=`echo "$RamSizeGB * 1024 * 1024 * 1024 * 3 / 4" | bc` + zRamSizeMB=`echo "$RamSizeGB * 1024 * 3 / 4" | bc` + else + zRamSizeBytes=`echo "$RamSizeGB * 1024 * 1024 * 1024 / 2" | bc` + zRamSizeMB=`echo "$RamSizeGB * 1024 / 2" | bc` + fi + # use MB avoid 32 bit overflow if [ $zRamSizeMB -gt 4096 ]; then zRamSizeBytes=4294967296 @@ -565,13 +572,7 @@ 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 - fi + echo $zRamSizeBytes > /sys/block/zram0/disksize # ZRAM may use more memory than it saves if SLAB_STORE_USER # debug option is enabled. @@ -671,11 +672,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