]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
zram: clear IDLE flag in mark_idle()
authorSergey Senozhatsky <senozhatsky@chromium.org>
Mon, 28 Oct 2024 15:36:15 +0000 (00:36 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 19:03:11 +0000 (20:03 +0100)
[ Upstream commit d37da422edb0664a2037e6d7d42fe6d339aae78a ]

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.

Link: https://lkml.kernel.org/r/20241028153629.1479791-3-senozhatsky@chromium.org
Fixes: 755804d16965 ("zram: introduce an aged idle interface")
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reported-by: Shin Kawamura <kawasin@google.com>
Acked-by: Brian Geffon <bgeffon@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/zram/zram_drv.c

index d7f7cc31aaa69c97cab1c40e90e1e69f99ce3d3c..d0432b1707ceb66e9bae34d3e644086cbc0ad0d2 100644 (file)
@@ -320,6 +320,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);
        }
 }