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