zram-swap: support swap priority
authorMaxim Storchak <m.storchak@gmail.com>
Thu, 9 Jan 2020 18:27:44 +0000 (20:27 +0200)
committerJohn Crispin <john@phrozen.org>
Wed, 15 Jan 2020 19:49:00 +0000 (20:49 +0100)
If zram-backed swap is added after an existing swap, it gets a lower
priority. Assiming that usually all other swaps are slower, there should
be a way to assign a higher priority to zram swap.

Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
package/system/zram-swap/Makefile
package/system/zram-swap/files/zram.init

index bcada98a813f01430ec94a00365495b00ccf397a..ee5e85927f9cb5bf79dc83bddcfb7929b0cf8515 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=zram-swap
 PKG_VERSION:=1.1
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
index ae432f3b0031fa4071e723a3dc77ca0ffcfc0ab6..49140ad40658620c9fc6d757dacf3f21021151a0 100755 (executable)
@@ -172,6 +172,8 @@ start()
        local zram_size="$( zram_getsize )"
        local zram_dev="$( zram_getdev )"
        zram_applicable "$zram_dev" || return 1
+       local zram_priority="$( uci -q get system.@system[0].zram_priority )"
+       zram_priority=${zram_priority:+-p $zram_priority}
 
        logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)"
 
@@ -180,7 +182,7 @@ start()
        zram_comp_streams "$zram_dev"
        echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename "$zram_dev" )/disksize"
        mkswap "$zram_dev"
-       swapon "$zram_dev"
+       swapon $zram_priority "$zram_dev"
 }
 
 stop()