All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] PM / Hibernate: Fixes related to user space interface
@ 2011-05-06 22:29 Rafael J. Wysocki
  2011-05-06 22:30 ` [PATCH 1/3] PM: Fix warning in pm_restrict_gfp_mask() during SNAPSHOT_S2RAM ioctl Rafael J. Wysocki
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2011-05-06 22:29 UTC (permalink / raw)
  To: Linux PM mailing list; +Cc: LKML, Alexandre Felipe Muller de Souza

Hi,

The following three patches fix bugs related to the hibernate user space
interface:

[1/3] - Fix warning from pm_restrict_gfp_mask() in the SNAPSHOT_S2RAM ioctl
        code path.

[2/3] - Make snapshot_release() call pm_restore_gfp_mask() if tasks weren't
        thawed before.

[3/3] - Make the SNAPSHOT_S2RAM clear data->ready.

With all of these patches applied, s2both actually works on my Toshiba test
machine, which is nice. :-)

Many thanks to Alexandre for turning my attention to these problems.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] PM: Fix warning in pm_restrict_gfp_mask() during SNAPSHOT_S2RAM ioctl
  2011-05-06 22:29 [PATCH 0/3] PM / Hibernate: Fixes related to user space interface Rafael J. Wysocki
  2011-05-06 22:30 ` [PATCH 1/3] PM: Fix warning in pm_restrict_gfp_mask() during SNAPSHOT_S2RAM ioctl Rafael J. Wysocki
@ 2011-05-06 22:30 ` Rafael J. Wysocki
  2011-05-06 22:31 ` [PATCH 2/3] PM / Hibernate: Make snapshot_release() restore GFP mask Rafael J. Wysocki
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2011-05-06 22:30 UTC (permalink / raw)
  To: Linux PM mailing list; +Cc: LKML, Alexandre Felipe Muller de Souza

From: Rafael J. Wysocki <rjw@sisk.pl>

A warning is printed by pm_restrict_gfp_mask() while the
SNAPSHOT_S2RAM ioctl is being executed after creating a hibernation
image, because pm_restrict_gfp_mask() has been called once already
before the image creation and suspend_devices_and_enter() calls it
once again.  This happens after commit 452aa6999e6703ffbddd7f6ea124d3
(mm/pm: force GFP_NOIO during suspend/hibernation and resume).

To avoid this issue, move pm_restrict_gfp_mask() and
pm_restore_gfp_mask() from suspend_devices_and_enter() to its caller
in kernel/power/suspend.c.

Reported-by: Alexandre Felipe Muller de Souza <alexandrefm@mandriva.com.br>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/suspend.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6/kernel/power/suspend.c
===================================================================
--- linux-2.6.orig/kernel/power/suspend.c
+++ linux-2.6/kernel/power/suspend.c
@@ -210,7 +210,6 @@ int suspend_devices_and_enter(suspend_st
 			goto Close;
 	}
 	suspend_console();
