public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Kexec jump: The first step to kexec base hibernation
@ 2007-07-11 15:30 Huang, Ying
  2007-07-11 11:13 ` Pavel Machek
  2007-07-12  0:22 ` Andrew Morton
  0 siblings, 2 replies; 125+ messages in thread
From: Huang, Ying @ 2007-07-11 15:30 UTC (permalink / raw)
  To: Pavel Machek, nigel, Rafael J. Wysocki, Jeremy Maitin-Shepard,
	Andrew Morton
  Cc: linux-kernel, linux-pm

Kexec base hibernation has some potential advantages over uswsusp and
suspend2. Some most obvious advantages are:

1. The hibernation image size can exceed half of memory size easily.
2. The hibernation image can be written to and read from almost
   anywhere, such as USB disk, NFS.

This patch implements the functionality of "jumping from kexeced
kernel to original kernel". That is, the following sequence is
possible:

1. Boot a kernel A
2. Work under kernel A
3. Kexec another kernel B in kernel A
4. Work under kernel B
5. Jump from kernel B to kernel A
6. Continue work under kernel A

This is the first step to implement kexec based hibernation. If the
memory image of kernel A is written to or read from a permanent media
in step 4, a preliminary version of kexec based hibernation can be
implemented.

The kernel B is run as a crashdump kernel in reserved memory
region. This is the biggest constrains of the patch. It is planed to
be eliminated in the next version. That is, instead of reserving memory
region previously, the needed memory region is backuped before kexec
and restored after jumping back.

Another constrains of the patch is that the CONFIG_ACPI must be turned
off to make kexec jump work. Because ACPI will put devices into low
power state, the kexeced kernel can not be booted properly under
it. This constrains can be eliminated by separating the suspend method
and hibernation method of the devices as proposed earlier in the LKML.

The kexec jump is implemented in the framework of software suspend. In
fact, the kexec based hibernation can be seen as just implementing the
image writing and reading method of software suspend with a kexeced
Linux kernel.

Now, only the i386 architecture is supported. The patch is based on
Linux kernel 2.6.22, and has been tested on my IBM T42.

Usage:

1. Compile kernel with following options selected:

CONFIG_X86_32=y
CONFIG_RELOCATABLE=y # not needed strictly, but it is more convenient with it
CONFIG_KEXEC=y
CONFIG_SOFTWARE_SUSPEND=y
CONFIG_KEXEC_HIBERNATION=y

2. Compile the kexec-tools with kdump and kjump patches added, the
   kdump patch can be found at:

http://lse.sourceforge.net/kdump/patches/kexec-tools-1.101-dkump10.patch

   While, the kexec-tools kjump patch is appended with the mail.

3. Boot compiled kernel, the reserved crash kernel memory region must
   be added to kernel command line as following:

   crashkernel=<XX>M@<XX>M

   Where, <XX> should be replaced by the real memory size and position.
Kexec jump - The first step to kexec base hibernation

Kexec base hibernation has some potential advantages over uswsusp and
suspend2. Some most obvious advantages are:

1. The hibernation image size can exceed half of memory size easily.
2. The hibernation image can be written to and read from almost
   anywhere, such as USB disk, NFS.

This patch implements the functionality of "jumping from kexeced
kernel to original kernel". That is, the following sequence is
possible:

1. Boot a kernel A
2. Work under kernel A
3. Kexec another kernel B in kernel A
4. Work under kernel B
5. Jump from kernel B to kernel A
6. Continue work under kernel A

This is the first step to implement kexec based hibernation. If the
memory image of kernel A is written to or read from a permanent media
in step 4, a preliminary version of kexec based hibernation can be
implemented.

The kernel B is run as a crashdump kernel in reserved memory
region. This is the biggest constrains of the patch. It is planed to
be eliminated in the next version. That is, instead of reserving memory
region previously, the needed memory region is backuped before kexec
and restored after jumping back.

Another constrains of the patch is that the CONFIG_ACPI must be turned
off to make kexec jump work. Because ACPI will put devices into low
power state, the kexeced kernel can not be booted properly under
it. This constrains can be eliminated by separating the suspend method
and hibernation method of the devices as proposed earlier in the LKML.

