diff options
Diffstat (limited to 'Documentation/vm/zswap.txt')
-rw-r--r-- | Documentation/vm/zswap.txt | 36 |
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. | |||
32 | An example command to enable zswap at runtime, assuming sysfs is mounted | 32 | An example command to enable zswap at runtime, assuming sysfs is mounted |
33 | at /sys, is: | 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 | When zswap is disabled at runtime it will stop storing pages that are | 37 | When zswap is disabled at runtime it will stop storing pages that are |
38 | being swapped out. However, it will _not_ immediately write out or fault | 38 | being 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 | |||
49 | evict pages from its own compressed pool on an LRU basis and write them back to | 49 | evict pages from its own compressed pool on an LRU basis and write them back to |
50 | the backing swap device in the case that the compressed pool is full. | 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 | 52 | Zswap makes use of zpool for the managing the compressed memory pool. Each |
53 | allocation in zbud is not directly accessible by address. Rather, a handle is | 53 | allocation in zpool is not directly accessible by address. Rather, a handle is |
54 | returned by the allocation routine and that handle must be mapped before being | 54 | returned by the allocation routine and that handle must be mapped before being |
55 | accessed. The compressed memory pool grows on demand and shrinks as compressed | 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 | When a swap page is passed from frontswap to zswap, zswap maintains a mapping | 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 | handle that references that compressed swap page. This mapping is achieved | 72 | handle that references that compressed swap page. This mapping is achieved |
61 | with a red-black tree per swap type. The swap offset is the search key for the | 73 | with a red-black tree per swap type. The swap offset is the search key for the |
62 | tree nodes. | 74 | tree 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 | ||
77 | Zswap allows the compressor to be selected at kernel boot time by setting the | 89 | The default compressor is lzo, but it can be selected at boot time by setting |
78 | “compressor” attribute. The default compressor is lzo. e.g. | 90 | the “compressor” attribute, e.g. zswap.compressor=lzo. It can also be changed |
79 | zswap.compressor=deflate | 91 | at runtime using the sysfs "compressor" attribute, e.g. |
92 | |||
93 | echo lzo > /sys/module/zswap/parameters/compressor | ||
94 | |||
95 | When the zpool and/or compressor parameter is changed at runtime, any existing | ||
96 | compressed pages are not modified; they are left in their own zpool. When a | ||
97 | request is made for a page in an old zpool, it is uncompressed using its | ||
98 | original compressor. Once all pages are removed from an old zpool, the zpool | ||
99 | and its compressor are freed. | ||
80 | 100 | ||
81 | A debugfs interface is provided for various statistic about pool size, number | 101 | A debugfs interface is provided for various statistic about pool size, number |
82 | of pages stored, and various counters for the reasons pages are rejected. | 102 | of pages stored, and various counters for the reasons pages are rejected. |