• Sergey Senozhatsky's avatar
    zram: preparation for multi-zcomp support · 7ac07a26
    Sergey Senozhatsky authored
    Patch series "zram: Support multiple compression streams", v5.
    
    This series adds support for multiple compression streams.  The main idea
    is that different compression algorithms have different characteristics
    and zram may benefit when it uses a combination of algorithms: a default
    algorithm that is faster but have lower compression rate and a secondary
    algorithm that can use higher compression rate at a price of slower
    compression/decompression.
    
    There are several use-case for this functionality:
    
    - huge pages re-compression: zstd or deflate can successfully compress
      huge pages (~50% of huge pages on my synthetic ChromeOS tests), IOW
      pages that lzo was not able to compress.
    
    - idle pages re-compression: idle/cold pages sit in the memory and we
      may reduce zsmalloc memory usage if we recompress those idle pages.
    
    Userspace has a number of ways to control the behavior and impact of zram
    recompression: what type of pages should be recompressed, size watermarks,
    etc.  Please refer to documentation patch.
    
    
    This patch (of 13):
    			
    The patch turns compression streams and compressor algorithm name struct
    zram members into arrays, so that we can have multiple compression streams
    support (in the next patches).
    
    The patch uses a rather explicit API for compressor selection:
    
    - Get primary (default) compression stream
    	zcomp_stream_get(zram->comps[ZRAM_PRIMARY_COMP])
    - Get secondary compression stream
    	zcomp_stream_get(zram->comps[ZRAM_SECONDARY_COMP])
    
    We use similar API for compression streams put().
    
    At this point we always have just one compression stream,
    since CONFIG_ZRAM_MULTI_COMP is not yet defined.
    
    Link: https://lkml.kernel.org/r/20221109115047.2921851-1-senozhatsky@chromium.org
    Link: https://lkml.kernel.org/r/20221109115047.2921851-2-senozhatsky@chromium.orgSigned-off-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
    Acked-by: default avatarMinchan Kim <minchan@kernel.org>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: Nitin Gupta <ngupta@vflare.org>
    Cc: Suleiman Souhlal <suleiman@google.com>
    Cc: Nhat Pham <nphamcs@gmail.com>
    Cc: Alexey Romanov <avromanov@sberdevices.ru>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    7ac07a26
zcomp.h 1.17 KB