Skip to content

Commit cb61dad

Browse files
nhatsmrtakpm00
authored andcommitted
zswap: export compression failure stats
During a zswap store attempt, the compression algorithm could fail (for e.g due to the page containing incompressible random data). This is not tracked in any of existing zswap counters, making it hard to monitor for and investigate. We have run into this problem several times in our internal investigations on zswap store failures. This patch adds a dedicated debugfs counter for compression algorithm failures. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Nhat Pham <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Cc: Dan Streetman <[email protected]> Cc: Domenico Cerasuolo <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Muchun Song <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Seth Jennings <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Vitaly Wool <[email protected]> Cc: Yosry Ahmed <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 9fb2047 commit cb61dad

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mm/zswap.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ static u64 zswap_pool_limit_hit;
6262
static u64 zswap_written_back_pages;
6363
/* Store failed due to a reclaim failure after pool limit was reached */
6464
static u64 zswap_reject_reclaim_fail;
65+
/* Store failed due to compression algorithm failure */
66+
static u64 zswap_reject_compress_fail;
6567
/* Compressed page was too big for the allocator to (optimally) store */
6668
static u64 zswap_reject_compress_poor;
6769
/* Store failed because underlying allocator could not get memory */
@@ -1312,8 +1314,10 @@ bool zswap_store(struct folio *folio)
13121314
ret = crypto_wait_req(crypto_acomp_compress(acomp_ctx->req), &acomp_ctx->wait);
13131315
dlen = acomp_ctx->req->dlen;
13141316

1315-
if (ret)
1317+
if (ret) {
1318+
zswap_reject_compress_fail++;
13161319
goto put_dstmem;
1320+
}
13171321

13181322
/* store */
13191323
zpool = zswap_find_zpool(entry);
@@ -1553,6 +1557,8 @@ static int zswap_debugfs_init(void)
15531557
zswap_debugfs_root, &zswap_reject_alloc_fail);
15541558
debugfs_create_u64("reject_kmemcache_fail", 0444,
15551559
zswap_debugfs_root, &zswap_reject_kmemcache_fail);
1560+
debugfs_create_u64("reject_compress_fail", 0444,
1561+
zswap_debugfs_root, &zswap_reject_compress_fail);
15561562
debugfs_create_u64("reject_compress_poor", 0444,
15571563
zswap_debugfs_root, &zswap_reject_compress_poor);
15581564
debugfs_create_u64("written_back_pages", 0444,

0 commit comments

Comments
 (0)