Skip to contentSkip to conversation

zram: add support for mem_limit

PATCH New Sinan Kaya 1 participant 1 message Apr 23, 2021

lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

PATCH 1/1 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.

---
 meta-oe/recipes-extended/zram/zram/zram-swap-init | 5 +++++
 1 file changed, 5 insertions(+)
meta-oe/recipes-extended/zram/zram/zram-swap-init +5 -0
index ccc3aafe3a..28082f7ff0 100755
@@ -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
Signature · 1 line
2.17.1