diff options
| author | Harry Pan <harry.pan@intel.com> | 2019-02-25 07:36:41 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-04-02 04:53:19 -0400 |
| commit | b5dee3130bb4014511f5d0dd46855ed843e3fdc8 (patch) | |
| tree | d9abfcf2fc0743aa3283653c27655fee6b4f5487 | |
| parent | 74a1dd86d1739eae2015a3832f62c1d6546893a7 (diff) | |
PM / sleep: Refactor filesystems sync to reduce duplication
Create a common helper to sync filesystems for system suspend and
hibernation.
Signed-off-by: Harry Pan <harry.pan@intel.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
[ rjw: Changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
| -rw-r--r-- | include/linux/suspend.h | 3 | ||||
| -rw-r--r-- | kernel/power/hibernate.c | 5 | ||||
| -rw-r--r-- | kernel/power/main.c | 9 | ||||
| -rw-r--r-- | kernel/power/suspend.c | 13 | ||||
| -rw-r--r-- | kernel/power/user.c | 5 |
5 files changed, 19 insertions, 16 deletions
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 3f529ad9a9d2..6b3ea9ea6a9e 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
| @@ -425,6 +425,7 @@ void restore_processor_state(void); | |||
| 425 | /* kernel/power/main.c */ | 425 | /* kernel/power/main.c */ |
| 426 | extern int register_pm_notifier(struct notifier_block *nb); | 426 | extern int register_pm_notifier(struct notifier_block *nb); |
| 427 | extern int unregister_pm_notifier(struct notifier_block *nb); | 427 | extern int unregister_pm_notifier(struct notifier_block *nb); |
| 428 | extern void ksys_sync_helper(void); | ||
| 428 | 429 | ||
| 429 | #define pm_notifier(fn, pri) { \ | 430 | #define pm_notifier(fn, pri) { \ |
| 430 | static struct notifier_block fn##_nb = \ | 431 | static struct notifier_block fn##_nb = \ |
| @@ -462,6 +463,8 @@ static inline int unregister_pm_notifier(struct notifier_block *nb) | |||
| 462 | return 0; | 463 | return 0; |
| 463 | } | 464 | } |
| 464 | 465 | ||
| 466 | static inline void ksys_sync_helper(void) {} | ||
| 467 | |||
| 465 | #define pm_notifier(fn, pri) do { (void)(fn); } while (0) | 468 | #define pm_notifier(fn, pri) do { (void)(fn); } while (0) |
| 466 | 469 | ||
| 467 | static inline bool pm_wakeup_pending(void) { return false; } | 470 | static inline bool pm_wakeup_pending(void) { return false; } |
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index abef759de7c8..cc105ecd9c07 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | 14 | ||
| 15 | #include <linux/export.h> | 15 | #include <linux/export.h> |
| 16 | #include <linux/suspend.h> | 16 | #include <linux/suspend.h> |
| 17 | #include <linux/syscalls.h> | ||
| 18 | #include <linux/reboot.h> | 17 | #include <linux/reboot.h> |
| 19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
| 20 | #include <linux/device.h> | 19 | #include <linux/device.h> |
| @@ -709,9 +708,7 @@ int hibernate(void) | |||
| 709 | goto Exit; | 708 | goto Exit; |
| 710 | } | 709 | } |
| 711 | 710 | ||
| 712 | pr_info("Syncing filesystems ... \n"); | 711 | ksys_sync_helper(); |
| 713 | ksys_sync(); | ||
| 714 | pr_info("done.\n"); | ||
| 715 | 712 | ||
| 716 | error = freeze_processes(); | 713 | error = freeze_processes(); |
| 717 | if (error) | 714 | if (error) |
diff --git a/kernel/power/main.c b/kernel/power/main.c index 98e76cad128b..40472a7c5536 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <linux/debugfs.h> | 16 | #include <linux/debugfs.h> |
| 17 | #include <linux/seq_file.h> | 17 | #include <linux/seq_file.h> |
| 18 | #include <linux/suspend.h> | 18 | #include <linux/suspend.h> |
| 19 | #include <linux/syscalls.h> | ||
| 19 | 20 | ||
| 20 | #include "power.h" | 21 | #include "power.h" |
| 21 | 22 | ||
| @@ -51,6 +52,14 @@ void unlock_system_sleep(void) | |||
| 51 | } | 52 | } |
| 52 | EXPORT_SYMBOL_GPL(unlock_system_sleep); | 53 | EXPORT_SYMBOL_GPL(unlock_system_sleep); |
| 53 | 54 | ||
| 55 | void ksys_sync_helper(void) | ||
| 56 | { | ||
| 57 | pr_info("Syncing filesystems ... "); | ||
| 58 | ksys_sync(); | ||
| 59 | pr_cont("done.\n"); | ||
| 60 | } | ||
| 61 | EXPORT_SYMBOL_GPL(ksys_sync_helper); | ||
| 62 | |||
| 54 | /* Routines for PM-transition notifications */ | 63 | /* Routines for PM-transition notifications */ |
| 55 | 64 | ||
| 56 | static BLOCKING_NOTIFIER_HEAD(pm_chain_head); | 65 | static BLOCKING_NOTIFIER_HEAD(pm_chain_head); |
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 0bd595a0b610..e39059dea38b 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | #include <linux/console.h> | 17 | #include <linux/console.h> |
| 18 | #include <linux/cpu.h> | 18 | #include <linux/cpu.h> |
| 19 | #include <linux/cpuidle.h> | 19 | #include <linux/cpuidle.h> |
| 20 | #include <linux/syscalls.h> | ||
| 21 | #include <linux/gfp.h> | 20 | #include <linux/gfp.h> |
| 22 | #include <linux/io.h> | 21 | #include <linux/io.h> |
| 23 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
| @@ -568,13 +567,11 @@ static int enter_state(suspend_state_t state) | |||
| 568 | if (state == PM_SUSPEND_TO_IDLE) | 567 | if (state == PM_SUSPEND_TO_IDLE) |
| 569 | s2idle_begin(); | 568 | s2idle_begin(); |
| 570 | 569 | ||
| 571 | #ifndef CONFIG_SUSPEND_SKIP_SYNC | 570 | if (!IS_ENABLED(CONFIG_SUSPEND_SKIP_SYNC)) { |
| 572 | trace_suspend_resume(TPS("sync_filesystems"), 0, true); | 571 | trace_suspend_resume(TPS("sync_filesystems"), 0, true); |
| 573 | pr_info("Syncing filesystems ... "); | 572 | ksys_sync_helper(); |
| 574 | ksys_sync(); | 573 | trace_suspend_resume(TPS("sync_filesystems"), 0, false); |
| 575 | pr_cont("done.\n"); | 574 | } |
| 576 | trace_suspend_resume(TPS("sync_filesystems"), 0, false); | ||
| 577 | #endif | ||
| 578 | 575 | ||
| 579 | pm_pr_dbg("Preparing system for sleep (%s)\n", mem_sleep_labels[state]); | 576 | pm_pr_dbg("Preparing system for sleep (%s)\n", mem_sleep_labels[state]); |
| 580 | pm_suspend_clear_flags(); | 577 | pm_suspend_clear_flags(); |
diff --git a/kernel/power/user.c b/kernel/power/user.c index 2d8b60a3c86b..cb24e840a3e6 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #include <linux/suspend.h> | 12 | #include <linux/suspend.h> |
| 13 | #include <linux/syscalls.h> | ||
| 14 | #include <linux/reboot.h> | 13 | #include <linux/reboot.h> |
| 15 | #include <linux/string.h> | 14 | #include <linux/string.h> |
| 16 | #include <linux/device.h> | 15 | #include <linux/device.h> |
| @@ -228,9 +227,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
| 228 | if (data->frozen) | 227 | if (data->frozen) |
| 229 | break; | 228 | break; |
| 230 | 229 | ||
| 231 | printk("Syncing filesystems ... "); | 230 | ksys_sync_helper(); |
| 232 | ksys_sync(); | ||
| 233 | printk("done.\n"); | ||
| 234 | 231 | ||
| 235 | error = freeze_processes(); | 232 | error = freeze_processes(); |
| 236 | if (error) | 233 | if (error) |
