* [RFC PATCH] zram: update ac_time of written back slots
@ 2026-03-31 6:25 Sergey Senozhatsky
2026-03-31 17:01 ` Brian Geffon
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Senozhatsky @ 2026-03-31 6:25 UTC (permalink / raw)
To: Andrew Morton, Minchan Kim, Brian Geffon
Cc: Richard Chang, linux-block, linux-mm, Sergey Senozhatsky,
Suren Baghdasaryan
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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [RFC PATCH] zram: update ac_time of written back slots
2026-03-31 6:25 [RFC PATCH] zram: update ac_time of written back slots Sergey Senozhatsky
@ 2026-03-31 17:01 ` Brian Geffon
0 siblings, 0 replies; 2+ messages in thread
From: Brian Geffon @ 2026-03-31 17:01 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: Andrew Morton, Minchan Kim, Richard Chang, linux-block, linux-mm,
Suren Baghdasaryan
On Tue, Mar 31, 2026 at 2:27 AM Sergey Senozhatsky
<senozhatsky@chromium.org> wrote:
>
> 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>
Acked-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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-31 17:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-31 6:25 [RFC PATCH] zram: update ac_time of written back slots Sergey Senozhatsky
2026-03-31 17:01 ` Brian Geffon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox