PM/Hibernation: Fix the early termination of test modes
Subsystems (2)
PATCH 1/1 PM/Hibernation: Fix the early termination of test modes
Commit 2aede851ddf08666f68ffc17be446420e9d2a056
(PM / Hibernate: Freeze kernel threads after preallocating memory) postponed the freezing of kernel threads to after preallocating memory for hibernation. But while doing that, the hibernation test TEST_FREEZER and the test mode HIBERNATION_TESTPROC were not moved accordingly.
As a result, when using these test modes, it only goes upto the freezing of userspace and exits, when in fact it should go till the complete end of task freezing stage, namely the freezing of kernel threads as well.
So, move these points of exit to appropriate places so that freezing of kernel threads is also tested while using these test harnesses. And while at it, add some documentation about these test modes.
---
Documentation/power/basic-pm-debugging.txt | 16 ++++++++++++---- kernel/power/hibernate.c | 28 ++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 10 deletions(-)
Documentation/power/basic-pm-debugging.txt +12 -4
@@ -38,10 +38,18 @@ identify what goes wrong. a) Test modes of hibernation -To find out why hibernation fails on your system, you can use a special testing -facility available if the kernel is compiled with CONFIG_PM_DEBUG set. Then, -there is the file /sys/power/pm_test that can be used to make the hibernation -core run in a test mode. There are 5 test modes available: +To find out why hibernation fails on your system, you can use some special +testing facilities available if the kernel is compiled with CONFIG_PM_DEBUG set. +Hibernation will then have 2 more modes that can be used, namely "testproc" and +"test". When the "testproc" mode is used, it executes everything upto the task +freezing phase and reverts back. When the "test" mode is used, it goes much +deeper down, stopping just short of actually hibernating the machine, and then +reverts back to normal state. + +However, there is an even more fine-grained debugging tool, also enabled by +setting CONFIG_PM_DEBUG: there appears a file /sys/power/pm_test that can be +used to make the hibernation core run in a test mode. +There are 5 test modes available: freezer - test the freezing of processes
kernel/power/hibernate.c +22 -6
@@ -55,6 +55,8 @@ enum {static int hibernation_mode =HIBERNATION_SHUTDOWN ; +static int freezer_test_done; +static const struct platform_hibernation_ops *hibernation_ops;/**
@@ -347,6 +349,17 @@ int hibernation_snapshot(int platform_mode)if (error) goto Close; +if (hibernation_test (TEST_FREEZER ) || +hibernation_testmode (HIBERNATION_TESTPROC )) { + +/* +* Indicate to the caller that we are returning due to a +* successful freezer test. +*/ + freezer_test_done =1 ; + goto Close; + } + error =dpm_prepare (PMSG_FREEZE );if (error) goto Complete_devices;
@@ -641,15 +654,13 @@ int hibernate(void)if (error) goto Finish; -if (hibernation_test (TEST_FREEZER )) - goto Thaw; - -if (hibernation_testmode (HIBERNATION_TESTPROC )) - goto Thaw; - error =hibernation_snapshot (hibernation_mode ==HIBERNATION_PLATFORM );if (error) goto Thaw; +if (freezer_test_done) { + freezer_test_done =0 ; + goto Thaw; + }if (in_suspend) {unsigned int flags =0 ;
@@ -864,6 +875,11 @@ static const char * const hibernation_modes[] = {* * If a platform hibernation driver is in use, 'platform' will be supported * and will be used by default. Otherwise, 'shutdown' will be used by default. +* The 2 test modes are useful only when CONFIG_PM_DEBUG is set. In that case, +* using the 'testproc' mode will do everything upto the freezing of tasks +* and exits after undoing all that it did. The 'test' mode is deeper, in that, +* it does everything except actually hibernating the machine and exits after +* restoring the machine back to its original state. * The selected option (i.e. the one corresponding to the current value of * hibernation_mode) is enclosed by a square bracket. *
Quoted 53 lines · Srivatsa S. Bhat
Commit
2aede851ddf08666f68ffc17be446420e9d2a056
(PM / Hibernate: Freeze kernel threads after preallocating memory) postponed the freezing of kernel threads to after preallocating memory for hibernation. But while doing that, the hibernation testTEST_FREEZERand the test modeHIBERNATION_TESTPROCwere not moved accordingly.As a result, when using these test modes, it only goes upto the freezing of userspace and exits, when in fact it should go till the complete end of task freezing stage, namely the freezing of kernel threads as well.
So, move these points of exit to appropriate places so that freezing of kernel threads is also tested while using these test harnesses. And while at it, add some documentation about these test modes.
Signed-off-by Srivatsa S. Bhat <[email protected]>---
Documentation/power/basic-pm-debugging.txt | 16 ++++++++++++---- kernel/power/hibernate.c | 28 ++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 10 deletions(-)Documentation/power/basic-pm-debugging.txt +12
-4@@ -38,10 +38,18 @@ identify what goes wrong. a) Test modes of hibernation -To find out why hibernation fails on your system, you can use a special testing -facility available if the kernel is compiled with CONFIG_PM_DEBUG set. Then, -there is the file /sys/power/pm_test that can be used to make the hibernation -core run in a test mode. There are 5 test modes available: +To find out why hibernation fails on your system, you can use some special +testing facilities available if the kernel is compiled with CONFIG_PM_DEBUG set. +Hibernation will then have 2 more modes that can be used, namely "testproc" and +"test". When the "testproc" mode is used, it executes everything upto the task +freezing phase and reverts back. When the "test" mode is used, it goes much +deeper down, stopping just short of actually hibernating the machine, and then +reverts back to normal state. + +However, there is an even more fine-grained debugging tool, also enabled by +setting CONFIG_PM_DEBUG: there appears a file /sys/power/pm_test that can be +used to make the hibernation core run in a test mode. +There are 5 test modes available: freezer - test the freezing of processeskernel/power/hibernate.c +0
-0
kernel/power/hibernate.c enum { · line 58
Quoted 4 lines
kernel/power/hibernate.c +1
-0@@ -55,6 +55,8 @@ enum {static int hibernation_mode =HIBERNATION_SHUTDOWN ; +static int freezer_test_done;
Make that a bool, please.
Quoted 6 lines
kernel/power/hibernate.c +1
-0+static const struct platform_hibernation_ops *hibernation_ops;/** @@ -347,6 +349,17 @@ int hibernation_snapshot(int platform_mode)if (error)
kernel/power/hibernate.c int hibernation_snapshot(int platform_mode) · line 359
Quoted 10 lines
kernel/power/hibernate.c +8
-0goto Close; +if (hibernation_test (TEST_FREEZER ) || +hibernation_testmode (HIBERNATION_TESTPROC )) { + +/* +* Indicate to the caller that we are returning due to a +* successful freezer test. +*/ + freezer_test_done =1 ;
And use 'true' here.
Quoted 29 lines
kernel/power/hibernate.c +7
-6+ goto Close; + } + error =dpm_prepare (PMSG_FREEZE );if (error) goto Complete_devices;@@ -641,15 +654,13 @@ int hibernate(void)if (error) goto Finish; -if (hibernation_test (TEST_FREEZER )) - goto Thaw; - -if (hibernation_testmode (HIBERNATION_TESTPROC )) - goto Thaw; - error =hibernation_snapshot (hibernation_mode ==HIBERNATION_PLATFORM );if (error) goto Thaw; +if (freezer_test_done) { + freezer_test_done =0 ; + goto Thaw; + }if (in_suspend) {unsigned int flags =0 ;@@ -864,6 +875,11 @@ static const char * const hibernation_modes[] = {*
kernel/power/hibernate.c static const char * const hibernation_modes[] = { · line 885
Quoted 10 lines
kernel/power/hibernate.c +5
-0* If a platform hibernation driver is in use, 'platform' will be supported * and will be used by default. Otherwise, 'shutdown' will be used by default. +* The 2 test modes are useful only when CONFIG_PM_DEBUG is set. In that case, +* using the 'testproc' mode will do everything upto the freezing of tasks +* and exits after undoing all that it did. The 'test' mode is deeper, in that, +* it does everything except actually hibernating the machine and exits after +* restoring the machine back to its original state. * The selected option (i.e. the one corresponding to the current value of * hibernation_mode) is enclosed by a square bracket. *
Thanks,
Rafael
Quoted 10 lines · Srivatsa S. Bhat
Commit
2aede851ddf08666f68ffc17be446420e9d2a056
(PM / Hibernate: Freeze kernel threads after preallocating memory) postponed the freezing of kernel threads to after preallocating memory for hibernation. But while doing that, the hibernation testTEST_FREEZERand the test modeHIBERNATION_TESTPROCwere not moved accordingly.As a result, when using these test modes, it only goes upto the freezing of userspace and exits, when in fact it should go till the complete end of task freezing stage, namely the freezing of kernel threads as well.
Quoted 5 lines
So, move these points of exit to appropriate places so that freezing of kernel threads is also tested while using these test harnesses. And while at it, add some documentation about these test modes.
Signed-off-by Srivatsa S. Bhat <[email protected]>
ACK.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html