If entry does not fulfill current mark_idle() parameters, e.g.
cutoff time, then we should clear its ZRAM_IDLE from previous
mark_idle() invocations.
Consider the following case:
- mark_idle() cutoff time 8h
- mark_idle() cutoff time 4h
- writeback() idle - will writeback entries with cutoff time 8h,
while it should only pick entries with cutoff time 4h
The bug was reported by Shin Kawamura.
Fixes: 755804d16965 ("zram: introduce an aged idle interface")
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
drivers/block/zram/zram_drv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index a16dbffcdca3..cee49bb0126d 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -410,6 +410,8 @@ static void mark_idle(struct zram *zram, ktime_t cutoff)
#endif
if (is_idle)
zram_set_flag(zram, index, ZRAM_IDLE);
+ else
+ zram_clear_flag(zram, index, ZRAM_IDLE);
zram_slot_unlock(zram, index);
}
}
--
2.47.0.163.g1226f6d8fa-goog
On Tue, Oct 29, 2024 at 12:36:15AM +0900, Sergey Senozhatsky wrote:
> If entry does not fulfill current mark_idle() parameters, e.g.
> cutoff time, then we should clear its ZRAM_IDLE from previous
> mark_idle() invocations.
>
> Consider the following case:
> - mark_idle() cutoff time 8h
> - mark_idle() cutoff time 4h
> - writeback() idle - will writeback entries with cutoff time 8h,
> while it should only pick entries with cutoff time 4h
>
> The bug was reported by Shin Kawamura.
Reported-by: Shin Kawamura <kawasin@google.com>
>
> Fixes: 755804d16965 ("zram: introduce an aged idle interface")
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Brian Geffon <bgeffon@google.com>
> ---
> drivers/block/zram/zram_drv.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index a16dbffcdca3..cee49bb0126d 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -410,6 +410,8 @@ static void mark_idle(struct zram *zram, ktime_t cutoff)
> #endif
> if (is_idle)
> zram_set_flag(zram, index, ZRAM_IDLE);
> + else
> + zram_clear_flag(zram, index, ZRAM_IDLE);
> zram_slot_unlock(zram, index);
> }
> }
> --
> 2.47.0.163.g1226f6d8fa-goog
>
On (24/10/28 13:57), Brian Geffon wrote:
> On Tue, Oct 29, 2024 at 12:36:15AM +0900, Sergey Senozhatsky wrote:
> > If entry does not fulfill current mark_idle() parameters, e.g.
> > cutoff time, then we should clear its ZRAM_IDLE from previous
> > mark_idle() invocations.
> >
> > Consider the following case:
> > - mark_idle() cutoff time 8h
> > - mark_idle() cutoff time 4h
> > - writeback() idle - will writeback entries with cutoff time 8h,
> > while it should only pick entries with cutoff time 4h
> >
> > The bug was reported by Shin Kawamura.
> Reported-by: Shin Kawamura <kawasin@google.com>
This is how it was in v1, but that triggered a warn
WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report
#16:
Reported-by: Shin Kawamura <kawasin@google.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
so I switched to less "formal" reported-by tag in v2.
© 2016 - 2026 Red Hat, Inc.