Skip to content

Commit

Permalink
lavender: Update ZRAM configuration from LA.UM.9.2.r1-03000-SDMxx0.0
Browse files Browse the repository at this point in the history
* 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
Signed-off-by: SparXFusion <[email protected]>
  • Loading branch information
fakeyatogod authored and SakthivelNadar committed Jan 7, 2022
1 parent 913db35 commit 5b8c3c5
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions rootdir/bin/init.qcom.post_boot.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -440,11 +452,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
Expand Down

0 comments on commit 5b8c3c5

Please sign in to comment.