Re: [PATCH v4 0/4] PM: hibernate: flush icache for restored pages from task context
From: Rafael J. Wysocki (Intel)
Date: Fri Nov 20 2026 - 12:43:46 EST
On Mon, Nov 16, 2026 at 4:46 AM Xiong Xin <xiongxin@xxxxxxxxxx> wrote:
>
> Hello,
>
> With `hibernate=nocompress`, load_image() submits the read bios
> asynchronously and hib_end_io() completes them from hardirq/softirq
> context. The flush_icache_range() call there, added by the
> commit f6cf0545ec69 ("PM / Hibernate: Call flush_icache_range() on pages
> restored in-place"), ends with kick_all_cpus_sync() on ARM64 and so
> triggers the WARN_ON_ONCE(!in_task()) in smp_call_function().
>
> This series fixes it by keeping the flush in task context, and first
> closes three pre-existing holes in the restore error paths that the
> rework would otherwise trip over.
>
> Patch 1 resets clean_pages_on_read when load_image() finishes, so that
> a failed nocompress resume can no longer leak the flag into a later
> compressed resume, where it made hib_end_io() call flush_icache_range()
> from interrupt context for the reused ring pages of
> load_compressed_image(). The flag is also cleared as soon as the load
> is known to have failed, so that the bios still in flight do not flush
> from interrupt context during the final drain.
>
> Patch 2 stops snapshot_write_next() from releasing all snapshot pages
> in place when one of its internal allocations fails: the read bios do
> not take page references, so freed pages could be handed out again
> while the device is still writing the image data into them. The image
> is now released by the outer error paths, after swsusp_read() has
> drained the batch.
>
> Patch 3 makes the error exits of load_compressed_image() wait for the
> read bios that may still be in flight before the ring pages are freed,
> like save_compressed_image() and load_image() already do.
>
> Patch 4 defers the flush on the nocompress path: hib_end_io() now only
> records the restored page on a per-batch list, and load_image() flushes
> the pages once hib_wait_io() has returned, preserving the asynchronous
> batched I/O.
>
> Patches 1 to 3 are unchanged since v3. Patch 4 now yields with
> cond_resched() in its flush loop, as the final drain may walk a
> multi-gigabyte image in one go. Many thanks to sashiko for the
> reviews of v2 and v3.
>
> Xiong Xin (4):
> PM: hibernate: reset clean_pages_on_read after load_image()
> PM: hibernate: do not free the image in place while restore I/O is in
> flight
> PM: hibernate: drain pending reads in compressed image load errors
> PM: hibernate: flush icache for restored pages from task context
>
> kernel/power/snapshot.c | 9 ++-----
> kernel/power/swap.c | 57 ++++++++++++++++++++++++++++++++++++-----
> 2 files changed, 52 insertions(+), 14 deletions(-)
>
> --
Applied as 7.5 material except for patch [3/4] that is equivalent to
already existing commit 931650685e35 ("PM: hibernate: Wait for
in-flight reads before freeing the read-ahead ring")
Thanks!