-	pm_restrict_gfp_mask();
 	suspend_test_start();
 	error = dpm_suspend_start(PMSG_SUSPEND);
 	if (error) {
@@ -227,7 +226,6 @@ int suspend_devices_and_enter(suspend_st
 	suspend_test_start();
 	dpm_resume_end(PMSG_RESUME);
 	suspend_test_finish("resume devices");
-	pm_restore_gfp_mask();
 	resume_console();
  Close:
 	if (suspend_ops->end)
@@ -288,7 +286,9 @@ int enter_state(suspend_state_t state)
 		goto Finish;
 
 	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
+	pm_restrict_gfp_mask();
 	error = suspend_devices_and_enter(state);
+	pm_restore_gfp_mask();
 
  Finish:
 	pr_debug("PM: Finishing wakeup.\n");


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] PM: Fix warning in pm_restrict_gfp_mask() during SNAPSHOT_S2RAM ioctl
  2011-05-06 22:29 [PATCH 0/3] PM / Hibernate: Fixes related to user space interface Rafael J. Wysocki
@ 2011-05-06 22:30 ` Rafael J. Wysocki
  2011-05-06 22:30 ` Rafael J. Wysocki
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2011-05-06 22:30 UTC (permalink / raw)
  To: Linux PM mailing list; +Cc: LKML, Alexandre Felipe Muller de Souza

From: Rafael J. Wysocki <rjw@sisk.pl>

A warning is printed by pm_restrict_gfp_mask() while the
SNAPSHOT_S2RAM ioctl is being executed after creating a hibernation
image, because pm_restrict_gfp_mask() has been called once already
before the image creation and suspend_devices_and_enter() calls it
once again.  This happens after commit 452aa6999e6703ffbddd7f6ea124d3
(mm/pm: force GFP_NOIO during suspend/hibernation and resume).

To avoid this issue, move pm_restrict_gfp_mask() and
pm_restore_gfp_mask() from suspend_devices_and_enter() to its caller
in kernel/power/suspend.c.

Reported-by: Alexandre Felipe Muller de Souza <alexandrefm@mandriva.com.br>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/suspend.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6/kernel/power/suspend.c
===================================================================
--- linux-2.6.orig/kernel/power/suspend.c
+++ linux-2.6/kernel/power/suspend.c
@@ -210,7 +210,6 @@ int suspend_devices_and_enter(suspend_st
 			goto Close;
 	}
 	suspend_console();
-	pm_restrict_gfp_mask();
 	suspend_test_start();
 	error = dpm_suspend_start(PMSG_SUSPEND);
 	if (error) {
@@ -227,7 +226,6 @@ int suspend_devices_and_enter(suspend_st
 	suspend_test_start();
 	dpm_resume_end(PMSG_RESUME);
 	suspend_test_finish("resume devices");
-	pm_restore_gfp_mask();
 	resume_console();
  Close:
 	if (suspend_ops->end)
@@ -288,7 +286,9 @@ int enter_state(suspend_state_t state)
 		goto Finish;
 
 	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
+	pm_restrict_gfp_mask();
 	error = suspend_devices_and_enter(state);
+	pm_restore_gfp_mask();
 
  Finish:
 	pr_debug("PM: Finishing wakeup.\n");

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] PM / Hibernate: Make snapshot_release() restore GFP mask
  2011-05-06 22:29 [PATCH 0/3] PM / Hibernate: Fixes related to user space interface Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2011-05-06 22:31 ` [PATCH 2/3] PM / Hibernate: Make snapshot_release() restore GFP mask Rafael J. Wysocki
@ 2011-05-06 22:31 ` Rafael J. Wysocki
  2011-05-06 22:32 ` [PATCH 3/3] PM / Hibernate: Fix ioctl SNAPSHOT_S2RAM Rafael J. Wysocki
  2011-05-06 22:32 ` Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2011-05-06 22:31 UTC (permalink / raw)
  To: Linux PM mailing list; +Cc: LKML, Alexandre Felipe Muller de Souza

From: Rafael J. Wysocki <rjw@sisk.pl>

If the process using the hibernate user space interface closes
/dev/snapshot after creating a hibernation image without thawing
tasks, snapshot_release() should call pm_restore_gfp_mask() to
restore the GFP mask used before the creation of the image.  Make
that happen.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/user.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/power/user.c
===================================================================
--- linux-2.6.orig/kernel/power/user.c
+++ linux-2.6/kernel/power/user.c
@@ -135,8 +135,10 @@ static int snapshot_release(struct inode
 	free_basic_memory_bitmaps();
 	data = filp->private_data;
 	free_all_swap_pages(data->swap);
-	if (data->frozen)
+	if (data->frozen) {
+		pm_restore_gfp_mask();
 		thaw_processes();
+	}
 	pm_notifier_call_chain(data->mode == O_RDONLY ?
 			PM_POST_HIBERNATION : PM_POST_RESTORE);
 	atomic_inc(&snapshot_device_available);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] PM / Hibernate: Make snapshot_release() restore GFP mask
  2011-05-06 22:29 [PATCH 0/3] PM / Hibernate: Fixes related to user space interface Rafael J. Wysocki
  2011-05-06 22:30 ` [PATCH 1/3] PM: Fix warning in pm_restrict_gfp_mask() during SNAPSHOT_S2RAM ioctl Rafael J. Wysocki
  2011-05-06 22:30 ` Rafael J. Wysocki
@ 2011-05-06 22:31 ` Rafael J. Wysocki
  2011-05-06 22:31 ` Rafael J. Wysocki
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2011-05-06 22:31 UTC (permalink / raw)
  To: Linux PM mailing list; +Cc: LKML, Alexandre Felipe Muller de Souza

From: Rafael J. Wysocki <rjw@sisk.pl>

If the process using the hibernate user space interface closes
/dev/snapshot after creating a hibernation image without thawing
tasks, snapshot_release() should call pm_restore_gfp_mask() to
restore the GFP mask used before the creation of the image.  Make
that happen.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/user.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/power/user.c
===================================================================
--- linux-2.6.orig/kernel/power/user.c
+++ linux-2.6/kernel/power/user.c
@@ -135,8 +135,10 @@ static int snapshot_release(struct inode
 	free_basic_memory_bitmaps();
 	data = filp->private_data;
 	free_all_swap_pages(data->swap);
-	if (data->frozen)
+	if (data->frozen) {
+		pm_restore_gfp_mask();
 		thaw_processes();
+	}
 	pm_notifier_call_chain(data->mode == O_RDONLY ?
 			PM_POST_HIBERNATION : PM_POST_RESTORE);
 	atomic_inc(&snapshot_device_available);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] PM / Hibernate: Fix ioctl SNAPSHOT_S2RAM
  2011-05-06 22:29 [PATCH 0/3] PM / Hibernate: Fixes related to user space interface Rafael J. Wysocki
                   ` (3 preceding siblings ...)
  2011-05-06 22:31 ` Rafael J. Wysocki
@ 2011-05-06 22:32 ` Rafael J. Wysocki
  2011-05-06 22:32 ` Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2011-05-06 22:32 UTC (permalink / raw)
  To: Linux PM mailing list; +Cc: LKML, Alexandre Felipe Muller de Souza

From: Rafael J. Wysocki <rjw@sisk.pl>

The SNAPSHOT_S2RAM ioctl used for implementing the feature allowing
one to suspend to RAM after creating a hibernation image is currently
broken, because it doesn't clear the "ready" flag in the struct
snapshot_data object handled by it.  As a result, the
SNAPSHOT_UNFREEZE doesn't work correctly after SNAPSHOT_S2RAM has
returned and the user space hibernate task cannot thaw the other
processes as appropriate.  Make SNAPSHOT_S2RAM clear data->ready
to fix this problem.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/user.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6/kernel/power/user.c
===================================================================
--- linux-2.6.orig/kernel/power/user.c
+++ linux-2.6/kernel/power/user.c
@@ -381,6 +381,7 @@ static long snapshot_ioctl(struct file *
 		 * PM_HIBERNATION_PREPARE
 		 */
 		error = suspend_devices_and_enter(PM_SUSPEND_MEM);
+		data->ready = 0;
 		break;
 
 	case SNAPSHOT_PLATFORM_SUPPORT:


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] PM / Hibernate: Fix ioctl SNAPSHOT_S2RAM
  2011-05-06 22:29 [PATCH 0/3] PM / Hibernate: Fixes related to user space interface Rafael J. Wysocki
                   ` (4 preceding siblings ...)
  2011-05-06 22:32 ` [PATCH 3/3] PM / Hibernate: Fix ioctl SNAPSHOT_S2RAM Rafael J. Wysocki
@ 2011-05-06 22:32 ` Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2011-05-06 22:32 UTC (permalink / raw)
  To: Linux PM mailing list; +Cc: LKML, Alexandre Felipe Muller de Souza

From: Rafael J. Wysocki <rjw@sisk.pl>

The SNAPSHOT_S2RAM ioctl used for implementing the feature allowing
one to suspend to RAM after creating a hibernation image is currently
broken, because it doesn't clear the "ready" flag in the struct
snapshot_data object handled by it.  As a result, the
SNAPSHOT_UNFREEZE doesn't work correctly after SNAPSHOT_S2RAM has
returned and the user space hibernate task cannot thaw the other
processes as appropriate.  Make SNAPSHOT_S2RAM clear data->ready
to fix this problem.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/user.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6/kernel/power/user.c
===================================================================
--- linux-2.6.orig/kernel/power/user.c
+++ linux-2.6/kernel/power/user.c
@@ -381,6 +381,7 @@ static long snapshot_ioctl(struct file *
 		 * PM_HIBERNATION_PREPARE
 		 */
 		error = suspend_devices_and_enter(PM_SUSPEND_MEM);
+		data->ready = 0;
 		break;
 
 	case SNAPSHOT_PLATFORM_SUPPORT:

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-05-06 22:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 22:29 [PATCH 0/3] PM / Hibernate: Fixes related to user space interface Rafael J. Wysocki
2011-05-06 22:30 ` [PATCH 1/3] PM: Fix warning in pm_restrict_gfp_mask() during SNAPSHOT_S2RAM ioctl Rafael J. Wysocki
2011-05-06 22:30 ` Rafael J. Wysocki
2011-05-06 22:31 ` [PATCH 2/3] PM / Hibernate: Make snapshot_release() restore GFP mask Rafael J. Wysocki
2011-05-06 22:31 ` Rafael J. Wysocki
2011-05-06 22:32 ` [PATCH 3/3] PM / Hibernate: Fix ioctl SNAPSHOT_S2RAM Rafael J. Wysocki
2011-05-06 22:32 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.