swsusp: allow resume from initramfs
Subsystems (3)
Hi!
From: [email protected]
When using a fully modularized kernel it is necessary to activate resume manually as the device node might not be available during kernel init.
This patch implements a new sysfs attribute '/sys/power/resume' which allows for manual activation of software resume. When read from it prints the configured resume device in 'major:minor' format. When written to it expects a device in 'major:minor' format. This device is then checked for a suspended image and resume is started if a valid image is found. The original functionality is left in place.
It should be used very carefully. I'll submit docs what that means; usage from initramfs should be okay.
Please apply,
Pavel
include/linux/suspend.h renamed from /include/linux/suspend.h +2 -0
@@ -35,6 +35,8 @@#define SUSPEND_PD_PAGES (x) (((x)*sizeof(struct pbe))/PAGE_SIZE+1) + +extern dev_t swsusp_resume_device;/* mm/vmscan.c */ extern int shrink_mem (void );
init/do_mounts.c renamed from /init/do_mounts.c +2 -2
@@ -53,7 +53,7 @@__setup ("ro" , readonly);__setup ("rw" , readwrite); -static dev_t __init try_name (char *name,int part) +static dev_t try_name (char *name,int part) {char path[64 ];char buf[32 ];
@@ -135,7 +135,7 @@* is mounted on rootfs /sys. */ -dev_t __init name_to_dev_t (char *name) +dev_t name_to_dev_t (char *name) {char s[32 ];char *p;
kernel/power/disk.c renamed from /kernel/power/disk.c +82 -17
183 lines not on this page · raw message
kernel/power/swsusp.c renamed from /kernel/power/swsusp.c +75 -26
211 lines not on this page · raw message
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Quoted 4 lines · Pavel Machek
When using a fully modularized kernel it is necessary to activate
resume manually as the device node might not be available during kernel init.
I don't understand how this can be affected by the modularness of the kernel. Can you explain a little more?
Would it not be simpler to just add "resume=03:02" to the boot command line?
Quoted 11 lines · Andrew Morton
Quoted 4 lines · Pavel Machek
When using a fully modularized kernel it is necessary to activate
resume manually as the device node might not be available during kernel init.I don't understand how this can be affected by the modularness of the kernel. Can you explain a little more?
Would it not be simpler to just add "resume=03:02" to the boot command line?
Problem is if 03:02 is IDE module, and you don't have it built into kernel. Then you want to insmod it from initramfs, and only then activate resume.
For some reasons (probably good ones) distributions insists on having everything as modules. At least SuSE and Debian want this... It also allows stuff like graphically asking "you booted wrong kernel, do you want me to wipe the signature, or will you reboot the correct kernel", because you can do it userspace in initrd before actually calling resume.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Quoted 2 lines · Andrew Morton
I don't understand how this can be affected by the modularness of the kernel. Can you explain a little more?
normally, resume takes place _before_ the initramfs is entered. If your swap device depends on a module that is loaded from initramfs, you are lost.
This patch (or the version in the kernel i am running right now at least) still does this (resume early), but if it does not find a device, it allows resume to be triggered from initramfs after the module is loaded.
Excerpt from dmesg on my machine (i did boot and not resume this time):
[...]
TCP established hash table entries: 32768 (order: 6, 262144 bytes) TCP bind hash table entries: 32768 (order: 5, 131072 bytes)
TCP: Hash tables configured (established 32768 bind 32768)
NET: Registered protocol family 1
PM: Checking swsusp image.
PM: Resume from disk failed.
ACPI wakeup devices:
LID PBTN PCI0 USB0 USB1 USB2 USB3 MODM PCIE
ACPI: (supports S0 S1 S3 S4 S4bios S5)
Freeing unused kernel memory: 204k freed
input: AT Translated Set 2 keyboard on isa0060/serio0
input: PS/2 Generic Mouse on isa0060/serio1
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ICH4: IDE controller at PCI slot 0000:00:1f.1
PCI: Enabling device 0000:00:1f.1 (0005 -> 0007)
ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 11
PCI: setting IRQ 11 as level-triggered
ACPI: PCI interrupt 0000:00:1f.1[A] -> GSI 11 (level, low) -> IRQ 11
ICH4: chipset revision 1
ICH4: not 100% native mode: will probe irqs later
ide0: BM-DMA at 0xbfa0-0xbfa7, BIOS settings: hda:DMA, hdb:pio
ide1: BM-DMA at 0xbfa8-0xbfaf, BIOS settings: hdc:DMA, hdd:pioProbing IDE interface ide0...
hda: IC25N060ATMR04-0, ATA DISK drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
Probing IDE interface ide1...
hdc: HL-DT-STCD-RW/DVD-ROM GCC-4243N, ATAPI CD/DVD-ROM drive ide1 at 0x170-0x177,0x376 on irq 15
hda: max request size: 1024KiB
hda: 117210240 sectors (60011 MB) w/7884KiB Cache, CHS=16383/255/63, UDMA(100)
hda: cache flushes supported
hda: hda1 hda2 hda3 hda4 < hda5 hda6 >
ide-floppy driver 0.99.newide
hdc: ATAPI 24X DVD-ROM CD-R/RW drive, 2048kB Cache, UDMA(33) Uniform CD-ROM driver Revision: 3.20
Attempting manual resume
PM: Checking swsusp image.
swsusp: Suspend partition has wrong signature?
PM: Resume from disk failed.
ReiserFS: hda3: found reiserfs format "3.6" with standard journal
ReiserFS: hda3: using ordered data mode
unfortunately the errors did not get caught by dmesg, but the first error is -6 (no such device), later it is -22 (-EINVAL, no valid suspend signature). This is in fact ok since i did not suspend before ;-)
Hope this helps (and the patch is working fine in my extended tests, it could get some documentation on how to set it up since it is not totally trivial. Hannes?).
Stefan
Quoted 4 lines · Andrew Morton
I don't understand how this can be affected by the modularness of the kernel. Can you explain a little more?
Would it not be simpler to just add "resume=03:02" to the boot command line?
In addition to what others have mentioned, there's also the situation where swap is on a logical volume. In that case, the initramfs needs to get LVM up and running before you can even think about resuming.
Swap on a logical volume is the default Fedora Core 3 partition layout, and I imagine it's the default for Red Hat Enterprise Linux 4 as well.
-Barry K. Nathan <[email protected]>
Hi Pavel et al.
Quoted 4 lines · Barry K. Nathan
Quoted 3 lines · Andrew Morton
I don't understand how this can be affected by the modularness of the kernel. Can you explain a little more?
Quoted 8 lines
Quoted 1 line
Would it not be simpler to just add "resume=03:02" to the boot command line?
In addition to what others have mentioned, there's also the situation where swap is on a logical volume. In that case, the initramfs needs to get LVM up and running before you can even think about resuming.
Swap on a logical volume is the default Fedora Core 3 partition layout, and I imagine it's the default for Red Hat Enterprise Linux 4 as well.
You guys are reinventing the wheel a lot at the moment and I'm in the middle of doing it for x86_64 lowlevel code :> Can we see if we can work a little more closely - perhaps we can get some shared code going that will allow us to handle these issues without stepping on each others' feet? In particular, shared code for
- initramfs and initrd support
- lowlevel suspend & resume
would be good, wouldn't it?
I'm tempted to add setting and checking signatures, but I'm also in the middle of implementing support for writing the image to a file, so that could get messy.
Regards,
Nigel
Signature · 6 lines
Nigel Cunningham Software Engineer, Canberra, Australia http://www.cyclades.com Bus: +61 (2) 6291 9554; Hme: +61 (2) 6292 8028; Mob: +61 (417) 100 574 Maintainer of Suspend2 Kernel Patches http://suspend2.net
Hi!
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines
I don't understand how this can be affected by the modularness of the kernel. Can you explain a little more?
Would it not be simpler to just add "resume=03:02" to the boot command line?
In addition to what others have mentioned, there's also the situation where swap is on a logical volume. In that case, the initramfs needs to get LVM up and running before you can even think about resuming.
Swap on a logical volume is the default Fedora Core 3 partition layout, and I imagine it's the default for Red Hat Enterprise Linux 4 as well.
Quoted 7 lines
You guys are reinventing the wheel a lot at the moment and I'm in the middle of doing it for
x86_64lowlevel code :> Can we see if we can work a little more closely - perhaps we can get some shared code going that will allow us to handle these issues without stepping on each others' feet? In particular, shared code for- initramfs and initrd support
Its actually done, and it was few strategically placed lines of code (like 20 lines). I do not think it can be meaningfully shared.
Quoted 1 line
- lowlevel suspend & resume
This makes very good sense to share. We have i386, x86-64 and ppc versions. They simply walk list of pbe's; that should be simple enough to be usable for suspend2, too....
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Hi.
Quoted 10 lines · Pavel Machek
Quoted 7 lines
You guys are reinventing the wheel a lot at the moment and I'm in the middle of doing it for
x86_64lowlevel code :> Can we see if we can work a little more closely - perhaps we can get some shared code going that will allow us to handle these issues without stepping on each others' feet? In particular, shared code for- initramfs and initrd support
Its actually done, and it was few strategically placed lines of code (like 20 lines). I do not think it can be meaningfully shared.
Mmm. But if we're both putting hooks in the same places...
Quoted 5 lines
Quoted 1 line
- lowlevel suspend & resume
This makes very good sense to share. We have i386, x86-64 and ppc versions. They simply walk list of pbe's; that should be simple enough to be usable for suspend2, too....
The CPU save and restore, yes. But I use a different format for recording the image metadata (I use bitmaps to record the locations of pages). Perhaps I should hasten to mention the bitmaps are discontiguous
- single pages connected by a kmalloc'd list. The copyback itself will need to stay distinct.
Regards,
Nigel
Signature · 6 lines
Nigel Cunningham Software Engineer, Canberra, Australia http://www.cyclades.com Bus: +61 (2) 6291 9554; Hme: +61 (2) 6292 8028; Mob: +61 (417) 100 574 Maintainer of Suspend2 Kernel Patches http://softwaresuspend.berlios.de
Hi!
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
You guys are reinventing the wheel a lot at the moment and I'm in the middle of doing it for
x86_64lowlevel code :> Can we see if we can work a little more closely - perhaps we can get some shared code going that will allow us to handle these issues without stepping on each others' feet? In particular, shared code for
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
- initramfs and initrd support
Its actually done, and it was few strategically placed lines of code (like 20 lines). I do not think it can be meaningfully shared.
Mmm. But if we're both putting hooks in the same places...
There are very little hooks... But we may want to make sure we have same userland interface. swsusp uses "echo 3:5 > /sys/power/resume" to trigger resume from device major 3 minor 5.
Quoted 11 lines
Quoted 5 lines
Quoted 1 line
- lowlevel suspend & resume
This makes very good sense to share. We have i386, x86-64 and ppc versions. They simply walk list of pbe's; that should be simple enough to be usable for suspend2, too....
The CPU save and restore, yes. But I use a different format for recording the image metadata (I use bitmaps to record the locations of pages). Perhaps I should hasten to mention the bitmaps are discontiguous
- single pages connected by a kmalloc'd list. The copyback itself will need to stay distinct.
Hmm, bitmaps? Okay, then low-level code needs to stay separate. (And thats bad, I wanted that one to be shared most).
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Hi.
Quoted 25 lines · Pavel Machek
Hi!
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
You guys are reinventing the wheel a lot at the moment and I'm in the middle of doing it for
x86_64lowlevel code :> Can we see if we can work a little more closely - perhaps we can get some shared code going that will allow us to handle these issues without stepping on each others' feet? In particular, shared code forQuoted 6 lines
Quoted 4 lines
Quoted 1 line
- initramfs and initrd support
Its actually done, and it was few strategically placed lines of code (like 20 lines). I do not think it can be meaningfully shared.
Mmm. But if we're both putting hooks in the same places...
There are very little hooks... But we may want to make sure we have same userland interface. swsusp uses "echo 3:5 >
/sys/power/resume" to trigger resume from device major 3 minor 5.Quoted 6 lines
Quoted 5 lines
Quoted 1 line
- lowlevel suspend & resume
This makes very good sense to share. We have i386, x86-64 and ppc versions. They simply walk list of pbe's; that should be simple enough to be usable for suspend2, too....
Quoted 8 lines
Quoted 5 lines
The CPU save and restore, yes. But I use a different format for recording the image metadata (I use bitmaps to record the locations of pages). Perhaps I should hasten to mention the bitmaps are discontiguous
- single pages connected by a kmalloc'd list. The copyback itself will need to stay distinct.Hmm, bitmaps? Okay, then low-level code needs to stay separate. (And thats bad, I wanted that one to be shared most).
Mmm. As you might remember, I used extents from 1.0 to save space. The feedback from the last submission to LKML about getting rid of the page_alloc.c hooks made me re-examine the use of the memory pool, which made me re-examine the format in which the data was stored. Switching to bitmaps meant that after saving the LRU pages, I can recalculate what remains to be saved without ever changing the result in the process. (Using extents, there was a small chance that the recalculated metadata would require an extra extent on an extra page, which means you have to recalculate everything again :<. With discontiguous bitmaps, I get efficient storage, no need for > order zero allocations and no feedback whatsoever when recalculating image metadata. Besides removing the memory pool code, I've already removed some more, and am about to simplify the code for the remaining extents (for storage metadata). I hope to also be able to further simplify the image preparation code too.
All that to say "Bitmaps were a definite win!". Perhaps I can sell you on the advantages of using them :>
By the way, did you see the effect of the memory eating patch? I didn't think about it until someone emailed me, but the improvement was 50x speed in the best case!
Nigel
Signature · 6 lines
Nigel Cunningham Software Engineer, Canberra, Australia http://www.cyclades.com Bus: +61 (2) 6291 9554; Hme: +61 (2) 6292 8028; Mob: +61 (417) 100 574 Maintainer of Suspend2 Kernel Patches http://softwaresuspend.berlios.de
Hi!
Quoted 18 lines
Quoted 2 lines
Hmm, bitmaps? Okay, then low-level code needs to stay separate. (And thats bad, I wanted that one to be shared most).
Mmm. As you might remember, I used extents from 1.0 to save space. The feedback from the last submission to LKML about getting rid of the
page_alloc.chooks made me re-examine the use of the memory pool, which made me re-examine the format in which the data was stored. Switching to bitmaps meant that after saving the LRU pages, I can recalculate what remains to be saved without ever changing the result in the process. (Using extents, there was a small chance that the recalculated metadata would require an extra extent on an extra page, which means you have to recalculate everything again :<. With discontiguous bitmaps, I get efficient storage, no need for > order zero allocations and no feedback whatsoever when recalculating image metadata. Besides removing the memory pool code, I've already removed some more, and am about to simplify the code for the remaining extents (for storage metadata). I hope to also be able to further simplify the image preparation code too.
Quoted 2 lines
All that to say "Bitmaps were a definite win!". Perhaps I can sell you on the advantages of using them :>
Not sure, if one bit goes wrong you put everything in the wrong places :-). Linklist seems just okay to me, no > 4K allocations. I'm not sure why recalculation is that big problem.
Quoted 3 lines
By the way, did you see the effect of the memory eating patch? I didn't think about it until someone emailed me, but the improvement was 50x speed in the best case!
Well, more interesting was that you actually freed much more memory with your patch. *You actually made memory freeing to work*. So yes, I like that one.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Hi.
Quoted 6 lines · Pavel Machek
Quoted 2 lines
All that to say "Bitmaps were a definite win!". Perhaps I can sell you on the advantages of using them :>
Not sure, if one bit goes wrong you put everything in the wrong places :-). Linklist seems just okay to me, no > 4K allocations. I'm not sure why recalculation is that big problem.
So you make sure all the bits are right :> I can understand you being happy with linked lists; it's just that they're really inefficient spacewise. Since you're freeing far more memory at the moment, it's not an issue.
Regarding recalculation being a problem, I want Suspend to always work. If you have unpredictable variation, you have a potential source of failure.
Quoted 7 lines
Quoted 3 lines
By the way, did you see the effect of the memory eating patch? I didn't think about it until someone emailed me, but the improvement was 50x speed in the best case!
Well, more interesting was that you actually freed much more memory with your patch. *You actually made memory freeing to work*. So yes, I like that one.
You might be misreading me. When you set the image size limit setting in Suspend2, it's a soft limit. The image size wouldn't actually get down to 2 meg; Suspend would just aim for that and eat memory until it saw it wasn't getting anywhere.
Regards,
Nigel
Signature · 6 lines
Nigel Cunningham Software Engineer, Canberra, Australia http://www.cyclades.com Bus: +61 (2) 6291 9554; Hme: +61 (2) 6292 8028; Mob: +61 (417) 100 574 Maintainer of Suspend2 Kernel Patches http://softwaresuspend.berlios.de
swsusp memory freeing [was Re: swsusp: allow resume from initramfs]
Hi!
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
By the way, did you see the effect of the memory eating patch? I didn't think about it until someone emailed me, but the improvement was 50x speed in the best case!
Quoted 8 lines
Quoted 3 lines
Well, more interesting was that you actually freed much more memory with your patch. *You actually made memory freeing to work*. So yes, I like that one.
You might be misreading me. When you set the image size limit setting in Suspend2, it's a soft limit. The image size wouldn't actually get down to 2 meg; Suspend would just aim for that and eat memory until it saw it wasn't getting anywhere.
Well, numbers looked like with same 2MB soft limit, "new" version actually freed more memory. Perhaps that's not the case...
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Quoted 4 lines · Andrew Morton
I don't understand how this can be affected by the modularness of the kernel. Can you explain a little more?
Would it not be simpler to just add "resume=03:02" to the boot command line?
initramfs can also be used to ask for a passphrase, hash it, and setup some (de)cryption dm tables.
Andreas
Great, with this patch I can setup an encrypted swap partition, and resume from it (after the initramfs asked for the password and set up the dm-crypt table).
But wait, I'm using swapfiles. swap is fine with files. what about swsuspend? and if it works with files, too, what about this resume interface?
Andreas
Hi!
Quoted 7 lines
Great, with this patch I can setup an encrypted swap partition, and resume from it (after the initramfs asked for the password and set up the dm-crypt table).
But wait, I'm using swapfiles. swap is fine with files. what about swsuspend? and if it works with files, too, what about this resume interface?
swsusp needs device.
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!