The kexec jump is implemented in the framework of software suspend. In
fact, the kexec based hibernation can be seen as just implementing the
image writing and reading method of software suspend with a kexeced
Linux kernel.

Now, only the i386 architecture is supported. The patch is based on
Linux kernel 2.6.22, and has been tested on my IBM T42.

Usage:

1. Compile kernel with following options selected:

CONFIG_X86_32=y
CONFIG_RELOCATABLE=y # not needed strictly, but it is more convenient with it
CONFIG_KEXEC=y
CONFIG_SOFTWARE_SUSPEND=y
CONFIG_KEXEC_HIBERNATION=y

2. Compile the kexec-tools with kdump and kjump patches added, the
   kdump patch can be found at:

http://lse.sourceforge.net/kdump/patches/kexec-tools-1.101-dkump10.patch

   While, the kexec-tools kjump patch is appended with the mail.

3. Boot compiled kernel, the reserved crash kernel memory region must
   be added to kernel command line as following:

   crashkernel=<XX>M@<XX>M

   Where, <XX> should be replaced by the real memory size and position.

4. Switch hibernation image operations, through shell command as follow:

   echo kexec > /sys/power/hibernation_image_ops

5. Boot the kexeced kernel as a crashdump kernel, the same kernel can
   be used if CONFIG_RELOCATABLE=y is selected. The kernel command
   line option as following must be appended to kernel command line.

   kexec_jump_buf_pfn=`cat /sys/kernel/kexec_jump_buf_pfn`

6. In the kexec booted kernel, switch hibernation image operations, as
   in 4.

7. In the kexec booted kernel, trigger the jumping back with following
   shell command.

   echo <a>:<b> > /sys/power/resume

   Where <a> and <b> is non-negative integer, at least one of them must
   be non-zero.

Hibernation image operations

This patch make it possible to have multiple implementations of
hibernation image operations such as write, read, check, etc, and they
can be switched at run time through writing the
"/sys/power/hibernation_image_ops". The uswsusp is the default
implementation.

Signed-off-by: Huang Ying <ying.huang@intel.com>

Kexec jump

This patch provide the kexec based implementation of hibernation image
operation. Now, only jumping between original kernel and kexeced
kernel is supported, real image write/read/check will be provided in
next patches.

Signed-off-by: Huang Ying <ying.huang@intel.com>

4. Switch hibernation image operations, through shell command as follow:

   echo kexec > /sys/power/hibernation_image_ops

5. Boot the kexeced kernel as a crashdump kernel, the same kernel Kexec jump - The first step to kexec base hibernation

Kexec base hibernation has some potential advantages over uswsusp and
suspend2. Some most obvious advantages are:

1. The hibernation image size can exceed half of memory size easily.
2. The hibernation image can be written to and read from almost
   anywhere, such as USB disk, NFS.

This patch implements the functionality of "jumping from kexeced
kernel to original kernel". That is, the following sequence is
possible:

1. Boot a kernel A
2. Work under kernel A
3. Kexec another kernel B in kernel A
4. Work under kernel B
5. Jump from kernel B to kernel A
6. Continue work under kernel A

This is the first step to implement kexec based hibernation. If the
memory image of kernel A is written to or read from a permanent media
in step 4, a preliminary version of kexec based hibernation can be
implemented.

The kernel B is run as a crashdump kernel in reserved memory
region. This is the biggest constrains of the patch. It is planed to
be eliminated in the next version. That is, instead of reserving memory
region previously, the needed memory region is backuped before kexec
and restored after jumping back.

Another constrains of the patch is that the CONFIG_ACPI must be turned
off to make kexec jump work. Because ACPI will put devices into low
power state, the kexeced kernel can not be booted properly under
it. This constrains can be eliminated by separating the suspend method
and hibernation method of the devices as proposed earlier in the LKML.

The kexec jump is implemented in the framework of software suspend. In
fact, the kexec based hibernation can be seen as just implementing the
image writing and reading method of software suspend with a kexeced
Linux kernel.

Now, only the i386 architecture is supported. The patch is based on
Linux kernel 2.6.22, and has been tested on my IBM T42.

