linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nigel Cunningham <nigel@tuxonice.net>
To: linux-pm@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, tuxonice-devel@lists.tuxonice.net
Cc: Nigel Cunningham <nigel@tuxonice.net>
Subject: [PATCH 17/19] TuxOnIce: Support for replacing swsusp.
Date: Thu,  7 May 2009 00:39:13 +1000	[thread overview]
Message-ID: <1241620755-22133-18-git-send-email-nigel@tuxonice.net> (raw)
In-Reply-To: <1241620755-22133-1-git-send-email-nigel@tuxonice.net>

Provide support for activating TuxOnIce via

	echo disk > /sys/power/state

together with a compile time option to control the default and a sysfs
entry in TuxOnIce's directories to toggle it at run time. Since at
resume time we don't know whether we wrote a TuxOnIce image, always
check for TuxOnIce images when checking for swsusp images (TuxOnIce
recognises swsusp signatures and won't complain about them).

Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
---
 kernel/power/Kconfig              |   14 ++++++++++++++
 kernel/power/disk.c               |   10 ++++++++++
 kernel/power/tuxonice.h           |    1 +
 kernel/power/tuxonice_builtin.c   |    3 +++
 kernel/power/tuxonice_highlevel.c |    2 ++
 5 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index f669cdd..dfe0328 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -259,6 +259,20 @@ menuconfig TOI_CORE
 		  bit. Keep image mode is a little less user friendly on purpose - it
 		  should not be used without thought!
 
+	config TOI_REPLACE_SWSUSP
+		bool "Replace swsusp by default"
+		default y
+		depends on TOI_CORE
+		---help---
+		  TuxOnIce can replace swsusp. This option makes that the default state,
+		  requiring you to echo 0 > /sys/power/tuxonice/replace_swsusp if you want
+		  to use the vanilla kernel functionality. Note that your initrd/ramfs will
+		  need to do this before trying to resume, too.
+		  With overriding swsusp enabled, echoing disk  to /sys/power/state will
+		  start a TuxOnIce cycle. If resume= doesn't specify an allocator and both
+		  the swap and file allocators are compiled in, the swap allocator will be
+		  used by default.
+
 	config TOI_IGNORE_LATE_INITCALL
 		bool "Wait for initrd/ramfs to run, by default"
 		default n
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 9a1174c..510730a 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -556,6 +556,9 @@ int hibernate(void)
 {
 	int error;
 
+	if (test_action_state(TOI_REPLACE_SWSUSP))
+		return try_tuxonice_hibernate();
+
 	mutex_lock(&pm_mutex);
 	/* The snapshot device should not be opened while we're running */
 	if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
@@ -637,6 +640,13 @@ int software_resume(void)
 {
 	int error;
 	unsigned int flags;
+	resume_attempted = 1;
+
+	/*
+	 * We can't know (until an image header - if any - is loaded), whether
+	 * we did override swsusp. We therefore ensure that both are tried.
+	 */
+	try_tuxonice_resume();
 
 	/*
 	 * If the user said "noresume".. bail out early.
diff --git a/kernel/power/tuxonice.h b/kernel/power/tuxonice.h
index 2262973..1d6349d 100644
--- a/kernel/power/tuxonice.h
+++ b/kernel/power/tuxonice.h
@@ -55,6 +55,7 @@ enum {
 	TOI_TEST_BIO,
 	TOI_NO_PAGESET2,
 	TOI_IGNORE_ROOTFS,
+	TOI_REPLACE_SWSUSP,
 	TOI_PAGESET2_FULL,
 	TOI_ABORT_ON_RESAVE_NEEDED,
 	TOI_NO_MULTITHREADED_IO,
diff --git a/kernel/power/tuxonice_builtin.c b/kernel/power/tuxonice_builtin.c
index dab9de2..da7680e 100644
--- a/kernel/power/tuxonice_builtin.c
+++ b/kernel/power/tuxonice_builtin.c
@@ -165,6 +165,9 @@ struct toi_boot_kernel_data toi_bkd __nosavedata
 		__attribute__((aligned(PAGE_SIZE))) = {
 	MY_BOOT_KERNEL_DATA_VERSION,
 	0,
+#ifdef CONFIG_TOI_REPLACE_SWSUSP
+	(1 << TOI_REPLACE_SWSUSP) |
+#endif
 	(1 << TOI_NO_FLUSHER_THREAD) |
 	(1 << TOI_PAGESET2_FULL) | (1 << TOI_LATE_CPU_HOTPLUG),
 };
diff --git a/kernel/power/tuxonice_highlevel.c b/kernel/power/tuxonice_highlevel.c
index 06f97e7..9bd5b34 100644
--- a/kernel/power/tuxonice_highlevel.c
+++ b/kernel/power/tuxonice_highlevel.c
@@ -1190,6 +1190,8 @@ static struct toi_sysfs_data sysfs_params[] = {
 	SYSFS_BIT("full_pageset2", SYSFS_RW, &toi_bkd.toi_action,
 			TOI_PAGESET2_FULL, 0),
 	SYSFS_BIT("reboot", SYSFS_RW, &toi_bkd.toi_action, TOI_REBOOT, 0),
+	SYSFS_BIT("replace_swsusp", SYSFS_RW, &toi_bkd.toi_action,
+			TOI_REPLACE_SWSUSP, 0),
 	SYSFS_STRING("resume_commandline", SYSFS_RW,
 			toi_bkd.toi_nosave_commandline, COMMAND_LINE_SIZE, 0,
 			NULL),
-- 
1.5.6.3


  parent reply	other threads:[~2009-05-06 14:53 UTC|newest]

Thread overview: 141+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-06 14:38 [RFC] TuxOnIce Nigel Cunningham
2009-05-06 14:38 ` [PATCH 1/19] TuxOnIce: Documentation Nigel Cunningham
2009-05-16 20:10   ` Vegard Nossum
2009-05-16 22:18     ` Nigel Cunningham
2009-05-06 14:38 ` [PATCH 2/19] TuxOnIce: GEMS support Nigel Cunningham
2009-05-06 14:38 ` [PATCH 3/19] TuxOnIce: Make drop_pagecache non-static and declared in mm.h Nigel Cunningham
2009-05-06 14:39 ` [PATCH 4/19] TuxOnIce: Add support for just thawing kernel threads Nigel Cunningham
2009-05-06 14:39 ` [PATCH 5/19] TuxOnIce: Create means of determining how many pages can be allocated Nigel Cunningham
2009-05-06 14:39 ` [PATCH 6/19] TuxOnIce: Make functions and variables shared with swsusp non-static Nigel Cunningham
2009-05-06 14:39 ` [PATCH 7/19] TuxOnIce: Modify swsusp bitmaps to allow modification during scanning Nigel Cunningham
2009-05-06 14:39 ` [PATCH 8/19] TuxOnIce: Add core TuxOnIce code Nigel Cunningham
2009-05-06 14:39 ` [PATCH 9/19] TuxOnIce: Netlink support Nigel Cunningham
2009-05-06 21:03   ` Sam Ravnborg
2009-05-06 21:35     ` Nigel Cunningham
2009-05-07  4:34       ` Sam Ravnborg
2009-05-06 14:39 ` [PATCH 10/19] TuxOnIce: Storage manager support Nigel Cunningham
2009-05-06 14:39 ` [PATCH 11/19] TuxOnIce: Block I/O engine Nigel Cunningham
2009-05-06 14:39 ` [PATCH 12/19] TuxOnIce: Compression support Nigel Cunningham
2009-05-06 14:39 ` [PATCH 13/19] TuxOnIce: File allocator Nigel Cunningham
2009-05-06 14:39 ` [PATCH 14/19] TuxOnIce: Swap support Nigel Cunningham
2009-05-06 14:39 ` [PATCH 15/19] TuxOnIce: Userspace user interface support Nigel Cunningham
2009-05-06 14:39 ` [PATCH 16/19] TuxOnIce: Warn user if an initrd doesn't include an attempt at resuming Nigel Cunningham
2009-05-06 14:39 ` Nigel Cunningham [this message]
2009-05-06 14:39 ` [PATCH 18/19] TuxOnIce: Provide a means of determining the freezer state Nigel Cunningham
2009-05-06 14:39 ` [PATCH 19/19] TuxOnIce: Don't try to wake kswapd if the freezer is on Nigel Cunningham
2009-05-07 12:09 ` [RFC] TuxOnIce Pavel Machek
2009-05-07 15:28   ` [TuxOnIce-devel] " Kenneth Crudup
2009-05-07 17:05     ` Kenneth Crudup
2009-05-09  9:10       ` Stefan Richter
2009-05-10  5:37       ` Pavel Machek
2009-05-10  5:37     ` Pavel Machek
2009-05-07 16:55   ` U Kuehn
2009-05-07 17:45     ` Rafael J. Wysocki
2009-05-07 17:49       ` Kenneth Crudup
2009-05-07 18:54         ` Fabio Comolli
2009-05-07 18:57           ` Kenneth Crudup
2009-05-07 17:52       ` Matt Price
2009-05-07 18:22         ` Rafael J. Wysocki
2009-05-07 18:57           ` Fabio Comolli
2009-05-07 19:27             ` Rafael J. Wysocki
2009-05-07 20:41               ` Nigel Cunningham
2009-05-07 23:14                 ` Jesse Barnes
2009-05-07 23:32                   ` Nigel Cunningham
2009-05-07 23:43                     ` Jesse Barnes
2009-05-08  0:13                       ` Nigel Cunningham
2009-05-08  0:39                         ` Jesse Barnes
2009-05-08  0:49                           ` Nigel Cunningham
2009-05-08  0:18                       ` Rafael J. Wysocki
2009-05-07 21:46             ` Pavel Machek
2009-05-08  7:11               ` Fabio Comolli
2009-05-07 21:42     ` Pavel Machek
2009-05-08  0:11     ` Alex Goebel
2009-05-07 17:42   ` Rafael J. Wysocki
2009-05-07 20:37     ` Nigel Cunningham
2009-05-07 21:51     ` Pavel Machek
2009-05-08  1:34       ` [TuxOnIce-devel] " Nigel Cunningham
2009-05-08 14:11         ` Rafael J. Wysocki
2009-05-08 21:52           ` Nigel Cunningham
2009-05-08 22:46             ` Rafael J. Wysocki
2009-05-08 23:30               ` Nigel Cunningham
2009-05-08 23:43                 ` Rafael J. Wysocki
2009-05-25 10:05                   ` Nigel Cunningham
2009-05-25 12:43                     ` Pavel Machek
2009-05-25 13:15                       ` Nigel Cunningham
2009-05-25 21:43                     ` Rafael J. Wysocki
     [not found]                       ` <1243288705.16743.129.camel@nigel-laptop>
2009-05-25 22:39                         ` Rafael J. Wysocki
2009-05-26  0:39                           ` Nigel Cunningham
2009-05-26 22:27                             ` Rafael J. Wysocki
2009-05-27  0:02                               ` Nigel Cunningham
2009-05-27 18:26                                 ` [linux-pm] " Len Brown
2009-05-25 22:45                       ` Oliver Neukum
2009-05-25 22:58                         ` Rafael J. Wysocki
2009-05-25 23:13                           ` Oliver Neukum
2009-05-27 14:38                             ` Martin Steigerwald
2009-05-26  0:42                           ` Nigel Cunningham
2009-05-26  9:19                           ` Pavel Machek
2009-05-26 11:07                             ` Oliver Neukum
2009-05-26 21:33                               ` Nigel Cunningham
2009-05-26 21:56                                 ` [linux-pm] " Alan Stern
2009-05-26 22:24                                   ` Oliver Neukum
2009-05-27  0:00                                     ` Nigel Cunningham
2009-05-26 23:59                                   ` Nigel Cunningham
2009-05-26 21:36                               ` Pavel Machek
2009-05-26 21:29                             ` Nigel Cunningham
2009-05-26 22:51                           ` Oliver Neukum
2009-05-26 23:10                             ` Rafael J. Wysocki
2009-05-26  0:42                         ` Nigel Cunningham
2009-05-08 23:44                 ` Ray Lee
2009-05-27 19:10                   ` Len Brown
2009-05-27 23:43                     ` Nigel Cunningham
2009-05-09 13:54                 ` Pavel Machek
2009-05-25  9:53                   ` Nigel Cunningham
2009-05-25 22:02                     ` Rafael J. Wysocki
2009-05-26  0:19                       ` Nigel Cunningham
2009-05-26 22:37                         ` Rafael J. Wysocki
2009-05-27  0:06                           ` Nigel Cunningham
2009-05-28 11:50                     ` Pavel Machek
2009-05-09 13:27               ` Pavel Machek
2009-05-09 19:32                 ` Rafael J. Wysocki
2009-05-09 22:22                   ` Nigel Cunningham
2009-05-14  9:16                   ` Pavel Machek
2009-05-16 23:11                     ` Nigel Cunningham
2009-05-09 13:03           ` Pavel Machek
2009-05-08 19:44         ` Bartlomiej Zolnierkiewicz
2009-05-08 21:03           ` Rafael J. Wysocki
2009-05-08 22:37             ` Nigel Cunningham
2009-05-08 21:59           ` Nigel Cunningham
2009-05-08 23:05             ` Bartlomiej Zolnierkiewicz
2009-05-08 23:15               ` Nigel Cunningham
2009-05-09 13:58                 ` Pavel Machek
2009-05-25  9:27                   ` Nigel Cunningham
2009-05-25 12:32                     ` Pavel Machek
2009-05-25 13:22                       ` Oliver Neukum
2009-05-25 13:26                         ` Pavel Machek
2009-05-25 21:50                           ` Nigel Cunningham
2009-05-25 21:39                       ` Nigel Cunningham
2009-05-25 22:29                         ` Oliver Neukum
2009-05-26  0:28                           ` Nigel Cunningham
2009-05-26  0:35                           ` david
2009-05-26  0:47                             ` Nigel Cunningham
2009-05-26  8:43                           ` Pavel Machek
2009-05-26 10:56                             ` Oliver Neukum
2009-05-09 11:12             ` Pekka Enberg
2009-05-07 22:37   ` trekker.dk
2009-05-08  1:17     ` Shannon McMackin
2009-05-08 21:47       ` Fabio Comolli
2009-05-10  5:38       ` Pavel Machek
2009-05-11 20:10         ` Vladislav Bolkhovitin
2009-05-10  5:38     ` Pavel Machek
2009-05-11 21:19       ` trekker.dk
2009-05-11 21:23         ` Pavel Machek
2009-05-13 20:19           ` trekker.dk
2009-05-13 20:24             ` Pavel Machek
2009-05-13 22:07               ` trekker.dk
2009-05-11 23:23         ` Alex Goebel
2009-05-16 19:07 ` Martin Steigerwald
2009-05-17  2:53   ` Matt Price
2009-05-17  3:06     ` Nigel Cunningham
2009-05-17  3:24       ` Matt Price
2009-05-17  3:57 ` Benjamin Herrenschmidt
2009-05-17  5:02   ` Nigel Cunningham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1241620755-22133-18-git-send-email-nigel@tuxonice.net \
    --to=nigel@tuxonice.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=tuxonice-devel@lists.tuxonice.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).