]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
PM: sleep: Add support for wakeup during filesystem sync
authorSamuel Wu <wusamuel@google.com>
Wed, 19 Nov 2025 17:14:24 +0000 (09:14 -0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 20 Nov 2025 21:29:40 +0000 (22:29 +0100)
commitbf8867eae17fde94d7081545cf90ca8d5aba690a
tree0d2682c743ac5c71b9c2d928a12e23f400f081fc
parenta857b530b355a9f2ded091b762207967a9a019f5
PM: sleep: Add support for wakeup during filesystem sync

Add helper function pm_sleep_fs_sync() and related data structures
as a preparation for allowing system suspend and hibernation to be
aborted by wakeup events while syncing file systems.

The new function, to be called by the suspend process in order to
sync file systems, uses a dedicated ordered workqueue to run
ksys_sync_helper() in parallel with the calling process.  Next, it
waits for the completion of the filesystem sync and periodically
checks if any system wakeup events are pending, in which case it will
return an error.

If that happens while the filesystem sync is still in progress, it
will continue, possibly after pm_sleep_fs_sync() has returned, and if
that function is called again before the sync is complete, a new work
item to run ksys_sync_helper() again will be queued (and waited for)
to increase the likelihood of writing all of the dirty pages in memory
back to persistent storage.

Suggested-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Samuel Wu <wusamuel@google.com>
Co-developed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ rjw: Subject and changelog rewrite, tags adjustment ]
Link: https://patch.msgid.link/20251119171426.4086783-2-wusamuel@google.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
kernel/power/main.c
kernel/power/power.h