From: Alexey Romanov <avromanov@sberdevices.ru>
To: <minchan@kernel.org>, <senozhatsky@chromium.org>,
<ngupta@vflare.org>, <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<kernel@sberdevices.ru>, <ddrokosov@sberdevices.ru>,
Alexey Romanov <avromanov@sberdevices.ru>
Subject: [RFC PATCH v1 2/4] zram: add merge sysfs knob
Date: Mon, 21 Nov 2022 22:00:18 +0300 [thread overview]
Message-ID: <20221121190020.66548-3-avromanov@sberdevices.ru> (raw)
In-Reply-To: <20221121190020.66548-1-avromanov@sberdevices.ru>
Allow zram to merge identical pages into signle one:
echo 1 > /sys/block/zramX/merge
Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
---
drivers/block/zram/zram_drv.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 716c2f72805e..1dae3564cabd 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1197,6 +1197,30 @@ static ssize_t compact_store(struct device *dev,
return len;
}
+static int zram_do_scan(struct zram *zram);
+
+static ssize_t merge_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct zram *zram = dev_to_zram(dev);
+ int ret;
+
+ down_read(&zram->init_lock);
+ if (!init_done(zram)) {
+ up_read(&zram->init_lock);
+ return -EINVAL;
+ }
+
+ ret = zram_do_scan(zram);
+ if (ret != 0) {
+ up_read(&zram->init_lock);
+ return -ENOMEM;
+ }
+
+ up_read(&zram->init_lock);
+ return len;
+}
+
static ssize_t io_stat_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -2569,6 +2593,7 @@ static const struct block_device_operations zram_devops = {
};
static DEVICE_ATTR_WO(compact);
+static DEVICE_ATTR_WO(merge);
static DEVICE_ATTR_RW(disksize);
static DEVICE_ATTR_RO(initstate);
static DEVICE_ATTR_WO(reset);
@@ -2609,6 +2634,7 @@ static struct attribute *zram_disk_attrs[] = {
#ifdef CONFIG_ZRAM_WRITEBACK
&dev_attr_bd_stat.attr,
#endif
+ &dev_attr_merge.attr,
&dev_attr_debug_stat.attr,
#ifdef CONFIG_ZRAM_MULTI_COMP
&dev_attr_recomp_algorithm.attr,
--
2.25.1
next prev parent reply other threads:[~2022-11-21 19:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 19:00 [RFC PATCH v1 0/4] Introduce merge identical pages mechanism Alexey Romanov
2022-11-21 19:00 ` [RFC PATCH v1 1/4] zram: introduce " Alexey Romanov
2022-11-23 8:25 ` Chen Wandun
2022-11-23 9:04 ` Aleksey Romanov
2022-11-21 19:00 ` Alexey Romanov [this message]
2022-11-21 20:44 ` [RFC PATCH v1 0/4] Introduce " Johannes Weiner
2022-11-22 3:00 ` Sergey Senozhatsky
2022-11-22 3:07 ` Sergey Senozhatsky
2022-11-22 12:14 ` Aleksey Romanov
2022-11-23 4:13 ` Sergey Senozhatsky
2022-11-23 8:53 ` Dmitry Rokosov
2022-12-01 10:14 ` Dmitry Rokosov
2022-12-01 10:47 ` Sergey Senozhatsky
2022-12-01 11:14 ` Dmitry Rokosov
2022-12-01 13:29 ` Sergey Senozhatsky
2023-01-11 14:00 ` Alexey Romanov
2023-02-06 10:37 ` Sergey Senozhatsky
2022-11-23 9:07 ` Aleksey Romanov
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=20221121190020.66548-3-avromanov@sberdevices.ru \
--to=avromanov@sberdevices.ru \
--cc=akpm@linux-foundation.org \
--cc=ddrokosov@sberdevices.ru \
--cc=kernel@sberdevices.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.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