Skip to contentSkip to conversation

power: suspend: Add suspend timeout handler

PATCH In review [email protected] 2 participants 3 messages Oct 16, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: suspend: Add suspend timeout handler

Thank you Rafael's promptly response.

Quoted 50 lines · Joseph Jang
Quoted 37 lines

From: josephjang <[email protected]>

Add suspend timeout handler to prevent device stuck during suspend/ resume process. Suspend timeout handler will dump disk sleep task at first round timeout and trigger kernel panic at second round timeout. The default timer for each round is 30 seconds.

Note: Can use following command to simulate suspend hang for testing.
adb shell echo 1 > /sys/power/pm_hang
adb shell echo mem > /sys/power/state

---
 include/linux/console.h |   1 +
 kernel/power/Kconfig    |   9 +++
 kernel/power/main.c     |  66 ++++++++++++++++
 kernel/power/suspend.c  | 162 ++++++++++++++++++++++++++++++++++++++++
 kernel/printk/printk.c  |   5 ++
 5 files changed, 243 insertions(+)
include/linux/console.h +1 -0
index 0670d3491e0e..ac468c602c0b 100644
@@ -192,6 +192,7 @@ static inline void console_sysfs_notify(void)
 { }
 #endif
 extern bool console_suspend_enabled;
+extern int is_console_suspended(void);
 
 /* Suspend and resume console messages over PM events */
 extern void suspend_console(void);
kernel/power/Kconfig +0 -0
index a7320f07689d..52b7a181b6d8 100644

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 215

Quoted 9 lines
kernel/power/Kconfig +6 -0
@@ -207,6 +207,15 @@ config PM_SLEEP_DEBUG
        def_bool y
        depends on PM_DEBUG && PM_SLEEP
 
+config PM_SLEEP_MONITOR
+       bool "Linux kernel suspend/resume process monitor"
+       depends on PM_SLEEP
+       help
+       This option will enable suspend/resume monitor to prevent device
+       stuck during suspend/resume process. Suspend timeout handler  

will

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 216

Quoted 1 line
kernel/power/Kconfig +1 -0
+       dump disk sleep task at first round timeout and trigger kernel  

panic

Quoted 14 lines

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 217

Quoted 1 line
kernel/power/Kconfig +1 -0
+       at second round timeout. The default timer for each round is 30  

seconds.

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 218

Quoted 1 line
kernel/power/Kconfig +1 -0
+

The facility associated with the Kconfig entry right below is supposed to do exactly the same thing.

What's the reason to add another one? What is missing?

Quoted 3 lines
kernel/power/Kconfig +0 -0
 config DPM_WATCHDOG
        bool "Device suspend/resume watchdog"
        depends on PM_DEBUG && PSTORE && EXPERT

Because we found some suspend hand issue that cannot be detected by "CONFIG_DPM_WATCHDOG" (which is focus on device PM).
Our suspend timeout monitor can cover PM core and Device PM hang issues.

Thank you,
Joseph.

#1 lore raw
Quoted 64 lines · On Fri, Oct 16, 2020 at 3:22 PM <[email protected]> wrote:

Thank you Rafael's promptly response.

Quoted 58 lines · Joseph Jang
Quoted 37 lines

From: josephjang <[email protected]>

Add suspend timeout handler to prevent device stuck during suspend/ resume process. Suspend timeout handler will dump disk sleep task at first round timeout and trigger kernel panic at second round timeout. The default timer for each round is 30 seconds.

Note: Can use following command to simulate suspend hang for testing.
adb shell echo 1 > /sys/power/pm_hang
adb shell echo mem > /sys/power/state

---
 include/linux/console.h |   1 +
 kernel/power/Kconfig    |   9 +++
 kernel/power/main.c     |  66 ++++++++++++++++
 kernel/power/suspend.c  | 162 ++++++++++++++++++++++++++++++++++++++++
 kernel/printk/printk.c  |   5 ++
 5 files changed, 243 insertions(+)
include/linux/console.h +1 -0
index 0670d3491e0e..ac468c602c0b 100644
@@ -192,6 +192,7 @@ static inline void console_sysfs_notify(void)
 { }
 #endif
 extern bool console_suspend_enabled;
+extern int is_console_suspended(void);
 
 /* Suspend and resume console messages over PM events */
 extern void suspend_console(void);
kernel/power/Kconfig +0 -0
index a7320f07689d..52b7a181b6d8 100644

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 215

Quoted 9 lines
kernel/power/Kconfig +6 -0
@@ -207,6 +207,15 @@ config PM_SLEEP_DEBUG
        def_bool y
        depends on PM_DEBUG && PM_SLEEP
 
