zram-generator: Unable to start swap-create@ service with zstd compressor
Could you create a new release? There is a commit in the master branch that fixed the zram creation with the zstd compressor. In version 0.2.0 you cannot create zram with zstd, the error is as follows:
Jan 10 13:34:34 laptop.local zram-generator[64345]: Error: Failed to configure disk size into /sys/block/zram0/disksize
Jan 10 13:34:34 laptop.local zram-generator[64345]: Caused by:
Jan 10 13:34:34 laptop.local zram-generator[64345]: Cannot allocate memory (os error 12)
Additional info: System: Fedora 33 (KDE) SystemD version: 246.7-2.fc33 zram-generator version: 0.2.0-4.fc33
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (17 by maintainers)
Commits related to this issue
- generator: call modprobe for compression modules Apparently the kernel sometimes doesn't load the appropriate compression algorithm (see #50, #53). Let's do an explicit modprobe call, similarly to wh... — committed to keszybz/zram-generator by keszybz 3 years ago
- generator: call modprobe for compression modules Apparently the kernel sometimes doesn't load the appropriate compression algorithm (see #50, #53). Let's do an explicit modprobe call, similarly to wh... — committed to keszybz/zram-generator by keszybz 3 years ago
- fix: manually load kernel modules for compression Creation of a zram device (with zstd as the compression alg) occasionally fails with ENOMEM: Jan 13 09:59:39 vultr.guest systemd[1]: Starting Create ... — committed to polarathene/zram-generator by polarathene 3 years ago
- fix: manually load kernel modules for compression Creation of a zram device (with zstd as the compression alg) occasionally fails with ENOMEM: Jan 13 09:59:39 vultr.guest systemd[1]: Starting Create ... — committed to polarathene/zram-generator by polarathene 3 years ago
Thank you for the extensive investigation. You are right, my code was checking the wrong thing.
This doesn’t mean that there is no kernel bug — the kernel does load the crypt module when necessary, so none of this should be necessary. But if it helps, then that’s good. Let’s continue the discussion in the pull request.
It doesn’t really matter if it’s Fedora or Ubuntu: everybody is using the same upstream kernel. Please sign up under https://bugzilla.kernel.org/show_bug.cgi?id=211173 if you can, this will help the bug get resolved. I’ll close this here, since it doesn’t seem to be a problem with the generator itself.
OK, so the issue is not because
zstdis not loaded, but because kzalloc fails. The error message is fromwhich calls
If the compression wasn’t available, EINVAL would be returned. We get ENOMEM either from
kzalloc()or fromzcomp_init(). Can you report a kernel bugzilla with your kernel version and other details?I raised selinux, but actually I don’t think it can be related, since there’s no explicit modprobe involved. (And even if an explicit modprobe is done, the generator is running in
init_tcontext, so it should have privs to do modprobe.)I think a race condition, i.e. a kernel bug, is the most likely explanation. The PR would resolve the issue in that case.
At the moment when
echo zstd >/sys/block/zram0/comp_algorithmreturns, I expectzstdmodule to be loaded by the kernel. This is what happens on my machines, but it clearly doesn’t always work this way.Thanks for the reply!
modprobe -r zram && modprobe zramdidn’t work for me, butmodprobe zstddid! Maybe we should detect this error, and show a possible solution instead of displayingCannot allocate memory?I assume you checked the closed issue on zstd with same error message, but if not, you might want to look at this.