From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Nitin Gupta <ngupta@vflare.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCHv4 4/9] zram: Introduce recompress sysfs knob
Date: Thu, 3 Nov 2022 15:03:48 +0900 [thread overview]
Message-ID: <Y2NZxD5SpHEObPaE@google.com> (raw)
In-Reply-To: <Y2M0t5etyJiUfeQi@google.com>
On (22/11/03 12:25), Sergey Senozhatsky wrote:
> > or we can introduce the threshold with action item.
> >
> > echo "idle 888" > /sys/block/zram0/recompress
> > echo "huge 888" > /sys/block/zram0/recompress
> > echo "normal 888" > /sys/block/zram0/recompress
>
> I like the latter one, when threshold is an optional argument.
> I probably would even go a bit further and add keywords:
>
> type=STRING threshold=INT
E.g. recompress support for type= and optional threshold=
We kind of don't have a use case of type=normal, as it is an equivalent
of no type. So we have huge, idle, huge_idle and no param means all
pages (which is sort of logical). threshold is optional.
---
drivers/block/zram/zram_drv.c | 55 ++++++++++++++++++++++-------------
1 file changed, 34 insertions(+), 21 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 9a614253de07..12f03745baf9 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1688,7 +1688,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec,
* Corresponding ZRAM slot should be locked.
*/
static int zram_recompress(struct zram *zram, u32 index, struct page *page,
- int size_watermark)
+ int size_threshold)
{
unsigned long handle_prev;
unsigned long handle_next;
@@ -1708,7 +1708,7 @@ static int zram_recompress(struct zram *zram, u32 index, struct page *page,
/*
* Do not recompress objects that are already "small enough".
*/
- if (comp_len_prev < size_watermark)
+ if (comp_len_prev < size_threshold)
return 0;
ret = zram_read_from_zspool(zram, page, index);
@@ -1780,29 +1780,42 @@ static ssize_t recompress_store(struct device *dev,
{
struct zram *zram = dev_to_zram(dev);
unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
+ char *args, *param, *val;
unsigned long index;
struct page *page;
ssize_t ret;
- int mode, size_watermark = 0;
-
- if (sysfs_streq(buf, "idle")) {
- mode = RECOMPRESS_IDLE;
- } else if (sysfs_streq(buf, "huge")) {
- mode = RECOMPRESS_HUGE;
- } else if (sysfs_streq(buf, "huge_idle")) {
- mode = RECOMPRESS_IDLE | RECOMPRESS_HUGE;
- } else {
- /*
- * We will re-compress only idle objects equal or greater
- * in size than watermark.
- */
- ret = kstrtoint(buf, 10, &size_watermark);
- if (ret)
- return ret;
- mode = RECOMPRESS_IDLE;
+ int mode = 0, size_threshold = 0;
+
+ args = skip_spaces(buf);
+ while (*args) {
+ args = next_arg(args, ¶m, &val);
+
+ if (!*val)
+ return -EINVAL;
+
+ if (!strcmp(param, "type")) {
+ if (!strcmp(val, "idle"))
+ mode = RECOMPRESS_IDLE;
+ if (!strcmp(val, "huge"))
+ mode = RECOMPRESS_HUGE;
+ if (!strcmp(val, "huge_idle"))
+ mode = RECOMPRESS_IDLE | RECOMPRESS_HUGE;
+ continue;
+ }
+
+ if (!strcmp(param, "threshold")) {
+ /*
+ * We will re-compress only idle objects equal or
+ * greater in size than watermark.
+ */
+ ret = kstrtoint(val, 10, &size_threshold);
+ if (ret)
+ return ret;
+ continue;
+ }
}
- if (size_watermark > PAGE_SIZE)
+ if (size_threshold > PAGE_SIZE)
return -EINVAL;
down_read(&zram->init_lock);
@@ -1841,7 +1854,7 @@ static ssize_t recompress_store(struct device *dev,
zram_test_flag(zram, index, ZRAM_RECOMP_SKIP))
goto next;
- err = zram_recompress(zram, index, page, size_watermark);
+ err = zram_recompress(zram, index, page, size_threshold);
next:
zram_slot_unlock(zram, index);
if (err) {
--
2.38.1.273.g43a17bfeac-goog
next prev parent reply other threads:[~2022-11-03 6:04 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 4:55 [PATCHv4 0/9] zram: Support multiple compression streams Sergey Senozhatsky
2022-10-18 4:55 ` [PATCHv4 1/9] zram: Preparation for multi-zcomp support Sergey Senozhatsky
2022-11-02 20:13 ` Minchan Kim
2022-11-03 2:40 ` Sergey Senozhatsky
2022-10-18 4:55 ` [PATCHv4 2/9] zram: Add recompression algorithm sysfs knob Sergey Senozhatsky
2022-11-02 20:15 ` Minchan Kim
2022-11-03 3:05 ` Sergey Senozhatsky
2022-11-03 3:54 ` Sergey Senozhatsky
2022-11-03 17:10 ` Minchan Kim
2022-11-03 4:09 ` Sergey Senozhatsky
2022-11-03 5:36 ` Sergey Senozhatsky
2022-11-03 17:11 ` Minchan Kim
2022-11-03 16:34 ` Minchan Kim
2022-11-04 3:18 ` Sergey Senozhatsky
2022-11-04 4:53 ` Sergey Senozhatsky
2022-11-04 17:43 ` Minchan Kim
2022-11-04 23:41 ` Sergey Senozhatsky
2022-11-05 0:00 ` Sergey Senozhatsky
2022-11-07 19:08 ` Minchan Kim
2022-11-08 0:40 ` Sergey Senozhatsky
2022-11-05 0:01 ` Minchan Kim
2022-11-05 1:30 ` Sergey Senozhatsky
2022-11-04 16:34 ` Minchan Kim
2022-11-04 23:25 ` Sergey Senozhatsky
2022-11-04 23:40 ` Minchan Kim
2022-11-04 23:44 ` Sergey Senozhatsky
2022-11-05 0:02 ` Minchan Kim
2022-10-18 4:55 ` [PATCHv4 3/9] zram: Factor out WB and non-WB zram read functions Sergey Senozhatsky
2022-11-02 20:20 ` Minchan Kim
2022-11-03 2:43 ` Sergey Senozhatsky
2022-10-18 4:55 ` [PATCHv4 4/9] zram: Introduce recompress sysfs knob Sergey Senozhatsky
2022-11-02 21:06 ` Minchan Kim
2022-11-03 3:25 ` Sergey Senozhatsky
2022-11-03 6:03 ` Sergey Senozhatsky [this message]
2022-11-03 17:00 ` Minchan Kim
2022-11-04 3:48 ` Sergey Senozhatsky
2022-11-04 7:12 ` Sergey Senozhatsky
2022-11-04 17:53 ` Minchan Kim
2022-11-04 17:27 ` Minchan Kim
2022-11-04 23:22 ` Sergey Senozhatsky
2022-11-04 7:53 ` Sergey Senozhatsky
2022-11-04 8:08 ` Sergey Senozhatsky
2022-11-04 17:47 ` Minchan Kim
2022-10-18 4:55 ` [PATCHv4 5/9] documentation: Add recompression documentation Sergey Senozhatsky
2022-10-18 4:55 ` [PATCHv4 6/9] zram: Add recompression algorithm choice to Kconfig Sergey Senozhatsky
2022-10-18 4:55 ` [PATCHv4 7/9] zram: Add recompress flag to read_block_state() Sergey Senozhatsky
2022-10-18 4:55 ` [PATCHv4 8/9] zram: Clarify writeback_store() comment Sergey Senozhatsky
2022-10-18 4:55 ` [PATCHv4 9/9] zram: Use IS_ERR_VALUE() to check for zs_malloc() errors Sergey Senozhatsky
2022-11-02 20:07 ` [PATCHv4 0/9] zram: Support multiple compression streams Minchan Kim
2022-11-03 3:36 ` Sergey Senozhatsky
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=Y2NZxD5SpHEObPaE@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.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;
as well as URLs for NNTP newsgroup(s).