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 Suggested-by: Suren Baghdasaryan Suggested-by: Brian Geffon --- 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