Usage:

1. Compile kernel with following options selected:

CONFIG_X86_32=y
CONFIG_RELOCATABLE=y # not needed strictly, but it is more convenient with it
CONFIG_KEXEC=y
CONFIG_SOFTWARE_SUSPEND=y
CONFIG_KEXEC_HIBERNATION=y

2. Compile the kexec-tools with kdump and kjump patches added, the
   kdump patch can be found at:

http://lse.sourceforge.net/kdump/patches/kexec-tools-1.101-dkump10.patch

   While, the kexec-tools kjump patch is appended with the mail.

3. Boot compiled kernel, the reserved crash kernel memory region must
   be added to kernel command line as following:

   crashkernel=<XX>M@<XX>M

   Where, <XX> should be replaced by the real memory size and position.

4. Switch hibernation image operations, through shell command as follow:

   echo kexec > /sys/power/hibernation_image_ops

5. Boot the kexeced kernel as a crashdump kernel, the same kernel can
   be used if CONFIG_RELOCATABLE=y is selected. The kernel command
   line option as following must be appended to kernel command line.

   kexec_jump_buf_pfn=`cat /sys/kernel/kexec_jump_buf_pfn`

6. In the kexec booted kernel, switch hibernation image operations, as
   in 4.

7. In the kexec booted kernel, trigger the jumping back with following
   shell command.

   echo <a>:<b> > /sys/power/resume

   Where <a> and <b> is non-negative integer, at least one of them must
   be non-zero.

Hibernation image operations

This patch make it possible to have multiple implementations of
hibernation image operations such as write, read, check, etc, and they
can be switched at run time through writing the
"/sys/power/hibernation_image_ops". The uswsusp is the default
implementation.

Signed-off-by: Huang Ying <ying.huang@intel.com>

Kexec jump

This patch provide the kexec based implementation of hibernation image
operation. Now, only jumping between original kernel and kexeced
kernel is supported, real image write/read/check will be provided in
next patches.

Signed-off-by: Huang Ying <ying.huang@intel.com>
can
   be used if CONFIG_RELOCATABLE=y is selected. The kernel command
   line option as following must be appended to kernel command line.

   kexec_jump_buf_pfn=`cat /sys/kernel/kexec_jump_buf_pfn`

6. In the kexec booted kernel, switch hibernation image operations, as
   in 4.

7. In the kexec booted kernel, trigger the jumping back with following
   shell command.

   echo <a>:<b> > /sys/power/resume

   Where <a> and <b> is non-negative integer, at least one of them must
   be non-zero.

Index: kexec-tools-1.101/kexec/arch/i386/crashdump-x86.c
===================================================================
--- kexec-tools-1.101.orig/kexec/arch/i386/crashdump-x86.c	2007-07-08 15:00:25.000000000 +0000
+++ kexec-tools-1.101/kexec/arch/i386/crashdump-x86.c	2007-07-09 22:58:46.000000000 +0000
@@ -428,6 +428,33 @@
 	return 0;
 }
 
