From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>,
Brian Geffon <bgeffon@google.com>
Cc: Richard Chang <richardycc@google.com>,
linux-block@vger.kernel.org, linux-mm@kvack.org,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Suren Baghdasaryan <surenb@google.com>
Subject: [RFC PATCH] zram: update ac_time of written back slots
Date: Tue, 31 Mar 2026 15:25:59 +0900 [thread overview]
Message-ID: <20260331062648.596077-1-senozhatsky@chromium.org> (raw)
This makes it possible to tell how long each particular
ZRAM_WB slot stays on the disk and, basically, to monitor
writeback efficiency.
Note that the patch factors out a small update_slot_ac_time()
helper, which we call on writeback completion, instead of
calling mark_slot_accessed(). The reasons being is that
mark_slot_accessed() clears ZRAM_PP_SLOT flag ahead of time,
while we want to keep that flag set as long as the slot is on
the post-processing list (unless the slot is freed concurrently).
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Suggested-by: Suren Baghdasaryan <surenb@google.com>
Suggested-by: Brian Geffon <bgeffon@google.com>
---
drivers/block/zram/zram_drv.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 5ecc4ba40e9d..dcea703a6766 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -185,15 +185,20 @@ static inline u32 get_slot_comp_priority(struct zram *zram, u32 index)
return prio & ZRAM_COMP_PRIORITY_MASK;
}
-static void mark_slot_accessed(struct zram *zram, u32 index)
+static void update_slot_ac_time(struct zram *zram, u32 index)
{
- clear_slot_flag(zram, index, ZRAM_IDLE);
- clear_slot_flag(zram, index, ZRAM_PP_SLOT);
#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
zram->table[index].attr.ac_time = (u32)ktime_get_boottime_seconds();
#endif
}
+static void mark_slot_accessed(struct zram *zram, u32 index)
+{
+ clear_slot_flag(zram, index, ZRAM_IDLE);
+ clear_slot_flag(zram, index, ZRAM_PP_SLOT);
+ update_slot_ac_time(zram, index);
+}
+
static inline void update_used_max(struct zram *zram, const unsigned long pages)
{
unsigned long cur_max = atomic_long_read(&zram->stats.max_used_pages);
@@ -952,6 +957,7 @@ static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)
zs_free(zram->mem_pool, get_slot_handle(zram, index));
set_slot_handle(zram, index, req->blk_idx);
set_slot_flag(zram, index, ZRAM_WB);
+ update_slot_ac_time(zram, index);
out:
slot_unlock(zram, index);
--
2.53.0.1018.g2bb0e51243-goog
next reply other threads:[~2026-03-31 6:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 6:25 Sergey Senozhatsky [this message]
2026-03-31 17:01 ` Brian Geffon
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=20260331062648.596077-1-senozhatsky@chromium.org \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=bgeffon@google.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=richardycc@google.com \
--cc=surenb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox