LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-29-2024, 02:11 PM   #1
garpu
Senior Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 1,617

Rep: Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935
using zram


So as not to drift the topic too much in the changelog thread...

So does one just not use regular swap with zram?

(Feel free to discuss other issues one might be having. I thought it would be good to have a discussion, in case there were grievances.)
 
Old 05-29-2024, 02:38 PM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,079

Rep: Reputation: Disabled
Quote:
Originally Posted by garpu View Post
So does one just not use regular swap with zram?
Nothing precludes to set up a swap partition and/or a swap file in addition to a swap space in zram. You'll just have to set the respective priorities of all your swap files and swap block devices to define in which order they will be used. You can use many swap block devices (swap partitions and swap spaces in zram) and swap files, see man swapon and to know even more man 2 swapon.

Last edited by Didier Spaier; 05-29-2024 at 02:48 PM.
 
2 members found this post helpful.
Old 05-29-2024, 09:59 PM   #3
garpu
Senior Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 1,617

Original Poster
Rep: Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935
Cool, thanks.

An observation: is it used more readily than conventional swap, and is it supposed to stick around more? I'm not seeing it go down... (That is, leave it alone to do its thing and quit poking at it?)

ETA from the current changelog thread:

Quote:
Originally Posted by Aeterna View Post
also, to really use ZSWAP modify sysctl.conf (adjust as needed):
vm.swappiness = 180
vm.watermark_boost_factor = 0
vm.watermark_scale_factor = 125
vm.vfs_cache_pressure = 75
vm.page-cluster = 0
I've got vm.swappiness set to 10. 180 means it's swapping all the time?

Last edited by garpu; 05-29-2024 at 10:07 PM.
 
Old 05-30-2024, 12:13 AM   #4
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
This was in the Latest Changelog thread, talk about ZSWAP:
Quote:
Originally Posted by Aeterna View Post
if you have a lot of RAM then default 20% is waste.
append zswap.max_pool_percent=xx to kernel.
to set amount of RAM used

modify rc.zram entry
SIZE=XX
to define zswap size

also, to really use ZSWAP modify sysctl.conf (adjust as needed):
vm.swappiness = 180
vm.watermark_boost_factor = 0
vm.watermark_scale_factor = 125
vm.vfs_cache_pressure = 75
vm.page-cluster = 0
ZSWAP is different from using ZRAM as swap. A couple of days ago Slackware current started setting up ZRAM as swap. ZSWAP is an alternative, and it is also available in the -current kernel.
 
Old 05-30-2024, 01:14 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,109

Rep: Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367
the only question if you really need it?
 
Old 05-30-2024, 01:24 AM   #6
PurpleSquirrel
LQ Newbie
 
Registered: Aug 2021
Location: Here
Distribution: Slackware 2.3 to post-15.0 current
Posts: 29

Rep: Reputation: 19
If you're using hibernation then you do need swap. Swap is where the hibernation image goes. I have mine sized to my RAM size plus my VRAM size plus enough extra to get to the next integer gigabyte (64GiB for future expansion, 8 GiB for the federated VRAM, 512 MiB for the integrated video RAM (which may be swiped from the RAM) and 512 MiB more to get to the next integer gigabyte, totaling 73 GiB.)

It's been years since I set up a computer without swap. Those machines were never happy. It didn't take much at all to get the computer running right, but it did take some amount of swap.

Last edited by PurpleSquirrel; 05-30-2024 at 01:29 AM.
 
1 members found this post helpful.
Old 05-30-2024, 01:44 AM   #7
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,994

Rep: Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565
I am letting this ride for now. I have yet to really test it out. So far I think I like this. I have not made any configuration changes.

Code:
# swapon --show 
NAME       TYPE      SIZE USED PRIO
/dev/sda2  partition 8.1G   0B   -2
/dev/zram0 partition 7.8G 1.2G  100
# free -h
               total        used        free      shared  buff/cache   available
Mem:           7.8Gi       2.5Gi       902Mi        16Mi       4.6Gi       5.2Gi
Swap:           15Gi       1.2Gi        14Gi
GKrellM is reporting: 16262M - 1271M - 7% (total MiB - used MiB - used %)

