All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hui Zhu <teawaterz@linux.alibaba.com>
To: sjenning@redhat.com, ddstreet@ieee.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Cc: Hui Zhu <teawaterz@linux.alibaba.com>
Subject: [PATCH] zswap: Add shrink_enabled that can disable swap shrink to increase store performance
Date: Fri, 25 Oct 2019 16:02:18 +0800	[thread overview]
Message-ID: <1571990538-6133-1-git-send-email-teawaterz@linux.alibaba.com> (raw)

zswap will try to shrink pool when zswap is full.
This commit add shrink_enabled that can disable swap shrink to increase
store performance.  User can disable swap shrink if care about the store
performance.

For example in a VM with 1 CPU 1G memory 4G swap:
echo lz4 > /sys/module/zswap/parameters/compressor
echo z3fold > /sys/module/zswap/parameters/zpool
echo 0 > /sys/module/zswap/parameters/same_filled_pages_enabled
echo 1 > /sys/module/zswap/parameters/enabled
usemem -a -n 1 $((4000 * 1024 * 1024))
4718592000 bytes / 114937822 usecs = 40091 KB/s
101700 usecs to free memory
echo 0 > /sys/module/zswap/parameters/shrink_enabled
usemem -a -n 1 $((4000 * 1024 * 1024))
4718592000 bytes / 8837320 usecs = 521425 KB/s
129577 usecs to free memory

The store speed increased when zswap shrink disabled.

Signed-off-by: Hui Zhu <teawaterz@linux.alibaba.com>
---
 mm/zswap.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/zswap.c b/mm/zswap.c
index 46a3223..731e3d1e 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -114,6 +114,10 @@ static bool zswap_same_filled_pages_enabled = true;
 module_param_named(same_filled_pages_enabled, zswap_same_filled_pages_enabled,
 		   bool, 0644);
 
+/* Enable/disable zswap shrink (enabled by default) */
+static bool zswap_shrink_enabled = true;
+module_param_named(shrink_enabled, zswap_shrink_enabled, bool, 0644);
+
 /*********************************
 * data structures
 **********************************/
@@ -947,6 +951,9 @@ static int zswap_shrink(void)
 	struct zswap_pool *pool;
 	int ret;
 
+	if (!zswap_shrink_enabled)
+		return -EPERM;
+
 	pool = zswap_pool_last_get();
 	if (!pool)
 		return -ENOENT;
-- 
2.7.4


             reply	other threads:[~2019-10-25  8:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  8:02 Hui Zhu [this message]
2019-11-08 16:04 ` [PATCH] zswap: Add shrink_enabled that can disable swap shrink to increase store performance Dan Streetman
2019-11-08 16:04   ` Dan Streetman
2019-11-11  1:57   ` Hui Zhu
2020-01-26 19:36     ` Dan Streetman
2020-01-26 19:36       ` Dan Streetman

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=1571990538-6133-1-git-send-email-teawaterz@linux.alibaba.com \
    --to=teawaterz@linux.alibaba.com \
    --cc=ddstreet@ieee.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sjenning@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.