linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Minchan Kim <minchan@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: [PATCHv3 10/11] zram: filter out recomp targets based on priority
Date: Thu, 30 Jan 2025 20:10:55 +0900	[thread overview]
Message-ID: <20250130111105.2861324-11-senozhatsky@chromium.org> (raw)
In-Reply-To: <20250130111105.2861324-1-senozhatsky@chromium.org>

Do no select for post processing slots that are already
compressed with same or higher priority compression
algorithm.

This should save some memory, as previously we would still
put those entries into corresponding post-processing buckets
and filter them out later in recompress_slot().

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
 drivers/block/zram/zram_drv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 3e91fd1dcfc7..500d6c8b17fc 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1813,7 +1813,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec,
 #define RECOMPRESS_IDLE		(1 << 0)
 #define RECOMPRESS_HUGE		(1 << 1)
 
-static int scan_slots_for_recompress(struct zram *zram, u32 mode,
+static int scan_slots_for_recompress(struct zram *zram, u32 mode, u32 prio_max,
 				     struct zram_pp_ctl *ctl)
 {
 	unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
@@ -1845,6 +1845,10 @@ static int scan_slots_for_recompress(struct zram *zram, u32 mode,
 		    zram_test_flag(zram, index, ZRAM_INCOMPRESSIBLE))
 			goto next;
 
+		/* Already compressed with same of higher priority */
+		if (zram_get_priority(zram, index) + 1 >= prio_max)
+			goto next;
+
 		pps->index = index;
 		place_pp_slot(zram, ctl, pps);
 		pps = NULL;
@@ -2134,7 +2138,7 @@ static ssize_t recompress_store(struct device *dev,
 		goto release_init_lock;
 	}
 
-	scan_slots_for_recompress(zram, mode, ctl);
+	scan_slots_for_recompress(zram, mode, prio_max, ctl);
 
 	ret = len;
 	while ((pps = select_pp_slot(ctl))) {
-- 
2.48.1.262.g85cc9f2d1e-goog



  parent reply	other threads:[~2025-01-30 11:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 11:10 [PATCHv3 00/11] zram: preemptible writes and occasionally preemptible reads Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 01/11] zram: switch to non-atomic entry locking Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 02/11] zram: do not use per-CPU compression streams Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 03/11] zram: remove crypto include Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 04/11] zram: remove max_comp_streams device attr Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 05/11] zram: remove two-staged handle allocation Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 06/11] zram: permit reclaim in zstd custom allocator Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 07/11] zram: permit reclaim in recompression handle allocation Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 08/11] zram: remove writestall zram_stats member Sergey Senozhatsky
2025-01-30 11:10 ` [PATCHv3 09/11] zram: limit max recompress prio to num_active_comps Sergey Senozhatsky
2025-01-30 11:10 ` Sergey Senozhatsky [this message]
2025-01-30 11:10 ` [PATCHv3 11/11] zram: unlock slot during recompression Sergey Senozhatsky
2025-01-30 14:18 ` [PATCHv3 00/11] zram: preemptible writes and occasionally preemptible reads 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=20250130111105.2861324-11-senozhatsky@chromium.org \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.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