parted -l reports:
Code:
[Disk /dev/zram0: 8327MB
Sector size (logical/physical): 4096B/4096B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system     Flags
 1      0.00B  8327MB  8327MB  linux-swap(v1)
 
Old 05-30-2024, 01:44 AM   #8
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
Quote:
Originally Posted by PurpleSquirrel View Post
If you're using hibernation then you do need swap. Swap is where the hibernation image goes. I have mine sized to my RAM size plus my VRAM size plus enough extra to get to the next integer gigabyte (64GiB for future expansion, 8 GiB for the federated VRAM, 512 MiB for the integrated video RAM (which may be swiped from the RAM) and 512 MiB more to get to the next integer gigabyte, totaling 73 GiB.)
That's a lot. Have you noticed that the hibernation image is now compressed?

This is from the kernel docs, Documentation/power/interface.txt:
Code:
/sys/power/image_size controls the size of hibernation images.

It can be written a string representing a non-negative integer that will be
used as a best-effort upper limit of the image size, in bytes.  The hibernation
core will do its best to ensure that the image size will not exceed that number.
However, if that turns out to be impossible to achieve, a hibernation image will
still be created and its size will be as small as possible.  In particular,
writing '0' to this file will enforce hibernation images to be as small as
possible.

Reading from this file returns the current image size limit, which is set to
around 2/5 of available RAM by default.
I did not change its value but read the default value by 'cat /sys/power/image_size' and created a swapfile of that size, and hibernation has succeeded with that.
 
Old 05-30-2024, 04:32 AM   #9
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
Quote:
Originally Posted by chrisretusn View Post
Code:
# swapon
# free -h
Another command: 'zramctl' or 'zramctl --output-all'.
 
1 members found this post helpful.
Old 05-30-2024, 09:18 AM   #10
Aeterna
Senior Member
 
Registered: Aug 2017
Location: Terra Mater
Distribution: VM Host: Slackware-current, VM Guests: Artix, Venom, antiX, Gentoo, FreeBSD, OpenBSD, OpenIndiana
Posts: 1,022

Rep: Reputation: Disabled
Quote:
Originally Posted by Petri Kaukasoina View Post
This was in the Latest Changelog thread, talk about ZSWAP:

ZSWAP is different from using ZRAM as swap. A couple of days ago Slackware current started setting up ZRAM as swap. ZSWAP is an alternative, and it is also available in the -current kernel.
I hope that it is clear that efficient use of ZRAM requires disabling swap.

Was this mentioned anywhere?

Otherwise zram will not work/will not be used even if it is enabled. So whatever Slackware did it did not enable ZRAM. Just loading module is not enough.

So if one has swap partition/swap file enabled then either disable it to use zram, or configure zswap.
zramctl does not show if the thing will be efficiently used.

Last edited by Aeterna; 05-30-2024 at 09:21 AM.
 
Old 05-30-2024, 09:23 AM   #11
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
Quote:
Originally Posted by Aeterna View Post
I hope that it is clear that efficient use of ZRAM requires disabling swap.
The priority of the swap in ZRAM is set as 100 while the ordinary swap has a negative priority. That means in practice that only ZRAM is used.
 
2 members found this post helpful.
Old 05-30-2024, 10:25 AM   #12
Pixxt
Member
 
Registered: May 2008
Distribution: Slackware, Debian,
Posts: 290

Rep: Reputation: 186Reputation: 186
Quote:
Originally Posted by Petri Kaukasoina View Post
The priority of the swap in ZRAM is set as 100 while the ordinary swap has a negative priority. That means in practice that only ZRAM is used.
Only in practice! I've used Zram is as swap replacement some years ago on netbooks and ram limited laptops. IMHO ZSWAP is better on desktops, and laptops not limited by storage. Zram works better where you have limited backing store for swap, i.e. phones, nucs, raspberry pi's and slow netbooks.
 
Old 05-30-2024, 11:19 AM   #13
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,079

Rep: Reputation: Disabled
Quote:
Originally Posted by Aeterna View Post
I hope that it is clear that efficient use of ZRAM requires disabling swap.

Was this mentioned anywhere?

Otherwise zram will not work/will not be used even if it is enabled.
No. The swap space with the highest priority gets used first, if exhausted the next by priority order gets used, regardless of its kind (zram, swap file, swap partition).
 
1 members found this post helpful.
Old 05-30-2024, 11:48 AM   #14
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,109

Rep: Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367Reputation: 7367
ok, so once more.
If you are low on RAM you can use zram, probably better/faster than a swapfile. If you have enough storage to create a swap file/partition.
But what about zswap? If you are low on RAM and low on storage too you can only get low on CPU too with zswap, nothing else.
using ram as swap is also more or less pointless. (especially if you are low on ram).
 
1 members found this post helpful.
Old 05-30-2024, 05:08 PM   #15
pghvlaans
Member
 
Registered: Jan 2021
Distribution: Slackware64 {15.0,-current}, FreeBSD, stuff on QEMU
Posts: 462

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
But going by what the /etc/default file says (1:4 compression), using a zram device equal in uncompressed size to total RAM means that 175% of capacity can be stored in used memory plus swap on the sticks themselves, which can easily be twice as fast as even an NVMe drive. For what it's worth, the compression level looked like it was somewhere between 1:4 and 1:5 when I tried it out yesterday.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: ZRAM Finally Promoted Out Of Staging In Linux Kernel LXer Syndicated Linux News 0 12-19-2013 06:50 AM
LXer: zRAM Is Still Hoping For A Promotion LXer Syndicated Linux News 0 11-26-2013 02:41 AM
LXer: ZRAM Might Finally Be Moved Out Of Linux Staging LXer Syndicated Linux News 0 08-15-2013 08:10 AM
LXer: Ubuntu Linux Considers Greater Usage Of zRAM LXer Syndicated Linux News 0 12-08-2012 03:30 PM
LXer: Increased Performance In Linux With zRam (Virtual Swap Compressed in RAM) LXer Syndicated Linux News 8 10-04-2011 12:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration