zram: add support for mem_limit

Some targets might be interested in limiting how big
zram can grow. If the variable is set in /etc/default/zram file,
configure it in mem_limit sysfs attribute.

Signed-off-by: Sinan Kaya <okaya@kernel.org>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
(cherry picked from commit cb1cf05378)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
This commit is contained in:
Sinan Kaya
2021-04-23 20:03:25 +00:00
committed by Armin Kuster
parent 981a6b3cb1
commit ef6adcba6f
@@ -24,3 +24,8 @@ modprobe -q zram || true
zramctl -a ${ZRAM_ALGORITHM} -s ${memzram}KB $device
mkswap -L "zram-swap" $device
devname="${device##*/}"
if [ ! -z ${ZRAM_SIZE_LIMIT+x} ]; then
echo ${ZRAM_SIZE_LIMIT} > /sys/block/$devname/mem_limit
fi