+config PM_SLEEP_MONITOR
+       bool "Linux kernel suspend/resume process monitor"
+       depends on PM_SLEEP
+       help
+       This option will enable suspend/resume monitor to prevent device
+       stuck during suspend/resume process. Suspend timeout handler

will

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 216

Quoted 1 line
kernel/power/Kconfig +1 -0
+       dump disk sleep task at first round timeout and trigger kernel

panic

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 217

Quoted 1 line
kernel/power/Kconfig +1 -0
+       at second round timeout. The default timer for each round is 30

seconds.

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 218

Quoted 1 line
kernel/power/Kconfig +1 -0
+

The facility associated with the Kconfig entry right below is supposed to do exactly the same thing.

What's the reason to add another one? What is missing?

Quoted 6 lines
Quoted 3 lines

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 221

Quoted 3 lines
kernel/power/Kconfig +0 -0
 config DPM_WATCHDOG
        bool "Device suspend/resume watchdog"
        depends on PM_DEBUG && PSTORE && EXPERT

Because we found some suspend hand issue that cannot be detected by "CONFIG_DPM_WATCHDOG" (which is focus on device PM).

What's that issue?

Quoted 1 line

Our suspend timeout monitor can cover PM core and Device PM hang issues.

Then I'd suggest to extend the existing watchdog instead of adding a whole new implementation.

#2 lore raw

Yes, I agree.

Rafael J. Wysocki <[email protected]> 於 2020年10月16日 週五 下午9:24寫道:

Quoted 79 lines · On Fri, Oct 16, 2020 at 3:22 PM <[email protected]> wrote:
Quoted 64 lines

Thank you Rafael's promptly response.

Quoted 58 lines · Joseph Jang
Quoted 37 lines

From: josephjang <[email protected]>

Add suspend timeout handler to prevent device stuck during suspend/ resume process. Suspend timeout handler will dump disk sleep task at first round timeout and trigger kernel panic at second round timeout. The default timer for each round is 30 seconds.

Note: Can use following command to simulate suspend hang for testing.
adb shell echo 1 > /sys/power/pm_hang
adb shell echo mem > /sys/power/state

---
 include/linux/console.h |   1 +
 kernel/power/Kconfig    |   9 +++
 kernel/power/main.c     |  66 ++++++++++++++++
 kernel/power/suspend.c  | 162 ++++++++++++++++++++++++++++++++++++++++
 kernel/printk/printk.c  |   5 ++
 5 files changed, 243 insertions(+)
include/linux/console.h +1 -0
index 0670d3491e0e..ac468c602c0b 100644
@@ -192,6 +192,7 @@ static inline void console_sysfs_notify(void)
 { }
 #endif
 extern bool console_suspend_enabled;
+extern int is_console_suspended(void);
 
 /* Suspend and resume console messages over PM events */
 extern void suspend_console(void);
kernel/power/Kconfig +0 -0
index a7320f07689d..52b7a181b6d8 100644

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 215

Quoted 9 lines
kernel/power/Kconfig +6 -0
@@ -207,6 +207,15 @@ config PM_SLEEP_DEBUG
        def_bool y
        depends on PM_DEBUG && PM_SLEEP
 
+config PM_SLEEP_MONITOR
+       bool "Linux kernel suspend/resume process monitor"
+       depends on PM_SLEEP
+       help
+       This option will enable suspend/resume monitor to prevent device
+       stuck during suspend/resume process. Suspend timeout handler

will

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 216

Quoted 1 line
kernel/power/Kconfig +1 -0
+       dump disk sleep task at first round timeout and trigger kernel

panic

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 217

Quoted 1 line
kernel/power/Kconfig +1 -0
+       at second round timeout. The default timer for each round is 30

seconds.

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 218

Quoted 1 line
kernel/power/Kconfig +1 -0
+

The facility associated with the Kconfig entry right below is supposed to do exactly the same thing.

What's the reason to add another one? What is missing?

Quoted 6 lines
Quoted 3 lines

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 221

Quoted 3 lines
kernel/power/Kconfig +0 -0
 config DPM_WATCHDOG
        bool "Device suspend/resume watchdog"
        depends on PM_DEBUG && PSTORE && EXPERT

Because we found some suspend hand issue that cannot be detected by "CONFIG_DPM_WATCHDOG" (which is focus on device PM).

What's that issue?

Quoted 1 line

Our suspend timeout monitor can cover PM core and Device PM hang issues.

Then I'd suggest to extend the existing watchdog instead of adding a whole new implementation.

Signature · 1 line
Embedded Software engineer