* [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl error/test paths @ 2011-12-01 13:15 Srivatsa S. Bhat 2011-12-01 15:47 ` Tejun Heo 0 siblings, 1 reply; 5+ messages in thread From: Srivatsa S. Bhat @ 2011-12-01 13:15 UTC (permalink / raw) To: rjw; +Cc: pavel, len.brown, tj, linux-kernel, linux-pm Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze kernel threads after preallocating memory) moved the freezing of kernel threads to hibernation_snapshot() function. So now, if the call to hibernation_snapshot() fails or returns early due to a successful hibernation test, the caller has to thaw processes to ensure that the system gets back to its original state. But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw processes. Fix this issue. But note that if hibernation_snapshot() returned due to a successful freezer test, we still send the value of 'in_suspend' (which is now 0) to userspace, because we are not in an error path per-se, and moreover, the value of in_suspend correctly depicts the situation here. Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> --- kernel/power/hibernate.c | 2 +- kernel/power/power.h | 2 ++ kernel/power/user.c | 13 ++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index a6b0503..624538a 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -55,7 +55,7 @@ enum { static int hibernation_mode = HIBERNATION_SHUTDOWN; -static bool freezer_test_done; +bool freezer_test_done; static const struct platform_hibernation_ops *hibernation_ops; diff --git a/kernel/power/power.h b/kernel/power/power.h index 23a2db1..0c4defe 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -50,6 +50,8 @@ static inline char *check_image_kernel(struct swsusp_info *info) #define SPARE_PAGES ((1024 * 1024) >> PAGE_SHIFT) /* kernel/power/hibernate.c */ +extern bool freezer_test_done; + extern int hibernation_snapshot(int platform_mode); extern int hibernation_restore(int platform_mode); extern int hibernation_platform_enter(void); diff --git a/kernel/power/user.c b/kernel/power/user.c index 6d8f535..b98b7e1 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c @@ -283,10 +283,17 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, } pm_restore_gfp_mask(); error = hibernation_snapshot(data->platform_support); - if (!error) + if (error) { + thaw_processes(); + } else { error = put_user(in_suspend, (int __user *)arg); - if (!error) - data->ready = 1; + if (!error && !freezer_test_done) + data->ready = 1; + if (freezer_test_done) { + freezer_test_done = false; + thaw_processes(); + } + } break; case SNAPSHOT_ATOMIC_RESTORE: ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl error/test paths 2011-12-01 13:15 [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl error/test paths Srivatsa S. Bhat @ 2011-12-01 15:47 ` Tejun Heo 2011-12-01 16:28 ` Srivatsa S. Bhat 0 siblings, 1 reply; 5+ messages in thread From: Tejun Heo @ 2011-12-01 15:47 UTC (permalink / raw) To: Srivatsa S. Bhat; +Cc: rjw, pavel, len.brown, linux-kernel, linux-pm On Thu, Dec 01, 2011 at 06:45:37PM +0530, Srivatsa S. Bhat wrote: > Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze > kernel threads after preallocating memory) moved the freezing of kernel > threads to hibernation_snapshot() function. > > So now, if the call to hibernation_snapshot() fails or returns early due > to a successful hibernation test, the caller has to thaw processes to > ensure that the system gets back to its original state. > > But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw > processes. Fix this issue. But note that if hibernation_snapshot() returned > due to a successful freezer test, we still send the value of 'in_suspend' > (which is now 0) to userspace, because we are not in an error path per-se, > and moreover, the value of in_suspend correctly depicts the situation here. > > Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Is this still applicable on top of pm-freezer branch? Thanks. -- tejun ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl error/test paths 2011-12-01 15:47 ` Tejun Heo @ 2011-12-01 16:28 ` Srivatsa S. Bhat 2011-12-01 21:53 ` Rafael J. Wysocki 2011-12-02 19:30 ` Pavel Machek 0 siblings, 2 replies; 5+ messages in thread From: Srivatsa S. Bhat @ 2011-12-01 16:28 UTC (permalink / raw) To: Tejun Heo; +Cc: rjw, pavel, len.brown, linux-kernel, linux-pm On 12/01/2011 09:17 PM, Tejun Heo wrote: > On Thu, Dec 01, 2011 at 06:45:37PM +0530, Srivatsa S. Bhat wrote: >> Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze >> kernel threads after preallocating memory) moved the freezing of kernel >> threads to hibernation_snapshot() function. >> >> So now, if the call to hibernation_snapshot() fails or returns early due >> to a successful hibernation test, the caller has to thaw processes to >> ensure that the system gets back to its original state. >> >> But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw >> processes. Fix this issue. But note that if hibernation_snapshot() returned >> due to a successful freezer test, we still send the value of 'in_suspend' >> (which is now 0) to userspace, because we are not in an error path per-se, >> and moreover, the value of in_suspend correctly depicts the situation here. >> >> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> > > Is this still applicable on top of pm-freezer branch? > Well, yes, but not in this form. Thanks for bringing that up! If the call to hibernation_snapshot() returns an error, we need not do anything since your freezer changes handle that case and call thaw_processes() automatically. But in case of return due to a successful freezer test, we would need to explicitly thaw processes since the freezer successfully froze them in the previous step. So the following patch would do that, for the pm-freezer branch: --- From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Subject: [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl test path Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze kernel threads after preallocating memory) moved the freezing of kernel threads to hibernation_snapshot() function. So now, if the call to hibernation_snapshot() returns early due to a successful hibernation test, the caller has to thaw processes to ensure that the system gets back to its original state. But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw processes in case hibernation_snapshot() returned due to a successful freezer test. Fix this issue. But note we still send the value of 'in_suspend' (which is now 0) to userspace, because we are not in an error path per-se, and moreover, the value of in_suspend correctly depicts the situation here. Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> --- kernel/power/hibernate.c | 2 +- kernel/power/power.h | 2 ++ kernel/power/user.c | 11 ++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 80c2d90..57bab63 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -55,7 +55,7 @@ enum { static int hibernation_mode = HIBERNATION_SHUTDOWN; -static bool freezer_test_done; +bool freezer_test_done; static const struct platform_hibernation_ops *hibernation_ops; diff --git a/kernel/power/power.h b/kernel/power/power.h index 23a2db1..0c4defe 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -50,6 +50,8 @@ static inline char *check_image_kernel(struct swsusp_info *info) #define SPARE_PAGES ((1024 * 1024) >> PAGE_SHIFT) /* kernel/power/hibernate.c */ +extern bool freezer_test_done; + extern int hibernation_snapshot(int platform_mode); extern int hibernation_restore(int platform_mode); extern int hibernation_platform_enter(void); diff --git a/kernel/power/user.c b/kernel/power/user.c index 7cc3f5b..c202e2e 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c @@ -281,10 +281,15 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, } pm_restore_gfp_mask(); error = hibernation_snapshot(data->platform_support); - if (!error) + if (!error) { error = put_user(in_suspend, (int __user *)arg); - if (!error) - data->ready = 1; + if (!error && !freezer_test_done) + data->ready = 1; + if (freezer_test_done) { + freezer_test_done = false; + thaw_processes(); + } + } break; case SNAPSHOT_ATOMIC_RESTORE: ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl error/test paths 2011-12-01 16:28 ` Srivatsa S. Bhat @ 2011-12-01 21:53 ` Rafael J. Wysocki 2011-12-02 19:30 ` Pavel Machek 1 sibling, 0 replies; 5+ messages in thread From: Rafael J. Wysocki @ 2011-12-01 21:53 UTC (permalink / raw) To: Srivatsa S. Bhat; +Cc: Tejun Heo, pavel, len.brown, linux-kernel, linux-pm On Thursday, December 01, 2011, Srivatsa S. Bhat wrote: > On 12/01/2011 09:17 PM, Tejun Heo wrote: > > > On Thu, Dec 01, 2011 at 06:45:37PM +0530, Srivatsa S. Bhat wrote: > >> Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze > >> kernel threads after preallocating memory) moved the freezing of kernel > >> threads to hibernation_snapshot() function. > >> > >> So now, if the call to hibernation_snapshot() fails or returns early due > >> to a successful hibernation test, the caller has to thaw processes to > >> ensure that the system gets back to its original state. > >> > >> But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw > >> processes. Fix this issue. But note that if hibernation_snapshot() returned > >> due to a successful freezer test, we still send the value of 'in_suspend' > >> (which is now 0) to userspace, because we are not in an error path per-se, > >> and moreover, the value of in_suspend correctly depicts the situation here. > >> > >> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> > > > > Is this still applicable on top of pm-freezer branch? > > > > > Well, yes, but not in this form. Thanks for bringing that up! > > If the call to hibernation_snapshot() returns an error, we need not do > anything since your freezer changes handle that case and call thaw_processes() > automatically. > But in case of return due to a successful freezer test, we would need to > explicitly thaw processes since the freezer successfully froze them in the > previous step. > > So the following patch would do that, for the pm-freezer branch: > > --- > From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> > Subject: [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl test path > > Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze > kernel threads after preallocating memory) moved the freezing of kernel > threads to hibernation_snapshot() function. > > So now, if the call to hibernation_snapshot() returns early due to a > successful hibernation test, the caller has to thaw processes to ensure > that the system gets back to its original state. > > But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw > processes in case hibernation_snapshot() returned due to a successful > freezer test. Fix this issue. But note we still send the value of 'in_suspend' > (which is now 0) to userspace, because we are not in an error path per-se, > and moreover, the value of in_suspend correctly depicts the situation here. > > Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Applied to linux-pm/linux-next. Thanks, Rafael > --- > > kernel/power/hibernate.c | 2 +- > kernel/power/power.h | 2 ++ > kernel/power/user.c | 11 ++++++++--- > 3 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c > index 80c2d90..57bab63 100644 > --- a/kernel/power/hibernate.c > +++ b/kernel/power/hibernate.c > @@ -55,7 +55,7 @@ enum { > > static int hibernation_mode = HIBERNATION_SHUTDOWN; > > -static bool freezer_test_done; > +bool freezer_test_done; > > static const struct platform_hibernation_ops *hibernation_ops; > > diff --git a/kernel/power/power.h b/kernel/power/power.h > index 23a2db1..0c4defe 100644 > --- a/kernel/power/power.h > +++ b/kernel/power/power.h > @@ -50,6 +50,8 @@ static inline char *check_image_kernel(struct swsusp_info *info) > #define SPARE_PAGES ((1024 * 1024) >> PAGE_SHIFT) > > /* kernel/power/hibernate.c */ > +extern bool freezer_test_done; > + > extern int hibernation_snapshot(int platform_mode); > extern int hibernation_restore(int platform_mode); > extern int hibernation_platform_enter(void); > diff --git a/kernel/power/user.c b/kernel/power/user.c > index 7cc3f5b..c202e2e 100644 > --- a/kernel/power/user.c > +++ b/kernel/power/user.c > @@ -281,10 +281,15 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, > } > pm_restore_gfp_mask(); > error = hibernation_snapshot(data->platform_support); > - if (!error) > + if (!error) { > error = put_user(in_suspend, (int __user *)arg); > - if (!error) > - data->ready = 1; > + if (!error && !freezer_test_done) > + data->ready = 1; > + if (freezer_test_done) { > + freezer_test_done = false; > + thaw_processes(); > + } > + } > break; > > case SNAPSHOT_ATOMIC_RESTORE: > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-pm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl error/test paths 2011-12-01 16:28 ` Srivatsa S. Bhat 2011-12-01 21:53 ` Rafael J. Wysocki @ 2011-12-02 19:30 ` Pavel Machek 1 sibling, 0 replies; 5+ messages in thread From: Pavel Machek @ 2011-12-02 19:30 UTC (permalink / raw) To: Srivatsa S. Bhat; +Cc: Tejun Heo, rjw, len.brown, linux-kernel, linux-pm > On 12/01/2011 09:17 PM, Tejun Heo wrote: > > > On Thu, Dec 01, 2011 at 06:45:37PM +0530, Srivatsa S. Bhat wrote: > >> Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze > >> kernel threads after preallocating memory) moved the freezing of kernel > >> threads to hibernation_snapshot() function. > >> > >> So now, if the call to hibernation_snapshot() fails or returns early due > >> to a successful hibernation test, the caller has to thaw processes to > >> ensure that the system gets back to its original state. > >> > >> But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw > >> processes. Fix this issue. But note that if hibernation_snapshot() returned > >> due to a successful freezer test, we still send the value of 'in_suspend' > >> (which is now 0) to userspace, because we are not in an error path per-se, > >> and moreover, the value of in_suspend correctly depicts the situation here. > >> > >> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> > > > > Is this still applicable on top of pm-freezer branch? > > > > > Well, yes, but not in this form. Thanks for bringing that up! > > If the call to hibernation_snapshot() returns an error, we need not do > anything since your freezer changes handle that case and call thaw_processes() > automatically. > But in case of return due to a successful freezer test, we would need to > explicitly thaw processes since the freezer successfully froze them in the > previous step. > > So the following patch would do that, for the pm-freezer branch: > > --- > From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> > Subject: [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl test path > > Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze > kernel threads after preallocating memory) moved the freezing of kernel > threads to hibernation_snapshot() function. > > So now, if the call to hibernation_snapshot() returns early due to a > successful hibernation test, the caller has to thaw processes to ensure > that the system gets back to its original state. > > But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw > processes in case hibernation_snapshot() returned due to a successful > freezer test. Fix this issue. But note we still send the value of 'in_suspend' > (which is now 0) to userspace, because we are not in an error path per-se, > and moreover, the value of in_suspend correctly depicts the situation here. > > Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Ack. -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-12-02 19:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-12-01 13:15 [PATCH] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl error/test paths Srivatsa S. Bhat 2011-12-01 15:47 ` Tejun Heo 2011-12-01 16:28 ` Srivatsa S. Bhat 2011-12-01 21:53 ` Rafael J. Wysocki 2011-12-02 19:30 ` Pavel Machek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox