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>
This commit is contained in:
Sinan Kaya 2021-04-23 20:03:25 +00:00 committed by Khem Raj
parent a7d0d87854
commit cb1cf05378

View File

@ -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