| From: Sergey Senozhatsky <senozhatsky@chromium.org> |
| Subject: Re: documentation: Add recompression documentation |
| Date: Tue, 18 Oct 2022 11:50:21 +0900 |
| |
| Document user-space visible device attributes that |
| are enabled by ZRAM_MULTI_COMP. |
| |
| Link: https://lkml.kernel.org/r/Y04UbTZh3fJYPhvJ@google.com |
| Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| --- |
| |
| Documentation/admin-guide/blockdev/zram.rst | 55 ++++++++++++++++++ |
| 1 file changed, 55 insertions(+) |
| |
| --- a/Documentation/admin-guide/blockdev/zram.rst~documentation-add-recompression-documentation-fix |
| +++ a/Documentation/admin-guide/blockdev/zram.rst |
| @@ -456,6 +456,61 @@ size::: |
| Recompression is mostly focused on idle pages (except for huge pages |
| recompression), so it works better in conjunction with memory tracking. |
| |
| +recompression |
| +------------- |
| + |
| +With CONFIG_ZRAM_MULTI_COMP, zram can recompress idle/huge pages using |
| +alternative (secondary) compression algorithm. The basic idea is that |
| +alternative compression algorithm can provide better compression ratio |
| +at a price of (potentially) slower compression/decompression speeds. |
| +Alternative compression algorithm can, for example, be more successful |
| +compressing huge pages (those that default algorithm failed to compress). |
| +Another application is idle pages recompression - pages that are cold and |
| +sit in the memory can be recompressed using more effective algorithm and, |
| +hence, reduce zsmalloc memory usage. |
| + |
| +With CONFIG_ZRAM_MULTI_COMP, zram will setup two compression algorithms |
| +per-CPU: primary and secondary ones. Primary zram compressor is explained |
| +in "3) Select compression algorithm", the secondary algorithm is configured |
| +in a similar way, using recomp_algorithm device attribute: |
| + |
| +Examples:: |
| + |
| + #show supported recompression algorithms |
| + cat /sys/block/zramX/recomp_algorithm |
| + zstd [lzo] |
| + |
| + #select zstd recompression algorithm |
| + echo zstd > /sys/block/zramX/recomp_algorithm |
| + |
| +Another device attribute that CONFIG_ZRAM_MULTI_COMP enables is recompress, |
| +which controls recompression: |
| + |
| +Examples:: |
| + |
| + #IDLE pages recompression is activated by `idle` mode |
| + echo idle > /sys/block/zramX/recompress |
| + |
| + #HUGE pages recompression is activated by `huge` mode |
| + echo huge > /sys/block/zram0/recompress |
| + |
| + #HUGE_IDLE pages recompression is activated by `huge_idle` mode |
| + echo huge_idle > /sys/block/zramX/recompress |
| + |
| +The number of idle pages can be significant, so user-space can pass a size |
| +watermark (in bytes) value to the recompress knob, to filter out idle pages |
| +for recompression: zram will recompress only idle pages of equal or greater |
| +size (bytes)::: |
| + |
| + #recompress idle pages larger than 3000 bytes |
| + echo 3000 > /sys/block/zramX/recompress |
| + |
| + #recompress idle pages larger than 2000 bytes |
| + echo 2000 > /sys/block/zramX/recompress |
| + |
| +Recompression is mostly focused on idle pages (except for huge pages |
| +recompression), so it works better in conjunction with memory tracking. |
| + |
| memory tracking |
| =============== |
| |
| _ |