hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/Documentation/vm/zswap.rst
....@@ -35,9 +35,11 @@
3535 device when the compressed pool reaches its size limit. This requirement had
3636 been identified in prior community discussions.
3737
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.
4143 An example command to enable zswap at runtime, assuming sysfs is mounted
4244 at ``/sys``, is::
4345
....@@ -64,9 +66,10 @@
6466 returned by the allocation routine and that handle must be mapped before being
6567 accessed. The compressed memory pool grows on demand and shrinks as compressed
6668 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.::
7073
7174 echo zbud > /sys/module/zswap/parameters/zpool
7275
....@@ -97,8 +100,9 @@
97100 * max_pool_percent - The maximum percentage of memory that the compressed
98101 pool can occupy.
99102
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``.
102106 It can also be changed at runtime using the sysfs "compressor"
103107 attribute, e.g.::
104108
....@@ -130,6 +134,19 @@
130134 existing pages which are marked as same-value filled pages remain stored
131135 unchanged in zswap until they are either loaded or invalidated.
132136
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
+
133150 A debugfs interface is provided for various statistic about pool size, number
134151 of pages stored, same-value filled pages and various counters for the reasons
135152 pages are rejected.