.. | .. |
---|
35 | 35 | device when the compressed pool reaches its size limit. This requirement had |
---|
36 | 36 | been identified in prior community discussions. |
---|
37 | 37 | |
---|
38 | | -Zswap is disabled by default but can be enabled at boot time by setting |
---|
39 | | -the ``enabled`` attribute to 1 at boot time. ie: ``zswap.enabled=1``. Zswap |
---|
40 | | -can also be enabled and disabled at runtime using the sysfs interface. |
---|
| 38 | +Whether Zswap is enabled at the boot time depends on whether |
---|
| 39 | +the ``CONFIG_ZSWAP_DEFAULT_ON`` Kconfig option is enabled or not. |
---|
| 40 | +This setting can then be overridden by providing the kernel command line |
---|
| 41 | +``zswap.enabled=`` option, for example ``zswap.enabled=0``. |
---|
| 42 | +Zswap can also be enabled and disabled at runtime using the sysfs interface. |
---|
41 | 43 | An example command to enable zswap at runtime, assuming sysfs is mounted |
---|
42 | 44 | at ``/sys``, is:: |
---|
43 | 45 | |
---|
.. | .. |
---|
64 | 66 | returned by the allocation routine and that handle must be mapped before being |
---|
65 | 67 | accessed. The compressed memory pool grows on demand and shrinks as compressed |
---|
66 | 68 | pages are freed. The pool is not preallocated. By default, a zpool |
---|
67 | | -of type zbud is created, but it can be selected at boot time by |
---|
68 | | -setting the ``zpool`` attribute, e.g. ``zswap.zpool=zbud``. It can |
---|
69 | | -also be changed at runtime using the sysfs ``zpool`` attribute, e.g.:: |
---|
| 69 | +of type selected in ``CONFIG_ZSWAP_ZPOOL_DEFAULT`` Kconfig option is created, |
---|
| 70 | +but it can be overridden at boot time by setting the ``zpool`` attribute, |
---|
| 71 | +e.g. ``zswap.zpool=zbud``. It can also be changed at runtime using the sysfs |
---|
| 72 | +``zpool`` attribute, e.g.:: |
---|
70 | 73 | |
---|
71 | 74 | echo zbud > /sys/module/zswap/parameters/zpool |
---|
72 | 75 | |
---|
.. | .. |
---|
97 | 100 | * max_pool_percent - The maximum percentage of memory that the compressed |
---|
98 | 101 | pool can occupy. |
---|
99 | 102 | |
---|
100 | | -The default compressor is lzo, but it can be selected at boot time by |
---|
101 | | -setting the ``compressor`` attribute, e.g. ``zswap.compressor=lzo``. |
---|
| 103 | +The default compressor is selected in ``CONFIG_ZSWAP_COMPRESSOR_DEFAULT`` |
---|
| 104 | +Kconfig option, but it can be overridden at boot time by setting the |
---|
| 105 | +``compressor`` attribute, e.g. ``zswap.compressor=lzo``. |
---|
102 | 106 | It can also be changed at runtime using the sysfs "compressor" |
---|
103 | 107 | attribute, e.g.:: |
---|
104 | 108 | |
---|
.. | .. |
---|
130 | 134 | existing pages which are marked as same-value filled pages remain stored |
---|
131 | 135 | unchanged in zswap until they are either loaded or invalidated. |
---|
132 | 136 | |
---|
| 137 | +To prevent zswap from shrinking pool when zswap is full and there's a high |
---|
| 138 | +pressure on swap (this will result in flipping pages in and out zswap pool |
---|
| 139 | +without any real benefit but with a performance drop for the system), a |
---|
| 140 | +special parameter has been introduced to implement a sort of hysteresis to |
---|
| 141 | +refuse taking pages into zswap pool until it has sufficient space if the limit |
---|
| 142 | +has been hit. To set the threshold at which zswap would start accepting pages |
---|
| 143 | +again after it became full, use the sysfs ``accept_threshold_percent`` |
---|
| 144 | +attribute, e. g.:: |
---|
| 145 | + |
---|
| 146 | + echo 80 > /sys/module/zswap/parameters/accept_threshold_percent |
---|
| 147 | + |
---|
| 148 | +Setting this parameter to 100 will disable the hysteresis. |
---|
| 149 | + |
---|
133 | 150 | A debugfs interface is provided for various statistic about pool size, number |
---|
134 | 151 | of pages stored, same-value filled pages and various counters for the reasons |
---|
135 | 152 | pages are rejected. |
---|