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

zswap: update docs for runtime-changeable attributes

Change the Documentation/vm/zswap.txt doc to indicate that the "zpool" and
"compressor" params are now changeable at runtime.

Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Cc: Seth Jennings <sjennings@variantweb.net>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dan Streetman and committed by
Linus Torvalds
9c4c5ef3 90b0fc26

+28 -8
+28 -8
Documentation/vm/zswap.txt
··· 32 32 An example command to enable zswap at runtime, assuming sysfs is mounted 33 33 at /sys, is: 34 34 35 - echo 1 > /sys/modules/zswap/parameters/enabled 35 + echo 1 > /sys/module/zswap/parameters/enabled 36 36 37 37 When zswap is disabled at runtime it will stop storing pages that are 38 38 being swapped out. However, it will _not_ immediately write out or fault ··· 49 49 evict pages from its own compressed pool on an LRU basis and write them back to 50 50 the backing swap device in the case that the compressed pool is full. 51 51 52 - Zswap makes use of zbud for the managing the compressed memory pool. Each 53 - allocation in zbud is not directly accessible by address. Rather, a handle is 52 + Zswap makes use of zpool for the managing the compressed memory pool. Each 53 + allocation in zpool is not directly accessible by address. Rather, a handle is 54 54 returned by the allocation routine and that handle must be mapped before being 55 55 accessed. The compressed memory pool grows on demand and shrinks as compressed 56 - pages are freed. The pool is not preallocated. 56 + pages are freed. The pool is not preallocated. By default, a zpool of type 57 + zbud is created, but it can be selected at boot time by setting the "zpool" 58 + attribute, e.g. zswap.zpool=zbud. It can also be changed at runtime using the 59 + sysfs "zpool" attribute, e.g. 60 + 61 + echo zbud > /sys/module/zswap/parameters/zpool 62 + 63 + The zbud type zpool allocates exactly 1 page to store 2 compressed pages, which 64 + means the compression ratio will always be 2:1 or worse (because of half-full 65 + zbud pages). The zsmalloc type zpool has a more complex compressed page 66 + storage method, and it can achieve greater storage densities. However, 67 + zsmalloc does not implement compressed page eviction, so once zswap fills it 68 + cannot evict the oldest page, it can only reject new pages. 57 69 58 70 When a swap page is passed from frontswap to zswap, zswap maintains a mapping 59 - of the swap entry, a combination of the swap type and swap offset, to the zbud 71 + of the swap entry, a combination of the swap type and swap offset, to the zpool 60 72 handle that references that compressed swap page. This mapping is achieved 61 73 with a red-black tree per swap type. The swap offset is the search key for the 62 74 tree nodes. ··· 86 74 * max_pool_percent - The maximum percentage of memory that the compressed 87 75 pool can occupy. 88 76 89 - Zswap allows the compressor to be selected at kernel boot time by setting the 90 - “compressor” attribute. The default compressor is lzo. e.g. 91 - zswap.compressor=deflate 77 + The default compressor is lzo, but it can be selected at boot time by setting 78 + the “compressor” attribute, e.g. zswap.compressor=lzo. It can also be changed 79 + at runtime using the sysfs "compressor" attribute, e.g. 80 + 81 + echo lzo > /sys/module/zswap/parameters/compressor 82 + 83 + When the zpool and/or compressor parameter is changed at runtime, any existing 84 + compressed pages are not modified; they are left in their own zpool. When a 85 + request is made for a page in an old zpool, it is uncompressed using its 86 + original compressor. Once all pages are removed from an old zpool, the zpool 87 + and its compressor are freed. 92 88 93 89 A debugfs interface is provided for various statistic about pool size, number 94 90 of pages stored, and various counters for the reasons pages are rejected.