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

zram: support priority parameter in recompression

recompress device attribute supports alg=NAME parameter so that we can
specify only one particular algorithm we want to perform recompression
with. However, with algo params we now can have several exactly same
secondary algorithms but each with its own params tuning (e.g. priority 1
configured to use more aggressive level, and priority 2 configured to use
a pre-trained dictionary). Support priority=NUM parameter so that we can
correctly determine which secondary algorithm we want to use.

Link: https://lkml.kernel.org/r/20240902105656.1383858-25-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nick Terrell <terrelln@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Andrew Morton
e899007a 97ee4842

+16 -1
+4 -1
Documentation/admin-guide/blockdev/zram.rst
··· 512 512 algorithm that successfully compresses a particular page. Sometimes, however, 513 513 it is convenient (and sometimes even necessary) to limit recompression to 514 514 only one particular algorithm so that it will not try any other algorithms. 515 - This can be achieved by providing a algo=NAME parameter::: 515 + This can be achieved by providing a `algo` or `priority` parameter::: 516 516 517 517 #use zstd algorithm only (if registered) 518 518 echo "type=huge algo=zstd" > /sys/block/zramX/recompress 519 + 520 + #use zstd algorithm only (if zstd was registered under priority 1) 521 + echo "type=huge priority=1" > /sys/block/zramX/recompress 519 522 520 523 memory tracking 521 524 ===============
+12
drivers/block/zram/zram_drv.c
··· 1855 1855 algo = val; 1856 1856 continue; 1857 1857 } 1858 + 1859 + if (!strcmp(param, "priority")) { 1860 + ret = kstrtouint(val, 10, &prio); 1861 + if (ret) 1862 + return ret; 1863 + 1864 + if (prio == ZRAM_PRIMARY_COMP) 1865 + prio = ZRAM_SECONDARY_COMP; 1866 + 1867 + prio_max = min(prio + 1, ZRAM_MAX_COMPS); 1868 + continue; 1869 + } 1858 1870 } 1859 1871 1860 1872 if (threshold >= huge_class_size)