Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

zram: add recompress flag to read_block_state()

Add a new flag to zram block state that shows if the page was recompressed
(using alternative compression algorithm).

Link: https://lkml.kernel.org/r/20221109115047.2921851-6-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Alexey Romanov <avromanov@sberdevices.ru>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Suleiman Souhlal <suleiman@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Andrew Morton
60e9b39e 84b33bf7

+9 -5
+6 -3
Documentation/admin-guide/blockdev/zram.rst
··· 411 411 If you enable the feature, you could see block state via 412 412 /sys/kernel/debug/zram/zram0/block_state". The output is as follows:: 413 413 414 - 300 75.033841 .wh. 415 - 301 63.806904 s... 416 - 302 63.806919 ..hi 414 + 300 75.033841 .wh.. 415 + 301 63.806904 s.... 416 + 302 63.806919 ..hi. 417 + 303 62.801919 ....r 417 418 418 419 First column 419 420 zram's block index. ··· 431 430 huge page 432 431 i: 433 432 idle page 433 + r: 434 + recompressed page (secondary compression algorithm) 434 435 435 436 First line of above example says 300th block is accessed at 75.033841sec 436 437 and the block's state is huge so it is written back to the backing
+3 -2
drivers/block/zram/zram_drv.c
··· 936 936 937 937 ts = ktime_to_timespec64(zram->table[index].ac_time); 938 938 copied = snprintf(kbuf + written, count, 939 - "%12zd %12lld.%06lu %c%c%c%c\n", 939 + "%12zd %12lld.%06lu %c%c%c%c%c\n", 940 940 index, (s64)ts.tv_sec, 941 941 ts.tv_nsec / NSEC_PER_USEC, 942 942 zram_test_flag(zram, index, ZRAM_SAME) ? 's' : '.', 943 943 zram_test_flag(zram, index, ZRAM_WB) ? 'w' : '.', 944 944 zram_test_flag(zram, index, ZRAM_HUGE) ? 'h' : '.', 945 - zram_test_flag(zram, index, ZRAM_IDLE) ? 'i' : '.'); 945 + zram_test_flag(zram, index, ZRAM_IDLE) ? 'i' : '.', 946 + zram_get_priority(zram, index) ? 'r' : '.'); 946 947 947 948 if (count <= copied) { 948 949 zram_slot_unlock(zram, index);