Repository navigation
zram: use a 4 KiB LZ4 hash table for independent pages - #503
Conversation
Build outputsCompared with the build of main at 2571baa; codex/lz4-compressor-110 is at d12e7d7, so outputs changed since then are listed too. 4 changed, 0 added, 0 removed of 570 outputs.
|
dormancygrace
left a comment
There was a problem hiding this comment.
Looks good.
- The 4 KiB table produces ordinary LZ4 block output.
- The small-table test passes, including round-trips for every length 0–4096, guard pages, bounded output and oversize rejection.
- Workspace alignment is enforced by the
static_assert. - Dictionary mode and larger pages keep the old path.
Two small notes:
dormancygrace
left a comment
There was a problem hiding this comment.
Review completed at e6825cb. Corrected a NULL dereference for NULL/misaligned small-table workspace and integrated the matching #501 API correction. The zram page-size/dictionary selection and bounded compression paths were independently checked. All 0..4096 lengths, guarded/unaligned buffers, bounded output, acceleration extremes and invalid workspaces pass normally and under ASan/UBSan; the complete LZ4 and zram patch stack applies to Linux 7.3 with exact context. Platform configuration/build tests pass. The runtime correction is substantive; this PR remains open.
There was a problem hiding this comment.
Final review at ccdfe3e: the small-table patch is now 0055-lz4-zram-small-table.patch after compressor patch 0054, with both test references updated. The patch blob is byte-for-byte identical to the previously reviewed fix. Current main and the renumbered #501 are integrated without changing the small-table runtime. Clean Linux 7.3 patch/Kconfig and guarded 0..4096-byte small-table tests pass normally and under ASan/UBSan. All 15 head checks pass, and the prepared main merge tree exactly matches the tested head. No unresolved findings.
Depends on #501. This PR contains only the small-table specialization and its zram integration.
Use a 4 KiB hash table for independent blocks up to 4096 bytes. On 4 KiB-page kernels, the zram backend uses a 4,128-byte workspace instead of 16,416 bytes when no dictionary is configured. On 4 KiB-page kernels, vmalloc backs these workspace requests with 8 KiB and 20 KiB respectively: 12 KiB less per no-dictionary context, excluding allocation metadata and virtual guard pages. This is workspace memory, not compressed zsmalloc savings. Generic callers, dictionary mode, and larger-page kernels retain the original table. The block format and decoder are unchanged.
The dedicated C906 object adds 1,940 bytes of text/readonly data; the generic compressor machine code is byte-identical to #501. On 1,413 synthetic and target-ELF pages, compressed bytes change from 2,901,428 to 2,909,962 (+0.294%); the largest per-page increase is 51 bytes. This corpus is not an observed swap distribution or a measurement of zsmalloc memory.
Validation:
Kernel microbenchmarks of the exact PR501 and PR503 implementations now pass on C906. The initial comparison favors the 4 KiB path, but an identical-code placement effect means its timing percentage remains preliminary. Real swap-pressure qualification and zsmalloc memory savings remain unmeasured. All 15 CI checks, including the full firmware build, pass.