[PATCH v3 1/4] PM: hibernate: reset clean_pages_on_read after load_image()

From: Xiong Xin

Date: Thu Oct 01 2026 - 23:42:56 EST


load_image() sets clean_pages_on_read but nothing clears it. If a
nocompress resume attempt fails and a compressed resume follows in the
same boot, the stale flag makes hib_end_io() call flush_icache_range()
from interrupt context for the reused ring pages of
load_compressed_image(), triggering the WARN_ON_ONCE(!in_task()) in
smp_call_function() on ARM64.

Reset the flag before load_image() returns, so that it cannot leak
into a later compressed resume.

Also clear it once the load is known to have failed, so that the bios
still in flight do not trigger the same interrupt-context flush during
the final drain.

Fixes: f6cf0545ec69 ("PM / Hibernate: Call flush_icache_range() on pages restored in-place")
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Link: https://sashiko.dev/#/patchset/20260926032416.467937-1-xiongxin%40kylinos.cn
Assisted-by: GLM:glm-5.3
Signed-off-by: Xiong Xin <xiongxin@xxxxxxxxxx>
---

New in v3, split from the single-patch v2 per review feedback from
sashiko, as it also fixes the stale clean_pages_on_read path on its
own; it now also covers the final drain of a failing load.
kernel/power/swap.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index c78f1593600b..7f3cc2cc5cca 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1125,6 +1125,9 @@ static int load_image(struct swap_map_handle *handle,
nr_pages / m * 10);
nr_pages++;
}
+ /* Stop flushing pages on load failure. */
+ if (ret < 0)
+ clean_pages_on_read = false;
err2 = hib_wait_io(&hb);
hib_finish_batch(&hb);
stop = ktime_get();
@@ -1137,6 +1140,7 @@ static int load_image(struct swap_map_handle *handle,
ret = -ENODATA;
}
swsusp_show_speed(start, stop, nr_to_read, "Read");
+ clean_pages_on_read = false;
return ret;
}

--
2.25.1