+/* Adds the kexec_backup= command line parameter to command line. */
+static int cmdline_add_backup(char *cmdline, unsigned long addr)
+{
+	int cmdlen, len, align = 1024;
+	char str[30], *ptr;
+
+	/* Passing in kexec_backup=xxxK format. Saves space required in cmdline.
+	 * Ensure 1K alignment*/
+	if (addr%align)
+		return -1;
+	addr = addr/align;
+	ptr = str;
+	strcpy(str, " kexec_backup=");
+	ptr += strlen(str);
+	ultoa(addr, ptr);
+	strcat(str, "K");
+	len = strlen(str);
+	cmdlen = strlen(cmdline) + len;
+	if (cmdlen > (COMMAND_LINE_SIZE - 1))
+		die("Command line overflow\n");
+	strcat(cmdline, str);
+#if 0
+		printf("Command line after adding backup\n");
+		printf("%s\n", cmdline);
+#endif
+	return 0;
+}
 
 /*
  * This routine is specific to i386 architecture to maintain the
@@ -724,5 +751,6 @@
 		return -1;
 	cmdline_add_memmap(mod_cmdline, memmap_p);
 	cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr);
+	cmdline_add_backup(mod_cmdline, info->backup_start);
 	return 0;
 }

^ permalink raw reply	[flat|nested] 125+ messages in thread
* Re: [PATCH 0/2] Kexec jump: The first step to kexec base
@ 2007-07-13  5:08 Al Boldi
  2007-07-13 15:28 ` [PATCH 0/2] Kexec jump: The first step to kexec base hibernation Al Boldi
  2007-07-13 15:28 ` Al Boldi
  0 siblings, 2 replies; 125+ messages in thread
From: Al Boldi @ 2007-07-13  5:08 UTC (permalink / raw)
  To: ying.huang; +Cc: linux-kernel

Huang, Ying wrote:
>
> Kexec jump - The first step to kexec base hibernation

Thanks a lot!

> Kexec base hibernation has some potential advantages over uswsusp and
> suspend2. Some most obvious advantages are:
>
> 1. The hibernation image size can exceed half of memory size easily.
> 2. The hibernation image can be written to and read from almost
>    anywhere, such as USB disk, NFS.
>
> This patch implements the functionality of "jumping from kexeced
> kernel to original kernel". That is, the following sequence is
> possible:
>
> 1. Boot a kernel A
> 2. Work under kernel A
> 3. Kexec another kernel B in kernel A
> 4. Work under kernel B
> 5. Jump from kernel B to kernel A
> 6. Continue work under kernel A

Great!

> This is the first step to implement kexec based hibernation. If the
> memory image of kernel A is written to or read from a permanent media
> in step 4, a preliminary version of kexec based hibernation can be
> implemented.

Sounds easy.

> The kernel B is run as a crashdump kernel in reserved memory
> region. This is the biggest constrains of the patch. It is planed to
> be eliminated in the next version. That is, instead of reserving memory
> region previously, the needed memory region is backuped before kexec
> and restored after jumping back.

Actually, backing up from within the normal kernel may produce 
inter-dependency deadlocks.  It's much better to just force-free some memory 
chunk out to swap.

> Another constrains of the patch is that the CONFIG_ACPI must be turned
> off to make kexec jump work. Because ACPI will put devices into low
> power state, the kexeced kernel can not be booted properly under
> it. This constrains can be eliminated by separating the suspend method
> and hibernation method of the devices as proposed earlier in the LKML.
>
> The kexec jump is implemented in the framework of software suspend. In
> fact, the kexec based hibernation can be seen as just implementing the
> image writing and reading method of software suspend with a kexeced
> Linux kernel.
>
> Now, only the i386 architecture is supported. The patch is based on
> Linux kernel 2.6.22, and has been tested on my IBM T42.
>
> Usage:
>
> 1. Compile kernel with following options selected:
>
> CONFIG_X86_32=y
> CONFIG_RELOCATABLE=y # not needed strictly, but it is more convenient with
> it CONFIG_KEXEC=y
> CONFIG_SOFTWARE_SUSPEND=y
> CONFIG_KEXEC_HIBERNATION=y

What about CONFIG_CRASH_DUMP=y ?
Also CONFIG_PHYSICAL_START=1000000 (=16M instead of default 1M).

> 2. Compile the kexec-tools with kdump and kjump patches added, the
>    kdump patch can be found at:
>
> http://lse.sourceforge.net/kdump/patches/kexec-tools-1.101-kdump10.patch
>
>    While, the kexec-tools kjump patch is appended with the mail.
>
> 3. Boot compiled kernel, the reserved crash kernel memory region must
>    be added to kernel command line as following:
>
>    crashkernel=<XX>M@<XX>M
>
>    Where, <XX> should be replaced by the real memory size and position.

Ok, booted with crashkernel=16M@16M.

> 4. Switch hibernation image operations, through shell command as follow:
>
>    echo kexec > /sys/power/hibernation_image_ops

Ok.

> 5. Boot the kexeced kernel as a crashdump kernel, the same kernel can
>    be used if CONFIG_RELOCATABLE=y is selected. The kernel command
>    line option as following must be appended to kernel command line.
>
>    kexec_jump_buf_pfn=`cat /sys/kernel/kexec_jump_buf_pfn`

You mean like:
# kexec -p vmlinux 
        --args-linux 
        --append="root=/dev/sda1 
                  kexec_jump_buf_pfn = `cat /sys/kernel/kexec_jump_buf_pfn`"

# cat c > /proc/sysrq

This loads ok.

> 6. In the kexec booted kernel, switch hibernation image operations, as
>    in 4.

Ok.

> 7. In the kexec booted kernel, trigger the jumping back with following
>    shell command.
>
>    echo <a>:<b> > /sys/power/resume
>
>    Where <a> and <b> is non-negative integer, at least one of them must
>    be non-zero.

This doesn't switch it, but rather reboots my machine.


Thanks!

--
Al


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

end of thread, other threads:[~2007-07-24 15:19 UTC | newest]

Thread overview: 125+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-11 15:30 [PATCH 0/2] Kexec jump: The first step to kexec base hibernation Huang, Ying
2007-07-11 11:13 ` Pavel Machek
2007-07-12 16:28   ` Huang, Ying
2007-07-12  8:54     ` Pavel Machek
2007-07-13 23:18       ` Huang, Ying
2007-07-12  0:22 ` Andrew Morton
2007-07-12  5:48   ` Jeremy Fitzhardinge
2007-07-12  6:43     ` david
2007-07-12 12:46       ` Rafael J. Wysocki
2007-07-12 13:51         ` Mark Lord
2007-07-12 14:49           ` Pavel Machek
2007-07-12 15:35           ` Rafael J. Wysocki
2007-07-12 16:03             ` Mark Lord
2007-07-12 16:35               ` Mark Lord
2007-07-12 20:05                 ` Jeremy Maitin-Shepard
2007-07-13  2:38                   ` Mark Lord
2007-07-12 16:09           ` [linux-pm] " Alan Stern
2007-07-12 18:49           ` david
2007-07-12 18:42         ` david
2007-07-12 19:20           ` Rafael J. Wysocki
2007-07-12 19:14             ` david
2007-07-12 19:45               ` Rafael J. Wysocki
2007-07-12 17:09     ` Huang, Ying
2007-07-12 12:47       ` Rafael J. Wysocki
2007-07-12 12:38   ` Rafael J. Wysocki
2007-07-12 14:43   ` Huang, Ying
2007-07-12  7:03     ` david
2007-07-12 17:18       ` Huang, Ying
2007-07-12 10:10         ` david
2007-07-12 13:01           ` Rafael J. Wysocki
2007-07-12 13:22             ` jimmy bahuleyan
2007-07-12 19:03             ` david
2007-07-12 13:55           ` Mark Lord
2007-07-12 19:05             ` david
2007-07-12 14:06           ` Pavel Machek
2007-07-12 12:53     ` Rafael J. Wysocki
2007-07-12 18:57       ` david
2007-07-12 19:34         ` Rafael J. Wysocki
2007-07-12 19:55           ` Jeremy Maitin-Shepard
2007-07-12 20:45             ` Rafael J. Wysocki
2007-07-13  3:12             ` david
2007-07-13  9:17               ` Rafael J. Wysocki
2007-07-13  9:25                 ` david
2007-07-13 11:41                   ` Rafael J. Wysocki
2007-07-14  7:51                     ` david
2007-07-14  8:33                       ` david
2007-07-14  9:24                         ` Rafael J. Wysocki
2007-07-14 20:00                       ` Rafael J. Wysocki
2007-07-14 20:34                         ` david
2007-07-14 21:06                           ` Rafael J. Wysocki
2007-07-14 21:13                             ` david
2007-07-15 10:31                               ` Rafael J. Wysocki
2007-07-15 19:23                                 ` david
2007-07-15 22:59                                   ` Rafael J. Wysocki
2007-07-15 23:22                                     ` david
2007-07-16 12:17                                       ` Rafael J. Wysocki
2007-07-16 14:42                                         ` Huang, Ying
2007-07-16 15:40                                           ` Rafael J. Wysocki
2007-07-17  4:18                                             ` david
2007-07-17 11:46                                               ` Rafael J. Wysocki
2007-07-14 21:34                         ` david
2007-07-15 10:39                           ` Rafael J. Wysocki
2007-07-15 19:33                             ` david
2007-07-15 23:11                               ` Rafael J. Wysocki
2007-07-15 23:33                                 ` david
2007-07-13  3:06           ` david
2007-07-13  5:42             ` Hibernating To Swap Considered Harmful Joseph Fannin
2007-07-13  5:57               ` david
2007-07-13  6:20                 ` Joseph Fannin
2007-07-13  6:27                   ` david
2007-07-13  7:15                     ` Joseph Fannin
2007-07-13 14:35                       ` Jeremy Maitin-Shepard
2007-07-17  0:12                         ` Joseph Fannin
2007-07-17  5:44                           ` Oliver Neukum
2007-07-17  6:28                             ` Joseph Fannin
2007-07-17  6:42                               ` david
2007-07-17  7:26                                 ` Joseph Fannin
2007-07-17  7:34                                   ` david
2007-07-17 11:54                                     ` Rafael J. Wysocki
2007-07-17 11:52                                   ` Rafael J. Wysocki
2007-07-17  7:10                               ` Oliver Neukum
2007-07-13  9:30               ` Rafael J. Wysocki
2007-07-14  0:45                 ` Joseph Fannin
2007-07-14  9:48                   ` Rafael J. Wysocki
2007-07-16  5:37                     ` Joseph Fannin
2007-07-13  9:29             ` [PATCH 0/2] Kexec jump: The first step to kexec base hibernation Rafael J. Wysocki
2007-07-13  9:38               ` david
2007-07-13 11:59                 ` Rafael J. Wysocki
2007-07-13 14:37                   ` [linux-pm] " Alan Stern
2007-07-13 15:31                     ` Rafael J. Wysocki
2007-07-14  7:13                     ` david
2007-07-13 15:12                   ` Jeremy Maitin-Shepard
2007-07-13 15:45                     ` Rafael J. Wysocki
2007-07-13 15:50                       ` Alan Stern
2007-07-13 16:54                         ` Eric W. Biederman
2007-07-13 18:15                           ` Alan Stern
2007-07-13 21:08                             ` Rafael J. Wysocki
2007-07-13 20:55                         ` Rafael J. Wysocki
2007-07-13 16:48                       ` Jeremy Maitin-Shepard
2007-07-13 21:23                         ` Rafael J. Wysocki
2007-07-14  7:12                   ` david
2007-07-13 17:32             ` Huang, Ying
2007-07-13 12:01               ` Rafael J. Wysocki
2007-07-12 16:32     ` Eric W. Biederman
2007-07-12 19:09       ` david
2007-07-12 19:49         ` Eric W. Biederman
2007-07-13 23:15       ` Huang, Ying
2007-07-13 16:43         ` Eric W. Biederman
2007-07-14  5:48           ` Huang, Ying
2007-07-14  9:59             ` Rafael J. Wysocki
2007-07-14 10:55               ` Huang, Ying
2007-07-14 19:16                 ` Rafael J. Wysocki
2007-07-15  9:30                   ` Huang, Ying
2007-07-15 10:49                     ` Rafael J. Wysocki
2007-07-24 14:00                       ` Huang, Ying
2007-07-24 15:27                         ` Rafael J. Wysocki
2007-07-17  8:13                     ` david
2007-07-17 11:59                       ` Rafael J. Wysocki
2007-07-17 12:48                       ` Huang, Ying
2007-07-17 14:22                         ` Rafael J. Wysocki
2007-07-18  0:25                           ` david
  -- strict thread matches above, loose matches on Subject: below --
2007-07-13  5:08 [PATCH 0/2] Kexec jump: The first step to kexec base Al Boldi
2007-07-13 15:28 ` [PATCH 0/2] Kexec jump: The first step to kexec base hibernation Al Boldi
2007-07-13 15:50   ` Rafael J. Wysocki
2007-07-14  6:07     ` Al Boldi
2007-07-13 15:28 ` Al Boldi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox