Bug 1185928

Summary: systemd-zram-service multicore handling is deprecated
Product: [openSUSE] openSUSE Distribution Reporter: Tiago Marques <bugs>
Component: OtherAssignee: Lubos Kocman <lubos.kocman>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Enhancement    
Priority: P5 - None CC: 95kreaninw95, ioannes
Version: Leap 42.3   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Tiago Marques 2021-05-11 15:39:07 UTC
Upon installing 'systemd-zram-service', I noticed it is generating two ZRAM block devices for swap.

Further look at '/sys/block/zram0/max_comp_streams', shows '2' per block device, which is correct for my system.
This is in line with the use of "per CPU compression streams":

https://github.com/torvalds/linux/commit/da9556a2367cf2261ab4d3e100693c82fb1ddb26

Currently the script is trying to do in parallel with ZRAM already having that baked in, even for the older LEAP kernel.
Per cpu number of streams is a significant performance improvement.

The simple fix is deleting the CPU count code and just setting 'num_cpus=1' on both scripts.
Comment 1 Chenzi Cao 2021-05-14 11:50:01 UTC
Hi Lubos, would you pelase take a look at this issue? I can not find a maintainer for package systemd-zram-service, thanks.
Comment 2 Archer Allstars 2022-08-30 23:23:00 UTC
I voted to make a change to this script, as creating zRAM devices based on the number of CPU cores can cause an issue too. See https://github.com/Nefelim4ag/systemd-swap/issues/176

It's a deprecated practice which can do more harm than good.

For anyone who want to fix this issue, you can do this by:

1. Open your file manager as an admin. Mine is: nautilus admin:///
2. Search for zramswapon file, edit the # get the number of CPUs to num_cpus=1.
3. Do the same for zramswapoff file.
4. Reboot your PC. Check zRAM with: sudo zramctl, now you should only have 1 zRAM device.
Comment 3 Archer Allstars 2022-09-02 01:52:12 UTC
I have created a request to change the systemd-zram-service package's zramswapon and zramswapoff scripts:

https://build.opensuse.org/request/show/1000767
Comment 4 Archer Allstars 2022-09-07 01:03:45 UTC
Factory SR 1000767 (https://build.opensuse.org/request/show/1000767) was accepted. The fix is delivered with Tumbleweed's snapshot 20220905.
Comment 5 Archer Allstars 2022-09-07 01:27:08 UTC
Sorry, my bad, I see the package is updated when I `sudo zypper dup`. It's updated at the filesystem's repo but hasn't yet made it to the factory. Nevertheless, it should be delivered on Tumbleweed's snapshot soon.