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

mm: zswap: remove same_filled module params

These knobs offer more fine-grained control to userspace than needed and
directly expose/influence kernel implementation; remove them.

For disabling same_filled handling, there is no logical reason to refuse
storing same-filled pages more efficiently and opt for compression.
Scanning pages for patterns may be an argument, but the page contents will
be read into the CPU cache anyway during compression. Also, removing the
same_filled handling code does not move the needle significantly in terms
of performance anyway [1].

For disabling non_same_filled handling, it was added when the compressed
pages in zswap were not being properly charged to memcgs, as workloads
could escape the accounting with compression [2]. This is no longer the
case after commit f4840ccfca25 ("zswap: memcg accounting"), and using
zswap without compression does not make much sense.

[1]https://lore.kernel.org/lkml/CAJD7tkaySFP2hBQw4pnZHJJwe3bMdjJ1t9VC2VJd=khn1_TXvA@mail.gmail.com/
[2]https://lore.kernel.org/lkml/19d5cdee-2868-41bd-83d5-6da75d72e940@maciej.szmigiero.name/

[yosryahmed@google.com: remove same_filled_pages from docs]
Link: https://lkml.kernel.org/r/ZhxFVggdyvCo79jc@google.com
Link: https://lkml.kernel.org/r/20240413022407.785696-5-yosryahmed@google.com
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Reviewed-by: Chengming Zhou <chengming.zhou@linux.dev>
Cc: "Maciej S. Szmigiero" <mail@maciej.szmigiero.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Yosry Ahmed and committed by
Andrew Morton
c074e146 e87b8814

-50
-29
Documentation/admin-guide/mm/zswap.rst
··· 111 111 compressed length of the page is set to zero and the pattern or same-filled 112 112 value is stored. 113 113 114 - Same-value filled pages identification feature is enabled by default and can be 115 - disabled at boot time by setting the ``same_filled_pages_enabled`` attribute 116 - to 0, e.g. ``zswap.same_filled_pages_enabled=0``. It can also be enabled and 117 - disabled at runtime using the sysfs ``same_filled_pages_enabled`` 118 - attribute, e.g.:: 119 - 120 - echo 1 > /sys/module/zswap/parameters/same_filled_pages_enabled 121 - 122 - When zswap same-filled page identification is disabled at runtime, it will stop 123 - checking for the same-value filled pages during store operation. 124 - In other words, every page will be then considered non-same-value filled. 125 - However, the existing pages which are marked as same-value filled pages remain 126 - stored unchanged in zswap until they are either loaded or invalidated. 127 - 128 - In some circumstances it might be advantageous to make use of just the zswap 129 - ability to efficiently store same-filled pages without enabling the whole 130 - compressed page storage. 131 - In this case the handling of non-same-value pages by zswap (enabled by default) 132 - can be disabled by setting the ``non_same_filled_pages_enabled`` attribute 133 - to 0, e.g. ``zswap.non_same_filled_pages_enabled=0``. 134 - It can also be enabled and disabled at runtime using the sysfs 135 - ``non_same_filled_pages_enabled`` attribute, e.g.:: 136 - 137 - echo 1 > /sys/module/zswap/parameters/non_same_filled_pages_enabled 138 - 139 - Disabling both ``zswap.same_filled_pages_enabled`` and 140 - ``zswap.non_same_filled_pages_enabled`` effectively disables accepting any new 141 - pages by zswap. 142 - 143 114 To prevent zswap from shrinking pool when zswap is full and there's a high 144 115 pressure on swap (this will result in flipping pages in and out zswap pool 145 116 without any real benefit but with a performance drop for the system), a
-2
Documentation/driver-api/crypto/iaa/iaa-crypto.rst
··· 457 457 # echo deflate-iaa > /sys/module/zswap/parameters/compressor 458 458 # echo zsmalloc > /sys/module/zswap/parameters/zpool 459 459 # echo 1 > /sys/module/zswap/parameters/enabled 460 - # echo 0 > /sys/module/zswap/parameters/same_filled_pages_enabled 461 460 # echo 100 > /proc/sys/vm/swappiness 462 461 # echo never > /sys/kernel/mm/transparent_hugepage/enabled 463 462 # echo 1 > /proc/sys/vm/overcommit_memory ··· 598 599 echo deflate-iaa > /sys/module/zswap/parameters/compressor 599 600 echo zsmalloc > /sys/module/zswap/parameters/zpool 600 601 echo 1 > /sys/module/zswap/parameters/enabled 601 - echo 0 > /sys/module/zswap/parameters/same_filled_pages_enabled 602 602 603 603 echo 100 > /proc/sys/vm/swappiness 604 604 echo never > /sys/kernel/mm/transparent_hugepage/enabled
-19
mm/zswap.c
··· 123 123 module_param_named(accept_threshold_percent, zswap_accept_thr_percent, 124 124 uint, 0644); 125 125 126 - /* 127 - * Enable/disable handling same-value filled pages (enabled by default). 128 - * If disabled every page is considered non-same-value filled. 129 - */ 130 - static bool zswap_same_filled_pages_enabled = true; 131 - module_param_named(same_filled_pages_enabled, zswap_same_filled_pages_enabled, 132 - bool, 0644); 133 - 134 - /* Enable/disable handling non-same-value filled pages (enabled by default) */ 135 - static bool zswap_non_same_filled_pages_enabled = true; 136 - module_param_named(non_same_filled_pages_enabled, zswap_non_same_filled_pages_enabled, 137 - bool, 0644); 138 - 139 126 /* Number of zpools in zswap_pool (empirically determined for scalability) */ 140 127 #define ZSWAP_NR_ZPOOLS 32 141 128 ··· 1380 1393 unsigned int pos, last_pos = PAGE_SIZE / sizeof(*page) - 1; 1381 1394 bool ret = false; 1382 1395 1383 - if (!zswap_same_filled_pages_enabled) 1384 - return false; 1385 - 1386 1396 page = kmap_local_folio(folio, 0); 1387 1397 val = page[0]; 1388 1398 ··· 1456 1472 atomic_inc(&zswap_same_filled_pages); 1457 1473 goto store_entry; 1458 1474 } 1459 - 1460 - if (!zswap_non_same_filled_pages_enabled) 1461 - goto freepage; 1462 1475 1463 1476 /* if entry is successfully added, it keeps the reference */ 1464 1477 entry->pool = zswap_pool_current_get();