From: Alexey Romanov <avromanov@sberdevices.ru>
To: <minchan@kernel.org>, <senozhatsky@chromium.org>,
<akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<kernel@sberdevices.ru>,
Alexey Romanov <avromanov@sberdevices.ru>
Subject: [RFC PATCH v1 4/5] zram: add fold sysfs knob
Date: Tue, 18 Apr 2023 09:25:02 +0300 [thread overview]
Message-ID: <20230418062503.62121-5-avromanov@sberdevices.ru> (raw)
In-Reply-To: <20230418062503.62121-1-avromanov@sberdevices.ru>
Allow zram to fold identical zsmalloc objects into single one:
echo 1 > /sys/block/zramX/fold
Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
---
drivers/block/zram/zram_drv.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index e290d6d97047..06a614d1643d 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1184,6 +1184,25 @@ static ssize_t compact_store(struct device *dev,
return len;
}
+#ifdef CONFIG_ZSMALLOC_FOLD
+static ssize_t fold_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ down_read(&zram->init_lock);
+ if (!init_done(zram)) {
+ up_read(&zram->init_lock);
+ return -EINVAL;
+ }
+
+ zs_fold(zram->mem_pool);
+ up_read(&zram->init_lock);
+
+ return len;
+}
+#endif
+
static ssize_t io_stat_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -2313,6 +2332,9 @@ static DEVICE_ATTR_RW(writeback_limit_enable);
static DEVICE_ATTR_RW(recomp_algorithm);
static DEVICE_ATTR_WO(recompress);
#endif
+#ifdef CONFIG_ZSMALLOC_FOLD
+static DEVICE_ATTR_WO(fold);
+#endif
static struct attribute *zram_disk_attrs[] = {
&dev_attr_disksize.attr,
@@ -2339,6 +2361,9 @@ static struct attribute *zram_disk_attrs[] = {
#ifdef CONFIG_ZRAM_MULTI_COMP
&dev_attr_recomp_algorithm.attr,
&dev_attr_recompress.attr,
+#endif
+#ifdef CONFIG_ZSMALLOC_FOLD
+ &dev_attr_fold.attr,
#endif
NULL,
};
--
2.38.1
next prev parent reply other threads:[~2023-04-18 6:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 6:24 [RFC PATCH v1 0/5] Introduce objects folding mechanism Alexey Romanov
2023-04-18 6:25 ` [RFC PATCH v1 3/5] mm/zsmalloc: introduce " Alexey Romanov
2023-04-18 6:25 ` Alexey Romanov [this message]
2023-05-02 10:38 ` [RFC PATCH v1 0/5] Introduce " Романов Алексей Васильевич
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=20230418062503.62121-5-avromanov@sberdevices.ru \
--to=avromanov@sberdevices.ru \
--cc=akpm@linux-foundation.org \
--cc=kernel@sberdevices.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=senozhatsky@chromium.org \
/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