aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/zram-swap/files/zram.init
diff options
context:
space:
mode:
authorEmil Muratov <gpm@hotplug.ru>2018-08-02 01:05:14 +0300
committerHauke Mehrtens <hauke@hauke-m.de>2018-09-29 17:23:11 +0200
commit70d3ffb47fcef901e4d86da4c9077ba8b8e2ba10 (patch)
tree1bc8bdfd7d6d90b6b3f7bfb63f27d2f07fbed4c5 /package/system/zram-swap/files/zram.init
parent814cae7362c3bd57e8fd9305d5d0b48ff219d4d0 (diff)
downloadupstream-70d3ffb47fcef901e4d86da4c9077ba8b8e2ba10.tar.gz
upstream-70d3ffb47fcef901e4d86da4c9077ba8b8e2ba10.tar.bz2
upstream-70d3ffb47fcef901e4d86da4c9077ba8b8e2ba10.zip
zram-swap: Add "max compression streams" configuration option
Config option to limit maximum compression streams per zram dev for multicore CPU's. This could be defined via 'zram_comp_streams' option in the 'system' section of '/etc/config/system' file or via cli (for e.x. with 'uci set system.@System[0].zram_comp_streams=2 && uci commit system'). Default is number of logical CPU cores. Signed-off-by: Emil Muratov <gpm@hotplug.ru>
Diffstat (limited to 'package/system/zram-swap/files/zram.init')
-rwxr-xr-xpackage/system/zram-swap/files/zram.init14
1 files changed, 14 insertions, 0 deletions
diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init
index 2db986f9a8..9fd4089c6b 100755
--- a/package/system/zram-swap/files/zram.init
+++ b/package/system/zram-swap/files/zram.init
@@ -93,6 +93,19 @@ zram_comp_algo()
fi
}
+zram_comp_streams()
+{
+ local dev="$1"
+ local logical_cpus=$( grep -ci "^processor" /proc/cpuinfo )
+ [ $logical_cpus -gt 1 ] || return 1
+ local zram_comp_streams="$( uci -q get system.@system[0].zram_comp_streams )"
+ [ -n "$zram_comp_streams" ] && [ "$zram_comp_streams" -le "$logical_cpus" ] || zram_comp_streams=$logical_cpus
+ if [ -e /sys/block/$( basename $dev )/max_comp_streams ]; then
+ logger -s -t zram_comp_streams -p daemon.debug "Set max compression streams to '$zram_comp_streams' for zram '$dev'"
+ echo $zram_comp_streams > /sys/block/$( basename $dev )/max_comp_streams
+ fi
+}
+
start()
{
local zram_size="$( zram_size )"
@@ -110,6 +123,7 @@ start()
zram_reset "$zram_dev" "enforcing defaults"
zram_comp_algo "$zram_dev"
+ zram_comp_streams "$zram_dev"
echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename "$zram_dev" )/disksize"
mkswap "$zram_dev"
swapon "$zram_dev"