From 17a3ee006a3ca6213049f7636e096d515eedc0b187c0fbf867d0bcf1b8ecf6bd Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 5 Sep 2022 11:01:40 +0000 Subject: [PATCH 1/2] Accepting request 1000767 from home:archerallstars 1. To disable multi-zRAM device creation (based on the number of CPU cores) in the original script, as it's deprecated, can cause some issues, and is unnecessary since kernel 4.7. See https://bugzilla.suse.com/show_bug.cgi?id=1185928 and https://github.com/Nefelim4ag/systemd-swap/issues/176 2. To change the zRAM compression algorithm from "lzo-rle" to "zstd", as it yields the highest compression ratio, hence the fastest to complete the task. Both compression ratio and speed are better than "lzo-rle". Therefore, changing the compression algorithm to "zstd" will benefit zRAM usage. See https://www.reddit.com/r/Fedora/comments/mzun99/new_zram_tuning_benchmarks/ OBS-URL: https://build.opensuse.org/request/show/1000767 OBS-URL: https://build.opensuse.org/package/show/filesystems/systemd-zram-service?expand=0&rev=6 --- zramswapoff | 12 +----------- zramswapon | 32 ++++++++------------------------ 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/zramswapoff b/zramswapoff index 552a27a..271222f 100644 --- a/zramswapoff +++ b/zramswapoff @@ -1,16 +1,6 @@ #!/bin/bash -# get the number of CPUs -num_cpus=$(grep -c processor /proc/cpuinfo) - -# set decremented number of CPUs -decr_num_cpus=$((num_cpus - 1)) - # Switching off swap -for i in $(seq 0 $decr_num_cpus); do -if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then -swapoff /dev/zram$i -fi -done +swapoff /dev/zram0 rmmod zram diff --git a/zramswapon b/zramswapon index 399a28d..09496b5 100644 --- a/zramswapon +++ b/zramswapon @@ -1,34 +1,18 @@ #!/bin/bash -# get the number of CPUs -num_cpus=$(grep -c processor /proc/cpuinfo) -# if something goes wrong, assume we have 1 -[ "$num_cpus" != 0 ] || num_cpus=1 - -# set decremented number of CPUs -decr_num_cpus=$((num_cpus - 1)) - # get the amount of memory in the machine mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+') mem_total=$((mem_total_kb * 1024)) -# load dependency modules -#modprobe zram zram_num_devices=$num_cpus -# Determine module parm -mod_parm=$(modinfo zram |grep parm |tr -s " " |cut -f2 -d ":") -modprobe zram $mod_parm=$num_cpus +# load the dependency module +modprobe zram -# initialize the devices -for i in $(seq 0 $decr_num_cpus); do -echo $((mem_total / num_cpus)) > /sys/block/zram$i/disksize -done +# initialize the device with zstd compression algorithm +echo zstd > /sys/block/zram0/comp_algorithm; +echo $mem_total > /sys/block/zram0/disksize -# Creating swap filesystems -for i in $(seq 0 $decr_num_cpus); do -mkswap /dev/zram$i -done +# Creating the swap filesystem +mkswap /dev/zram0 # Switch the swaps on -for i in $(seq 0 $decr_num_cpus); do -swapon -p 100 /dev/zram$i -done +swapon -p 100 /dev/zram0 From 0f9c2bf699d215e41f49a85a12617768da8765be58e184ef37d68985d79ac65c Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 7 Sep 2022 13:58:00 +0000 Subject: [PATCH 2/2] fill changes after SR 1000767 OBS-URL: https://build.opensuse.org/package/show/filesystems/systemd-zram-service?expand=0&rev=7 --- systemd-zram-service.changes | 6 ++++++ systemd-zram-service.spec | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/systemd-zram-service.changes b/systemd-zram-service.changes index 218552a..2d3eeb7 100644 --- a/systemd-zram-service.changes +++ b/systemd-zram-service.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Sep 7 00:00:00 CEST 2022 - dsterba@suse.cz + +- disable multi-zram devices (deprecated, not necessary since 4.7) +- change compression to zstd + ------------------------------------------------------------------- Mon Dec 13 16:18:04 UTC 2021 - Johannes Segitz diff --git a/systemd-zram-service.spec b/systemd-zram-service.spec index 6651853..42e088f 100644 --- a/systemd-zram-service.spec +++ b/systemd-zram-service.spec @@ -1,7 +1,7 @@ # # spec file for package systemd-zram-service # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # Copyright (c) 2012-2018 Malcolm J Lewis # # All modifications and additions to the file contributed by third parties