From: Barry Song <21cnbao@gmail.com>
To: akpm@linux-foundation.org, hannes@cmpxchg.org,
linux-mm@kvack.org, yosryahmed@google.com
Cc: linux-kernel@vger.kernel.org, Barry Song <v-songbaohua@oppo.com>,
Chengming Zhou <zhouchengming@bytedance.com>,
Nhat Pham <nphamcs@gmail.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: [PATCH] mm: zswap: increase reject_compress_poor but not reject_compress_fail if compression returns ENOSPC
Date: Fri, 16 Feb 2024 16:05:39 +1300 [thread overview]
Message-ID: <20240216030539.110404-1-21cnbao@gmail.com> (raw)
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
next reply other threads:[~2024-02-16 5:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 3:05 Barry Song [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240216030539.110404-1-21cnbao@gmail.com \
--to=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=v-songbaohua@oppo.com \
--cc=yosryahmed@google.com \
--cc=zhouchengming@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox