wok rev 21917

linux-zram: split swap according to cores count
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Oct 05 11:36:18 2019 +0200 (2019-10-05)
parents 0601356024df
children 423ad3757fef
files easy-rsa/receipt linux-zram/stuff/compcache linux64-zram/stuff/compcache
line diff
     1.1 --- a/easy-rsa/receipt	Sat Oct 05 10:18:31 2019 +0100
     1.2 +++ b/easy-rsa/receipt	Sat Oct 05 11:36:18 2019 +0200
     1.3 @@ -15,13 +15,13 @@
     1.4  # Rules to gen a SliTaz package suitable for Tazpkg.
     1.5  genpkg_rules()
     1.6  {
     1.7 -	mkdir -p $install/usr/share $fs/usr/share/ $fs/usr/bin
     1.8 +	mkdir -p $install/usr/share $fs/usr/share $fs/usr/bin
     1.9  	cp -a $src/doc $install/usr/share
    1.10  	cp -a $src/easyrsa${VERSION%%.*} $fs/usr/share/easy-rsa
    1.11  	cat > $fs/usr/bin/make-cadir <<EOT
    1.12  #!/bin/sh
    1.13  
    1.14 -[ -e "\${1:-.}" ] && echo "Usage: \$0 DIRECTORY" && exit 1
    1.15 +[ -e "\${1:-.}" ] && echo "Usage: \$0 DIRECTORY_TO_CREATE" && exit 1
    1.16  
    1.17  mkdir -m 700 -p "\$1"
    1.18  ln -s /usr/share/easy-rsa/easyrsa "\$1"
     2.1 --- a/linux-zram/stuff/compcache	Sat Oct 05 10:18:31 2019 +0100
     2.2 +++ b/linux-zram/stuff/compcache	Sat Oct 05 11:36:18 2019 +0200
     2.3 @@ -17,12 +17,18 @@
     2.4        exit 1
     2.5      fi
     2.6      action 'Loading module...'
     2.7 -    modprobe zram zram_num_devices=1 &&
     2.8 -    [ -n "$SIZE_KB" ] && echo $(($SIZE_KB * 1024)) > /sys/block/zram0/disksize
     2.9 +    devices=$(awk '/cpu cores/{c=$4} /processor/{p++}
    2.10 +	END { if (c>0) p=c; if (p==0) p++; print p }' /proc/cpuinfo)
    2.11 +    modprobe zram zram_num_devices=$devices &&
    2.12 +    [ -n "$SIZE_KB" ] && for i in $(seq 0 $(($devices-1))); do
    2.13 +	echo $(($SIZE_KB * 1024 / $devices)) > /sys/block/zram$i/disksize
    2.14 +    done
    2.15      status
    2.16  
    2.17      action 'Starting %s: %s...' "$DESC" $NAME
    2.18 -    mkswap /dev/zram0 && swapon /dev/zram0 -p 100
    2.19 +    for i in $(seq 0 $(($devices-1))); do
    2.20 +	mkswap /dev/zram$i && swapon /dev/zram$i -p 100
    2.21 +    done
    2.22      status
    2.23      ;;
    2.24    stop)
    2.25 @@ -31,7 +37,9 @@
    2.26        exit 1
    2.27      fi
    2.28      action 'Stopping %s: %s...' "$DESC" $NAME
    2.29 -    swapoff /dev/zram0 && echo 1 > /sys/block/zram0/reset
    2.30 +    for i in $(cd /sys/block/; ls -d zram*); do
    2.31 +	swapoff /dev/$i && echo 1 > /sys/block/$i/reset
    2.32 +    done
    2.33      status
    2.34      action 'Unloading module...'
    2.35      rmmod zram
     3.1 --- a/linux64-zram/stuff/compcache	Sat Oct 05 10:18:31 2019 +0100
     3.2 +++ b/linux64-zram/stuff/compcache	Sat Oct 05 11:36:18 2019 +0200
     3.3 @@ -17,12 +17,18 @@
     3.4        exit 1
     3.5      fi
     3.6      action 'Loading module...'
     3.7 -    modprobe zram zram_num_devices=1 &&
     3.8 -    [ -n "$SIZE_KB" ] && echo $(($SIZE_KB * 1024)) > /sys/block/zram0/disksize
     3.9 +    devices=$(awk '/cpu cores/{c=$4} /processor/{p++}
    3.10 +	END { if (c>0) p=c; if (p==0) p++; print p }' /proc/cpuinfo)
    3.11 +    modprobe zram zram_num_devices=$devices &&
    3.12 +    [ -n "$SIZE_KB" ] && for i in $(seq 0 $(($devices-1))); do
    3.13 +	echo $(($SIZE_KB * 1024 / $devices)) > /sys/block/zram$i/disksize
    3.14 +    done
    3.15      status
    3.16  
    3.17      action 'Starting %s: %s...' "$DESC" $NAME
    3.18 -    mkswap /dev/zram0 && swapon /dev/zram0 -p 100
    3.19 +    for i in $(seq 0 $(($devices-1))); do
    3.20 +	mkswap /dev/zram$i && swapon /dev/zram$i -p 100
    3.21 +    done
    3.22      status
    3.23      ;;
    3.24    stop)
    3.25 @@ -31,7 +37,9 @@
    3.26        exit 1
    3.27      fi
    3.28      action 'Stopping %s: %s...' "$DESC" $NAME
    3.29 -    swapoff /dev/zram0 && echo 1 > /sys/block/zram0/reset
    3.30 +    for i in $(cd /sys/block/; ls -d zram*); do
    3.31 +	swapoff /dev/$i && echo 1 > /sys/block/$i/reset
    3.32 +    done
    3.33      status
    3.34      action 'Unloading module...'
    3.35      rmmod zram