[PATCH] mm/zswap: add crypto engine failures debugfs counter

From: SeongJae Park
Date: Wed Aug 13 2025 - 14:13:24 EST


compress_fail counts failures of general attempts to compress a given
apge into a size smaller than PAGE_SIZE. It could be happened because
the content of the page is not easy to be compressed, or the crypto
engine error-ed for any reason. Adda new debugfs file, namely
compress_engine_fail, for coutning the latter case. Keep the
comress_fail count, since the failures due to the compression ratio
failure can be calculated by subtracting the new counter
(compress_engine_fail) value from that of the existing one
(compress_fail).

Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
mm/zswap.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/mm/zswap.c b/mm/zswap.c
index 0fb940d03268..6b2144126fba 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -62,6 +62,8 @@ static u64 zswap_reject_reclaim_fail;
static u64 zswap_reject_compress_fail;
/* Compression into a size of <PAGE_SIZE failed */
static u64 zswap_compress_fail;
+/* Compression failed by the crypto engine */
+static u64 zswap_compress_engine_fail;
/* Compressed page was too big for the allocator to (optimally) store */
static u64 zswap_reject_compress_poor;
/* Load or writeback failed due to decompression failure */
@@ -988,6 +990,8 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,
*/
if (comp_ret || dlen >= PAGE_SIZE) {
zswap_compress_fail++;
+ if (comp_ret)
+ zswap_compress_engine_fail++;
if (mem_cgroup_zswap_writeback_enabled(
folio_memcg(page_folio(page)))) {
comp_ret = 0;
@@ -1841,6 +1845,8 @@ static int zswap_debugfs_init(void)
zswap_debugfs_root, &zswap_reject_compress_fail);
debugfs_create_u64("compress_fail", 0444,
zswap_debugfs_root, &zswap_compress_fail);
+ debugfs_create_u64("compress_engine_fail", 0444,
+ zswap_debugfs_root, &zswap_compress_engine_fail);
debugfs_create_u64("reject_compress_poor", 0444,
zswap_debugfs_root, &zswap_reject_compress_poor);
debugfs_create_u64("decompress_fail", 0444,
--
2.39.5