linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: zswap: increase reject_compress_poor but not reject_compress_fail if compression returns ENOSPC
@ 2024-02-16  3:05 Barry Song
  2024-02-16  8:23 ` Yosry Ahmed
  0 siblings, 1 reply; 6+ messages in thread
From: Barry Song @ 2024-02-16  3:05 UTC (permalink / raw)
  To: akpm, hannes, linux-mm, yosryahmed
  Cc: linux-kernel, Barry Song, Chengming Zhou, Nhat Pham, Sergey Senozhatsky

From: Barry Song <v-songbaohua@oppo.com>

My commit fc8580edbaa6 ("mm: zsmalloc: return -ENOSPC rather than -EINVAL
in zs_malloc while size is too large") wanted to depend on zs_malloc's
returned ENOSPC to distinguish the case that compressed data is larger
than the original data from normal compression cases. The commit, for
sure, was correct and worked as expected but the code wouldn't run to
there after commit 744e1885922a ("crypto: scomp - fix req->dst buffer
overflow") as Chengming's this patch makes zswap_store() goto out
immediately after the special compression case happens. So there is
no chance to execute zs_malloc() now. We need to fix the count right
after compressions return ENOSPC.

Fixes: fc8580edbaa6 ("mm: zsmalloc: return -ENOSPC rather than -EINVAL in zs_malloc while size is too large")
Cc: Chengming Zhou <zhouchengming@bytedance.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
---
 mm/zswap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index 6319d2281020..9a21dbe8c056 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1627,7 +1627,10 @@ bool zswap_store(struct folio *folio)
 	dlen = acomp_ctx->req->dlen;
 
 	if (ret) {
-		zswap_reject_compress_fail++;
+		if (ret == -ENOSPC)
+			zswap_reject_compress_poor++;
+		else
+			zswap_reject_compress_fail++;
 		goto put_dstmem;
 	}
 
-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-16 20:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-16  3:05 [PATCH] mm: zswap: increase reject_compress_poor but not reject_compress_fail if compression returns ENOSPC Barry Song
2024-02-16  8:23 ` Yosry Ahmed
2024-02-16  9:07   ` Chengming Zhou
2024-02-16  9:16     ` Barry Song
2024-02-16 20:01       ` Yosry Ahmed
2024-02-16  9:17   ` Nhat Pham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox