You are not logged in.

#1 2016-02-08 16:34:43

kozaki
Member
From: London >. < Paris
Registered: 2005-06-13
Posts: 673
Website

[Solved] zswap creation

As my desktop has 4 GB of RAM and swap, I thought I'd test zswap for when under load. Now after some tries... Where has my zswap devices gone?

grep zswap /boot/grub/grub.cfg

    linux /vmlinuz-linux-ck root=UUID=38d050af-3ac5-4f3d-b931-ced48ec75e2d rw zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4 ipv6.disable=1 libahci.ignore_sss=1 pcie_aspm=force quiet elevator=bfq

% grep zswap /boot/grub/grub.cfg  /etc/fstab

# Swap
/dev/zram0                      none        swap    defaults,pri=100    0 0 
/dev/zram1                      none        swap    defaults,pri=100    0 0 
/data/swapfile1                     none            swap    defaults,pri=10         0 0
/media/medfiles/swapfile2       none            swap    defaults,pri=10         0 0

% dmesg |grep zswap  # I've read it should say 'Loading zswap' somewhere

dmesg |grep swap
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-linux-ck root=UUID=38d050af-3ac5-4f3d-b931-ced48ec75e2d rw zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4 ipv6.disable=1 libahci.ignore_sss=1 pcie_aspm=force quiet
[    0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-linux-ck root=UUID=38d050af-3ac5-4f3d-b931-ced48ec75e2d rw zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4 ipv6.disable=1 libahci.ignore_sss=1 pcie_aspm=force quiet
[    0.200918] zswap: loaded using pool lz4/zbud

% grep . /sys/module/zswap/parameters/*

/sys/module/zswap/parameters/compressor:lz4
/sys/module/zswap/parameters/enabled:Y
/sys/module/zswap/parameters/max_pool_percent:25
/sys/module/zswap/parameters/zpool:zbud

Should be in right?
Also there's nothing in our  wiki or in zswap documentation that say "Create" "mkzwap" or make a udev rule.

% swapon -s

Filename                                Type            Size    Used    Priority
/media/medfiles/swapfile2               file            2097148 0       10
/data/swapfile1                         file            2097148 0       10

% ls -l /dev/zram*

ls: cannot access /dev/zram*: No such file or directory

Whether it's the doc (e.g. devices creation) or just me, something's missing here!

Last edited by kozaki (2016-02-08 18:30:29)


Seeded last month: Arch 50 gig, derivatives 1 gig
Desktop @3.3GHz 8 gig RAM, linux-ck
laptop #1 Atom 2 gig RAM, Arch linux stock i686 (6H w/ 6yrs old battery smile) #2: ARM Tegra K1, 4 gig RAM, ChrOS
Atom Z520 2 gig RAM, OMV (Debian 7) kernel 3.16 bpo on SDHC | PGP Key: 0xFF0157D9

Offline

#2 2016-02-08 17:16:01

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: [Solved] zswap creation

You don't create zswap devices. Stuff to be swapped out goes through zswap and gets either compressed and held in RAM or put on the disk (if it doesn't compress well).

Run "grep -R . /sys/kernel/debug/zswap/" to see zswap stats.

Offline

#3 2016-02-08 17:24:14

kozaki
Member
From: London >. < Paris
Registered: 2005-06-13
Posts: 673
Website

Re: [Solved] zswap creation

OK, I will load some stuff and check /sys/kernel/debug/zswap/
I may have mixed the zram devices use by zswap with its zram usage (where swapon -s show them since there they are swap).

Thanks a lot lucke.

EDIT1:
I resized tmpfs to 3 GB, started a needed webkitfltk compil and launched a few RAM hungry apps. Then I saw the kernel zswap in action

% free -mt                                                                                                                        Mon Feb  8 19:15:38 2016

              total        used        free      shared  buff/cache   available
Mem:           3775        2212         693         564         870         933
Swap:          4095         118        3977
Total:         7871        2330        4671

% swapon -s

Filename                                Type            Size    Used    Priority
/media/medfiles/swapfile2               file            2097148 60488   10
/data/swapfile1                         file            2097148 60484   10

% grep -R . /sys/kernel/debug/zswap/

/sys/kernel/debug/zswap/stored_pages:23159
/sys/kernel/debug/zswap/pool_total_size:47443968
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:7084
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0

The 'pool_total_size' somehow follows the physical swap use, though I dunno yet what's the relationship between these two.

EDIT2

I certainly did not read enough before asking:
- zswap: See also
- Kernel & Hardware» ZSWAP is coming

So
% dmesg |grep swap

[    0.200918] zswap: loaded using pool lz4/zbud

entails to say zswap is on and ready to act when RAM is full? E.g. won't be there in case there was an issue preventing to swapon the physical swap (I bet the kernel checks physical swap is there before it loads zswap), yeap?

Last edited by kozaki (2016-02-08 18:48:05)


Seeded last month: Arch 50 gig, derivatives 1 gig
Desktop @3.3GHz 8 gig RAM, linux-ck
laptop #1 Atom 2 gig RAM, Arch linux stock i686 (6H w/ 6yrs old battery smile) #2: ARM Tegra K1, 4 gig RAM, ChrOS
Atom Z520 2 gig RAM, OMV (Debian 7) kernel 3.16 bpo on SDHC | PGP Key: 0xFF0157D9

Offline

#4 2016-02-08 19:25:07

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: [Solved] zswap creation

pool_total_size shows how much memory is used by compressed swap pages (in bytes, 45 MB in your case), it can take as much RAM as specified by max_pool_percent, stored_pages is how many swap pages are stored in RAM (one page is 4 kB on x86 and x86_64), as far as I understand the best compression ratio zswap can achieve is 2, as it pairs compressed pages in one regular page.

The message in dmesg shows that zswap is enabled - I don't really know what is shown if you have no physical swap.

Offline

#5 2016-02-08 20:01:53

kozaki
Member
From: London >. < Paris
Registered: 2005-06-13
Posts: 673
Website

Re: [Solved] zswap creation

Makes more sense now. Thank you.

And you can't really say from the log

févr. 08 20:31:47 llewellyn kernel: zswap: loaded using pool lz4/zbud
févr. 08 20:32:57 llewellyn systemd[1]: swap.target: Job swap.target/start failed with result 'dependency'.

Seems the kernel does not check for physical swap before loading zswap, nor log something useful somehow hmm

Last edited by kozaki (2016-02-08 20:02:17)


Seeded last month: Arch 50 gig, derivatives 1 gig
Desktop @3.3GHz 8 gig RAM, linux-ck
laptop #1 Atom 2 gig RAM, Arch linux stock i686 (6H w/ 6yrs old battery smile) #2: ARM Tegra K1, 4 gig RAM, ChrOS
Atom Z520 2 gig RAM, OMV (Debian 7) kernel 3.16 bpo on SDHC | PGP Key: 0xFF0157D9

Offline

#6 2017-01-21 07:59:10

Xelvet
Member
Registered: 2014-02-20
Posts: 84

Re: [Solved] zswap creation

systemd-swap.service: Main process exited, code=exited, status=255/n/a

Is this actually normal behaviour?

Offline

#7 2021-10-15 20:08:23

foobarrior
Member
Registered: 2012-03-11
Posts: 11

Re: [Solved] zswap creation

kozaki wrote:

Seems the kernel does not check for physical swap before loading zswap, nor log something useful somehow hmm

Thank you, kozaki!

I just had a similar issue. I didn't use any swap, which hiddenly resulted in zswap not working!

Enabling at least some swap makes zswap work.

Offline

Board footer

Powered by FluxBB