[BUG] zram-generator 1.2.1: unit-suffixed zram-size (e.g. 15G) yields disksize 2^20x too large - zram setup always fails with ENOMEM

Open
#1,081 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
linux, shell

Research direction

The report traces the failure to process_size() in the upstream zram-generator's src/config.rs and names the pinned tests test_eval_size_expression_32g and test_eval_size_expression_500k. Read that function and those tests first, then check how the CachyOS packaging obtains the generator; done means unit-suffixed sizes produce the intended disk size and the regression tests cover both examples.

Written by the indexing model from the issue text.

Description

Packages: zram-generator 1.2.1-1.1, systemd 262-1, linux-cachyos 7.2.9-2 (same on 7.2.9-1)

/etc/systemd/zram-generator.conf:

[zram0]
compression-algorithm = zstd
zram-size = 15G
swap-priority = 100
fs-type = swap

Every setup attempt fails (repro: systemctl restart [email protected]):

zram-generator[1587]: Error: Failed to configure disk size into /sys/block/zram0/disksize
zram-generator[1587]: Caused by:
zram-generator[1587]:     Cannot allocate memory (os error 12)
kernel: zram-generator: vmalloc error: size 61440000000000, exceeds total pages, mode:0xdc0(GFP_KERNEL|__GFP_ZERO)
kernel:  vzalloc_noprof+0x5f/0x70
kernel:  disksize_store+0x6b/0x370 [zram]
kernel:  kernfs_fop_write_iter+0xe4/0x190
kernel:  __x64_sys_write+0x24a/0x450

The generator hands the kernel a disksize of 15,728,640,000,000,000 bytes (15.7 PB) for zram-size = 15G. process_size() (src/config.rs) multiplies the evaluated expression result by 1024*1024 unconditionally, while unit suffixes inside the expression are decimal — the v1.2.1 tests pin these semantics:

// test_eval_size_expression_32g
dev_with_zram_size_size(Some("32G"), 5000) == 32 * 1000_000_000 * 1024 * 1024
// test_eval_size_expression_500k
dev_with_zram_size_size(Some("500k"), 5000) == 500 * 1000 * 1024 * 1024

So any unit-suffixed zram-size ends up 2^20x larger than intended. The kernel's metadata table for that disksize is (disksize >> 12) * 16 = 61,440,000,000,000 bytes — exactly the vzalloc size in the log — which exceeds total memory, so disksize_store fails with -ENOMEM. Kernel side is fine; the requested value is absurd.

Bare MB expressions are unaffected (zram-size = ram, the cachyos-settings default), which is why only configs with a unit suffix break.

First occurrence in the retained journal: 2026-10-12 00:00:02 on 7.2.9-1; identical on 7.2.9-2. zram-generator, systemd and the config file predate both kernels (2026-05-04 / 2026-09-28 / 2026-07-16), so this is not a kernel regression. Side note: the zram module was not auto-loaded at boot on the 2026-10-10 boot (no modules-load.d entry, no zram: Added device until 2026-10-12 00:00:02), so the unit does not always fire at all.

Workaround: express the size as a bare MB value — zram-size = 15360 for 15 GiB.

Upstream: systemd/zram-generator, v1.2.1, src/config.rs (test_eval_size_expression_32g, test_eval_size_expression_500k).

Dominant language
Shell
Stars
4.9k
Forks
190
Avg merge
1d 3h
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CachyOS/linux-cachyos

All issues in CachyOS/linux-cachyos

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.