kernel/power/hibernate.c | 6 +++- kernel/power/main.c | 77 ++++++++++++++++++++++++++++++++++++---- kernel/power/power.h | 1 + kernel/power/suspend.c | 6 +++- kernel/power/user.c | 4 ++- 5 files changed, 84 insertions(+), 10 deletions(-)
At the start of suspend and hibernate, filesystems will sync to save the current state of the device. However, the long tail of the filesystem sync can take upwards of 25 seconds. If during this filesystem sync there is some wakeup signal, it will not be processed until the sync is complete; from a user's perspective, this looks like the device is unresponsive to any form of input. This patch adds functionality to handle a sleep abort signal when in the filesystem sync phase of suspend or hibernate. This topic was first discussed by Saravana Kannan at LPC 2024 [1], where the general consensus was to allow filesystem sync on a parallel thread. In case of a wakeup signal, the suspend process will stop waiting on an in-progress filesystem sync, and instead abort suspend before the filesystem sync is complete. Furthermore, in the case of the back-to-back sleeps, a subsequent filesystem sync is enqueued to ensure the latest files are synced right before sleep. The framework still allows for an early abort in this case. [1]: https://lpc.events/event/18/contributions/1845/ Suggested-by: Saravana Kannan <saravanak@google.com> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Samuel Wu <wusamuel@google.com> Samuel Wu (2): PM: Add framework to abort during fs_sync PM: Call pm_sleep_fs_sync() instead of ksys_sync_helper() Changes in v7: - Switched to polling for wakeup/fs_sync finishing per Rafael's patch in v6 - Added header files for wait queue and atomics (modify Rafael's patch) - Cleaned up wq on error in pm_start_workqueues (modify Rafael's patch) - Changed atomic_add_return(-1, cnt) == 0 to atomic_dec_and_test(cnt) (modify Rafael's patch) - v6 link: https://lore.kernel.org/all/20251030210110.298612-1-wusamuel@google.com/ Changes in v6: - Use spin_lock_irq() in thread context - Use dedicated ordered workqueue for sync work items - Use a counter instead of two bools for synchronization - Queue fs_sync if it's not already pending on workqueue - pm_wakeup_clear(0) is prequisite to this feature, so move it within function - Updated commit text for motive of back-to-back fs syncs - Tighter lock/unlock around setup, checks, and loop - Fix function definitions for CONFIG_PM_SLEEP=n - v5 link: https://lore.kernel.org/all/20251017233907.2305303-1-wusamuel@google.com/ Changes in v5: - Update spin_lock() to spin_lock_irqsave() since abort can be in IRQ context - Updated changelog description to be more precise regarding continuing abort sleep before fs_sync() is complete - Rename abort_sleep_during_fs_sync() to pm_stop_waiting_for_fs_sync() - Simplify from a goto to do-while in pm_sleep_fs_sync() - v4 link: https://lore.kernel.org/all/20250911185314.2377124-1-wusamuel@google.com Changes in v4: - Removed patch 1/3 of v3 as it is already picked up on linux-pm - Squashed patches 2/3 and 3/3 from v3 into this single patch - Added abort during fs_sync functionality to hibernate in addition to suspend - Moved variables and functions for abort from power/suspend.c to power/main.c - Renamed suspend_fs_sync_with_abort() to pm_sleep_fs_sync() - Renamed suspend_abort_fs_sync() to abort_sleep_during_fs_sync() - v3 link: https://lore.kernel.org/all/20250821004237.2712312-1-wusamuel@google.com/ Changes in v3: - Split v2 patch into 3 patches - Moved pm_wakeup_clear() outside of if(sync_on_suspend_enabled) condition - Updated documentation and comments within kernel/power/suspend.c - v2 link: https://lore.kernel.org/all/20250812232126.1814253-1-wusamuel@google.com/ Changes in v2: - Added documentation for suspend_abort_fs_sync() - Made suspend_fs_sync_lock and suspend_fs_sync_complete declaration static - v1 link: https://lore.kernel.org/all/20250815004635.3684650-1-wusamuel@google.com kernel/power/hibernate.c | 6 +++- kernel/power/main.c | 77 ++++++++++++++++++++++++++++++++++++---- kernel/power/power.h | 1 + kernel/power/suspend.c | 6 +++- kernel/power/user.c | 4 ++- 5 files changed, 84 insertions(+), 10 deletions(-) -- 2.52.0.rc1.455.g30608eb744-goog
On Wed, Nov 19, 2025 at 6:14 PM Samuel Wu <wusamuel@google.com> wrote: > > At the start of suspend and hibernate, filesystems will sync to save the > current state of the device. However, the long tail of the filesystem > sync can take upwards of 25 seconds. If during this filesystem sync > there is some wakeup signal, it will not be processed until the sync is > complete; from a user's perspective, this looks like the device is > unresponsive to any form of input. > > This patch adds functionality to handle a sleep abort signal when in > the filesystem sync phase of suspend or hibernate. This topic was first > discussed by Saravana Kannan at LPC 2024 [1], where the general > consensus was to allow filesystem sync on a parallel thread. In case of > a wakeup signal, the suspend process will stop waiting on an in-progress > filesystem sync, and instead abort suspend before the filesystem sync is > complete. > > Furthermore, in the case of the back-to-back sleeps, a subsequent > filesystem sync is enqueued to ensure the latest files are synced right > before sleep. The framework still allows for an early abort in this case. > > [1]: https://lpc.events/event/18/contributions/1845/ > > Suggested-by: Saravana Kannan <saravanak@google.com> > Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > Signed-off-by: Samuel Wu <wusamuel@google.com> > > Samuel Wu (2): > PM: Add framework to abort during fs_sync > PM: Call pm_sleep_fs_sync() instead of ksys_sync_helper() Both patches applied as 6.19 material with updated subjects and changelogs, thanks!
© 2016 - 2025 Red Hat, Inc.