diff options
author | fakeyatogod <fakeyatokami@gmail.com> | 2021-04-27 10:01:21 +0530 |
---|---|---|
committer | Sebastiano Barezzi <barezzisebastiano@gmail.com> | 2021-08-14 01:35:29 +0200 |
commit | 38961367c5490d49e06bc344c028ee89b5d3623c (patch) | |
tree | 925e5655fbcb68ee6da762507d90cf98eb73999a | |
parent | a51b2dfc6c3b75b7669fda24fe80b0cf0369702c (diff) |
sdm660-common: Update ZRAM configuration
From LA.UM.9.2.r1-03000-SDMxx0.0
* Otherwise zram remained disabled
- Increase ZRAM swap size.
- post_boot: Ensure SLAB_STORE_USER is disabled for zram kmem_caches
- post_boot: Set zRam disk size to 50% of RAM size.
- Set zRam disk size to 50% of RAM size for non-Go devices.
- post_boot: update zram setting avoid 32 bit overflow
- post_boot: use 'MB' as deault unit for zram disksize setting
- post_boot: updating post_boot for <=2 GB devices
Change-Id: I73ec74c4a10f2d0c65506d73f43fe64a20ed2cc5
-rwxr-xr-x[-rw-r--r--] | rootdir/etc/init.qcom.post_boot.sh | 38 |
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 |