Skip to contentSkip to conversation

Hibernation considerations

DISCUSSION Rafael J. Wysocki 21 participants 362 messages Jul 15, 2007 – Aug 21, 2007 2 messages not in the archive Page 1 of 2

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hi,

Since many alternative approaches to hibernation are now being considered and discussed, I thought it might be a good idea to list some things that in my not so humble opinion should be taken care of by any hibernation framework. They are listed below, not in any particular order, because I think they all are important. Still, I might have forgotten something, so everyone with experience in implementing hibernation, especially Pavel and Nigel, please check if the list is complete.

(1) Filesystems mounted before the hibernation are untouchable

When there's a memory snapshot, either in the form of a hibernation image, or in the form of the "old" kernel and processes available to the "new" kexeced kernel responsible for saving their memory, the filesystems mounted before the hibernation should not be accessed, even for reading, because that would cause their on-disk state to be inconsistent with the snapshot and might lead to a filesystem corruption.

(2) Swap space in use before the hibernation must be handled with care

If swap space is used for saving the memory snapshot, the snapshot-saving application (or kernel) must be careful enough not to overwrite swap pages that contain valid memory contents stored in there before the hibernation.

(3) There are memory regions that must not be saved or restored

Some memory regions contain data that shouldn't be overwritten during the restore, because that might lead to the system not working correctly afterwards. Also, on some systems there are valid 'struct pages' structures that in fact corresond to memory holes and we should not attempt to save those pages.

(4) The user should be able to limit the size of a hibernation image

There are a couple of reasons of that. For example, the storage space used for saving the image may be smaller than the entire RAM or the user may want the image to be saved quickier.

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing the same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar settings requested by the applications before a hibernation should be binding after the restore.

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

(9) Hibernation framework should not be too difficult to set up

It follows from my experience that if the users are required to do too much work to set up a hibernation framework, they will not use it as long as there are simpler alternatives (some of them will not use hibernation at all if it's too difficult to get to work). On the other hand, if the users are provided with a working hibernation framework by their distribution and they find it useful, they are not likely to use kernel.org kernels if t's too difficult to replace the distribution kernel with a generic one due to the hibernation framework's requirements.

All of the existing hibernation frameworks have been written with the above points in mind and that's why they are what they are. In particular, the existence of the tasks freezer, hated by some people to the point of insanity, follows directly from points (1), (4) and (5).

In my opinion any hibernation framework that doesn't take the above requirements into account in any way will be a failure. Moreover, the existing frameworks fail to follow some of them too, so I consider all of these frameworks as a work in progress. For this reason, I will much more appreciate ideas allowing us to improve the existing frameworks in a more or less evolutionary way, then attempts to replace them all with something entirely new.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#1 lore raw

Hi.

Quoted 3 lines · On Sunday 15 July 2007 22:33:32 Rafael J. Wysocki wrote:

Hi,

Since many alternative approaches to hibernation are now being considered

and

Quoted 1 line

discussed, I thought it might be a good idea to list some things that in my

not

Quoted 1 line

so humble opinion should be taken care of by any hibernation framework.

They

Quoted 8 lines

are listed below, not in any particular order, because I think they all are important. Still, I might have forgotten something, so everyone with experience in implementing hibernation, especially Pavel and Nigel, please check if the list is complete.

(1) Filesystems mounted before the hibernation are untouchable

When there's a memory snapshot, either in the form of a hibernation

image,

Quoted 2 lines

or in the form of the "old" kernel and processes available to the "new" kexeced kernel responsible for saving their memory, the filesystems

mounted

Quoted 2 lines

before the hibernation should not be accessed, even for reading, because that would cause their on-disk state to be inconsistent with the

snapshot

Quoted 5 lines

and might lead to a filesystem corruption.

(2) Swap space in use before the hibernation must be handled with care

If swap space is used for saving the memory snapshot, the

snapshot-saving

Quoted 1 line

application (or kernel) must be careful enough not to overwrite swap

pages

Quoted 1 line

that contain valid memory contents stored in there before the

hibernation.

Quoted 4 lines

(3) There are memory regions that must not be saved or restored

Some memory regions contain data that shouldn't be overwritten during

the

Quoted 3 lines

restore, because that might lead to the system not working correctly afterwards. Also, on some systems there are valid 'struct pages' structures that in fact corresond to memory holes and we should not

attempt

Quoted 8 lines

to save those pages.

(4) The user should be able to limit the size of a hibernation image

There are a couple of reasons of that. For example, the storage space used for saving the image may be smaller than the entire RAM or the user may want the image to be saved quickier.

Quoted 7 lines

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing

the

Quoted 9 lines

same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar settings requested by the applications before a hibernation should be binding after the restore.

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the same state in which they were before the corresponding hibernation. Of

course

Quoted 6 lines

in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

(7) On ACPI systems special platform-related actions have to be carried out

at

Quoted 4 lines

the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering

of

Quoted 2 lines

code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states

etc.).

Quoted 5 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the system with the help of certain hibernation framework, then this framework is

not

Quoted 1 line

very useful in practice. It might be useful to perform some special

tasks

Quoted 6 lines

(eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

(9) Hibernation framework should not be too difficult to set up

It follows from my experience that if the users are required to do too

much

Quoted 3 lines

work to set up a hibernation framework, they will not use it as long as there are simpler alternatives (some of them will not use hibernation at all if it's too difficult to get to work). On the other hand, if the

users

Quoted 2 lines

are provided with a working hibernation framework by their distribution and they find it useful, they are not likely to use kernel.org kernels

if

Quoted 1 line

t's too difficult to replace the distribution kernel with a generic one

due

Quoted 5 lines

to the hibernation framework's requirements.

All of the existing hibernation frameworks have been written with the above points in mind and that's why they are what they are. In particular, the existence of the tasks freezer, hated by some people to the point of

insanity,

Quoted 4 lines

follows directly from points (1), (4) and (5).

In my opinion any hibernation framework that doesn't take the above requirements into account in any way will be a failure. Moreover, the

existing

Quoted 2 lines

frameworks fail to follow some of them too, so I consider all of these frameworks as a work in progress. For this reason, I will much more

appreciate

Quoted 3 lines

ideas allowing us to improve the existing frameworks in a more or less evolutionary way, then attempts to replace them all with something entirely new.

Sounds good to me. Nothing extra occurs immediately.

Regards,

Nigel

Signature · 2 lines
See http://www.tuxonice.net for Howtos, FAQs, mailing
lists, wiki and bugzilla info.
#2 lore raw
In reply to Rafael J. Wysocki
Quoted 9 lines · * Rafael J. Wysocki ([email protected]) wrote:

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing the same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar

That would be _so_ embarrassing in a library; I'd rather the audio player had the opportunity to consider whether restarting was a good idea.

Quoted 8 lines

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

2) Some level of debugging needs to be available so that users can provide something so you can see why something hasn't hibernated or why (as in the case of this tosh laptop) it still takes power during hibernation.

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#3 lore raw
In reply to Rafael J. Wysocki
Quoted 9 lines · * Rafael J. Wysocki ([email protected]) wrote:

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing the same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar

That would be _so_ embarrassing in a library; I'd rather the audio player had the opportunity to consider whether restarting was a good idea.

Quoted 8 lines

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

2) Some level of debugging needs to be available so that users can provide something so you can see why something hasn't hibernated or why (as in the case of this tosh laptop) it still takes power during hibernation.

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#4 lore raw
Quoted 24 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Rafael J. Wysocki ([email protected]) wrote:

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing the same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar

That would be _so_ embarrassing in a library; I'd rather the audio player had the opportunity to consider whether restarting was a good idea.

Quoted 8 lines

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

Quoted 7 lines

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

Quoted 4 lines

2) Some level of debugging needs to be available so that users can provide something so you can see why something hasn't hibernated or why (as in the case of this tosh laptop) it still takes power during hibernation.

I agree.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#5 lore raw
Quoted 33 lines · Rafael J. Wysocki
Quoted 24 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Rafael J. Wysocki ([email protected]) wrote:

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing the same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar

That would be _so_ embarrassing in a library; I'd rather the audio player had the opportunity to consider whether restarting was a good idea.

Quoted 8 lines

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

Quoted 7 lines

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Quoted 4 lines

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

he's talking about the main system useing an encrypted device/partition, not the hibernate image being stored encrypted.

This would require the main system 'forget' the keys when it does the hinbernate and prompt for it again during the wake-up phase.

David Lang

#6 lore raw
In reply to Rafael J. Wysocki
Quoted 33 lines · Rafael J. Wysocki
Quoted 24 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Rafael J. Wysocki ([email protected]) wrote:

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing the same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar

That would be _so_ embarrassing in a library; I'd rather the audio player had the opportunity to consider whether restarting was a good idea.

Quoted 8 lines

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

Quoted 7 lines

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Quoted 4 lines

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

he's talking about the main system useing an encrypted device/partition, not the hibernate image being stored encrypted.

This would require the main system 'forget' the keys when it does the hinbernate and prompt for it again during the wake-up phase.

David Lang

#7 lore raw
Quoted 9 lines · * [email protected] ([email protected]) wrote:
Quoted 6 lines · Rafael J. Wysocki

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must
have" feature for a framework to be generally useful (many users don't use it
anyway).

Quoted 5 lines

he's talking about the main system useing an encrypted device/partition, not the hibernate image being stored encrypted.

This would require the main system 'forget' the keys when it does the hinbernate and prompt for it again during the wake-up phase.

Indeed - although as I say I really don't know what you would do with
apps using the mounts at that point. Still it seems like a
sensible requrest from the security side.

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#8 lore raw
In reply to [email protected]
Quoted 9 lines · * [email protected] ([email protected]) wrote:
Quoted 6 lines · Rafael J. Wysocki

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must
have" feature for a framework to be generally useful (many users don't use it
anyway).

Quoted 5 lines

he's talking about the main system useing an encrypted device/partition, not the hibernate image being stored encrypted.

This would require the main system 'forget' the keys when it does the hinbernate and prompt for it again during the wake-up phase.

Indeed - although as I say I really don't know what you would do with
apps using the mounts at that point. Still it seems like a
sensible requrest from the security side.

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#9 lore raw
Quoted 13 lines · Dr. David Alan Gilbert
Quoted 12 lines · * [email protected] ([email protected]) wrote:
Quoted 6 lines · Rafael J. Wysocki

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must
have" feature for a framework to be generally useful (many users don't use it
anyway).

he's talking about the main system useing an encrypted device/partition, not the hibernate image being stored encrypted.

Quoted 6 lines
Quoted 2 lines

This would require the main system 'forget' the keys when it does the hinbernate and prompt for it again during the wake-up phase.

Indeed - although as I say I really don't know what you would do with
apps using the mounts at that point. Still it seems like a
sensible requrest from the security side.

along the same lines, it would probably be a good idea to have the ability for a system to re-ask for the pass phrase periodicly while the system is running.

I see two possible approaches to these issues.

1. implement the periodic re-request capability, and when going into hibernate time-out any known pass phrases.

this is a lot of work overall, but the suspend portion is trivial so there would not be any suspend surprises.

2. flush the keyring on hibernate and have the resume process re-populate it (either by pokeing directly into the memory, or by providing a table that the resuming kernel reads from during wake-up to re-populate it)

this is less work, but it's all suspend related so it will get less testing.

David Lang

#10 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Quoted 4 lines

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

Forgetting the filesystem/swap decryption keys before hibernation is probably harder to do - there may be sensitive data in the kernel memory image that weren't cleared - even if the key itself is not there.

In my opinion, encrypted hibernation is what every notebook user should want - that's the only way how to make sure data from the notebook aren't available when the notebook is physically stolen.

Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs
#11 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Quoted 4 lines

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

Forgetting the filesystem/swap decryption keys before hibernation is probably harder to do - there may be sensitive data in the kernel memory image that weren't cleared - even if the key itself is not there.

In my opinion, encrypted hibernation is what every notebook user should want - that's the only way how to make sure data from the notebook aren't available when the notebook is physically stolen.

Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs
#12 lore raw
Quoted 10 lines · Vojtech Pavlik
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Quoted 8 lines
Quoted 4 lines

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

I was talking about hibernation image encryption. Arguably, if the image is encrypted, you don't need to worry about its contents, including the keys for other kinds of encryption (eg. fs encryption).

Quoted 3 lines

Forgetting the filesystem/swap decryption keys before hibernation is probably harder to do - there may be sensitive data in the kernel memory image that weren't cleared - even if the key itself is not there.

If the image is encrypted, its contents are not available to anyone unauthorized and that includes the filesystem/swap decryption keys.

Quoted 3 lines

In my opinion, encrypted hibernation is what every notebook user should want - that's the only way how to make sure data from the notebook aren't available when the notebook is physically stolen.

Provided that there are any sensitive (to the user or her employer etc.) data in the notebook.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#13 lore raw
In reply to Vojtech Pavlik
Quoted 10 lines · Vojtech Pavlik
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Quoted 8 lines
Quoted 4 lines

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

I was talking about hibernation image encryption. Arguably, if the image is encrypted, you don't need to worry about its contents, including the keys for other kinds of encryption (eg. fs encryption).

Quoted 3 lines

Forgetting the filesystem/swap decryption keys before hibernation is probably harder to do - there may be sensitive data in the kernel memory image that weren't cleared - even if the key itself is not there.

If the image is encrypted, its contents are not available to anyone unauthorized and that includes the filesystem/swap decryption keys.

Quoted 3 lines

In my opinion, encrypted hibernation is what every notebook user should want - that's the only way how to make sure data from the notebook aren't available when the notebook is physically stolen.

Provided that there are any sensitive (to the user or her employer etc.) data in the notebook.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#14 lore raw

encrypted hibernation (was Re: Hibernation considerations)

In reply to Vojtech Pavlik

Hi!

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Quoted 8 lines
Quoted 4 lines

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

Actually, we can do most of that stuff already.

We can encrypt filesystems, encrypt swaps (LVM), and encrypt hibernation.

What we _can't_ do is to hibernate on LVM encrypted partition, and we could only suspend to swap partition. Bad combination, but here's way
out: just use separate (raw) partition for hibernation.

Ok, that needs re-partitioning; if that's bad, just swapoff before hibernation and mkswap/swapon after its done.

Index: suspend.c
===================================================================
RCS file: /cvsroot/suspend/suspend/suspend.c,v
retrieving revision 1.82

suspend.c +14 -0
diff -u -u -r1.82 suspend.c
@@ -59,6 +59,7 @@
 static unsigned long pref_image_size = IMAGE_SIZE;
 static int suspend_loglevel = SUSPEND_LOGLEVEL;
 static char compute_checksum;
+static int raw_partition = 1;
 #ifdef CONFIG_COMPRESS
 static char compress;
 #else
@@ -184,6 +185,9 @@
 	int error;
 	loff_t free_swap;
 
+	if (raw_partition)
+		return 1*1024*1024*1024;
+
 	error = ioctl(dev, SNAPSHOT_AVAIL_SWAP, &free_swap);
 	if (!error)
 		return free_swap;
@@ -197,6 +201,12 @@
 	int error;
 	loff_t offset;
 
+	if (raw_partition) {
+		static int cur_offset = 0;
+		cur_offset += page_size;
+		return cur_offset;
+	}
+
 	error = ioctl(dev, SNAPSHOT_GET_SWAP_PAGE, &offset);
 	if (!error)
 		return offset;
@@ -205,6 +215,8 @@
 
 static inline int free_swap_pages(int dev)
 {
+	if (raw_partition)
+		return 0;
 	return ioctl(dev, SNAPSHOT_FREE_SWAP_PAGES, 0);
 }
 
@@ -213,6 +225,8 @@
 	struct resume_swap_area swap;
 	int error;
 
+	if (raw_partition)
+		return 0;
 	swap.dev = blkdev;
 	swap.offset = offset;
 	error = ioctl(dev, SNAPSHOT_SET_SWAP_AREA, &swap);
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#15 lore raw

encrypted hibernation (was Re: Hibernation considerations)

In reply to Vojtech Pavlik

Hi!

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Quoted 8 lines
Quoted 4 lines

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

Actually, we can do most of that stuff already.

We can encrypt filesystems, encrypt swaps (LVM), and encrypt hibernation.

What we _can't_ do is to hibernate on LVM encrypted partition, and we could only suspend to swap partition. Bad combination, but here's way
out: just use separate (raw) partition for hibernation.

Ok, that needs re-partitioning; if that's bad, just swapoff before hibernation and mkswap/swapon after its done.

Index: suspend.c
===================================================================
RCS file: /cvsroot/suspend/suspend/suspend.c,v
retrieving revision 1.82

suspend.c +14 -0
diff -u -u -r1.82 suspend.c
@@ -59,6 +59,7 @@
 static unsigned long pref_image_size = IMAGE_SIZE;
 static int suspend_loglevel = SUSPEND_LOGLEVEL;
 static char compute_checksum;
+static int raw_partition = 1;
 #ifdef CONFIG_COMPRESS
 static char compress;
 #else
@@ -184,6 +185,9 @@
 	int error;
 	loff_t free_swap;
 
+	if (raw_partition)
+		return 1*1024*1024*1024;
+
 	error = ioctl(dev, SNAPSHOT_AVAIL_SWAP, &free_swap);
 	if (!error)
 		return free_swap;
@@ -197,6 +201,12 @@
 	int error;
 	loff_t offset;
 
+	if (raw_partition) {
+		static int cur_offset = 0;
+		cur_offset += page_size;
+		return cur_offset;
+	}
+
 	error = ioctl(dev, SNAPSHOT_GET_SWAP_PAGE, &offset);
 	if (!error)
 		return offset;
@@ -205,6 +215,8 @@
 
 static inline int free_swap_pages(int dev)
 {
+	if (raw_partition)
+		return 0;
 	return ioctl(dev, SNAPSHOT_FREE_SWAP_PAGES, 0);
 }
 
@@ -213,6 +225,8 @@
 	struct resume_swap_area swap;
 	int error;
 
+	if (raw_partition)
+		return 0;
 	swap.dev = blkdev;
 	swap.offset = offset;
 	error = ioctl(dev, SNAPSHOT_SET_SWAP_AREA, &swap);
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#16 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

Quoted 13 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 11 lines
Quoted 10 lines
Quoted 5 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

Quoted 7 lines
Quoted 3 lines

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

Actually, we can do most of that stuff already.

We can encrypt filesystems, encrypt swaps (LVM), and encrypt hibernation.

But can you do what my original question was; find a way to lose a luks encrypted device key and cleanly unmount the filesystem that was using it? (and preferably put it all back together after resume).

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#17 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

In reply to Pavel Machek
Quoted 13 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 11 lines
Quoted 10 lines
Quoted 5 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

Quoted 7 lines
Quoted 3 lines

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

Actually, we can do most of that stuff already.

We can encrypt filesystems, encrypt swaps (LVM), and encrypt hibernation.

But can you do what my original question was; find a way to lose a luks encrypted device key and cleanly unmount the filesystem that was using it? (and preferably put it all back together after resume).

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#18 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not

       remember the key accross a hibernation;

Why exactly (assuming that the hibernation image is encrypted)?

Greetings,
Rafael

#19 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

Quoted 9 lines · * Rafael J. Wysocki ([email protected]) wrote:
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not

       remember the key accross a hibernation;

Why exactly (assuming that the hibernation image is encrypted)?

I was assuming the hibernation image was not encrypted.
Certainly if it meant a penalty during normal operation (e.g. encrypted swap) it wouldn't be.

(I have a small amount of encrypted data in a luks partition, most of the time it isn't used, only rarely do apps have it open and I'm not actually worried about crawling through swap to find out what is there - this is just a personal laptop; I appreciate these concerns are different depending what you are storing).

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#20 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

In reply to Rafael J. Wysocki
Quoted 9 lines · * Rafael J. Wysocki ([email protected]) wrote:
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not

       remember the key accross a hibernation;

Why exactly (assuming that the hibernation image is encrypted)?

I was assuming the hibernation image was not encrypted.
Certainly if it meant a penalty during normal operation (e.g. encrypted swap) it wouldn't be.

(I have a small amount of encrypted data in a luks partition, most of the time it isn't used, only rarely do apps have it open and I'm not actually worried about crawling through swap to find out what is there - this is just a personal laptop; I appreciate these concerns are different depending what you are storing).

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#21 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

Hi!

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not

       remember the key accross a hibernation;

Why exactly (assuming that the hibernation image is encrypted)?

I was assuming the hibernation image was not encrypted.
Certainly if it meant a penalty during normal operation (e.g. encrypted swap) it wouldn't be.

uswsusp works the way you want. Don't encrypt normal swap, and uswsusp will still be encrypted.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#22 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

In reply to Dr. David Alan Gilbert

Hi!

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not

       remember the key accross a hibernation;

Why exactly (assuming that the hibernation image is encrypted)?

I was assuming the hibernation image was not encrypted.
Certainly if it meant a penalty during normal operation (e.g. encrypted swap) it wouldn't be.

uswsusp works the way you want. Don't encrypt normal swap, and uswsusp will still be encrypted.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#23 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

In reply to Dr. David Alan Gilbert
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not

       remember the key accross a hibernation;

Why exactly (assuming that the hibernation image is encrypted)?

Greetings,
Rafael

#24 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

In reply to Dr. David Alan Gilbert
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

Quoted 8 lines
Quoted 3 lines

Actually, we can do most of that stuff already.

We can encrypt filesystems, encrypt swaps (LVM), and encrypt hibernation.

But can you do what my original question was; find a way to lose a luks encrypted device key and cleanly unmount the filesystem that was using it? (and preferably put it all back together after resume).

If you lose the device key, how are you going to get luks to find it again when resuming? Wouldn't it make more sense to have it remember the key? I can't see it being advisable to allow input or similar before resume has completed...

Signature · 6 lines
Michael Chang

Please avoid sending me Word or PowerPoint attachments. Send me ODT,
RTF, or HTML instead.
See http://www.gnu.org/philosophy/no-word-attachments.html
Thank you.
#25 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

In reply to Dr. David Alan Gilbert
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

If a user uses an encrypted filesystem, then he also needs an encrypted swap and encrypted hibernation image: Otherwise the fileystem encryption is not very useful.

Quoted 8 lines
Quoted 3 lines

Actually, we can do most of that stuff already.

We can encrypt filesystems, encrypt swaps (LVM), and encrypt hibernation.

But can you do what my original question was; find a way to lose a luks encrypted device key and cleanly unmount the filesystem that was using it? (and preferably put it all back together after resume).

If you lose the device key, how are you going to get luks to find it again when resuming? Wouldn't it make more sense to have it remember the key? I can't see it being advisable to allow input or similar before resume has completed...

Signature · 6 lines
Michael Chang

Please avoid sending me Word or PowerPoint attachments. Send me ODT,
RTF, or HTML instead.
See http://www.gnu.org/philosophy/no-word-attachments.html
Thank you.
#26 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

Hello,

We already have a sample at:
http://wiki.tuxonice.net/EncryptedSwapAndRoot
It stores the keys of mounted partitions on an encrypted swap, which has the same encryption with different keyset.
It also shows how to resume from encrypted swap, And you can optionally store the keys on hardware device such as smartcards.

Best Regards,
Alon Bar-Lev

Quoted 54 lines · Michael Chang
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced

to

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

reenter the phrase. However I don't know what the best

thing

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

to do to partitions/applications using the luks device is.

Encryption is possible with both the userland hibernation (aka

uswsusp) and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

TuxOnIce (formerly known as suspend2). Still, I don't consider it

as a "must

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

have" feature for a framework to be generally useful (many users

don't use it

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

anyway).

If a user uses an encrypted filesystem, then he also needs an

encrypted

Quoted 1 line
Quoted 1 line
Quoted 1 line

swap and encrypted hibernation image: Otherwise the fileystem

encryption

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

is not very useful.

Actually, we can do most of that stuff already.

We can encrypt filesystems, encrypt swaps (LVM), and encrypt

hibernation.

Quoted 5 lines

But can you do what my original question was; find a way to lose a luks encrypted device key and cleanly unmount the filesystem that was using it? (and preferably put it all back together after resume).

If you lose the device key, how are you going to get luks to find it again when resuming? Wouldn't it make more sense to have it remember the key? I can't see it being advisable to allow input or similar before resume has completed...

--
Michael Chang

Please avoid sending me Word or PowerPoint attachments. Send me ODT, RTF, or HTML instead.
See http://www.gnu.org/philosophy/no-word-attachments.html
Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#27 lore raw

Re: encrypted hibernation (was Re: Hibernation considerations)

In reply to Michael Chang

Hello,

We already have a sample at:
http://wiki.tuxonice.net/EncryptedSwapAndRoot
It stores the keys of mounted partitions on an encrypted swap, which has the same encryption with different keyset.
It also shows how to resume from encrypted swap, And you can optionally store the keys on hardware device such as smartcards.

Best Regards,
Alon Bar-Lev

Quoted 54 lines · Michael Chang
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Pavel Machek ([email protected]) wrote:

Hi!

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced

to

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

reenter the phrase. However I don't know what the best

thing

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

to do to partitions/applications using the luks device is.

Encryption is possible with both the userland hibernation (aka

uswsusp) and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

TuxOnIce (formerly known as suspend2). Still, I don't consider it

as a "must

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

have" feature for a framework to be generally useful (many users

don't use it

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

anyway).

If a user uses an encrypted filesystem, then he also needs an

encrypted

Quoted 1 line
Quoted 1 line
Quoted 1 line

swap and encrypted hibernation image: Otherwise the fileystem

encryption

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

is not very useful.

Actually, we can do most of that stuff already.

We can encrypt filesystems, encrypt swaps (LVM), and encrypt

hibernation.

Quoted 5 lines

But can you do what my original question was; find a way to lose a luks encrypted device key and cleanly unmount the filesystem that was using it? (and preferably put it all back together after resume).

If you lose the device key, how are you going to get luks to find it again when resuming? Wouldn't it make more sense to have it remember the key? I can't see it being advisable to allow input or similar before resume has completed...

--
Michael Chang

Please avoid sending me Word or PowerPoint attachments. Send me ODT, RTF, or HTML instead.
See http://www.gnu.org/philosophy/no-word-attachments.html
Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#28 lore raw
In reply to Dr. David Alan Gilbert
Quoted 24 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Rafael J. Wysocki ([email protected]) wrote:

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing the same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar

That would be _so_ embarrassing in a library; I'd rather the audio player had the opportunity to consider whether restarting was a good idea.

Quoted 8 lines

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

Quoted 7 lines

Or the user unplugs their flash drive after hibernation rather than before.

Two things which I think would be nice to consider are:
1) Encryption - I'd actually prefer if my luks device did not remember the key accross a hibernation; I want to be forced to reenter the phrase. However I don't know what the best thing to do to partitions/applications using the luks device is.

Encryption is possible with both the userland hibernation (aka uswsusp) and TuxOnIce (formerly known as suspend2). Still, I don't consider it as a "must have" feature for a framework to be generally useful (many users don't use it anyway).

Quoted 4 lines

2) Some level of debugging needs to be available so that users can provide something so you can see why something hasn't hibernated or why (as in the case of this tosh laptop) it still takes power during hibernation.

I agree.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#29 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

(3) There are memory regions that must not be saved or restored

Some memory regions contain data that shouldn't be overwritten during
the restore, because that might lead to the system not working correctly afterwards. Also, on some systems there are valid 'struct pages' structures that in fact corresond to memory holes and we should not attempt to save those pages.

That's only true if we use the current swsusp code to restore the image. If this becomes an issue, we can always use the kexec approach to restore the image, even if that required a double kexec boot to slot in the hibernation kernel, as kexec boot overhead is low.

Quoted 11 lines

(5) Hibernation should be transparent from the applications' point of view

Generally, applications should not notice that hibernation took place. [Note that I don't regard all processes as applications and I think
that there may be processes which need to handle the hibernation in a special way.] Ideally, for example, if some audio is being played when a hibernation starts, the audio player should be able to continue playing the same audio after the restore from the point in which it has been interrupted by the hibernation. Also, the CPU affinities and similar settings requested by the applications before a hibernation should be binding after the restore.

Using kexec may be as transparent as it gets. What's critical here, is to never try memory dependent operations from within the normal kernel, not even backup, as that would get you into an inter-dependency mess we dearly want to avoid.

Quoted 9 lines

(6) State of devices from before hibernation should be restored, if possible

If possible, during a restore devices should be brought back to the
same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

This part could easily be handled by the normal kernel before and after resume.

Quoted 9 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering
of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 7 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

Thanks!

--
Al

#30 lore raw
Quoted 15 lines · Al Boldi

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 7 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 6 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

What about (9)? Would it be that a user choosing to build a kernel with hibernate support gets a additional modular kernel built (which he should then use for resumption) or he should configure & build the modular kernel independent of main kernel?

Or will the Linux boot procedure change so that it always goes thru a modular part followed by kexec (just to be uniform)?

Although the kexec approach seems interesting, the final user-scenario seems a bit complex (or confusing).

-jb

Signature · 1 line
Tact is the art of making a point without making an enemy.
#31 lore raw
In reply to Al Boldi
Quoted 15 lines · Al Boldi

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 7 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 6 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

What about (9)? Would it be that a user choosing to build a kernel with hibernate support gets a additional modular kernel built (which he should then use for resumption) or he should configure & build the modular kernel independent of main kernel?

Or will the Linux boot procedure change so that it always goes thru a modular part followed by kexec (just to be uniform)?

Although the kexec approach seems interesting, the final user-scenario seems a bit complex (or confusing).

-jb

Signature · 1 line
Tact is the art of making a point without making an enemy.
#32 lore raw
Quoted 27 lines · jimmy bahuleyan
Quoted 15 lines · Al Boldi

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 8 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

What about (9)? Would it be that a user choosing to build a kernel with hibernate support gets a additional modular kernel built (which he should then use for resumption) or he should configure & build the modular kernel independent of main kernel?

Quoted 5 lines

Or will the Linux boot procedure change so that it always goes thru a modular part followed by kexec (just to be uniform)?

Although the kexec approach seems interesting, the final user-scenario seems a bit complex (or confusing).

Well, it may sound confusing because it is so unexpectedly simple. I didn't answer to (9) because from a user pov nothing should change, and everything should be scriptable such that the user wouldn't even notice the kernel using a new hibernation approach.

Thanks!

--
Al

#33 lore raw
In reply to jimmy bahuleyan
Quoted 27 lines · jimmy bahuleyan
Quoted 15 lines · Al Boldi

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 8 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

What about (9)? Would it be that a user choosing to build a kernel with hibernate support gets a additional modular kernel built (which he should then use for resumption) or he should configure & build the modular kernel independent of main kernel?

Quoted 5 lines

Or will the Linux boot procedure change so that it always goes thru a modular part followed by kexec (just to be uniform)?

Although the kexec approach seems interesting, the final user-scenario seems a bit complex (or confusing).

Well, it may sound confusing because it is so unexpectedly simple. I didn't answer to (9) because from a user pov nothing should change, and everything should be scriptable such that the user wouldn't even notice the kernel using a new hibernation approach.

Thanks!

--
Al

#34 lore raw
In reply to Al Boldi
Quoted 9 lines · Al Boldi
Quoted 6 lines

If possible, during a restore devices should be brought back to the
same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

This part could easily be handled by the normal kernel before and after resume.

I agree with you except for the word "easily". And there are some things the kernel simply punts on (I'm thinking of the current VGA font).

Quoted 10 lines
Quoted 9 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering
of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

Quoted 5 lines

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

Quoted 8 lines
Quoted 7 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

Does that include the time required for probing PCI buses? On my desktop system, PCI probing incurs a five-second timeout delay because of a bug in the BIOS's USB firmware. Don't be so sure that kexec will always be lightning fast; it is always better to avoid unnecessary boots.

Alan Stern

#35 lore raw
In reply to Al Boldi
Quoted 9 lines · Al Boldi
Quoted 6 lines

If possible, during a restore devices should be brought back to the
same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

This part could easily be handled by the normal kernel before and after resume.

I agree with you except for the word "easily". And there are some things the kernel simply punts on (I'm thinking of the current VGA font).

Quoted 10 lines
Quoted 9 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering
of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

Quoted 5 lines

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

Quoted 8 lines
Quoted 7 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

Does that include the time required for probing PCI buses? On my desktop system, PCI probing incurs a five-second timeout delay because of a bug in the BIOS's USB firmware. Don't be so sure that kexec will always be lightning fast; it is always better to avoid unnecessary boots.

Alan Stern

#36 lore raw
Quoted 9 lines · Alan Stern
Quoted 8 lines · Al Boldi
Quoted 7 lines

If possible, during a restore devices should be brought back to
the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

Quoted 6 lines
Quoted 2 lines

This part could easily be handled by the normal kernel before and after resume.

I agree with you except for the word "easily". And there are some things the kernel simply punts on (I'm thinking of the current VGA font).

Why; can you explain?

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI
methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

Quoted 5 lines

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 6 lines

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

Ok, after applying the latest kexec patches, I was able to use the kexec'd kernel to suspend to ram and resume to the normal kernel, while working under a full-blown X session. It went without a hitch. All that is needed now are the dump/restore hibernation-image routines.

Quoted 15 lines
Quoted 9 lines
Quoted 8 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

Quoted 3 lines

Does that include the time required for probing PCI buses? On my desktop system, PCI probing incurs a five-second timeout delay because of a bug in the BIOS's USB firmware.

Using a modular kernel you would only insmod those modules that you need to dump the image, which is mainly the diskdriver. If you wanted to dump it onto USB flash, then you would insmod that driver, and if that driver is slow due to a bug, then a fix should be in order.

Quoted 3 lines

Don't be so sure that kexec will
always be lightning fast; it is always better to avoid unnecessary boots.

Agreed, but what we want to achieve right know is a proof of concept. Later, I could imagine a specially stub'd device driver to be kexec'd instead of the full kernel.

Thanks!

--
Al

#37 lore raw
In reply to Alan Stern
Quoted 9 lines · Alan Stern
Quoted 8 lines · Al Boldi
Quoted 7 lines

If possible, during a restore devices should be brought back to
the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

Quoted 6 lines
Quoted 2 lines

This part could easily be handled by the normal kernel before and after resume.

I agree with you except for the word "easily". And there are some things the kernel simply punts on (I'm thinking of the current VGA font).

Why; can you explain?

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI
methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

Quoted 5 lines

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 6 lines

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

Ok, after applying the latest kexec patches, I was able to use the kexec'd kernel to suspend to ram and resume to the normal kernel, while working under a full-blown X session. It went without a hitch. All that is needed now are the dump/restore hibernation-image routines.

Quoted 15 lines
Quoted 9 lines
Quoted 8 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

Quoted 3 lines

Does that include the time required for probing PCI buses? On my desktop system, PCI probing incurs a five-second timeout delay because of a bug in the BIOS's USB firmware.

Using a modular kernel you would only insmod those modules that you need to dump the image, which is mainly the diskdriver. If you wanted to dump it onto USB flash, then you would insmod that driver, and if that driver is slow due to a bug, then a fix should be in order.

Quoted 3 lines

Don't be so sure that kexec will
always be lightning fast; it is always better to avoid unnecessary boots.

Agreed, but what we want to achieve right know is a proof of concept. Later, I could imagine a specially stub'd device driver to be kexec'd instead of the full kernel.

Thanks!

--
Al

#38 lore raw
Quoted 13 lines · Al Boldi
Quoted 12 lines · Alan Stern
Quoted 10 lines · Al Boldi
Quoted 7 lines

If possible, during a restore devices should be brought back to
the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

This part could easily be handled by the normal kernel before and after resume.

Quoted 7 lines
Quoted 3 lines

I agree with you except for the word "easily". And there are some things the kernel simply punts on (I'm thinking of the current VGA font).

Why; can you explain?

From personal experience I can assure you that it hasn't been easy

getting the USB subsystem to restore devices following a hibernate. (In fact the current implementation goes against the spirit, if not the letter, of the USB spec.) And making it work requires user intervention.

As for the VGA font, the effect is easy to see: Run setfont before hibernating; when you resume the original font will be back. The kernel simply does not bother to save the VGA font information across a hibernate.

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 6 lines

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

Quoted 4 lines

Ok, after applying the latest kexec patches, I was able to use the kexec'd kernel to suspend to ram and resume to the normal kernel, while working under a full-blown X session. It went without a hitch. All that is needed now are the dump/restore hibernation-image routines.

That's exactly my point. While doing suspend-to-RAM from a kexec'd kernel may be simple, saving the hibernation image will add complications.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

Quoted 8 lines
Quoted 3 lines

Does that include the time required for probing PCI buses? On my desktop system, PCI probing incurs a five-second timeout delay because of a bug in the BIOS's USB firmware.

Using a modular kernel you would only insmod those modules that you need to dump the image, which is mainly the diskdriver. If you wanted to dump it onto USB flash, then you would insmod that driver, and if that driver is slow due to a bug, then a fix should be in order.

I said nothing about dumping onto USB flash. I was referring to PCI probing; presumably any reasonable kernel for desktop/laptop systems will include PCI support.

And the bug isn't in Linux; it is in the firmware. There's no way to fix it short of a BIOS upgrade (and this particular BIOS is no longer supported).

Alan Stern

#39 lore raw
In reply to Al Boldi
Quoted 13 lines · Al Boldi
Quoted 12 lines · Alan Stern
Quoted 10 lines · Al Boldi
Quoted 7 lines

If possible, during a restore devices should be brought back to
the same state in which they were before the corresponding hibernation. Of course in some situations it might be impossible to do that (eg. the user connected the hibernated system to a different IP subnet and then restored), but as a general rule, we should do our best to restore the state of devices, which is directly related to point (5) above.

This part could easily be handled by the normal kernel before and after resume.

Quoted 7 lines
Quoted 3 lines

I agree with you except for the word "easily". And there are some things the kernel simply punts on (I'm thinking of the current VGA font).

Why; can you explain?

From personal experience I can assure you that it hasn't been easy

getting the USB subsystem to restore devices following a hibernate. (In fact the current implementation goes against the spirit, if not the letter, of the USB spec.) And making it work requires user intervention.

As for the VGA font, the effect is easy to see: Run setfont before hibernating; when you resume the original font will be back. The kernel simply does not bother to save the VGA font information across a hibernate.

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 6 lines

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

Quoted 4 lines

Ok, after applying the latest kexec patches, I was able to use the kexec'd kernel to suspend to ram and resume to the normal kernel, while working under a full-blown X session. It went without a hitch. All that is needed now are the dump/restore hibernation-image routines.

That's exactly my point. While doing suspend-to-RAM from a kexec'd kernel may be simple, saving the hibernation image will add complications.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

Quoted 8 lines
Quoted 3 lines

Does that include the time required for probing PCI buses? On my desktop system, PCI probing incurs a five-second timeout delay because of a bug in the BIOS's USB firmware.

Using a modular kernel you would only insmod those modules that you need to dump the image, which is mainly the diskdriver. If you wanted to dump it onto USB flash, then you would insmod that driver, and if that driver is slow due to a bug, then a fix should be in order.

I said nothing about dumping onto USB flash. I was referring to PCI probing; presumably any reasonable kernel for desktop/laptop systems will include PCI support.

And the bug isn't in Linux; it is in the firmware. There's no way to fix it short of a BIOS upgrade (and this particular BIOS is no longer supported).

Alan Stern

#40 lore raw
Quoted 18 lines · Alan Stern
Quoted 16 lines · Al Boldi
Quoted 14 lines · Alan Stern
Quoted 5 lines · Al Boldi

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

Quoted 8 lines
Quoted 4 lines

Ok, after applying the latest kexec patches, I was able to use the kexec'd kernel to suspend to ram and resume to the normal kernel, while working under a full-blown X session. It went without a hitch. All that is needed now are the dump/restore hibernation-image routines.

That's exactly my point. While doing suspend-to-RAM from a kexec'd kernel may be simple, saving the hibernation image will add complications.

suspend-to-RAM should not involve kexec, the only reason for doing the kexec to to get a seperate userspace to use for suspend-to-disk operations instead of trying to partially freeze the sustem and keep useing it.

David Lang

#41 lore raw
In reply to Alan Stern
Quoted 18 lines · Alan Stern
Quoted 16 lines · Al Boldi
Quoted 14 lines · Alan Stern
Quoted 5 lines · Al Boldi

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

Quoted 8 lines
Quoted 4 lines

Ok, after applying the latest kexec patches, I was able to use the kexec'd kernel to suspend to ram and resume to the normal kernel, while working under a full-blown X session. It went without a hitch. All that is needed now are the dump/restore hibernation-image routines.

That's exactly my point. While doing suspend-to-RAM from a kexec'd kernel may be simple, saving the hibernation image will add complications.

suspend-to-RAM should not involve kexec, the only reason for doing the kexec to to get a seperate userspace to use for suspend-to-disk operations instead of trying to partially freeze the sustem and keep useing it.

David Lang

#42 lore raw
In reply to Alan Stern
Quoted 4 lines · Alan Stern

As for the VGA font, the effect is easy to see: Run setfont before hibernating; when you resume the original font will be back. The kernel simply does not bother to save the VGA font information across a hibernate.

This could probably be handled by a device suspend/resume call; but this problem is not specific to kexec.

Quoted 10 lines
Quoted 4 lines

Ok, after applying the latest kexec patches, I was able to use the kexec'd kernel to suspend to ram and resume to the normal kernel, while working under a full-blown X session. It went without a hitch. All that is needed now are the dump/restore hibernation-image routines.

That's exactly my point. While doing suspend-to-RAM from a kexec'd kernel may be simple, saving the hibernation image will add complications.

From a kexec'd hibernation kernel pov, both S3 and S4 look conceptually

exactly the same. The only difference is, in S3 the memory is in memory and in S4 the memory is on storage. All device handling is exactly the same, so if there is a problem with device handling between the kexec'd hibernation kernel and the normal kernel, then that would have made itself visible.

Quoted 3 lines · [email protected] wrote:

suspend-to-RAM should not involve kexec, the only reason for doing the kexec to to get a seperate userspace to use for suspend-to-disk operations instead of trying to partially freeze the sustem and keep useing it.

Or you could do suspend-to-disk-and-RAM. But in the above case, it was meant to test kexec compatibility with device suspend/resume calls.

Thanks!

--
Al

#43 lore raw
In reply to Alan Stern
Quoted 4 lines · Alan Stern

As for the VGA font, the effect is easy to see: Run setfont before hibernating; when you resume the original font will be back. The kernel simply does not bother to save the VGA font information across a hibernate.

This could probably be handled by a device suspend/resume call; but this problem is not specific to kexec.

Quoted 10 lines
Quoted 4 lines

Ok, after applying the latest kexec patches, I was able to use the kexec'd kernel to suspend to ram and resume to the normal kernel, while working under a full-blown X session. It went without a hitch. All that is needed now are the dump/restore hibernation-image routines.

That's exactly my point. While doing suspend-to-RAM from a kexec'd kernel may be simple, saving the hibernation image will add complications.

From a kexec'd hibernation kernel pov, both S3 and S4 look conceptually

exactly the same. The only difference is, in S3 the memory is in memory and in S4 the memory is on storage. All device handling is exactly the same, so if there is a problem with device handling between the kexec'd hibernation kernel and the normal kernel, then that would have made itself visible.

Quoted 3 lines · [email protected] wrote:

suspend-to-RAM should not involve kexec, the only reason for doing the kexec to to get a seperate userspace to use for suspend-to-disk operations instead of trying to partially freeze the sustem and keep useing it.

Or you could do suspend-to-disk-and-RAM. But in the above case, it was meant to test kexec compatibility with device suspend/resume calls.

Thanks!

--
Al

#44 lore raw
Quoted 8 lines · Al Boldi
Quoted 3 lines · [email protected] wrote:

suspend-to-RAM should not involve kexec, the only reason for doing the kexec to to get a seperate userspace to use for suspend-to-disk operations instead of trying to partially freeze the sustem and keep useing it.

Or you could do suspend-to-disk-and-RAM. But in the above case, it was meant to test kexec compatibility with device suspend/resume calls.

the point I am trying to make here is that there is no reason that the kexec approach needs to do _any_ suspend/resume calls.

all that is needed is the ability of the new kernel to initialize the devices it needs.

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

5. power-on boot.

6. resume-from-disk

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

yes it's more steps, but each step is logicly seperate, and each step will be excercised on a regular basis, so the combination of the steps will also be reliable.

this is far better then creating yet another way to pause the system that only a few people will use.

David Lang

#45 lore raw
Quoted 7 lines · [email protected] wrote:
Quoted 6 lines · Al Boldi
Quoted 4 lines · [email protected] wrote:

suspend-to-RAM should not involve kexec, the only reason for doing the kexec to to get a seperate userspace to use for suspend-to-disk operations instead of trying to partially freeze the sustem and keep useing it.

Quoted 5 lines
Quoted 2 lines

Or you could do suspend-to-disk-and-RAM. But in the above case, it was meant to test kexec compatibility with device suspend/resume calls.

the point I am trying to make here is that there is no reason that the kexec approach needs to do _any_ suspend/resume calls.

When you go through ACPI, then that implies calling suspend/resume calls.

Quoted 2 lines

all that is needed is the ability of the new kernel to initialize the devices it needs.

We have to go through ACPI, for wakeup functions to succeed. A simple power-off won't do.

Quoted 17 lines

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

Quoted 7 lines

5. power-on boot.

6. resume-from-disk

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

Exactly, which is why your scheme would break down on #3, and that's why you need to call S3 from within the kexec'd hibernation kernel after saving the hibernation image.

Thanks!

--
Al

#46 lore raw
In reply to [email protected]
Quoted 7 lines · [email protected] wrote:
Quoted 6 lines · Al Boldi
Quoted 4 lines · [email protected] wrote:

suspend-to-RAM should not involve kexec, the only reason for doing the kexec to to get a seperate userspace to use for suspend-to-disk operations instead of trying to partially freeze the sustem and keep useing it.

Quoted 5 lines
Quoted 2 lines

Or you could do suspend-to-disk-and-RAM. But in the above case, it was meant to test kexec compatibility with device suspend/resume calls.

the point I am trying to make here is that there is no reason that the kexec approach needs to do _any_ suspend/resume calls.

When you go through ACPI, then that implies calling suspend/resume calls.

Quoted 2 lines

all that is needed is the ability of the new kernel to initialize the devices it needs.

We have to go through ACPI, for wakeup functions to succeed. A simple power-off won't do.

Quoted 17 lines

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

Quoted 7 lines

5. power-on boot.

6. resume-from-disk

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

Exactly, which is why your scheme would break down on #3, and that's why you need to call S3 from within the kexec'd hibernation kernel after saving the hibernation image.

Thanks!

--
Al

#47 lore raw
Quoted 8 lines · Al Boldi
Quoted 7 lines · [email protected] wrote:
Quoted 6 lines · Al Boldi
Quoted 4 lines · [email protected] wrote:

suspend-to-RAM should not involve kexec, the only reason for doing the kexec to to get a seperate userspace to use for suspend-to-disk operations instead of trying to partially freeze the sustem and keep useing it.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Or you could do suspend-to-disk-and-RAM. But in the above case, it was meant to test kexec compatibility with device suspend/resume calls.

the point I am trying to make here is that there is no reason that the kexec approach needs to do _any_ suspend/resume calls.

When you go through ACPI, then that implies calling suspend/resume calls.

then don't go through ACPI

Quoted 5 lines
Quoted 2 lines

all that is needed is the ability of the new kernel to initialize the devices it needs.

We have to go through ACPI, for wakeup functions to succeed. A simple power-off won't do.

the kexec switch being posted requires ACPI be disabled, so it's clearly possible to switch kernels and initialize devices without ACPI

Quoted 21 lines
Quoted 21 lines

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

5. power-on boot.

6. resume-from-disk

Quoted 7 lines
Quoted 3 lines

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

Exactly, which is why your scheme would break down on #3, and that's why you need to call S3 from within the kexec'd hibernation kernel after saving the hibernation image.

when a kexec is called, how does the kernel know what to execute? something needs to tell it what to do, and I think that something is either something in the kexec image, or it's something passed as a parameter to that image.

all that would be needed to do #3 safely is to have the kernel that you restarted on #2 do a suspend-to-ram before it does anything else.

David Lang

#48 lore raw
Quoted 6 lines · [email protected] wrote:
Quoted 2 lines · Al Boldi

We have to go through ACPI, for wakeup functions to succeed. A simple power-off won't do.

the kexec switch being posted requires ACPI be disabled, so it's clearly possible to switch kernels and initialize devices without ACPI

It's a given that kexec works in the absence of ACPI; what we have to handle is the ACPI states across kernel invocations, to ensure wakeup functions succeed. If you don't need this, then just power off.

Quoted 29 lines
Quoted 21 lines
Quoted 21 lines

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

5. power-on boot.

6. resume-from-disk

Quoted 7 lines
Quoted 3 lines

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

Exactly, which is why your scheme would break down on #3, and that's why you need to call S3 from within the kexec'd hibernation kernel after saving the hibernation image.

Quoted 7 lines

when a kexec is called, how does the kernel know what to execute? something needs to tell it what to do, and I think that something is either something in the kexec image, or it's something passed as a parameter to that image.

all that would be needed to do #3 safely is to have the kernel that you restarted on #2 do a suspend-to-ram before it does anything else.

If you mean by kernel 'the normal kernel', then this won't work, because it would imply a change of state after saving its image.

If you mean by kernel 'the kexec'd hibernation kernel', then you wouldn't need to do #2, but rather do #3 right after dumping the image in #1.

[...insert from another post...]

Quoted 8 lines
Quoted 3 lines

BTW, it would be really helpful if people would actually try the kexec hibernation patches, as this may yield a much more constructive discussion.

I would love to, but so far I don't see the nessasary pieces

once I kexec to the new kernel, how can it find out what pages of memory (and swap) need to be saved?

No need to save the swap, all you need to do is to dump /dev/oldmem onto storage, and if that dump image is compatible with swsusp, then a normal kernel should be able to resume from this image via /dev/snapshot.

Thanks!

--
Al

#49 lore raw
In reply to [email protected]
Quoted 6 lines · [email protected] wrote:
Quoted 2 lines · Al Boldi

We have to go through ACPI, for wakeup functions to succeed. A simple power-off won't do.

the kexec switch being posted requires ACPI be disabled, so it's clearly possible to switch kernels and initialize devices without ACPI

It's a given that kexec works in the absence of ACPI; what we have to handle is the ACPI states across kernel invocations, to ensure wakeup functions succeed. If you don't need this, then just power off.

Quoted 29 lines
Quoted 21 lines
Quoted 21 lines

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

5. power-on boot.

6. resume-from-disk

Quoted 7 lines
Quoted 3 lines

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

Exactly, which is why your scheme would break down on #3, and that's why you need to call S3 from within the kexec'd hibernation kernel after saving the hibernation image.

Quoted 7 lines

when a kexec is called, how does the kernel know what to execute? something needs to tell it what to do, and I think that something is either something in the kexec image, or it's something passed as a parameter to that image.

all that would be needed to do #3 safely is to have the kernel that you restarted on #2 do a suspend-to-ram before it does anything else.

If you mean by kernel 'the normal kernel', then this won't work, because it would imply a change of state after saving its image.

If you mean by kernel 'the kexec'd hibernation kernel', then you wouldn't need to do #2, but rather do #3 right after dumping the image in #1.

[...insert from another post...]

Quoted 8 lines
Quoted 3 lines

BTW, it would be really helpful if people would actually try the kexec hibernation patches, as this may yield a much more constructive discussion.

I would love to, but so far I don't see the nessasary pieces

once I kexec to the new kernel, how can it find out what pages of memory (and swap) need to be saved?

No need to save the swap, all you need to do is to dump /dev/oldmem onto storage, and if that dump image is compatible with swsusp, then a normal kernel should be able to resume from this image via /dev/snapshot.

Thanks!

--
Al

#50 lore raw
Quoted 60 lines · Al Boldi
Quoted 6 lines · [email protected] wrote:
Quoted 2 lines · Al Boldi

We have to go through ACPI, for wakeup functions to succeed. A simple power-off won't do.

the kexec switch being posted requires ACPI be disabled, so it's clearly possible to switch kernels and initialize devices without ACPI

It's a given that kexec works in the absence of ACPI; what we have to handle is the ACPI states across kernel invocations, to ensure wakeup functions succeed. If you don't need this, then just power off.

Quoted 29 lines
Quoted 21 lines
Quoted 21 lines

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

5. power-on boot.

6. resume-from-disk

Quoted 7 lines
Quoted 3 lines

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

Exactly, which is why your scheme would break down on #3, and that's why you need to call S3 from within the kexec'd hibernation kernel after saving the hibernation image.

Quoted 7 lines

when a kexec is called, how does the kernel know what to execute? something needs to tell it what to do, and I think that something is either something in the kexec image, or it's something passed as a parameter to that image.

all that would be needed to do #3 safely is to have the kernel that you restarted on #2 do a suspend-to-ram before it does anything else.

If you mean by kernel 'the normal kernel', then this won't work, because it would imply a change of state after saving its image.

If you mean by kernel 'the kexec'd hibernation kernel', then you wouldn't need to do #2, but rather do #3 right after dumping the image in #1.

[...insert from another post...]

Quoted 4 lines
Quoted 3 lines

BTW, it would be really helpful if people would actually try the kexec hibernation patches, as this may yield a much more constructive discussion.

Quoted 6 lines
Quoted 4 lines

I would love to, but so far I don't see the nessasary pieces

once I kexec to the new kernel, how can it find out what pages of memory (and swap) need to be saved?

No need to save the swap,

Correct.

Quoted 1 line

all you need to do is to dump /dev/oldmem onto storage,

I'm not sure of that.

Quoted 1 line

and if that dump image is compatible with swsusp,

No, it's not. swusp additionally needs to know PFNs to restore the pages into.

Quoted 2 lines

then a normal kernel should be able to resume from this image via /dev/snapshot.

Nope.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#51 lore raw
In reply to Al Boldi
Quoted 46 lines · Al Boldi
Quoted 6 lines · [email protected] wrote:
Quoted 2 lines · Al Boldi

We have to go through ACPI, for wakeup functions to succeed. A simple power-off won't do.

the kexec switch being posted requires ACPI be disabled, so it's clearly possible to switch kernels and initialize devices without ACPI

It's a given that kexec works in the absence of ACPI; what we have to handle is the ACPI states across kernel invocations, to ensure wakeup functions succeed. If you don't need this, then just power off.

Quoted 34 lines
Quoted 21 lines
Quoted 21 lines

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

5. power-on boot.

6. resume-from-disk

Quoted 7 lines
Quoted 3 lines

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

Exactly, which is why your scheme would break down on #3, and that's why you need to call S3 from within the kexec'd hibernation kernel after saving the hibernation image.

when a kexec is called, how does the kernel know what to execute? something needs to tell it what to do, and I think that something is either something in the kexec image, or it's something passed as a parameter to that image.

Quoted 5 lines
Quoted 2 lines

all that would be needed to do #3 safely is to have the kernel that you restarted on #2 do a suspend-to-ram before it does anything else.

If you mean by kernel 'the normal kernel', then this won't work, because it would imply a change of state after saving its image.

yes, it would change the state, but if it only changes the state in ways that aren't visable to the outside world why would it matter?

if power dies you restore from the disk image (useing the non ACPI approach), and the changes that you make are just lost

Quoted 8 lines

If you mean by kernel 'the kexec'd hibernation kernel', then you wouldn't need to do #2, but rather do #3 right after dumping the image in #1.

[...insert from another post...]

Quoted 4 lines
Quoted 3 lines

BTW, it would be really helpful if people would actually try the kexec hibernation patches, as this may yield a much more constructive discussion.

Quoted 8 lines
Quoted 4 lines

I would love to, but so far I don't see the nessasary pieces

once I kexec to the new kernel, how can it find out what pages of memory (and swap) need to be saved?

No need to save the swap, all you need to do is to dump /dev/oldmem onto storage, and if that dump image is compatible with swsusp, then a normal kernel should be able to resume from this image via /dev/snapshot.

Rafael is saying that there's more involved, you can't just dump /dev/oldmem, you have to avoid specific pages.

as for swap, saving that may be required, depending on how clean you want toleave the box for other OS's in the meantime.

David Lang

#52 lore raw
In reply to Al Boldi
Quoted 46 lines · Al Boldi
Quoted 6 lines · [email protected] wrote:
Quoted 2 lines · Al Boldi

We have to go through ACPI, for wakeup functions to succeed. A simple power-off won't do.

the kexec switch being posted requires ACPI be disabled, so it's clearly possible to switch kernels and initialize devices without ACPI

It's a given that kexec works in the absence of ACPI; what we have to handle is the ACPI states across kernel invocations, to ensure wakeup functions succeed. If you don't need this, then just power off.

Quoted 34 lines
Quoted 21 lines
Quoted 21 lines

suspend-to-disk-and-ram could be implemented as three seperate steps

1. suspend-to-disk

2. resume-from-disk

3. suspend-to-ram

followed by either

4. resume-from-ram

or

4. battery dies and loptop powers off completely

5. power-on boot.

6. resume-from-disk

Quoted 7 lines
Quoted 3 lines

all that you need to do is to make sure that the system doesn't run anything that would affect permanent media or the outside world between steps #2 and #3

Exactly, which is why your scheme would break down on #3, and that's why you need to call S3 from within the kexec'd hibernation kernel after saving the hibernation image.

when a kexec is called, how does the kernel know what to execute? something needs to tell it what to do, and I think that something is either something in the kexec image, or it's something passed as a parameter to that image.

Quoted 5 lines
Quoted 2 lines

all that would be needed to do #3 safely is to have the kernel that you restarted on #2 do a suspend-to-ram before it does anything else.

If you mean by kernel 'the normal kernel', then this won't work, because it would imply a change of state after saving its image.

yes, it would change the state, but if it only changes the state in ways that aren't visable to the outside world why would it matter?

if power dies you restore from the disk image (useing the non ACPI approach), and the changes that you make are just lost

Quoted 8 lines

If you mean by kernel 'the kexec'd hibernation kernel', then you wouldn't need to do #2, but rather do #3 right after dumping the image in #1.

[...insert from another post...]

Quoted 4 lines
Quoted 3 lines

BTW, it would be really helpful if people would actually try the kexec hibernation patches, as this may yield a much more constructive discussion.

Quoted 8 lines
Quoted 4 lines

I would love to, but so far I don't see the nessasary pieces

once I kexec to the new kernel, how can it find out what pages of memory (and swap) need to be saved?

No need to save the swap, all you need to do is to dump /dev/oldmem onto storage, and if that dump image is compatible with swsusp, then a normal kernel should be able to resume from this image via /dev/snapshot.

Rafael is saying that there's more involved, you can't just dump /dev/oldmem, you have to avoid specific pages.

as for swap, saving that may be required, depending on how clean you want toleave the box for other OS's in the meantime.

David Lang

#53 lore raw
In reply to Al Boldi
Quoted 5 lines · Al Boldi

From a kexec'd hibernation kernel pov, both S3 and S4 look conceptually exactly the same. The only difference is, in S3 the memory is in memory and in S4 the memory is on storage. All device handling is exactly the same, so if there is a problem with device handling between the kexec'd hibernation kernel and the normal kernel, then that would have made itself visible.

You have contradicted yourself. "In S3 the memory is in memory and in S4 the memory is on storage". How does the memory get onto storage? The kexec'd hibernation kernel writes it there. To do so it accesses a storage device.

Consequently the device handling _cannot_ be exactly the same in S3 and S4.

Alan Stern

#54 lore raw
In reply to Al Boldi
Quoted 5 lines · Al Boldi

From a kexec'd hibernation kernel pov, both S3 and S4 look conceptually exactly the same. The only difference is, in S3 the memory is in memory and in S4 the memory is on storage. All device handling is exactly the same, so if there is a problem with device handling between the kexec'd hibernation kernel and the normal kernel, then that would have made itself visible.

You have contradicted yourself. "In S3 the memory is in memory and in S4 the memory is on storage". How does the memory get onto storage? The kexec'd hibernation kernel writes it there. To do so it accesses a storage device.

Consequently the device handling _cannot_ be exactly the same in S3 and S4.

Alan Stern

#55 lore raw
Quoted 8 lines · Alan Stern
Quoted 6 lines · Al Boldi

From a kexec'd hibernation kernel pov, both S3 and S4 look conceptually exactly the same. The only difference is, in S3 the memory is in memory and in S4 the memory is on storage. All device handling is exactly the same, so if there is a problem with device handling between the kexec'd hibernation kernel and the normal kernel, then that would have made itself visible.

Quoted 7 lines

You have contradicted yourself. "In S3 the memory is in memory and in S4 the memory is on storage". How does the memory get onto storage? The kexec'd hibernation kernel writes it there. To do so it accesses a storage device.

Consequently the device handling _cannot_ be exactly the same in S3 and S4.

Ok, you should have read this in the context of suspending/resuming from/to the normal kernel, and in that case they are exactly the same, i.e. kexec -e for suspend and kexec -j for resume.

BTW, it would be really helpful if people would actually try the kexec hibernation patches, as this may yield a much more constructive discussion.

Thanks!

--
Al

#56 lore raw
In reply to Alan Stern
Quoted 8 lines · Alan Stern
Quoted 6 lines · Al Boldi

From a kexec'd hibernation kernel pov, both S3 and S4 look conceptually exactly the same. The only difference is, in S3 the memory is in memory and in S4 the memory is on storage. All device handling is exactly the same, so if there is a problem with device handling between the kexec'd hibernation kernel and the normal kernel, then that would have made itself visible.

Quoted 7 lines

You have contradicted yourself. "In S3 the memory is in memory and in S4 the memory is on storage". How does the memory get onto storage? The kexec'd hibernation kernel writes it there. To do so it accesses a storage device.

Consequently the device handling _cannot_ be exactly the same in S3 and S4.

Ok, you should have read this in the context of suspending/resuming from/to the normal kernel, and in that case they are exactly the same, i.e. kexec -e for suspend and kexec -j for resume.

BTW, it would be really helpful if people would actually try the kexec hibernation patches, as this may yield a much more constructive discussion.

Thanks!

--
Al

#57 lore raw
Quoted 17 lines · Al Boldi
Quoted 8 lines · Alan Stern
Quoted 6 lines · Al Boldi

From a kexec'd hibernation kernel pov, both S3 and S4 look conceptually exactly the same. The only difference is, in S3 the memory is in memory and in S4 the memory is on storage. All device handling is exactly the same, so if there is a problem with device handling between the kexec'd hibernation kernel and the normal kernel, then that would have made itself visible.

Quoted 7 lines

You have contradicted yourself. "In S3 the memory is in memory and in S4 the memory is on storage". How does the memory get onto storage? The kexec'd hibernation kernel writes it there. To do so it accesses a storage device.

Consequently the device handling _cannot_ be exactly the same in S3 and S4.

Quoted 6 lines

Ok, you should have read this in the context of suspending/resuming from/to the normal kernel, and in that case they are exactly the same, i.e. kexec -e for suspend and kexec -j for resume.

BTW, it would be really helpful if people would actually try the kexec hibernation patches, as this may yield a much more constructive discussion.

I would love to, but so far I don't see the nessasary pieces

once I kexec to the new kernel, how can it find out what pages of memory (and swap) need to be saved?

If i knew that then I could write a trivial perl program to save those pages with the appropriate headers to make a suspend file.

however, I'm now being told that that suspend file won't work if the machine is actually powered off, so there's a need to something more for the wake-up side of things as well.

David Lang

#58 lore raw
In reply to Alan Stern
Quoted 16 lines · Alan Stern
Quoted 10 lines
Quoted 9 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering
of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

Quoted 5 lines

This should be the responsibility of the kexec'd hibernating kernel. Note though in (6), the normal kernel takes care of preparing devices, then the hibernating kernel dumps the image and either calls S4 or S3. On resume from S3 it can immediately switch over to the normal kernel, and from S4 the known bootup would occur.

Quoted 6 lines

Is it really that simple? Somehow I doubt it. In order for some devices to remain available for the kexec'd kernel to use, they cannot be suspended at the ACPI level. So the kexec'd kernel will have to handle the ACPI requirements for those devices. Likewise, it would have to handle the ACPI interactions which need to be done after all devices are prepared for the transition to S3 or S4.

so if there are two states for hardware

1. able to be detected and initialized with the standard boot routines

2. ACPI suspend mode, requireing ACPI specifics to wake up

is it possible to detect which is needed? cna you try the ACPI wakeup and if it doesn't work go to the standard boot routine (or vice-versa)?

Quoted 14 lines
Quoted 8 lines
Quoted 7 lines

(8) Hibernation and restore should not be too slow

In my opinion, if more than one minute is needed to hibernate the
system with the help of certain hibernation framework, then this framework is not very useful in practice. It might be useful to perform some special tasks (eg. moving a server to another place without taking it down), but it is not very useful, for example, to notebook users.

Quoted 5 lines

The latest hibernating kexec patches boot a kexec'd modular kernel with initramfs into crashkernel=16M@16M in less than one second. Switch-back is almost instant. Add to this the time required to either store or restore the image, and it may be obvious that this approach isn't slower, but maybe even faster than the current swsusp.

Quoted 5 lines

Does that include the time required for probing PCI buses? On my desktop system, PCI probing incurs a five-second timeout delay because of a bug in the BIOS's USB firmware. Don't be so sure that kexec will always be lightning fast; it is always better to avoid unnecessary boots.

some drivers will have delays on some machines (especially when you consider hardware bugs that have to be worked around), but at the moment nothing is remotely close to the 'limit' of 60 seconds being talked about here.

although with some machines the mear trasnfer times for the data could cause noticable delays (if you have a server with 128G of ram it may take a while to get it to a drive)

David Lang

#59 lore raw
In reply to Rafael J. Wysocki

Hi,
I think a (10) is needed to be clear:

(10) This depends directly on (9)
Easy Userinterface for the average user, no one wants to edit several files and use a long commandline for a suspend (not all know about alias(P)), so keeping the effort to suspend your system low, please.(eg for my TuxOnIce i just type hibernate as root/ sudo hibernate as normal user and the suspend begin, the rest is automatically done by the configuration(for me this is shutting down my wireless interface)

Cornelius Riemenschneider

My source of power: www.humppa.com

#60 lore raw
Quoted 11 lines · Cornelius Riemenschneider

Hi,
I think a (10) is needed to be clear:

(10) This depends directly on (9)
Easy Userinterface for the average user, no one wants to edit several files and use a long commandline for a suspend (not all know about alias(P)), so keeping the effort to suspend your system low, please.(eg for my TuxOnIce i just type hibernate as root/ sudo hibernate as normal user and the suspend begin, the rest is automatically done by the configuration(for me this is shutting down my wireless interface)

Quoted 1 line

Cornelius Riemenschneider

for both #9 and #10, if there are complex command lines that need to be used, they can be put into scripts (including things like 'sudo hibernate')

this doesn't prevent people from useing kernel.org kernels, in fact the seperate between the main system and what's used for hibernation may make it easier to change the main kernel (all that you would need is to enable kexec in your main kernel and 'everything else would just work')

now if you need/want to change out your hibernate kernel you will have to change the hibernate scripts to tell them to use the new kernel. yes this is an extra step, but it can still be simple. for that matter, it may be possible for the distros to agree enough to add 'make install_hibernate' to the kernel makefiles like they have 'make install' that will just 'do the right thing' for each particular distro.

makeing things explicit and flexible may require complex command lines to implement, but nothing says that the user (even a moderatly advanced user) needs to deal with those command lines directly.

David Lang

#61 lore raw
In reply to Rafael J. Wysocki
Quoted 10 lines · Rafael J. Wysocki

Hi,

Since many alternative approaches to hibernation are now being considered and discussed, I thought it might be a good idea to list some things that in my not so humble opinion should be taken care of by any hibernation framework. They are listed below, not in any particular order, because I think they all are important. Still, I might have forgotten something, so everyone with experience in implementing hibernation, especially Pavel and Nigel, please check if the list is complete.

Quoted 8 lines

(1) Filesystems mounted before the hibernation are untouchable

When there's a memory snapshot, either in the form of a hibernation image, or in the form of the "old" kernel and processes available to the "new" kexeced kernel responsible for saving their memory, the filesystems mounted before the hibernation should not be accessed, even for reading, because that would cause their on-disk state to be inconsistent with the snapshot and might lead to a filesystem corruption.

AFAIK this is only the case with ext3, all other filesystems could be accessed read-only safely

this is arguably a bug with ext3 (and has been discussed as such), but right now the ext3 team has decided not to change this bahavior so hibernate needs to work around it. but don't mistake a work-around for a single (admittedly very popular) filesystem with a hard and fast directive.

Quoted 5 lines

(2) Swap space in use before the hibernation must be handled with care

If swap space is used for saving the memory snapshot, the snapshot-saving application (or kernel) must be careful enough not to overwrite swap pages that contain valid memory contents stored in there before the hibernation.

true, in fact, given that many distros and live-CD's autodetect swap partitions and consider them fair game, I would argue that the best thing to do would be to have the main system free up it's swap partitions before going into hibernation.

however, this could be a decision of the particular hibernate routines.

for the kexec approach the mapping of what swap pages are in use is one more chunk of data that needs to be assembled and made available through a defined interface.

Quoted 5 lines

(4) The user should be able to limit the size of a hibernation image

There are a couple of reasons of that. For example, the storage space used for saving the image may be smaller than the entire RAM or the user may want the image to be saved quickier.

it may make sense for this to be split into hard and soft limits.

if you try to save more then the storage space can hold you cannot continue, but if you are just a little over the arbatrary size limit that was set to make things fast you are better off saving things as-is then punting, going back to the system, trying to free more ram, and trying a hibernate again.

with the kexec approach the enforcment of these limits is also split into two sections.

when the hibernate command is given in the main kernel, it's userspace needs to follow some policy to decide how much (if any) memory to free.

this could be anything from 'none, try and save all caches' to 'anything you can to minimize the amount of data to be saved, trash all caches' to something in between like 'try and free up enough memory to get the saved data below 1G, but save caches beyond that point'

then when the second kernel runs, it's userspace tools get the list of what memory should be saved that the main kernel handed to it, and then decides if this is acceptable (probably mostly the hard limits of 'can this work') and proceeds to save it somewhere.

but since the kexec command and the preporation of the devices can change the memory, the estimates done by the first kernel's userspace are just that, estimates.

Quoted 7 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

now, for suspend-to-ram you need to be aware of every possible power saving option you have and the cost of each of them, and here the ACPI modes are heavily used.

I think this is mixing suspend and hibernate still.

David Lang

#62 lore raw
Quoted 61 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 10 lines · Rafael J. Wysocki

Hi,

Since many alternative approaches to hibernation are now being considered and discussed, I thought it might be a good idea to list some things that in my not so humble opinion should be taken care of by any hibernation framework. They are listed below, not in any particular order, because I think they all are important. Still, I might have forgotten something, so everyone with experience in implementing hibernation, especially Pavel and Nigel, please check if the list is complete.

Quoted 8 lines

(1) Filesystems mounted before the hibernation are untouchable

When there's a memory snapshot, either in the form of a hibernation image, or in the form of the "old" kernel and processes available to the "new" kexeced kernel responsible for saving their memory, the filesystems mounted before the hibernation should not be accessed, even for reading, because that would cause their on-disk state to be inconsistent with the snapshot and might lead to a filesystem corruption.

AFAIK this is only the case with ext3, all other filesystems could be accessed read-only safely

this is arguably a bug with ext3 (and has been discussed as such), but right now the ext3 team has decided not to change this bahavior so hibernate needs to work around it. but don't mistake a work-around for a single (admittedly very popular) filesystem with a hard and fast directive.

Quoted 5 lines

(2) Swap space in use before the hibernation must be handled with care

If swap space is used for saving the memory snapshot, the snapshot-saving application (or kernel) must be careful enough not to overwrite swap pages that contain valid memory contents stored in there before the hibernation.

true, in fact, given that many distros and live-CD's autodetect swap partitions and consider them fair game, I would argue that the best thing to do would be to have the main system free up it's swap partitions before going into hibernation.

however, this could be a decision of the particular hibernate routines.

for the kexec approach the mapping of what swap pages are in use is one more chunk of data that needs to be assembled and made available through a defined interface.

Quoted 5 lines

(4) The user should be able to limit the size of a hibernation image

There are a couple of reasons of that. For example, the storage space used for saving the image may be smaller than the entire RAM or the user may want the image to be saved quickier.

it may make sense for this to be split into hard and soft limits.

if you try to save more then the storage space can hold you cannot continue, but if you are just a little over the arbatrary size limit that was set to make things fast you are better off saving things as-is then punting, going back to the system, trying to free more ram, and trying a hibernate again.

Quoted 5 lines

with the kexec approach the enforcment of these limits is also split into two sections.

when the hibernate command is given in the main kernel, it's userspace needs to follow some policy to decide how much (if any) memory to free.

How are you going to achieve this without (a) having hibernation-aware user space or (b) the freezer?

Quoted 17 lines

this could be anything from 'none, try and save all caches' to 'anything you can to minimize the amount of data to be saved, trash all caches' to something in between like 'try and free up enough memory to get the saved data below 1G, but save caches beyond that point'

then when the second kernel runs, it's userspace tools get the list of what memory should be saved that the main kernel handed to it, and then decides if this is acceptable (probably mostly the hard limits of 'can this work') and proceeds to save it somewhere.

but since the kexec command and the preporation of the devices can change the memory, the estimates done by the first kernel's userspace are just that, estimates.

Quoted 3 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

Quoted 7 lines
Quoted 4 lines

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 5 lines

now, for suspend-to-ram you need to be aware of every possible power saving option you have and the cost of each of them, and here the ACPI modes are heavily used.

I think this is mixing suspend and hibernate still.

Yes, it is, but that's not we who's mixing. We just need to handle some systems built with ACPI in mind.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#63 lore raw
Quoted 62 lines · Rafael J. Wysocki
Quoted 61 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 10 lines · Rafael J. Wysocki

Hi,

Since many alternative approaches to hibernation are now being considered and discussed, I thought it might be a good idea to list some things that in my not so humble opinion should be taken care of by any hibernation framework. They are listed below, not in any particular order, because I think they all are important. Still, I might have forgotten something, so everyone with experience in implementing hibernation, especially Pavel and Nigel, please check if the list is complete.

Quoted 8 lines

(1) Filesystems mounted before the hibernation are untouchable

When there's a memory snapshot, either in the form of a hibernation image, or in the form of the "old" kernel and processes available to the "new" kexeced kernel responsible for saving their memory, the filesystems mounted before the hibernation should not be accessed, even for reading, because that would cause their on-disk state to be inconsistent with the snapshot and might lead to a filesystem corruption.

AFAIK this is only the case with ext3, all other filesystems could be accessed read-only safely

this is arguably a bug with ext3 (and has been discussed as such), but right now the ext3 team has decided not to change this bahavior so hibernate needs to work around it. but don't mistake a work-around for a single (admittedly very popular) filesystem with a hard and fast directive.

Quoted 5 lines

(2) Swap space in use before the hibernation must be handled with care

If swap space is used for saving the memory snapshot, the snapshot-saving application (or kernel) must be careful enough not to overwrite swap pages that contain valid memory contents stored in there before the hibernation.

true, in fact, given that many distros and live-CD's autodetect swap partitions and consider them fair game, I would argue that the best thing to do would be to have the main system free up it's swap partitions before going into hibernation.

however, this could be a decision of the particular hibernate routines.

for the kexec approach the mapping of what swap pages are in use is one more chunk of data that needs to be assembled and made available through a defined interface.

Quoted 5 lines

(4) The user should be able to limit the size of a hibernation image

There are a couple of reasons of that. For example, the storage space used for saving the image may be smaller than the entire RAM or the user may want the image to be saved quickier.

it may make sense for this to be split into hard and soft limits.

if you try to save more then the storage space can hold you cannot continue, but if you are just a little over the arbatrary size limit that was set to make things fast you are better off saving things as-is then punting, going back to the system, trying to free more ram, and trying a hibernate again.

Quoted 8 lines
Quoted 5 lines

with the kexec approach the enforcment of these limits is also split into two sections.

when the hibernate command is given in the main kernel, it's userspace needs to follow some policy to decide how much (if any) memory to free.

How are you going to achieve this without (a) having hibernation-aware user space or (b) the freezer?

the hibernate command is a userspace command, but the fact that other things in userspace are running at the same time is exactly why this is only an estimate and best-effort as I said in the paragraph below.

Quoted 12 lines
Quoted 12 lines

but since the kexec command and the preporation of the devices can change the memory, the estimates done by the first kernel's userspace are just that, estimates.

Quoted 7 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

Quoted 7 lines
Quoted 2 lines

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

so if a machine is actually powered off the /dev/suspend process won't work?

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

David Lang

Quoted 14 lines
Quoted 5 lines

now, for suspend-to-ram you need to be aware of every possible power saving option you have and the cost of each of them, and here the ACPI modes are heavily used.

I think this is mixing suspend and hibernate still.

Yes, it is, but that's not we who's mixing. We just need to handle some systems built with ACPI in mind.

Greetings,
Rafael

#64 lore raw
Quoted 92 lines · On Monday, 16 July 2007 00:42, [email protected] wrote:
Quoted 62 lines · Rafael J. Wysocki
Quoted 61 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 10 lines · Rafael J. Wysocki

Hi,

Since many alternative approaches to hibernation are now being considered and discussed, I thought it might be a good idea to list some things that in my not so humble opinion should be taken care of by any hibernation framework. They are listed below, not in any particular order, because I think they all are important. Still, I might have forgotten something, so everyone with experience in implementing hibernation, especially Pavel and Nigel, please check if the list is complete.

Quoted 8 lines

(1) Filesystems mounted before the hibernation are untouchable

When there's a memory snapshot, either in the form of a hibernation image, or in the form of the "old" kernel and processes available to the "new" kexeced kernel responsible for saving their memory, the filesystems mounted before the hibernation should not be accessed, even for reading, because that would cause their on-disk state to be inconsistent with the snapshot and might lead to a filesystem corruption.

AFAIK this is only the case with ext3, all other filesystems could be accessed read-only safely

this is arguably a bug with ext3 (and has been discussed as such), but right now the ext3 team has decided not to change this bahavior so hibernate needs to work around it. but don't mistake a work-around for a single (admittedly very popular) filesystem with a hard and fast directive.

Quoted 5 lines

(2) Swap space in use before the hibernation must be handled with care

If swap space is used for saving the memory snapshot, the snapshot-saving application (or kernel) must be careful enough not to overwrite swap pages that contain valid memory contents stored in there before the hibernation.

true, in fact, given that many distros and live-CD's autodetect swap partitions and consider them fair game, I would argue that the best thing to do would be to have the main system free up it's swap partitions before going into hibernation.

however, this could be a decision of the particular hibernate routines.

for the kexec approach the mapping of what swap pages are in use is one more chunk of data that needs to be assembled and made available through a defined interface.

Quoted 5 lines

(4) The user should be able to limit the size of a hibernation image

There are a couple of reasons of that. For example, the storage space used for saving the image may be smaller than the entire RAM or the user may want the image to be saved quickier.

it may make sense for this to be split into hard and soft limits.

if you try to save more then the storage space can hold you cannot continue, but if you are just a little over the arbatrary size limit that was set to make things fast you are better off saving things as-is then punting, going back to the system, trying to free more ram, and trying a hibernate again.

Quoted 8 lines
Quoted 5 lines

with the kexec approach the enforcment of these limits is also split into two sections.

when the hibernate command is given in the main kernel, it's userspace needs to follow some policy to decide how much (if any) memory to free.

How are you going to achieve this without (a) having hibernation-aware user space or (b) the freezer?

the hibernate command is a userspace command, but the fact that other things in userspace are running at the same time is exactly why this is only an estimate and best-effort as I said in the paragraph below.

Quoted 15 lines
Quoted 14 lines

but since the kexec command and the preporation of the devices can change the memory, the estimates done by the first kernel's userspace are just that, estimates.

Quoted 7 lines

(7) On ACPI systems special platform-related actions have to be carried out at the right points, so that the platform works correctly after the restore

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Quoted 7 lines
Quoted 4 lines

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

so if a machine is actually powered off the /dev/suspend process won't work?

No, it sort of works as usual, but after the restore the platform is not in the correct state.

Quoted 3 lines

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

True, that's problematic.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#65 lore raw
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · On Monday, 16 July 2007 00:42, [email protected] wrote:
Quoted 15 lines · Rafael J. Wysocki
Quoted 9 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 4 lines · Rafael J. Wysocki

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 5 lines
Quoted 2 lines

so if a machine is actually powered off the /dev/suspend process won't work?

No, it sort of works as usual, but after the restore the platform is not in the correct state.

this is not hibernate as I and many others are thinking of it.

hibernate as we are thinking would work on basicly any hardware, including things with no ACPI or power savings support. and the system could be in hibernate mode for any time period.

for that matter, after a system is put into hibernate mode the system could be completely disassembled and any components replaced and the system would work after a resume (assuming you still have access to the suspend image)

Quoted 5 lines
Quoted 3 lines

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

True, that's problematic.

putting it mildly.

David Lang

#66 lore raw
Quoted 29 lines · On Monday, 16 July 2007 01:49, [email protected] wrote:
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · On Monday, 16 July 2007 00:42, [email protected] wrote:
Quoted 15 lines · Rafael J. Wysocki
Quoted 9 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 4 lines · Rafael J. Wysocki

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 5 lines
Quoted 2 lines

so if a machine is actually powered off the /dev/suspend process won't work?

No, it sort of works as usual, but after the restore the platform is not in the correct state.

this is not hibernate as I and many others are thinking of it.

Quoted 8 lines

hibernate as we are thinking would work on basicly any hardware, including things with no ACPI or power savings support. and the system could be in hibernate mode for any time period.

for that matter, after a system is put into hibernate mode the system could be completely disassembled and any components replaced and the system would work after a resume (assuming you still have access to the suspend image)

Well, this is not how ACPI defines the S4 sleep state. If the system is in S4, that corresponds to our hibernation, you are _not_ allowed to disassemble it.

I've just done an experiment on my test desktop. I had enabled suspend support in the CMOS setup and afterwards I made Linux hibernate in the "platform" mode. Then, when the system was powred on, the BIOS showed me a nice "Resume from hibernation" screen that is not normally displayed during boot. This clearly means that some information has been preserved by the platform across the hibernate/restore cycle. We are supposed to handle that.

Greetngs,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#67 lore raw
Quoted 43 lines · Rafael J. Wysocki
Quoted 29 lines · On Monday, 16 July 2007 01:49, [email protected] wrote:
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · On Monday, 16 July 2007 00:42, [email protected] wrote:
Quoted 15 lines · Rafael J. Wysocki
Quoted 9 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 4 lines · Rafael J. Wysocki

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 5 lines
Quoted 2 lines

so if a machine is actually powered off the /dev/suspend process won't work?

No, it sort of works as usual, but after the restore the platform is not in the correct state.

this is not hibernate as I and many others are thinking of it.

Quoted 8 lines

hibernate as we are thinking would work on basicly any hardware, including things with no ACPI or power savings support. and the system could be in hibernate mode for any time period.

for that matter, after a system is put into hibernate mode the system could be completely disassembled and any components replaced and the system would work after a resume (assuming you still have access to the suspend image)

Well, this is not how ACPI defines the S4 sleep state. If the system is in S4, that corresponds to our hibernation, you are _not_ allowed to disassemble it.

Quoted 7 lines

I've just done an experiment on my test desktop. I had enabled suspend support in the CMOS setup and afterwards I made Linux hibernate in the "platform" mode. Then, when the system was powred on, the BIOS showed me a nice "Resume from hibernation" screen that is not normally displayed during boot. This clearly means that some information has been preserved by the platform across the hibernate/restore cycle. We are supposed to handle that.

What I believe he's getting at is that Linux hibernation shouldn't be tied to any ACPI states. Yes, when available and working most people will want to enter ACPI S4 but we should still have the option of doing a normal poweroff. With the latter method it would look just like regular power off/on cycle to the firmware. And that would definitely be useful for things like working around buggy ACPI implementations or supporting platforms that don't do ACPI at all. That is the difference between the platform and shutdown options in /sys/power/disk, isn't it?

Quoted 3 lines

Greetngs,
Rafael

Jim.

#68 lore raw
Quoted 52 lines · Jim Crilly
Quoted 43 lines · Rafael J. Wysocki
Quoted 29 lines · On Monday, 16 July 2007 01:49, [email protected] wrote:
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · On Monday, 16 July 2007 00:42, [email protected] wrote:
Quoted 15 lines · Rafael J. Wysocki
Quoted 9 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 4 lines · Rafael J. Wysocki

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 5 lines
Quoted 2 lines

so if a machine is actually powered off the /dev/suspend process won't work?

No, it sort of works as usual, but after the restore the platform is not in the correct state.

this is not hibernate as I and many others are thinking of it.

Quoted 8 lines

hibernate as we are thinking would work on basicly any hardware, including things with no ACPI or power savings support. and the system could be in hibernate mode for any time period.

for that matter, after a system is put into hibernate mode the system could be completely disassembled and any components replaced and the system would work after a resume (assuming you still have access to the suspend image)

Well, this is not how ACPI defines the S4 sleep state. If the system is in S4, that corresponds to our hibernation, you are _not_ allowed to disassemble it.

Quoted 7 lines

I've just done an experiment on my test desktop. I had enabled suspend support in the CMOS setup and afterwards I made Linux hibernate in the "platform" mode. Then, when the system was powred on, the BIOS showed me a nice "Resume from hibernation" screen that is not normally displayed during boot. This clearly means that some information has been preserved by the platform across the hibernate/restore cycle. We are supposed to handle that.

Quoted 8 lines

What I believe he's getting at is that Linux hibernation shouldn't be tied to any ACPI states. Yes, when available and working most people will want to enter ACPI S4 but we should still have the option of doing a normal poweroff. With the latter method it would look just like regular power off/on cycle to the firmware. And that would definitely be useful for things like working around buggy ACPI implementations or supporting platforms that don't do ACPI at all. That is the difference between the platform and shutdown options in /sys/power/disk, isn't it?

Yes, but this is not my point.

The point is that there are systems that _require_ the ACPI handling to work correctly after the restore and we need to that _that_ into consideration.

IOW, there are poeple for whom the non-ACPI framework won't work as expected.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#69 lore raw
Quoted 62 lines · Rafael J. Wysocki
Quoted 52 lines · Jim Crilly
Quoted 43 lines · Rafael J. Wysocki
Quoted 29 lines · On Monday, 16 July 2007 01:49, [email protected] wrote:
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · On Monday, 16 July 2007 00:42, [email protected] wrote:
Quoted 15 lines · Rafael J. Wysocki
Quoted 9 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 4 lines · Rafael J. Wysocki

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 5 lines
Quoted 2 lines

so if a machine is actually powered off the /dev/suspend process won't work?

No, it sort of works as usual, but after the restore the platform is not in the correct state.

this is not hibernate as I and many others are thinking of it.

Quoted 8 lines

hibernate as we are thinking would work on basicly any hardware, including things with no ACPI or power savings support. and the system could be in hibernate mode for any time period.

for that matter, after a system is put into hibernate mode the system could be completely disassembled and any components replaced and the system would work after a resume (assuming you still have access to the suspend image)

Well, this is not how ACPI defines the S4 sleep state. If the system is in S4, that corresponds to our hibernation, you are _not_ allowed to disassemble it.

Quoted 7 lines

I've just done an experiment on my test desktop. I had enabled suspend support in the CMOS setup and afterwards I made Linux hibernate in the "platform" mode. Then, when the system was powred on, the BIOS showed me a nice "Resume from hibernation" screen that is not normally displayed during boot. This clearly means that some information has been preserved by the platform across the hibernate/restore cycle. We are supposed to handle that.

Quoted 8 lines

What I believe he's getting at is that Linux hibernation shouldn't be tied to any ACPI states. Yes, when available and working most people will want to enter ACPI S4 but we should still have the option of doing a normal poweroff. With the latter method it would look just like regular power off/on cycle to the firmware. And that would definitely be useful for things like working around buggy ACPI implementations or supporting platforms that don't do ACPI at all. That is the difference between the platform and shutdown options in /sys/power/disk, isn't it?

Quoted 6 lines

Yes, but this is not my point.

The point is that there are systems that _require_ the ACPI handling to work correctly after the restore and we need to that _that_ into consideration.

IOW, there are poeple for whom the non-ACPI framework won't work as expected.

why would the type of hibernate that I'm talking about (power off, not S4 mode) not work on a box that has ACPI?

you are saying that it wouldn't work right after a restore, but that's only if the restored image is expecting to have it's devices in ACPI sleep modes. my answer is "don't do that then" S4 mode does not save power compared to powering off, and when doing a hibernate you should be prepared to run out of battery before you wake up, which would then look like a power-on

the S4 mode sounds like a deeper version of suspend-to-ram, with all of the limitations of STR becouse you still require power continuously and must remain in complete control of the machine.

if you want to do a suspend to S4 mode, go for it, but we need to have a different name for that then for the suspend-to-disk-and-poer-off mode that I thought was hibernate

David Lang

#70 lore raw
Quoted 2 lines · On Mon, Jul 16, 2007 at 09:28:13PM -0700, [email protected] wrote:

why would the type of hibernate that I'm talking about (power off, not S4 mode) not work on a box that has ACPI?

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

Signature · 1 line
Matthew Garrett | [email protected]
#71 lore raw
In reply to [email protected]
Quoted 2 lines · On Mon, Jul 16, 2007 at 09:28:13PM -0700, [email protected] wrote:

why would the type of hibernate that I'm talking about (power off, not S4 mode) not work on a box that has ACPI?

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

Signature · 1 line
Matthew Garrett | [email protected]
#72 lore raw
Quoted 8 lines · Matthew Garrett
Quoted 2 lines · On Mon, Jul 16, 2007 at 09:28:13PM -0700, [email protected] wrote:

why would the type of hibernate that I'm talking about (power off, not S4 mode) not work on a box that has ACPI?

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

only if the kexec isn't able to initialize those devices.

David Lang

#73 lore raw
In reply to Matthew Garrett
Quoted 8 lines · Matthew Garrett
Quoted 2 lines · On Mon, Jul 16, 2007 at 09:28:13PM -0700, [email protected] wrote:

why would the type of hibernate that I'm talking about (power off, not S4 mode) not work on a box that has ACPI?

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

only if the kexec isn't able to initialize those devices.

David Lang

#74 lore raw
Quoted 6 lines · On Tue, Jul 17, 2007 at 08:19:32AM -0700, [email protected] wrote:
Quoted 3 lines · Matthew Garrett

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

only if the kexec isn't able to initialize those devices.

If you aren't using ACPI, you probably don't know how to.

Signature · 1 line
Matthew Garrett | [email protected]
#75 lore raw
In reply to [email protected]
Quoted 6 lines · On Tue, Jul 17, 2007 at 08:19:32AM -0700, [email protected] wrote:
Quoted 3 lines · Matthew Garrett

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

only if the kexec isn't able to initialize those devices.

If you aren't using ACPI, you probably don't know how to.

Signature · 1 line
Matthew Garrett | [email protected]
#76 lore raw
Quoted 9 lines · Matthew Garrett
Quoted 6 lines · On Tue, Jul 17, 2007 at 08:19:32AM -0700, [email protected] wrote:
Quoted 3 lines · Matthew Garrett

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

only if the kexec isn't able to initialize those devices.

If you aren't using ACPI, you probably don't know how to.

the current kexec patch to allow you to move back to the original kernel requires ACPI be disabled to work.

that states pretty strongly that kexec isn't dependant on ACPI to initialize devices.

David Lang

#77 lore raw
Quoted 8 lines · On Tue, Jul 17, 2007 at 08:54:24PM -0700, [email protected] wrote:
Quoted 6 lines · Matthew Garrett
Quoted 5 lines · On Tue, Jul 17, 2007 at 08:19:32AM -0700, [email protected] wrote:
Quoted 3 lines · Matthew Garrett

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

only if the kexec isn't able to initialize those devices.

If you aren't using ACPI, you probably don't know how to.

the current kexec patch to allow you to move back to the original kernel requires ACPI be disabled to work.

Which means it isn't putting the hardware into S4, which means that you don't get the platform wakeup events.

Signature · 1 line
Matthew Garrett | [email protected]
#78 lore raw
In reply to [email protected]
Quoted 8 lines · On Tue, Jul 17, 2007 at 08:54:24PM -0700, [email protected] wrote:
Quoted 6 lines · Matthew Garrett
Quoted 5 lines · On Tue, Jul 17, 2007 at 08:19:32AM -0700, [email protected] wrote:
Quoted 3 lines · Matthew Garrett

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

only if the kexec isn't able to initialize those devices.

If you aren't using ACPI, you probably don't know how to.

the current kexec patch to allow you to move back to the original kernel requires ACPI be disabled to work.

Which means it isn't putting the hardware into S4, which means that you don't get the platform wakeup events.

Signature · 1 line
Matthew Garrett | [email protected]
#79 lore raw
Quoted 11 lines · Matthew Garrett
Quoted 10 lines · On Tue, Jul 17, 2007 at 08:54:24PM -0700, [email protected] wrote:
Quoted 8 lines · Matthew Garrett
Quoted 6 lines · On Tue, Jul 17, 2007 at 08:19:32AM -0700, [email protected] wrote:
Quoted 3 lines · Matthew Garrett

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

only if the kexec isn't able to initialize those devices.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

If you aren't using ACPI, you probably don't know how to.

the current kexec patch to allow you to move back to the original kernel requires ACPI be disabled to work.

Which means it isn't putting the hardware into S4, which means that you don't get the platform wakeup events.

Ok, I was misunderstanding what you meant by wakeup device support. if you are meaning things like wake-on-lan then yes, you do loose that with no ACPI support, but that is acceptable to many people. I understand it's not for some, and I'm not saying that this should be the only type of suspend, but I'm also saying that this should be one option.

David Lang

#80 lore raw
In reply to Matthew Garrett
Quoted 11 lines · Matthew Garrett
Quoted 10 lines · On Tue, Jul 17, 2007 at 08:54:24PM -0700, [email protected] wrote:
Quoted 8 lines · Matthew Garrett
Quoted 6 lines · On Tue, Jul 17, 2007 at 08:19:32AM -0700, [email protected] wrote:
Quoted 3 lines · Matthew Garrett

Powering off rather than using S4 means you lose most wakeup device support. That would be a functional regression compared to the current code.

only if the kexec isn't able to initialize those devices.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

If you aren't using ACPI, you probably don't know how to.

the current kexec patch to allow you to move back to the original kernel requires ACPI be disabled to work.

Which means it isn't putting the hardware into S4, which means that you don't get the platform wakeup events.

Ok, I was misunderstanding what you meant by wakeup device support. if you are meaning things like wake-on-lan then yes, you do loose that with no ACPI support, but that is acceptable to many people. I understand it's not for some, and I'm not saying that this should be the only type of suspend, but I'm also saying that this should be one option.

David Lang

#81 lore raw
In reply to Jim Crilly
Quoted 52 lines · Jim Crilly
Quoted 43 lines · Rafael J. Wysocki
Quoted 29 lines · On Monday, 16 July 2007 01:49, [email protected] wrote:
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · On Monday, 16 July 2007 00:42, [email protected] wrote:
Quoted 15 lines · Rafael J. Wysocki
Quoted 9 lines · On Sunday, 15 July 2007 22:13, [email protected] wrote:
Quoted 4 lines · Rafael J. Wysocki

The ACPI specification requires us to invoke some global ACPI methods during the hibernation and during the restore. Moreover, the ordering of code related to these ACPI methods may not be arbitrary (eg. some of them have to be executed after devices are put into low power states etc.).

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 5 lines
Quoted 2 lines

so if a machine is actually powered off the /dev/suspend process won't work?

No, it sort of works as usual, but after the restore the platform is not in the correct state.

this is not hibernate as I and many others are thinking of it.

Quoted 8 lines

hibernate as we are thinking would work on basicly any hardware, including things with no ACPI or power savings support. and the system could be in hibernate mode for any time period.

for that matter, after a system is put into hibernate mode the system could be completely disassembled and any components replaced and the system would work after a resume (assuming you still have access to the suspend image)

Well, this is not how ACPI defines the S4 sleep state. If the system is in S4, that corresponds to our hibernation, you are _not_ allowed to disassemble it.

Quoted 7 lines

I've just done an experiment on my test desktop. I had enabled suspend support in the CMOS setup and afterwards I made Linux hibernate in the "platform" mode. Then, when the system was powred on, the BIOS showed me a nice "Resume from hibernation" screen that is not normally displayed during boot. This clearly means that some information has been preserved by the platform across the hibernate/restore cycle. We are supposed to handle that.

Quoted 8 lines

What I believe he's getting at is that Linux hibernation shouldn't be tied to any ACPI states. Yes, when available and working most people will want to enter ACPI S4 but we should still have the option of doing a normal poweroff. With the latter method it would look just like regular power off/on cycle to the firmware. And that would definitely be useful for things like working around buggy ACPI implementations or supporting platforms that don't do ACPI at all. That is the difference between the platform and shutdown options in /sys/power/disk, isn't it?

Yes, but this is not my point.

The point is that there are systems that _require_ the ACPI handling to work correctly after the restore and we need to that _that_ into consideration.

IOW, there are poeple for whom the non-ACPI framework won't work as expected.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#82 lore raw
In reply to [email protected]
Quoted 8 lines · On Sun, 15 Jul 2007 [email protected] wrote:
Quoted 7 lines
Quoted 2 lines

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 6 lines

so if a machine is actually powered off the /dev/suspend process won't work?

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

Alan Stern

#83 lore raw
In reply to [email protected]
Quoted 8 lines · On Sun, 15 Jul 2007 [email protected] wrote:
Quoted 7 lines
Quoted 2 lines

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

Quoted 6 lines

so if a machine is actually powered off the /dev/suspend process won't work?

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

Alan Stern

#84 lore raw

Hi.

Quoted 3 lines · On Monday 16 July 2007 09:15:47 Alan Stern wrote:
Quoted 1 line · On Sun, 15 Jul 2007 [email protected] wrote:
Quoted 1 line
Quoted 1 line

for a pure hibernate mode, you will be powering off the box after

saving

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI

callbacks

Quoted 1 line
Quoted 1 line
Quoted 1 line

aren't used during the hibernation. That's just experience and it's in

line

Quoted 11 lines
Quoted 8 lines
Quoted 1 line

with the ACPI spec.

so if a machine is actually powered off the /dev/suspend process won't work?

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

Well then, I know one or two people who would argue that the ACPI spec is faulty. :\

Regards,

Nigel

Signature · 5 lines
Nigel Cunningham
Christian Reformed Church of Cobden
103 Curdie Street, Cobden 3266, Victoria, Australia
Ph. +61 3 5595 1185 / +61 417 100 574
Communal Worship: 11 am Sunday.
#85 lore raw
In reply to Alan Stern

Hi.

Quoted 3 lines · On Monday 16 July 2007 09:15:47 Alan Stern wrote:
Quoted 1 line · On Sun, 15 Jul 2007 [email protected] wrote:
Quoted 1 line
Quoted 1 line

for a pure hibernate mode, you will be powering off the box after

saving

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI

callbacks

Quoted 1 line
Quoted 1 line
Quoted 1 line

aren't used during the hibernation. That's just experience and it's in

line

Quoted 11 lines
Quoted 8 lines
Quoted 1 line

with the ACPI spec.

so if a machine is actually powered off the /dev/suspend process won't work?

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

Well then, I know one or two people who would argue that the ACPI spec is faulty. :\

Regards,

Nigel

Signature · 5 lines
Nigel Cunningham
Christian Reformed Church of Cobden
103 Curdie Street, Cobden 3266, Victoria, Australia
Ph. +61 3 5595 1185 / +61 417 100 574
Communal Worship: 11 am Sunday.
#86 lore raw
Quoted 5 lines · Nigel Cunningham
Quoted 2 lines

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

Well then, I know one or two people who would argue that the ACPI spec is faulty. :\

It's hard to argue against that. In fact there are people who would argue that the ACPI spec is incomplete and inconsistent period, regardless of any questions about what happens between hibernate and resume. :-)

Alan Stern

#87 lore raw
In reply to Nigel Cunningham
Quoted 5 lines · Nigel Cunningham
Quoted 2 lines

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

Well then, I know one or two people who would argue that the ACPI spec is faulty. :\

It's hard to argue against that. In fact there are people who would argue that the ACPI spec is incomplete and inconsistent period, regardless of any questions about what happens between hibernate and resume. :-)

Alan Stern

#88 lore raw
Quoted 5 lines · Alan Stern
Quoted 3 lines · Nigel Cunningham
Quoted 2 lines

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

Quoted 7 lines
Quoted 2 lines

Well then, I know one or two people who would argue that the ACPI spec is faulty. :\

It's hard to argue against that. In fact there are people who would argue that the ACPI spec is incomplete and inconsistent period, regardless of any questions about what happens between hibernate and resume. :-)

That's true, but OTOH it's difficult to argue with my notebook's firmware about that. ;-)

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#89 lore raw
In reply to Alan Stern
Quoted 5 lines · Alan Stern
Quoted 3 lines · Nigel Cunningham
Quoted 2 lines

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

Quoted 7 lines
Quoted 2 lines

Well then, I know one or two people who would argue that the ACPI spec is faulty. :\

It's hard to argue against that. In fact there are people who would argue that the ACPI spec is incomplete and inconsistent period, regardless of any questions about what happens between hibernate and resume. :-)

That's true, but OTOH it's difficult to argue with my notebook's firmware about that. ;-)

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#90 lore raw
In reply to Alan Stern
Quoted 13 lines · Alan Stern
Quoted 11 lines · On Sun, 15 Jul 2007 [email protected] wrote:
Quoted 7 lines
Quoted 2 lines

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

so if a machine is actually powered off the /dev/suspend process won't work?

Quoted 6 lines
Quoted 3 lines

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

then we need a third mode of operation.

mode 1: Suspend-to-ram

the system is paused and put into a low-power mode but data remains in
memory and the system stays awake enough to keep the memory refreshed.

mode 2: new

the system is paused, data is stored to permanent media, and the system
is put into a ultra-low power mode.

mode 3: hibernate

the system is paused, data is stored to permanent media, and the system
is powered off

with mode 3 there are no requirements or limitations about what can be done with the hardware before a resume (the resume could even take place on a different piece of identical hardware)

mode 2 could be what you are talking about doing, although I don't see any advantage of creating it in additon to mode 3, it doesn't use any less power and it locks the system so that it can't be used for anything else in the meantime. I guess if it was significantly faster to do then mode 3 there may be _some_ reason to consider it, but I don't see the speed difference.

David Lang

#91 lore raw
In reply to Alan Stern
Quoted 13 lines · Alan Stern
Quoted 11 lines · On Sun, 15 Jul 2007 [email protected] wrote:
Quoted 7 lines
Quoted 2 lines

for a pure hibernate mode, you will be powering off the box after saving the suspend image. why are there any special ACPI modes involved?

Because, for example, on my machine the status of power supply (present vs not present) is not updated correctly after the restore if ACPI callbacks aren't used during the hibernation. That's just experience and it's in line with the ACPI spec.

so if a machine is actually powered off the /dev/suspend process won't work?

Quoted 6 lines
Quoted 3 lines

remember that the system may run a different OS between the hibernate and the resume, makeing any assumptions about what state the hardware is in when you start the resume is a problem.

As I understand it, running a different OS between the hibernate and the resume would violate the ACPI spec.

then we need a third mode of operation.

mode 1: Suspend-to-ram

the system is paused and put into a low-power mode but data remains in
memory and the system stays awake enough to keep the memory refreshed.

mode 2: new

the system is paused, data is stored to permanent media, and the system
is put into a ultra-low power mode.

mode 3: hibernate

the system is paused, data is stored to permanent media, and the system
is powered off

with mode 3 there are no requirements or limitations about what can be done with the hardware before a resume (the resume could even take place on a different piece of identical hardware)

mode 2 could be what you are talking about doing, although I don't see any advantage of creating it in additon to mode 3, it doesn't use any less power and it locks the system so that it can't be used for anything else in the meantime. I guess if it was significantly faster to do then mode 3 there may be _some_ reason to consider it, but I don't see the speed difference.

David Lang

#92 lore raw
Quoted 21 lines · On Sun, 15 Jul 2007 [email protected] wrote:

then we need a third mode of operation.

mode 1: Suspend-to-ram

the system is paused and put into a low-power mode but data remains in
memory and the system stays awake enough to keep the memory refreshed.

mode 2: new

the system is paused, data is stored to permanent media, and the system
is put into a ultra-low power mode.

mode 3: hibernate

the system is paused, data is stored to permanent media, and the system
is powered off

with mode 3 there are no requirements or limitations about what can be done with the hardware before a resume (the resume could even take place on a different piece of identical hardware)

Quoted 6 lines

mode 2 could be what you are talking about doing, although I don't see any advantage of creating it in additon to mode 3, it doesn't use any less power and it locks the system so that it can't be used for anything else in the meantime. I guess if it was significantly faster to do then mode 3 there may be _some_ reason to consider it, but I don't see the speed difference.

Part of the problem here is that ACPI already has its own terminology, and you're trying to invent a new one instead of using the existing one.

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

You have to understand that the ACPI spec is weird and complex. The mere fact that you have written a system image to disk changes the way ACPI regards the shutdown procedure. Even though you may treat all the devices and the rest of the hardware exactly the same, it's a different operation as far as ACPI is concerned, with different requirements.

Yes, it's bizarre. Why do you think so many people have complained so vehemently about ACPI for all these years?

Alan Stern

#93 lore raw
Quoted 30 lines · Alan Stern
Quoted 21 lines · On Sun, 15 Jul 2007 [email protected] wrote:

then we need a third mode of operation.

mode 1: Suspend-to-ram

the system is paused and put into a low-power mode but data remains in
memory and the system stays awake enough to keep the memory refreshed.

mode 2: new

the system is paused, data is stored to permanent media, and the system
is put into a ultra-low power mode.

mode 3: hibernate

the system is paused, data is stored to permanent media, and the system
is powered off

with mode 3 there are no requirements or limitations about what can be done with the hardware before a resume (the resume could even take place on a different piece of identical hardware)

Quoted 6 lines

mode 2 could be what you are talking about doing, although I don't see any advantage of creating it in additon to mode 3, it doesn't use any less power and it locks the system so that it can't be used for anything else in the meantime. I guess if it was significantly faster to do then mode 3 there may be _some_ reason to consider it, but I don't see the speed difference.

Quoted 7 lines

Part of the problem here is that ACPI already has its own terminology, and you're trying to invent a new one instead of using the existing one.

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

Quoted 8 lines

You have to understand that the ACPI spec is weird and complex. The mere fact that you have written a system image to disk changes the way ACPI regards the shutdown procedure. Even though you may treat all the devices and the rest of the hardware exactly the same, it's a different operation as far as ACPI is concerned, with different requirements.

Yes, it's bizarre. Why do you think so many people have complained so vehemently about ACPI for all these years?

so let's act as if ACPI doesn't exist and make a suspend-to-disk that works without it and looks to ACPI like a complete power off/on cycle (but looks to the user like a suspend/resume cycle)

this should avoid all the headaches about ACPI completely becouse you just don't make any ACPI calls at all.

this will also work on any type of system, and it will work in the presence of dead batteries, failed components, booting other OS's, moveing the image to different hardware, etc.

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

David Lang

#94 lore raw
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Alan Stern

#95 lore raw
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#96 lore raw
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

David Lang

#97 lore raw
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

I would rather avoid such pitfalls, if I could.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#98 lore raw
Quoted 54 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Quoted 7 lines

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

David Lang

#99 lore raw
In reply to Rafael J. Wysocki
Quoted 54 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Quoted 7 lines

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

David Lang

#100 lore raw
Quoted 62 lines · On Tuesday, 17 July 2007 19:06, [email protected] wrote:
Quoted 60 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

Quoted 8 lines
Quoted 1 line

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

[Please refer to section 15.3 of the 3.0b ACPI spec for details.]

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#101 lore raw
Quoted 72 lines · Rafael J. Wysocki
Quoted 62 lines · On Tuesday, 17 July 2007 19:06, [email protected] wrote:
Quoted 60 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

Quoted 8 lines
Quoted 1 line

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

no, systems that remain powered while asleep are a different type of suspend then ones that don't.

Quoted 14 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

Quoted 1 line

[Please refer to section 15.3 of the 3.0b ACPI spec for details.]

you are starting from the assumption that ACPI S4 mode should be used.

I'm saying that a suspend that uses ACPI S4 mode is fundamentally different from one that does a power off instead.

from my point of view the ACPI S4 sleep mode has far more in common with suspend-to-ram then with the suspend-to-disk that I'm talking about

non-ACPI hibernate

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system. restore makes no assumptions about the state of the hardware when it is restored restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

ACPI suspends

since the box never completely powers off:
a complete power failure breaks the suspend
the OS must remain in control so other uses must be prevented. hardware must remain in the ACPI state from suspend until restore. restore can be faster (some initialization may be able to be skipped)
requires ACPI hardware support

under the catagory of ACPI suspends you have

fast suspend-to-ram (stop scheduling, put the CPU to sleep, as long as
the memory keeps getting refreshed)
slow suspend-to-ram (stop scheduling, put as much of the hardware as
possible to sleep, including spinning down disks and other things that take a while to undo)
suspend-to-disk (stop scheduleing, copy the ram somewhere so that it
doesn't need to be refreshed, put everything into low-power mode)

and there are probably quite a few others as well. but they are all in
the same family in that you have to worry about ACPI states, and they all have the same restrictions on what can happen between suspend and resume

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

David Lang

#102 lore raw

[email protected] writes:

[snip]

Quoted 3 lines

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

It may have certain differences from the user point of view, but from the implementation view, it seems that it is nearly exactly the same. The only differences seem to be:

- rather than shutting down, do whatever is necessary to stick the system in S4 state.

- make sure ACPI isn't initialized by the "load image" kernel

- rather than "resume from hibernate" ACPI by initializing it normally, issue the special hibernate-related methods.

Thus, it seems that supporting ACPI S4 will have a very minimal affect on the hibernate implementation.

Signature · 1 line
Jeremy Maitin-Shepard
#103 lore raw
Quoted 15 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 3 lines

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

It may have certain differences from the user point of view, but from the implementation view, it seems that it is nearly exactly the same. The only differences seem to be:

- rather than shutting down, do whatever is necessary to stick the system in S4 state.

Quoted 7 lines

- make sure ACPI isn't initialized by the "load image" kernel

- rather than "resume from hibernate" ACPI by initializing it normally, issue the special hibernate-related methods.

Thus, it seems that supporting ACPI S4 will have a very minimal affect on the hibernate implementation.

from what Rafael is saying supporting ACPI S4 mode requires a very fundamentally different restore approach, and in addition imposes very different restrictions on what can be done with the machine while it's suspended.

David Lang

#104 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 15 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 3 lines

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

It may have certain differences from the user point of view, but from the implementation view, it seems that it is nearly exactly the same. The only differences seem to be:

- rather than shutting down, do whatever is necessary to stick the system in S4 state.

Quoted 7 lines

- make sure ACPI isn't initialized by the "load image" kernel

- rather than "resume from hibernate" ACPI by initializing it normally, issue the special hibernate-related methods.

Thus, it seems that supporting ACPI S4 will have a very minimal affect on the hibernate implementation.

Still, you need to take it into account.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#105 lore raw
In reply to [email protected]

[email protected] writes:

[snip]

Quoted 3 lines

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

It may have certain differences from the user point of view, but from the implementation view, it seems that it is nearly exactly the same. The only differences seem to be:

- rather than shutting down, do whatever is necessary to stick the system in S4 state.

- make sure ACPI isn't initialized by the "load image" kernel

- rather than "resume from hibernate" ACPI by initializing it normally, issue the special hibernate-related methods.

Thus, it seems that supporting ACPI S4 will have a very minimal affect on the hibernate implementation.

Signature · 1 line
Jeremy Maitin-Shepard
#106 lore raw
In reply to [email protected]
Quoted 97 lines · On Tuesday, 17 July 2007 22:18, [email protected] wrote:
Quoted 72 lines · Rafael J. Wysocki
Quoted 62 lines · On Tuesday, 17 July 2007 19:06, [email protected] wrote:
Quoted 60 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

Quoted 8 lines
Quoted 1 line

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

no, systems that remain powered while asleep are a different type of suspend then ones that don't.

Quoted 14 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

Quoted 6 lines
Quoted 1 line

[Please refer to section 15.3 of the 3.0b ACPI spec for details.]

you are starting from the assumption that ACPI S4 mode should be used.

I'm saying that a suspend that uses ACPI S4 mode is fundamentally different from one that does a power off instead.

It is different, but not fundamentally.

Quoted 33 lines

from my point of view the ACPI S4 sleep mode has far more in common with suspend-to-ram then with the suspend-to-disk that I'm talking about

non-ACPI hibernate

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system. restore makes no assumptions about the state of the hardware when it is restored restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

ACPI suspends

since the box never completely powers off:
a complete power failure breaks the suspend
the OS must remain in control so other uses must be prevented. hardware must remain in the ACPI state from suspend until restore. restore can be faster (some initialization may be able to be skipped)
requires ACPI hardware support

under the catagory of ACPI suspends you have

fast suspend-to-ram (stop scheduling, put the CPU to sleep, as long as
the memory keeps getting refreshed)
slow suspend-to-ram (stop scheduling, put as much of the hardware as
possible to sleep, including spinning down disks and other things that take a while to undo)
suspend-to-disk (stop scheduleing, copy the ram somewhere so that it
doesn't need to be refreshed, put everything into low-power mode)

Quoted 7 lines

and there are probably quite a few others as well. but they are all in
the same family in that you have to worry about ACPI states, and they all have the same restrictions on what can happen between suspend and resume

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

OTOH, there are many people who would want the ACPI suspends to be handled and they don't really care for the power-off-only hibernation.

If you aren't going to support the ACPI hibernation, your framework will be incomplete and therefore not generally useful.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#107 lore raw
Quoted 148 lines · Rafael J. Wysocki
Quoted 97 lines · On Tuesday, 17 July 2007 22:18, [email protected] wrote:
Quoted 72 lines · Rafael J. Wysocki
Quoted 62 lines · On Tuesday, 17 July 2007 19:06, [email protected] wrote:
Quoted 60 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

Quoted 8 lines
Quoted 1 line

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

no, systems that remain powered while asleep are a different type of suspend then ones that don't.

Quoted 14 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

Quoted 6 lines
Quoted 1 line

[Please refer to section 15.3 of the 3.0b ACPI spec for details.]

you are starting from the assumption that ACPI S4 mode should be used.

I'm saying that a suspend that uses ACPI S4 mode is fundamentally different from one that does a power off instead.

It is different, but not fundamentally.

Quoted 33 lines

from my point of view the ACPI S4 sleep mode has far more in common with suspend-to-ram then with the suspend-to-disk that I'm talking about

non-ACPI hibernate

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system. restore makes no assumptions about the state of the hardware when it is restored restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

ACPI suspends

since the box never completely powers off:
a complete power failure breaks the suspend
the OS must remain in control so other uses must be prevented. hardware must remain in the ACPI state from suspend until restore. restore can be faster (some initialization may be able to be skipped)
requires ACPI hardware support

under the catagory of ACPI suspends you have

fast suspend-to-ram (stop scheduling, put the CPU to sleep, as long as
the memory keeps getting refreshed)
slow suspend-to-ram (stop scheduling, put as much of the hardware as
possible to sleep, including spinning down disks and other things that take a while to undo)
suspend-to-disk (stop scheduleing, copy the ram somewhere so that it
doesn't need to be refreshed, put everything into low-power mode)

Quoted 7 lines

and there are probably quite a few others as well. but they are all in
the same family in that you have to worry about ACPI states, and they all have the same restrictions on what can happen between suspend and resume

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

Quoted 5 lines

OTOH, there are many people who would want the ACPI suspends to be handled and they don't really care for the power-off-only hibernation.

If you aren't going to support the ACPI hibernation, your framework will be incomplete and therefore not generally useful.

if you make the framework limited by the ACPI requriement, your framework will not be able to be used in all cases and is therefor incomplete and not generally useful.

see, I can make authoritative sounding declarations too. :-)

I agree that some people want ACPI suspends, but you don't seem to allow the fact that some people don't, and those people don't want to have the ACPI based limits. they _especially_ don't want those limits when it appears as if supporting those limits is what's preventing their much simpler case from working reliably.

I strongly suspect that the majority of users don't care about ACPI, they want to be able to pause and resume their machine. they may want a couple options for how fast the resume is (trading resume speed against how much power the system eats), but the deep sleep modes (suspend-to-disk, hibernate) probably have restore times that are close enough to each other that very few people would care enough to opt for a ACPI S4 mode that won't survive a loss of battery power over a non-ACPI mode that would.

David Lang

#108 lore raw
Quoted 153 lines · On Tuesday, 17 July 2007 22:53, [email protected] wrote:
Quoted 151 lines · Rafael J. Wysocki
Quoted 97 lines · On Tuesday, 17 July 2007 22:18, [email protected] wrote:
Quoted 72 lines · Rafael J. Wysocki
Quoted 62 lines · On Tuesday, 17 July 2007 19:06, [email protected] wrote:
Quoted 60 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

Quoted 8 lines
Quoted 1 line

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

no, systems that remain powered while asleep are a different type of suspend then ones that don't.

Quoted 14 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

Quoted 6 lines
Quoted 1 line

[Please refer to section 15.3 of the 3.0b ACPI spec for details.]

you are starting from the assumption that ACPI S4 mode should be used.

I'm saying that a suspend that uses ACPI S4 mode is fundamentally different from one that does a power off instead.

It is different, but not fundamentally.

Quoted 33 lines

from my point of view the ACPI S4 sleep mode has far more in common with suspend-to-ram then with the suspend-to-disk that I'm talking about

non-ACPI hibernate

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system. restore makes no assumptions about the state of the hardware when it is restored restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

ACPI suspends

since the box never completely powers off:
a complete power failure breaks the suspend
the OS must remain in control so other uses must be prevented. hardware must remain in the ACPI state from suspend until restore. restore can be faster (some initialization may be able to be skipped)
requires ACPI hardware support

under the catagory of ACPI suspends you have

fast suspend-to-ram (stop scheduling, put the CPU to sleep, as long as
the memory keeps getting refreshed)
slow suspend-to-ram (stop scheduling, put as much of the hardware as
possible to sleep, including spinning down disks and other things that take a while to undo)
suspend-to-disk (stop scheduleing, copy the ram somewhere so that it
doesn't need to be refreshed, put everything into low-power mode)

Quoted 7 lines

and there are probably quite a few others as well. but they are all in
the same family in that you have to worry about ACPI states, and they all have the same restrictions on what can happen between suspend and resume

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

OTOH, there are many people who would want the ACPI suspends to be handled and they don't really care for the power-off-only hibernation.

Quoted 8 lines
Quoted 2 lines

If you aren't going to support the ACPI hibernation, your framework will be incomplete and therefore not generally useful.

if you make the framework limited by the ACPI requriement, your framework will not be able to be used in all cases and is therefor incomplete and not generally useful.

see, I can make authoritative sounding declarations too. :-)

Well, being able to support ACPI need not imply being unable to work in the other cases. Conversely, being able to work in non-ACPI cases need not imply being unable to support ACPI. Hence, you can support ACPI and be able to work in the other cases at the same time.

Try again. ;-)

Quoted 2 lines

I agree that some people want ACPI suspends, but you don't seem to allow the fact that some people don't,

No, I do.

What I'm trying to say is that we should support the ACPI S4 transition and resume, which DOES NOT MEAN that we should support ONLY that.

Quoted 1 line

and those people don't want to have the ACPI based limits.

There are NO ACPI LIMITS! There only are things that you need to implement if you're going to support ACPI, but they need not be used ALWAYS, no?

Quoted 11 lines

they _especially_ don't want those limits when it appears as if supporting those limits is what's preventing their much simpler case from working reliably.

I strongly suspect that the majority of users don't care about ACPI, they want to be able to pause and resume their machine. they may want a couple options for how fast the resume is (trading resume speed against how much power the system eats), but the deep sleep modes (suspend-to-disk, hibernate) probably have restore times that are close enough to each other that very few people would care enough to opt for a ACPI S4 mode that won't survive a loss of battery power over a non-ACPI mode that would.

Please don't argue like that, these are not arguments for avoiding the ACPI support. Arguably, you can support _both_ ACPI and non-ACPI hibernation, so design for being able to support both. End of story (as far as I'm concerned).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#109 lore raw
Quoted 80 lines · Rafael J. Wysocki
Quoted 79 lines · On Tuesday, 17 July 2007 22:53, [email protected] wrote:
Quoted 67 lines · Rafael J. Wysocki
Quoted 16 lines · On Tuesday, 17 July 2007 22:18, [email protected] wrote:
Quoted 14 lines · Rafael J. Wysocki

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

Quoted 6 lines
Quoted 1 line

[Please refer to section 15.3 of the 3.0b ACPI spec for details.]

you are starting from the assumption that ACPI S4 mode should be used.

I'm saying that a suspend that uses ACPI S4 mode is fundamentally different from one that does a power off instead.

It is different, but not fundamentally.

Quoted 33 lines

from my point of view the ACPI S4 sleep mode has far more in common with suspend-to-ram then with the suspend-to-disk that I'm talking about

non-ACPI hibernate

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system. restore makes no assumptions about the state of the hardware when it is restored restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

ACPI suspends

since the box never completely powers off:
a complete power failure breaks the suspend
the OS must remain in control so other uses must be prevented. hardware must remain in the ACPI state from suspend until restore. restore can be faster (some initialization may be able to be skipped)
requires ACPI hardware support

under the catagory of ACPI suspends you have

fast suspend-to-ram (stop scheduling, put the CPU to sleep, as long as
the memory keeps getting refreshed)
slow suspend-to-ram (stop scheduling, put as much of the hardware as
possible to sleep, including spinning down disks and other things that take a while to undo)
suspend-to-disk (stop scheduleing, copy the ram somewhere so that it
doesn't need to be refreshed, put everything into low-power mode)

Quoted 7 lines

and there are probably quite a few others as well. but they are all in
the same family in that you have to worry about ACPI states, and they all have the same restrictions on what can happen between suspend and resume

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

Quoted 5 lines

OTOH, there are many people who would want the ACPI suspends to be handled and they don't really care for the power-off-only hibernation.

If you aren't going to support the ACPI hibernation, your framework will be incomplete and therefore not generally useful.

if you make the framework limited by the ACPI requriement, your framework will not be able to be used in all cases and is therefor incomplete and not generally useful.

Quoted 8 lines
Quoted 1 line

see, I can make authoritative sounding declarations too. :-)

Well, being able to support ACPI need not imply being unable to work in the other cases. Conversely, being able to work in non-ACPI cases need not imply being unable to support ACPI. Hence, you can support ACPI and be able to work in the other cases at the same time.

Try again. ;-)

I thought it was you who was saying that the restore operation requried ACPI if you used ACPI at all.

Quoted 7 lines
Quoted 2 lines

I agree that some people want ACPI suspends, but you don't seem to allow the fact that some people don't,

No, I do.

What I'm trying to say is that we should support the ACPI S4 transition and resume, which DOES NOT MEAN that we should support ONLY that.

it has sounded like you are saying that if you support ACPI S4 sleep then it's incompatible with powering off.

Quoted 4 lines
Quoted 1 line

and those people don't want to have the ACPI based limits.

There are NO ACPI LIMITS! There only are things that you need to implement if you're going to support ACPI, but they need not be used ALWAYS, no?

yes there are limits. the fact that you can't remove the battery in S4 mode without messing things up is a limit, the fact that it's against ACPI specs to boot another OS before resume is a limit. you seem to keep pointing out requirements of ACPI that limit what can be done. I do not disagree about these being requirements _if you are useing ACPI_, but if you don't need ACPI they should not limit you.

Quoted 12 lines
Quoted 11 lines

they _especially_ don't want those limits when it appears as if supporting those limits is what's preventing their much simpler case from working reliably.

I strongly suspect that the majority of users don't care about ACPI, they want to be able to pause and resume their machine. they may want a couple options for how fast the resume is (trading resume speed against how much power the system eats), but the deep sleep modes (suspend-to-disk, hibernate) probably have restore times that are close enough to each other that very few people would care enough to opt for a ACPI S4 mode that won't survive a loss of battery power over a non-ACPI mode that would.

Quoted 3 lines

Please don't argue like that, these are not arguments for avoiding the ACPI support. Arguably, you can support _both_ ACPI and non-ACPI hibernation, so design for being able to support both. End of story (as far as I'm concerned).

I wish I understood how you are saying this, becouse it does not match what I thought I have been reading for the last few days.

David Lang

#110 lore raw

[email protected] writes:

[snip]

Quoted 5 lines
Quoted 2 lines

There are NO ACPI LIMITS! There only are things that you need to implement if you're going to support ACPI, but they need not be used ALWAYS, no?

yes there are limits. the fact that you can't remove the battery in S4 mode without messing things up is a limit,

You won't mess things up as long as the resuming kernel knows that it should resume as if the system were shutdown, rather than sent to S4 state. Maybe it is even possible to detect what type of resuming is needed automatically. Similarly, booting another OS shouldn't be a problem, except that if you do it without powering off the system first, some devices might not work under the other OS if the other OS doesn't initialize them properly.

[snip]

Signature · 1 line
Jeremy Maitin-Shepard
#111 lore raw
In reply to [email protected]

[email protected] writes:

[snip]

Quoted 5 lines
Quoted 2 lines

There are NO ACPI LIMITS! There only are things that you need to implement if you're going to support ACPI, but they need not be used ALWAYS, no?

yes there are limits. the fact that you can't remove the battery in S4 mode without messing things up is a limit,

You won't mess things up as long as the resuming kernel knows that it should resume as if the system were shutdown, rather than sent to S4 state. Maybe it is even possible to detect what type of resuming is needed automatically. Similarly, booting another OS shouldn't be a problem, except that if you do it without powering off the system first, some devices might not work under the other OS if the other OS doesn't initialize them properly.

[snip]

Signature · 1 line
Jeremy Maitin-Shepard
#112 lore raw
In reply to [email protected]
Quoted 153 lines · On Tuesday, 17 July 2007 22:53, [email protected] wrote:
Quoted 151 lines · Rafael J. Wysocki
Quoted 97 lines · On Tuesday, 17 July 2007 22:18, [email protected] wrote:
Quoted 72 lines · Rafael J. Wysocki
Quoted 62 lines · On Tuesday, 17 July 2007 19:06, [email protected] wrote:
Quoted 60 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

Quoted 8 lines
Quoted 1 line

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

no, systems that remain powered while asleep are a different type of suspend then ones that don't.

Quoted 14 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

Quoted 6 lines
Quoted 1 line

[Please refer to section 15.3 of the 3.0b ACPI spec for details.]

you are starting from the assumption that ACPI S4 mode should be used.

I'm saying that a suspend that uses ACPI S4 mode is fundamentally different from one that does a power off instead.

It is different, but not fundamentally.

Quoted 33 lines

from my point of view the ACPI S4 sleep mode has far more in common with suspend-to-ram then with the suspend-to-disk that I'm talking about

non-ACPI hibernate

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system. restore makes no assumptions about the state of the hardware when it is restored restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

ACPI suspends

since the box never completely powers off:
a complete power failure breaks the suspend
the OS must remain in control so other uses must be prevented. hardware must remain in the ACPI state from suspend until restore. restore can be faster (some initialization may be able to be skipped)
requires ACPI hardware support

under the catagory of ACPI suspends you have

fast suspend-to-ram (stop scheduling, put the CPU to sleep, as long as
the memory keeps getting refreshed)
slow suspend-to-ram (stop scheduling, put as much of the hardware as
possible to sleep, including spinning down disks and other things that take a while to undo)
suspend-to-disk (stop scheduleing, copy the ram somewhere so that it
doesn't need to be refreshed, put everything into low-power mode)

Quoted 7 lines

and there are probably quite a few others as well. but they are all in
the same family in that you have to worry about ACPI states, and they all have the same restrictions on what can happen between suspend and resume

the non-ACPI hibernate behaves very differently, and for some people (and I think I am one of them) it will meet their needs better then _any_ of the ACPI suspends.

OTOH, there are many people who would want the ACPI suspends to be handled and they don't really care for the power-off-only hibernation.

Quoted 8 lines
Quoted 2 lines

If you aren't going to support the ACPI hibernation, your framework will be incomplete and therefore not generally useful.

if you make the framework limited by the ACPI requriement, your framework will not be able to be used in all cases and is therefor incomplete and not generally useful.

see, I can make authoritative sounding declarations too. :-)

Well, being able to support ACPI need not imply being unable to work in the other cases. Conversely, being able to work in non-ACPI cases need not imply being unable to support ACPI. Hence, you can support ACPI and be able to work in the other cases at the same time.

Try again. ;-)

Quoted 2 lines

I agree that some people want ACPI suspends, but you don't seem to allow the fact that some people don't,

No, I do.

What I'm trying to say is that we should support the ACPI S4 transition and resume, which DOES NOT MEAN that we should support ONLY that.

Quoted 1 line

and those people don't want to have the ACPI based limits.

There are NO ACPI LIMITS! There only are things that you need to implement if you're going to support ACPI, but they need not be used ALWAYS, no?

Quoted 11 lines

they _especially_ don't want those limits when it appears as if supporting those limits is what's preventing their much simpler case from working reliably.

I strongly suspect that the majority of users don't care about ACPI, they want to be able to pause and resume their machine. they may want a couple options for how fast the resume is (trading resume speed against how much power the system eats), but the deep sleep modes (suspend-to-disk, hibernate) probably have restore times that are close enough to each other that very few people would care enough to opt for a ACPI S4 mode that won't survive a loss of battery power over a non-ACPI mode that would.

Please don't argue like that, these are not arguments for avoiding the ACPI support. Arguably, you can support _both_ ACPI and non-ACPI hibernation, so design for being able to support both. End of story (as far as I'm concerned).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#113 lore raw
In reply to [email protected]

Hi!

Quoted 5 lines

from my point of view the ACPI S4 sleep mode has far more in common with suspend-to-ram then with the suspend-to-disk that I'm talking about

non-ACPI hibernate

Quoted 10 lines

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system.
restore makes no assumptions about the state of the hardware when it is restored
restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#114 lore raw
In reply to [email protected]

Hi!

Quoted 5 lines

from my point of view the ACPI S4 sleep mode has far more in common with suspend-to-ram then with the suspend-to-disk that I'm talking about

non-ACPI hibernate

Quoted 10 lines

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system.
restore makes no assumptions about the state of the hardware when it is restored
restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#115 lore raw

Pavel Machek <[email protected]> writes:

[snip]

Quoted 3 lines

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.

It seems that it should be possible to initialize ACPI as if the system just booted up normally. Then battery status and such should be correct, since they are correct after normal initialization.

It should be possible to make hibernate look just like a reboot to all of the devices, including ACPI stuff.

Signature · 1 line
Jeremy Maitin-Shepard
#116 lore raw

Hi!

Quoted 8 lines

Pavel Machek <[email protected]> writes:

[snip]

Quoted 3 lines

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.

Quoted 6 lines

It seems that it should be possible to initialize ACPI as if the system just booted up normally. Then battery status and such should be correct, since they are correct after normal initialization.

It should be possible to make hibernate look just like a reboot to all of the devices, including ACPI stuff.

Patch to make that work with swsusp/shutdown method would be indeed welcome. It does not work today.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#117 lore raw
Quoted 14 lines · Pavel Machek

Hi!

Quoted 12 lines

Pavel Machek <[email protected]> writes:

[snip]

Quoted 3 lines

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.

It seems that it should be possible to initialize ACPI as if the system just booted up normally. Then battery status and such should be correct, since they are correct after normal initialization.

Quoted 5 lines
Quoted 2 lines

It should be possible to make hibernate look just like a reboot to all of the devices, including ACPI stuff.

Patch to make that work with swsusp/shutdown method would be indeed welcome. It does not work today.

is this a problem in the restore path?

with the kexec approach (and ignoring suspend to ram and disk for the moment) the system will actually get shutdown completely after the image is written. on resume it gets cold booted. at this point the ACPI stuff should have no problem

now if the ACPI drivers are storing something in ram about the battery status and AC power status, but don't re-check after the resume, it seems to me that they can't possibly be reliable anyway. if they do re-check after the resume then where's the problem?

David Lang

#118 lore raw

Hi!

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.

It seems that it should be possible to initialize ACPI as if the system just booted up normally. Then battery status and such should be correct, since they are correct after normal initialization.

Quoted 5 lines
Quoted 2 lines

It should be possible to make hibernate look just like a reboot to all of the devices, including ACPI stuff.

Patch to make that work with swsusp/shutdown method would be indeed welcome. It does not work today.

is this a problem in the restore path?

Quoted 8 lines

with the kexec approach (and ignoring suspend to ram and disk for the moment) the system will actually get shutdown completely after the image is written. on resume it gets cold booted. at this point the ACPI stuff should have no problem

now if the ACPI drivers are storing something in ram about the battery status and AC power status, but don't re-check after the resume, it seems

That seems to be the problem. They store something in ram, and we don't tell them that we resumed. That's why platform mode is important, and way to go on ACPI systems.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#119 lore raw
Quoted 21 lines · Pavel Machek
Quoted 21 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.

It seems that it should be possible to initialize ACPI as if the system just booted up normally. Then battery status and such should be correct, since they are correct after normal initialization.

Quoted 5 lines
Quoted 2 lines

It should be possible to make hibernate look just like a reboot to all of the devices, including ACPI stuff.

Patch to make that work with swsusp/shutdown method would be indeed welcome. It does not work today.

is this a problem in the restore path?

with the kexec approach (and ignoring suspend to ram and disk for the moment) the system will actually get shutdown completely after the image is written. on resume it gets cold booted. at this point the ACPI stuff should have no problem

Quoted 7 lines
Quoted 3 lines

now if the ACPI drivers are storing something in ram about the battery status and AC power status, but don't re-check after the resume, it seems

That seems to be the problem. They store something in ram, and we don't tell them that we resumed. That's why platform mode is important, and way to go on ACPI systems.

this sounds like the few drivers that do this sort of thing (and this should only be the things that report status, drivers that enable devices should be taken care of) need a 'forget what you think you know, check the reality of the hardware' function.

even without suspend I've sen these drivers get out of sync with reality, and so such a function call would be useful to get them back in sync in any case.

if such a 'check reality' function was available it should be straightforward to call it after a non-ACPI hibrnate/resume

David Lang

#120 lore raw
In reply to [email protected]

Hi!

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.

It seems that it should be possible to initialize ACPI as if the system just booted up normally. Then battery status and such should be correct, since they are correct after normal initialization.

Quoted 5 lines
Quoted 2 lines

It should be possible to make hibernate look just like a reboot to all of the devices, including ACPI stuff.

Patch to make that work with swsusp/shutdown method would be indeed welcome. It does not work today.

is this a problem in the restore path?

Quoted 8 lines

with the kexec approach (and ignoring suspend to ram and disk for the moment) the system will actually get shutdown completely after the image is written. on resume it gets cold booted. at this point the ACPI stuff should have no problem

now if the ACPI drivers are storing something in ram about the battery status and AC power status, but don't re-check after the resume, it seems

That seems to be the problem. They store something in ram, and we don't tell them that we resumed. That's why platform mode is important, and way to go on ACPI systems.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#121 lore raw
In reply to Jeremy Maitin-Shepard

Hi!

Quoted 8 lines

Pavel Machek <[email protected]> writes:

[snip]

Quoted 3 lines

So it will be break at least battery status and "AC plugged in" status, because those are handled by ACPI and we do not know how to control them by hand.

Quoted 6 lines

It seems that it should be possible to initialize ACPI as if the system just booted up normally. Then battery status and such should be correct, since they are correct after normal initialization.

It should be possible to make hibernate look just like a reboot to all of the devices, including ACPI stuff.

Patch to make that work with swsusp/shutdown method would be indeed welcome. It does not work today.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#122 lore raw
In reply to [email protected]

Hi,

Sorry for joining late, just a small annotation:

Quoted 11 lines · On Tue, Jul 17, 2007 at 01:18:13PM -0700, [email protected] wrote:

non-ACPI hibernate

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system. restore makes no assumptions about the state of the hardware when it is restored restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

Quoted 3 lines

ACPI suspends

since the box never completely powers off:A

wrong

Quoted 1 line

a complete power failure breaks the suspend

wrong

Quoted 6 lines

the OS must remain in control so other uses must be prevented. hardware must remain in the ACPI state from suspend until restore. restore can be faster (some initialization may be able to be skipped)
requires ACPI hardware support

under the catagory of ACPI suspends you have

ACPI S4 turns off the machine completely and you can remove the battery (this is even required somewhere in the spec). Any state saving is done in CMOS RAM or flash.

But for example many Notebooks resume much faster if they go through the ACPI S4 hooks during suspend (less than one second from "lid open" to "grub" while they need ~10 seconds through the BIOS on a "normal" boot. My Toughbook resumes on "Lid Opened" after S4, it doesn't after a shutdown.

So there will be differences.
I'm not saying that they are too important, but 20% faster resume still is a good saving for me.

No need to restart this thread btw ;-)

Have fun,

Stefan

Signature · 6 lines
Stefan Seyfried
QA / R&D Team Mobile Devices        |              "Any ideas, John?"
SUSE LINUX Products GmbH, Nürnberg  | "Well, surrounding them's out." 

This footer brought to you by insane German lawmakers:
SUSE Linux Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
#123 lore raw
In reply to [email protected]

Hi,

Sorry for joining late, just a small annotation:

Quoted 11 lines · On Tue, Jul 17, 2007 at 01:18:13PM -0700, [email protected] wrote:

non-ACPI hibernate

since the box powers off
it uses zero power while suspended
another OS could be run before a resume
hardware can be swapped, suspend image could be sent around the world to be restored on another system. restore makes no assumptions about the state of the hardware when it is restored restore is slower (full BIOS boot is required)
should be able to work on just about any hardware (the limit is the ability to initialize the devices)

Quoted 3 lines

ACPI suspends

since the box never completely powers off:A

wrong

Quoted 1 line

a complete power failure breaks the suspend

wrong

Quoted 6 lines

the OS must remain in control so other uses must be prevented. hardware must remain in the ACPI state from suspend until restore. restore can be faster (some initialization may be able to be skipped)
requires ACPI hardware support

under the catagory of ACPI suspends you have

ACPI S4 turns off the machine completely and you can remove the battery (this is even required somewhere in the spec). Any state saving is done in CMOS RAM or flash.

But for example many Notebooks resume much faster if they go through the ACPI S4 hooks during suspend (less than one second from "lid open" to "grub" while they need ~10 seconds through the BIOS on a "normal" boot. My Toughbook resumes on "Lid Opened" after S4, it doesn't after a shutdown.

So there will be differences.
I'm not saying that they are too important, but 20% faster resume still is a good saving for me.

No need to restart this thread btw ;-)

Have fun,

Stefan

Signature · 6 lines
Stefan Seyfried
QA / R&D Team Mobile Devices        |              "Any ideas, John?"
SUSE LINUX Products GmbH, Nürnberg  | "Well, surrounding them's out." 

This footer brought to you by insane German lawmakers:
SUSE Linux Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
#124 lore raw
In reply to Rafael J. Wysocki

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

I'm not sure the majority of notebook users will want wakeup support in exchange for some power consumption while the system is off. I think many people would not consider the trouble of having to press the power button instead of merely opening the lid too great.

Furthermore, S4 mode is of course also not suitable if you intend to replace the battery while the system is hibernated.

It does seem that it is useful to provide S4 as an option, but certainly just shutting down should also be an option on all systems.

Quoted 4 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

It seems that it most certainly must be done AFTER saving the image, as the image obviously cannot be saved after entering S4 state, since S4 state is nearly the same as powering off completely and all memory will be lost.

Quoted 8 lines

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

It seems that the implementation of that behavior for Linux cannot be quite so simple, since resume from hibernation is driven (in general) from an initrd/initramfs rather than directly from the kernel initialization sequence, in order to support modular drivers and features like DM and LVM.

Thus, there would have to be a new "delay_acpi_initialization" kernel command-line option. Additionally, there would be a sysfs interface to tell the kernel to proceed with the ACPI initialization as normal. This would be used by an initrd/initramfs after determining that a resume from hibernate will not be done. If a resume from hibernate is done, this hook won't be used, and instead the resumed kernel will call the ACPI hibernate resume stuff if S4 state was used; otherwise, the resumed kernel will just re-initialize ACPI as normal. Also, if the in-kernel code for checking if a resume can be done does not find a hibernate image, it will also invoke the delayed ACPI initialization.

Signature · 1 line
Jeremy Maitin-Shepard
#125 lore raw
Quoted 10 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

Quoted 4 lines

I'm not sure the majority of notebook users will want wakeup support in exchange for some power consumption while the system is off. I think many people would not consider the trouble of having to press the power button instead of merely opening the lid too great.

I think you mean to say that they would be willing to trade wakeup support in exchange for lower power consumption...

Quoted 2 lines

Furthermore, S4 mode is of course also not suitable if you intend to replace the battery while the system is hibernated.

exactly, and how many users realize that replacing the battery, or allowing the battery to die completely will cause the restore to fail?

Quoted 2 lines

It does seem that it is useful to provide S4 as an option, but certainly just shutting down should also be an option on all systems.

absolutly.

Quoted 9 lines
Quoted 4 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

It seems that it most certainly must be done AFTER saving the image, as the image obviously cannot be saved after entering S4 state, since S4 state is nearly the same as powering off completely and all memory will be lost.

and the image-saving kernel could kexec back to the main kernel if the main kernel then knows that it should execute the S4 mode instead of restoring.

Quoted 15 lines
Quoted 8 lines

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

It seems that the implementation of that behavior for Linux cannot be quite so simple, since resume from hibernation is driven (in general) from an initrd/initramfs rather than directly from the kernel initialization sequence, in order to support modular drivers and features like DM and LVM.

Quoted 10 lines

Thus, there would have to be a new "delay_acpi_initialization" kernel command-line option. Additionally, there would be a sysfs interface to tell the kernel to proceed with the ACPI initialization as normal. This would be used by an initrd/initramfs after determining that a resume from hibernate will not be done. If a resume from hibernate is done, this hook won't be used, and instead the resumed kernel will call the ACPI hibernate resume stuff if S4 state was used; otherwise, the resumed kernel will just re-initialize ACPI as normal. Also, if the in-kernel code for checking if a resume can be done does not find a hibernate image, it will also invoke the delayed ACPI initialization.

remember, one of the thoughts for a good hibernate implementation is that the image may be over the network, not on the local disk. you don't want the kernel trying to implment everything nessasary to get the image back.

David Lang

#126 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 40 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

I'm not sure the majority of notebook users will want wakeup support in exchange for some power consumption while the system is off. I think many people would not consider the trouble of having to press the power button instead of merely opening the lid too great.

Furthermore, S4 mode is of course also not suitable if you intend to replace the battery while the system is hibernated.

It does seem that it is useful to provide S4 as an option, but certainly just shutting down should also be an option on all systems.

Quoted 4 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

It seems that it most certainly must be done AFTER saving the image, as the image obviously cannot be saved after entering S4 state, since S4 state is nearly the same as powering off completely and all memory will be lost.

Quoted 8 lines

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

Quoted 5 lines

It seems that the implementation of that behavior for Linux cannot be quite so simple, since resume from hibernation is driven (in general) from an initrd/initramfs rather than directly from the kernel initialization sequence, in order to support modular drivers and features like DM and LVM.

That's correct.

Quoted 10 lines

Thus, there would have to be a new "delay_acpi_initialization" kernel command-line option. Additionally, there would be a sysfs interface to tell the kernel to proceed with the ACPI initialization as normal. This would be used by an initrd/initramfs after determining that a resume from hibernate will not be done. If a resume from hibernate is done, this hook won't be used, and instead the resumed kernel will call the ACPI hibernate resume stuff if S4 state was used; otherwise, the resumed kernel will just re-initialize ACPI as normal. Also, if the in-kernel code for checking if a resume can be done does not find a hibernate image, it will also invoke the delayed ACPI initialization.

Yes, something like this.

My point is, though, that it really requires some thought and needs to be remebered about.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#127 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 40 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 5 lines

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

I'm not sure the majority of notebook users will want wakeup support in exchange for some power consumption while the system is off. I think many people would not consider the trouble of having to press the power button instead of merely opening the lid too great.

Furthermore, S4 mode is of course also not suitable if you intend to replace the battery while the system is hibernated.

It does seem that it is useful to provide S4 as an option, but certainly just shutting down should also be an option on all systems.

Quoted 4 lines

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

It seems that it most certainly must be done AFTER saving the image, as the image obviously cannot be saved after entering S4 state, since S4 state is nearly the same as powering off completely and all memory will be lost.

Quoted 8 lines

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

Quoted 5 lines

It seems that the implementation of that behavior for Linux cannot be quite so simple, since resume from hibernation is driven (in general) from an initrd/initramfs rather than directly from the kernel initialization sequence, in order to support modular drivers and features like DM and LVM.

That's correct.

Quoted 10 lines

Thus, there would have to be a new "delay_acpi_initialization" kernel command-line option. Additionally, there would be a sysfs interface to tell the kernel to proceed with the ACPI initialization as normal. This would be used by an initrd/initramfs after determining that a resume from hibernate will not be done. If a resume from hibernate is done, this hook won't be used, and instead the resumed kernel will call the ACPI hibernate resume stuff if S4 state was used; otherwise, the resumed kernel will just re-initialize ACPI as normal. Also, if the in-kernel code for checking if a resume can be done does not find a hibernate image, it will also invoke the delayed ACPI initialization.

Yes, something like this.

My point is, though, that it really requires some thought and needs to be remebered about.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#128 lore raw
In reply to [email protected]
Quoted 62 lines · On Tuesday, 17 July 2007 19:06, [email protected] wrote:
Quoted 60 lines · Rafael J. Wysocki
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

Quoted 8 lines
Quoted 1 line

I would rather avoid such pitfalls, if I could.

Ok, what is it that you think ACPI fundamentally changes in this process?

keep in mind that we are not makeing the assumption that the hardware will remain powered (even a little bit), or the assumption that nothing else will run on the hardware (eliminating any possibility that the hardware is in a known ACPI state)

Well, first, the fact is that _some_ systems _will_ be powered while in hibernation (the majority of notebooks, for example) and you should assume that the platform _may_ retain some information accross the hibernation/restore cycle. In that case you _should_ _not_ trash the information retained by the platform.

Now, with that in mind, ACPI requires us to make the system enter the S4 sleep state as a result of the hibernation procedure. In my opinion this may be done after saving the image, but still this means, for example, that the image-saving kernel needs to support ACPI.

Next, during the restore, we should first check if the image is present (and valid) _without_ turning ACPI on (note that this is not done by the current hibernation code and that leads to strange problems on some systems). Then, if the image is present (and valid), we should first load it, jump to the hibernated kernel and _then_ turn ACPI on and execute the _BFS and _WAK ACPI global methods (again, this is not done by the current code in that order, which is wrong). Only after that is the hibernated kernel supposed to continue.

[Please refer to section 15.3 of the 3.0b ACPI spec for details.]

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#129 lore raw
In reply to [email protected]
Quoted 46 lines · On Tuesday, 17 July 2007 17:29, [email protected] wrote:
Quoted 28 lines · Rafael J. Wysocki
Quoted 20 lines · Alan Stern
Quoted 14 lines · On Mon, 16 Jul 2007 [email protected] wrote:
Quoted 3 lines

I agree, it would be good to have a non-ACPI-specific hibernation mode, something which would look to ACPI like a normal shutdown. But I'm not so sure this is possible.

why would it not be possible?

I can't think of anything much more frustrating then thinking that I suspended a system and then discovering that becouse the battery went dead (a complete power loss) that the system wouldn't boot up properly. to me this would be a fairly common condition (when I'm mobile I use the machine until I am out of battery, then stop and it may be a long time (days) before I can charge the thing up again) this would not be a reliable suspend as far as I'm concerned.

Quoted 3 lines

for suspend-to-ram you have to worry about ACPI states and what you are doing with them, for suspend-to-disk you can ignore them and completely power the system off instead.

Quoted 6 lines

If the only problem with doing this would be lack of wakeup support then I'm all for it. There must be a lot of people who would like their computers to hibernate with power drain as close to 0 as possible and who don't care about remote wakeup. In fact they might even prefer not to have wakeup support, so the computer doesn't resume at unexpected times.

Quoted 6 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

doing suspend-to-ram should be orthoginal to doing hibernate-to-disk. some people will want both, some won't.

at the moment kexec doesn't work with ACPI, that is a limitation that should be fixed, but makeing it able to work with ACPI enabled doesn't mean that it needs to be changed to depend on ACPI and it especially doesn't mean that it should pick up the limitations of the existing ACPI based hibernation approaches.

Quoted 6 lines

if there is no ACPI on the system it should work, if ther is ACPI on the system it should still work.

Quoted 1 line

Thus, it seems reasonable to think of the ACPI handling in advance.

but don't become dependant on ACPI.

Not dependent, but with the possibility of ACPI support taken into account.

Arguably you can create a framework that, for example, will not allow the user to adjust the size of the image, but then adding such a functionality may require you to change the entire design. Same thing with ACPI.

I would rather avoid such pitfalls, if I could.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#130 lore raw
In reply to Rafael J. Wysocki

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 8 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

As far as I understand, ACPI support is only useful for hibernate to the extent that it allows some or all of the following features:

- possibly shows a nice looking "hibernate" LED
- possibly allows the BIOS to show something about hibernate
- possibly allows the lid or keyboard to "wake up" (turn on) the system

Note that properly restoring device state (or even properly determining whether on external/mains power vs. battery) on resume is not something that should require special hibernate ACPI support, since it should be possible to make hibernate (and in general it will be the case that hibernate will) look exactly like a reboot to the BIOS/ACPI/devices. The problem that you mentioned on your system regarding power source information would seem to just be a problem with how ACPI is reinitialized after resuming from hibernation, which is not at all surprising since we know it (the use of driver calls for hibernate) is currently broken in many ways.

It seems that enabling S4 mode should just be treated as a special shutdown mode, independent of hibernate. In practice, it may likely only be useful in conjunction with hibernate, but there doesn't seem to be any reason it needs to be coupled.

It would be useful to determine whether it is necessary to initialize ACPI specially after "resuming" from S4 mode, though, or whether they can be initialized normally (i.e. by a normal kernel for instance, completely unaware of hibernate). If they can be initialized normally, then it seems that it is unnecessary to have any ACPI S4 mode support in the resume path, and it can merely exist as a special shutdown mode. Note that it seems a bit odd if ACPI can't be initialized normally after resume from S4 (and still work), since the "load image" kernel initializes everything normally before attempting to resume the hibernated system.

Signature · 1 line
Jeremy Maitin-Shepard
#131 lore raw
In reply to Rafael J. Wysocki

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 8 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

As far as I understand, ACPI support is only useful for hibernate to the extent that it allows some or all of the following features:

- possibly shows a nice looking "hibernate" LED
- possibly allows the BIOS to show something about hibernate
- possibly allows the lid or keyboard to "wake up" (turn on) the system

Note that properly restoring device state (or even properly determining whether on external/mains power vs. battery) on resume is not something that should require special hibernate ACPI support, since it should be possible to make hibernate (and in general it will be the case that hibernate will) look exactly like a reboot to the BIOS/ACPI/devices. The problem that you mentioned on your system regarding power source information would seem to just be a problem with how ACPI is reinitialized after resuming from hibernation, which is not at all surprising since we know it (the use of driver calls for hibernate) is currently broken in many ways.

It seems that enabling S4 mode should just be treated as a special shutdown mode, independent of hibernate. In practice, it may likely only be useful in conjunction with hibernate, but there doesn't seem to be any reason it needs to be coupled.

It would be useful to determine whether it is necessary to initialize ACPI specially after "resuming" from S4 mode, though, or whether they can be initialized normally (i.e. by a normal kernel for instance, completely unaware of hibernate). If they can be initialized normally, then it seems that it is unnecessary to have any ACPI S4 mode support in the resume path, and it can merely exist as a special shutdown mode. Note that it seems a bit odd if ACPI can't be initialized normally after resume from S4 (and still work), since the "load image" kernel initializes everything normally before attempting to resume the hibernated system.

Signature · 1 line
Jeremy Maitin-Shepard
#132 lore raw
Quoted 36 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 8 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

As far as I understand, ACPI support is only useful for hibernate to the extent that it allows some or all of the following features:

- possibly shows a nice looking "hibernate" LED
- possibly allows the BIOS to show something about hibernate
- possibly allows the lid or keyboard to "wake up" (turn on) the system

Note that properly restoring device state (or even properly determining whether on external/mains power vs. battery) on resume is not something that should require special hibernate ACPI support, since it should be possible to make hibernate (and in general it will be the case that hibernate will) look exactly like a reboot to the BIOS/ACPI/devices. The problem that you mentioned on your system regarding power source information would seem to just be a problem with how ACPI is reinitialized after resuming from hibernation, which is not at all surprising since we know it (the use of driver calls for hibernate) is currently broken in many ways.

It seems that enabling S4 mode should just be treated as a special shutdown mode, independent of hibernate. In practice, it may likely only be useful in conjunction with hibernate, but there doesn't seem to be any reason it needs to be coupled.

Quoted 10 lines

It would be useful to determine whether it is necessary to initialize ACPI specially after "resuming" from S4 mode, though, or whether they can be initialized normally (i.e. by a normal kernel for instance, completely unaware of hibernate). If they can be initialized normally, then it seems that it is unnecessary to have any ACPI S4 mode support in the resume path, and it can merely exist as a special shutdown mode. Note that it seems a bit odd if ACPI can't be initialized normally after resume from S4 (and still work), since the "load image" kernel initializes everything normally before attempting to resume the hibernated system.

Unfortunately, this is more complicated (please see my recent reply to David).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#133 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 36 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 8 lines

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

As far as I understand, ACPI support is only useful for hibernate to the extent that it allows some or all of the following features:

- possibly shows a nice looking "hibernate" LED
- possibly allows the BIOS to show something about hibernate
- possibly allows the lid or keyboard to "wake up" (turn on) the system

Note that properly restoring device state (or even properly determining whether on external/mains power vs. battery) on resume is not something that should require special hibernate ACPI support, since it should be possible to make hibernate (and in general it will be the case that hibernate will) look exactly like a reboot to the BIOS/ACPI/devices. The problem that you mentioned on your system regarding power source information would seem to just be a problem with how ACPI is reinitialized after resuming from hibernation, which is not at all surprising since we know it (the use of driver calls for hibernate) is currently broken in many ways.

It seems that enabling S4 mode should just be treated as a special shutdown mode, independent of hibernate. In practice, it may likely only be useful in conjunction with hibernate, but there doesn't seem to be any reason it needs to be coupled.

Quoted 10 lines

It would be useful to determine whether it is necessary to initialize ACPI specially after "resuming" from S4 mode, though, or whether they can be initialized normally (i.e. by a normal kernel for instance, completely unaware of hibernate). If they can be initialized normally, then it seems that it is unnecessary to have any ACPI S4 mode support in the resume path, and it can merely exist as a special shutdown mode. Note that it seems a bit odd if ACPI can't be initialized normally after resume from S4 (and still work), since the "load image" kernel initializes everything normally before attempting to resume the hibernated system.

Unfortunately, this is more complicated (please see my recent reply to David).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#134 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · Rafael J. Wysocki

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

Absolutely. This needs to be done in such a way that it will work:

	On platforms without ACPI;

	On platforms with ACPI where we do a non-ACPI type of shutdown
	to whatever extent it is possible (or perhaps an ACPI-aware
	shutdown rather than change to S4);

	On platforms with ACPI where we do an ACPI-aware transition
	to S4.

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel? After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

Alan Stern

#135 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · Rafael J. Wysocki

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

Absolutely. This needs to be done in such a way that it will work:

	On platforms without ACPI;

	On platforms with ACPI where we do a non-ACPI type of shutdown
	to whatever extent it is possible (or perhaps an ACPI-aware
	shutdown rather than change to S4);

	On platforms with ACPI where we do an ACPI-aware transition
	to S4.

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel? After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

Alan Stern

#136 lore raw
Quoted 22 lines · Alan Stern
Quoted 8 lines · Rafael J. Wysocki

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

Absolutely. This needs to be done in such a way that it will work:

	On platforms without ACPI;

	On platforms with ACPI where we do a non-ACPI type of shutdown
	to whatever extent it is possible (or perhaps an ACPI-aware
	shutdown rather than change to S4);

	On platforms with ACPI where we do an ACPI-aware transition
	to S4.
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Sure.

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:
* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)
* execute the _PTS global control method
* switch off the nonlocal CPUs (eg. nonboot CPUs on x86)
* execute the _GTS global control method
* set the GPE enable registers corresponding to the wake-up devices)
* make the platform enter S4 (there's a well defined procedure for that) I think that this should be done by the image-saving kernel.

(2) Upon start-up (by which I mean what happens after the user has pressed the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI (we don't do that now, but I see no reason for not doing it in the new framework)
* if the image is present (and valid), load it
* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading kernel, but the remaining operations have to be carried out by the restored kernel.

In the remaining two cases we generally don't need to bother with the global ACPI handling.

Quoted 4 lines

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel?

No, I think the image-saving kernel should suspend. Then, on resume the platform will go back to it and it will jump back to the hibernated kernel.

Quoted 3 lines

After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

That's correct, but ...

Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#137 lore raw
Quoted 16 lines · Rafael J. Wysocki
Quoted 4 lines · Alan Stern

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel?

No, I think the image-saving kernel should suspend. Then, on resume the platform will go back to it and it will jump back to the hibernated kernel.

Quoted 3 lines

After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

That's correct, but ...

Quoted 8 lines
Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

this is where we disagree.

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

there is only a problem if something takes place that would prevent the restore-from-disk from working. if this is done in a non-ACPI way that will work across a power cycle you don't have to worry about the hardware state not matching anyway.

Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

suspend-to-both doesn't really make sense if the suspend-to-disk portion is useing the ACPI S4 mode.

if you don't run out of power you will restore-from-ram

if you do run out of power the restore-from-disk won't work either becouse devices are not in the right ACPI states.

David Lang

#138 lore raw

[email protected] writes:

[snip]

Quoted 5 lines

this is where we disagree.

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

It would be okay to switch the "hibernated" kernel in order to e.g. initiate a suspend to ram provided that everything is done atomically with interrupts off, for instance. It is not clear, though, that it is possible to suspend to ram atomically like that.

There is also the question of what state the devices will be in when switching back from the "save image" kernel to the "hibernated" kernel.

[snip]

Signature · 1 line
Jeremy Maitin-Shepard
#139 lore raw
In reply to [email protected]

[email protected] writes:

[snip]

Quoted 5 lines

this is where we disagree.

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

It would be okay to switch the "hibernated" kernel in order to e.g. initiate a suspend to ram provided that everything is done atomically with interrupts off, for instance. It is not clear, though, that it is possible to suspend to ram atomically like that.

There is also the question of what state the devices will be in when switching back from the "save image" kernel to the "hibernated" kernel.

[snip]

Signature · 1 line
Jeremy Maitin-Shepard
#140 lore raw
Quoted 6 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 1 line

this is where we disagree.

Quoted 8 lines
Quoted 3 lines

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

It would be okay to switch the "hibernated" kernel in order to e.g. initiate a suspend to ram provided that everything is done atomically with interrupts off, for instance. It is not clear, though, that it is possible to suspend to ram atomically like that.

why would it neeed to be with interrupts off?

I am arguing that it wouldn't matter if the "hibernated" kernel changed every bit of ram, as long as it didn't change anything that would be visable when the ram is overwritten by the saved image.

Quoted 2 lines

There is also the question of what state the devices will be in when switching back from the "save image" kernel to the "hibernated" kernel.

yes, this is a key factor.

if the saved image assumes that the hardware is in some ACPI mode instead of re-initializeing the hardware then the suspend-to-ram operation could leave them in a different mode.

but if the saved image doesn't make assumptions about the hardware modes and initializes the hardware then it shouldn't matter.

David Lang

#141 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 6 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 1 line

this is where we disagree.

Quoted 8 lines
Quoted 3 lines

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

It would be okay to switch the "hibernated" kernel in order to e.g. initiate a suspend to ram provided that everything is done atomically with interrupts off, for instance. It is not clear, though, that it is possible to suspend to ram atomically like that.

why would it neeed to be with interrupts off?

I am arguing that it wouldn't matter if the "hibernated" kernel changed every bit of ram, as long as it didn't change anything that would be visable when the ram is overwritten by the saved image.

Quoted 2 lines

There is also the question of what state the devices will be in when switching back from the "save image" kernel to the "hibernated" kernel.

yes, this is a key factor.

if the saved image assumes that the hardware is in some ACPI mode instead of re-initializeing the hardware then the suspend-to-ram operation could leave them in a different mode.

but if the saved image doesn't make assumptions about the hardware modes and initializes the hardware then it shouldn't matter.

David Lang

#142 lore raw
In reply to [email protected]
Quoted 27 lines · On Tuesday, 17 July 2007 22:34, [email protected] wrote:
Quoted 16 lines · Rafael J. Wysocki
Quoted 4 lines · Alan Stern

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel?

No, I think the image-saving kernel should suspend. Then, on resume the platform will go back to it and it will jump back to the hibernated kernel.

Quoted 3 lines

After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

That's correct, but ...

Quoted 8 lines
Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

Quoted 6 lines

this is where we disagree.

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

Quoted 10 lines

there is only a problem if something takes place that would prevent the restore-from-disk from working. if this is done in a non-ACPI way that will work across a power cycle you don't have to worry about the hardware state not matching anyway.

Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

suspend-to-both doesn't really make sense if the suspend-to-disk portion is useing the ACPI S4 mode.

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image, even if something may not work correctly after the restore, than to risk a loss of data.

Quoted 4 lines

if you don't run out of power you will restore-from-ram

if you do run out of power the restore-from-disk won't work either becouse devices are not in the right ACPI states.

See above.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#143 lore raw
Quoted 30 lines · Rafael J. Wysocki
Quoted 29 lines · On Tuesday, 17 July 2007 22:34, [email protected] wrote:
Quoted 16 lines · Rafael J. Wysocki
Quoted 4 lines · Alan Stern

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel?

No, I think the image-saving kernel should suspend. Then, on resume the platform will go back to it and it will jump back to the hibernated kernel.

Quoted 3 lines

After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

That's correct, but ...

Quoted 8 lines
Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

this is where we disagree.

Quoted 7 lines
Quoted 4 lines

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

Quoted 8 lines
Quoted 8 lines

there is only a problem if something takes place that would prevent the restore-from-disk from working. if this is done in a non-ACPI way that will work across a power cycle you don't have to worry about the hardware state not matching anyway.

Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

Quoted 7 lines
Quoted 2 lines

suspend-to-both doesn't really make sense if the suspend-to-disk portion is useing the ACPI S4 mode.

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image, even if something may not work correctly after the restore, than to risk a loss of data.

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

Quoted 12 lines
Quoted 4 lines

if you don't run out of power you will restore-from-ram

if you do run out of power the restore-from-disk won't work either becouse devices are not in the right ACPI states.

See above.

Greetings,
Rafael

#144 lore raw

[email protected] writes:

[snip]

Quoted 6 lines
Quoted 2 lines

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

What does "stopping userspace" mean? You already said it does not mean disabling interrupts. But using the freezer is also not an option, since the avoidance of that is the main reason for the kexec approach in the first place.

[snip]

Quoted 8 lines
Quoted 2 lines

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image,

even

Quoted 2 lines

if something may not work correctly after the restore, than to risk a loss of data.

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

It should be possible on any system to do a hibernate followed by a shutdown (and then resume properly, without any problems). Thus, for handling suspend to both, you resume as if the system had been shutdown, rather than resuming as if the system came from S4.

Signature · 1 line
Jeremy Maitin-Shepard
#145 lore raw
Quoted 7 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 2 lines
Quoted 2 lines

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

Quoted 8 lines
Quoted 3 lines

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

What does "stopping userspace" mean? You already said it does not mean disabling interrupts. But using the freezer is also not an option, since the avoidance of that is the main reason for the kexec approach in the first place.

just don't schedule any non-kernel threads.

remember that the normal shutdown/suspend procedure is (from another related thread)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

sys_reboot(LINUX_REBOOT_CMD_KEXEC)
kernel_kexec
kernel_restart_prepare
device_shutdown
machine_shutdown
machine_kexec

I'm just saying that instead of going back to the normal operation of the kernel you just go directly to the new shutdown routine instead.

Quoted 8 lines

[snip]

Quoted 5 lines
Quoted 2 lines

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image,

even

Quoted 2 lines

if something may not work correctly after the restore, than to risk a loss of data.

Quoted 7 lines
Quoted 2 lines

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

It should be possible on any system to do a hibernate followed by a shutdown (and then resume properly, without any problems). Thus, for handling suspend to both, you resume as if the system had been shutdown, rather than resuming as if the system came from S4.

I agree with this, but according to Rafael if the "hibernated" image is assuming that the devices were put into low-power mode by ACPI and you boot up instead the system doesn't work right.

David Lang

#146 lore raw
Quoted 44 lines · On Tuesday, 17 July 2007 23:27, [email protected] wrote:
Quoted 7 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 2 lines
Quoted 2 lines

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

Quoted 8 lines
Quoted 3 lines

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

What does "stopping userspace" mean? You already said it does not mean disabling interrupts. But using the freezer is also not an option, since the avoidance of that is the main reason for the kexec approach in the first place.

just don't schedule any non-kernel threads.

remember that the normal shutdown/suspend procedure is (from another related thread)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

sys_reboot(LINUX_REBOOT_CMD_KEXEC)
kernel_kexec
kernel_restart_prepare
device_shutdown
machine_shutdown
machine_kexec

I'm just saying that instead of going back to the normal operation of the kernel you just go directly to the new shutdown routine instead.

Quoted 11 lines

[snip]

Quoted 8 lines
Quoted 2 lines

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image,

even

Quoted 2 lines

if something may not work correctly after the restore, than to risk a loss of data.

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

Quoted 8 lines
Quoted 4 lines

It should be possible on any system to do a hibernate followed by a shutdown (and then resume properly, without any problems). Thus, for handling suspend to both, you resume as if the system had been shutdown, rather than resuming as if the system came from S4.

I agree with this, but according to Rafael if the "hibernated" image is assuming that the devices were put into low-power mode by ACPI and you boot up instead the system doesn't work right.

That's correct, some devices don't work right, but these are not disks. They usually are devices closely related to the platform, like the embedded controller.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#147 lore raw
In reply to [email protected]
Quoted 44 lines · On Tuesday, 17 July 2007 23:27, [email protected] wrote:
Quoted 7 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 2 lines
Quoted 2 lines

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

Quoted 8 lines
Quoted 3 lines

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

What does "stopping userspace" mean? You already said it does not mean disabling interrupts. But using the freezer is also not an option, since the avoidance of that is the main reason for the kexec approach in the first place.

just don't schedule any non-kernel threads.

remember that the normal shutdown/suspend procedure is (from another related thread)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

sys_reboot(LINUX_REBOOT_CMD_KEXEC)
kernel_kexec
kernel_restart_prepare
device_shutdown
machine_shutdown
machine_kexec

I'm just saying that instead of going back to the normal operation of the kernel you just go directly to the new shutdown routine instead.

Quoted 11 lines

[snip]

Quoted 8 lines
Quoted 2 lines

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image,

even

Quoted 2 lines

if something may not work correctly after the restore, than to risk a loss of data.

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

Quoted 8 lines
Quoted 4 lines

It should be possible on any system to do a hibernate followed by a shutdown (and then resume properly, without any problems). Thus, for handling suspend to both, you resume as if the system had been shutdown, rather than resuming as if the system came from S4.

I agree with this, but according to Rafael if the "hibernated" image is assuming that the devices were put into low-power mode by ACPI and you boot up instead the system doesn't work right.

That's correct, some devices don't work right, but these are not disks. They usually are devices closely related to the platform, like the embedded controller.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#148 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 24 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 6 lines
Quoted 2 lines

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

What does "stopping userspace" mean? You already said it does not mean disabling interrupts. But using the freezer is also not an option, since the avoidance of that is the main reason for the kexec approach in the first place.

[snip]

Quoted 5 lines
Quoted 2 lines

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image,

even

Quoted 2 lines

if something may not work correctly after the restore, than to risk a loss of data.

Quoted 7 lines
Quoted 2 lines

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

It should be possible on any system to do a hibernate followed by a shutdown (and then resume properly, without any problems). Thus, for handling suspend to both, you resume as if the system had been shutdown, rather than resuming as if the system came from S4.

Exactly.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#149 lore raw
In reply to [email protected]

[email protected] writes:

[snip]

Quoted 6 lines
Quoted 2 lines

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

What does "stopping userspace" mean? You already said it does not mean disabling interrupts. But using the freezer is also not an option, since the avoidance of that is the main reason for the kexec approach in the first place.

[snip]

Quoted 8 lines
Quoted 2 lines

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image,

even

Quoted 2 lines

if something may not work correctly after the restore, than to risk a loss of data.

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

It should be possible on any system to do a hibernate followed by a shutdown (and then resume properly, without any problems). Thus, for handling suspend to both, you resume as if the system had been shutdown, rather than resuming as if the system came from S4.

Signature · 1 line
Jeremy Maitin-Shepard
#150 lore raw
In reply to [email protected]
Quoted 37 lines · On Tuesday, 17 July 2007 23:17, [email protected] wrote:
Quoted 35 lines · Rafael J. Wysocki
Quoted 33 lines · On Tuesday, 17 July 2007 22:34, [email protected] wrote:
Quoted 16 lines · Rafael J. Wysocki
Quoted 4 lines · Alan Stern

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel?

No, I think the image-saving kernel should suspend. Then, on resume the platform will go back to it and it will jump back to the hibernated kernel.

Quoted 3 lines

After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

That's correct, but ...

Quoted 8 lines
Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

this is where we disagree.

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

Quoted 6 lines
Quoted 2 lines

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

This is plain reinventing the freezer under another guise, sorry. ;-)

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

there is only a problem if something takes place that would prevent the restore-from-disk from working. if this is done in a non-ACPI way that will work across a power cycle you don't have to worry about the hardware state not matching anyway.

Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

suspend-to-both doesn't really make sense if the suspend-to-disk portion is useing the ACPI S4 mode.

Quoted 7 lines
Quoted 4 lines

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image, even if something may not work correctly after the restore, than to risk a loss of data.

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

The experience shows that this is not the case. The disks usually work (you have to initialize them without ACPI anyway to load the image, no?).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#151 lore raw
In reply to [email protected]
Quoted 37 lines · On Tuesday, 17 July 2007 23:17, [email protected] wrote:
Quoted 35 lines · Rafael J. Wysocki
Quoted 33 lines · On Tuesday, 17 July 2007 22:34, [email protected] wrote:
Quoted 16 lines · Rafael J. Wysocki
Quoted 4 lines · Alan Stern

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel?

No, I think the image-saving kernel should suspend. Then, on resume the platform will go back to it and it will jump back to the hibernated kernel.

Quoted 3 lines

After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

That's correct, but ...

Quoted 8 lines
Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

this is where we disagree.

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

Quoted 6 lines
Quoted 2 lines

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

just don't schedule any userspace tasks. all you need to do is to execute the ACPI sleep functions. you normally do that after stopping userspace anyway.

This is plain reinventing the freezer under another guise, sorry. ;-)

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

there is only a problem if something takes place that would prevent the restore-from-disk from working. if this is done in a non-ACPI way that will work across a power cycle you don't have to worry about the hardware state not matching anyway.

Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

suspend-to-both doesn't really make sense if the suspend-to-disk portion is useing the ACPI S4 mode.

Quoted 7 lines
Quoted 4 lines

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image, even if something may not work correctly after the restore, than to risk a loss of data.

if things don't work correctly you are still risking the loss of data, the user just doesn't know it.

The experience shows that this is not the case. The disks usually work (you have to initialize them without ACPI anyway to load the image, no?).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#152 lore raw
In reply to [email protected]
Quoted 27 lines · On Tuesday, 17 July 2007 22:34, [email protected] wrote:
Quoted 16 lines · Rafael J. Wysocki
Quoted 4 lines · Alan Stern

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel?

No, I think the image-saving kernel should suspend. Then, on resume the platform will go back to it and it will jump back to the hibernated kernel.

Quoted 3 lines

After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

That's correct, but ...

Quoted 8 lines
Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

Quoted 6 lines

this is where we disagree.

why not? if all that the hibernated kernel does is to suspend-to-ram and makes no changes to disks or TCP connections anything that it does do would be lost if power were to fail and you instead did a restore from disk.

How do you guarantee that no tasks are scheduled when you get back to the hibernated kernel?

Quoted 10 lines

there is only a problem if something takes place that would prevent the restore-from-disk from working. if this is done in a non-ACPI way that will work across a power cycle you don't have to worry about the hardware state not matching anyway.

Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

suspend-to-both doesn't really make sense if the suspend-to-disk portion is useing the ACPI S4 mode.

Well, not exactly. If your battery runs out of power while you're suspended, but you have the image saved, it's still better to restore from the image, even if something may not work correctly after the restore, than to risk a loss of data.

Quoted 4 lines

if you don't run out of power you will restore-from-ram

if you do run out of power the restore-from-disk won't work either becouse devices are not in the right ACPI states.

See above.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#153 lore raw
In reply to Rafael J. Wysocki

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 6 lines
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Quoted 6 lines

Sure.

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:

I assume you mean "in order to enter the sleep state", rather than "upon entering the sleep state". I still don't understand what you mean by "which IMO can be done _after_ the image has been saved"; as far as I understand, the last step of this process, "make the platform enter S4", is almost like a shutdown as far as the kernel is concerned (except for the tiny detail of having to call those special ACPI methods on resume); consequently, it would seem that nothing can be done after that step.

Quoted 9 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)
* execute the _PTS global control method
* switch off the nonlocal CPUs (eg. nonboot CPUs on x86)
* execute the _GTS global control method
* set the GPE enable registers corresponding to the wake-up devices)
* make the platform enter S4 (there's a well defined procedure for that) I think that this should be done by the image-saving kernel.

I agree.

Quoted 4 lines

(2) Upon start-up (by which I mean what happens after the user has pressed the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI (we don't do that now, but I see no reason for not doing it in the new framework)

Quoted 8 lines

* if the image is present (and valid), load it
* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading kernel, but the remaining operations have to be carried out by the restored
kernel.

It doesn't seem like a problem for that to be the case, but out of curiosity why do those methods need to be executed by the "restored" kernel, rather than the "image loading" kernel. Do they require some information from ACPI-related kernel data structures that were populated by the normal ACPI initialization?

[snip]

Quoted 2 lines

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

I agree.

Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

If all of the devices that the image writing kernel doesn't know about have already been shut down/powered off by the hibernated kernel, then does the "image writing" kernel still need to know about them in order to suspend to RAM properly (i.e. without leaving some devices on wasting power)?

Signature · 1 line
Jeremy Maitin-Shepard
#154 lore raw
In reply to Rafael J. Wysocki

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 6 lines
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Quoted 6 lines

Sure.

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:

I assume you mean "in order to enter the sleep state", rather than "upon entering the sleep state". I still don't understand what you mean by "which IMO can be done _after_ the image has been saved"; as far as I understand, the last step of this process, "make the platform enter S4", is almost like a shutdown as far as the kernel is concerned (except for the tiny detail of having to call those special ACPI methods on resume); consequently, it would seem that nothing can be done after that step.

Quoted 9 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)
* execute the _PTS global control method
* switch off the nonlocal CPUs (eg. nonboot CPUs on x86)
* execute the _GTS global control method
* set the GPE enable registers corresponding to the wake-up devices)
* make the platform enter S4 (there's a well defined procedure for that) I think that this should be done by the image-saving kernel.

I agree.

Quoted 4 lines

(2) Upon start-up (by which I mean what happens after the user has pressed the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI (we don't do that now, but I see no reason for not doing it in the new framework)

Quoted 8 lines

* if the image is present (and valid), load it
* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading kernel, but the remaining operations have to be carried out by the restored
kernel.

It doesn't seem like a problem for that to be the case, but out of curiosity why do those methods need to be executed by the "restored" kernel, rather than the "image loading" kernel. Do they require some information from ACPI-related kernel data structures that were populated by the normal ACPI initialization?

[snip]

Quoted 2 lines

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

I agree.

Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

If all of the devices that the image writing kernel doesn't know about have already been shut down/powered off by the hibernated kernel, then does the "image writing" kernel still need to know about them in order to suspend to RAM properly (i.e. without leaving some devices on wasting power)?

Signature · 1 line
Jeremy Maitin-Shepard
#155 lore raw
Quoted 17 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 6 lines
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Quoted 6 lines

Sure.

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:

Quoted 11 lines

I assume you mean "in order to enter the sleep state", rather than "upon entering the sleep state". I still don't understand what you mean by "which IMO can be done _after_ the image has been saved"; as far as I understand, the last step of this process, "make the platform enter S4", is almost like a shutdown as far as the kernel is concerned (except for the tiny detail of having to call those special ACPI methods on resume); consequently, it would seem that nothing can be done after that step.

Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

David Lang

#156 lore raw

[email protected] writes:

[snip]

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

The image-saving kernel can be made to know about all of the "wake up" devices; all other devices should have already been powered off by the "hibernated" kernel.

Signature · 1 line
Jeremy Maitin-Shepard
#157 lore raw
In reply to [email protected]

[email protected] writes:

[snip]

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

The image-saving kernel can be made to know about all of the "wake up" devices; all other devices should have already been powered off by the "hibernated" kernel.

Signature · 1 line
Jeremy Maitin-Shepard
#158 lore raw
Quoted 8 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

Quoted 6 lines
Quoted 2 lines

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

The image-saving kernel can be made to know about all of the "wake up" devices; all other devices should have already been powered off by the "hibernated" kernel.

not nessasarily.

for example, you don't want the "hibernated" kernel to spin down your disks in the general case, but your image-writing kernel may not have drivers in it to talk to some of the disks. when things are powered off this just isn't an issue, but if you use S4 mode instead it is.

David Lang

#159 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 8 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

Quoted 6 lines
Quoted 2 lines

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

The image-saving kernel can be made to know about all of the "wake up" devices; all other devices should have already been powered off by the "hibernated" kernel.

not nessasarily.

for example, you don't want the "hibernated" kernel to spin down your disks in the general case, but your image-writing kernel may not have drivers in it to talk to some of the disks. when things are powered off this just isn't an issue, but if you use S4 mode instead it is.

David Lang

#160 lore raw
Quoted 10 lines · On Tuesday, 17 July 2007 23:06, [email protected] wrote:
Quoted 8 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

The image-saving kernel can be made to know about all of the "wake up" devices; all other devices should have already been powered off by the "hibernated" kernel.

not nessasarily.

More than that. The hibernated kernel should not power off any devices, because that is _wasteful_ (unless, of course, the powering off a device is the only way to quiesce it).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#161 lore raw
In reply to [email protected]
Quoted 10 lines · On Tuesday, 17 July 2007 23:06, [email protected] wrote:
Quoted 8 lines · Jeremy Maitin-Shepard

[email protected] writes:

[snip]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

The image-saving kernel can be made to know about all of the "wake up" devices; all other devices should have already been powered off by the "hibernated" kernel.

not nessasarily.

More than that. The hibernated kernel should not power off any devices, because that is _wasteful_ (unless, of course, the powering off a device is the only way to quiesce it).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#162 lore raw
In reply to [email protected]
Quoted 27 lines · On Tuesday, 17 July 2007 22:37, [email protected] wrote:
Quoted 25 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 6 lines
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Quoted 6 lines

Sure.

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:

I assume you mean "in order to enter the sleep state", rather than "upon entering the sleep state". I still don't understand what you mean by "which IMO can be done _after_ the image has been saved"; as far as I understand, the last step of this process, "make the platform enter S4", is almost like a shutdown as far as the kernel is concerned (except for the tiny detail of having to call those special ACPI methods on resume); consequently, it would seem that nothing can be done after that step.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

Good observation. :-)

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#163 lore raw
In reply to [email protected]
Quoted 27 lines · On Tuesday, 17 July 2007 22:37, [email protected] wrote:
Quoted 25 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 6 lines
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Quoted 6 lines

Sure.

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:

I assume you mean "in order to enter the sleep state", rather than "upon entering the sleep state". I still don't understand what you mean by "which IMO can be done _after_ the image has been saved"; as far as I understand, the last step of this process, "make the platform enter S4", is almost like a shutdown as far as the kernel is concerned (except for the tiny detail of having to call those special ACPI methods on resume); consequently, it would seem that nothing can be done after that step.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)

this can't be done by the image-saving kernel if that kernel doesn't know about the device.

Good observation. :-)

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#164 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 12 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 7 lines
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Sure.

Quoted 7 lines
Quoted 4 lines

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:

I assume you mean "in order to enter the sleep state", rather than "upon entering the sleep state".

Yes, that seems to be more accurate.

Quoted 6 lines

I still don't understand what you mean by
"which IMO can be done _after_ the image has been saved"; as far as I understand, the last step of this process, "make the platform enter S4", is almost like a shutdown as far as the kernel is concerned (except for the tiny detail of having to call those special ACPI methods on resume); consequently, it would seem that nothing can be done after that step.

Well, the ACPI spec suggests to save the image somewhere after the devices have been but into low power states, which is kind of unreasonable. :-)

Quoted 25 lines
Quoted 9 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)
* execute the _PTS global control method
* switch off the nonlocal CPUs (eg. nonboot CPUs on x86)
* execute the _GTS global control method
* set the GPE enable registers corresponding to the wake-up devices)
* make the platform enter S4 (there's a well defined procedure for that) I think that this should be done by the image-saving kernel.

I agree.

Quoted 4 lines

(2) Upon start-up (by which I mean what happens after the user has pressed the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI (we don't do that now, but I see no reason for not doing it in the new framework)

Quoted 8 lines

* if the image is present (and valid), load it
* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading kernel, but the remaining operations have to be carried out by the restored
kernel.

Quoted 5 lines

It doesn't seem like a problem for that to be the case, but out of curiosity why do those methods need to be executed by the "restored" kernel, rather than the "image loading" kernel. Do they require some information from ACPI-related kernel data structures that were populated by the normal ACPI initialization?

Well, there are some complications. For example, _BFS and _WAK should be executed with interrupts on (I'm told that the AML interpreter might not work with interrupts disabled) and the nonboot CPUs should be offline while they are being executed. Perhaps we should also avoid playing with APICs and things like that after executing _WAK, so it's better to execute them from the restored kernel.

Quoted 7 lines

[snip]

Quoted 2 lines

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

I agree.

Quoted 8 lines
Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

If all of the devices that the image writing kernel doesn't know about have already been shut down/powered off by the hibernated kernel, then does the "image writing" kernel still need to know about them in order to suspend to RAM properly (i.e. without leaving some devices on wasting power)?

For some devices it may be illegal to leave them powered on while entering S3.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#165 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 12 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 7 lines
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Sure.

Quoted 7 lines
Quoted 4 lines

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:

I assume you mean "in order to enter the sleep state", rather than "upon entering the sleep state".

Yes, that seems to be more accurate.

Quoted 6 lines

I still don't understand what you mean by
"which IMO can be done _after_ the image has been saved"; as far as I understand, the last step of this process, "make the platform enter S4", is almost like a shutdown as far as the kernel is concerned (except for the tiny detail of having to call those special ACPI methods on resume); consequently, it would seem that nothing can be done after that step.

Well, the ACPI spec suggests to save the image somewhere after the devices have been but into low power states, which is kind of unreasonable. :-)

Quoted 25 lines
Quoted 9 lines

* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)
* execute the _PTS global control method
* switch off the nonlocal CPUs (eg. nonboot CPUs on x86)
* execute the _GTS global control method
* set the GPE enable registers corresponding to the wake-up devices)
* make the platform enter S4 (there's a well defined procedure for that) I think that this should be done by the image-saving kernel.

I agree.

Quoted 4 lines

(2) Upon start-up (by which I mean what happens after the user has pressed the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI (we don't do that now, but I see no reason for not doing it in the new framework)

Quoted 8 lines

* if the image is present (and valid), load it
* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading kernel, but the remaining operations have to be carried out by the restored
kernel.

Quoted 5 lines

It doesn't seem like a problem for that to be the case, but out of curiosity why do those methods need to be executed by the "restored" kernel, rather than the "image loading" kernel. Do they require some information from ACPI-related kernel data structures that were populated by the normal ACPI initialization?

Well, there are some complications. For example, _BFS and _WAK should be executed with interrupts on (I'm told that the AML interpreter might not work with interrupts disabled) and the nonboot CPUs should be offline while they are being executed. Perhaps we should also avoid playing with APICs and things like that after executing _WAK, so it's better to execute them from the restored kernel.

Quoted 7 lines

[snip]

Quoted 2 lines

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

I agree.

Quoted 8 lines
Quoted 2 lines

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

If all of the devices that the image writing kernel doesn't know about have already been shut down/powered off by the hibernated kernel, then does the "image writing" kernel still need to know about them in order to suspend to RAM properly (i.e. without leaving some devices on wasting power)?

For some devices it may be illegal to leave them powered on while entering S3.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#166 lore raw
In reply to Alan Stern
Quoted 22 lines · Alan Stern
Quoted 8 lines · Rafael J. Wysocki

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

Absolutely. This needs to be done in such a way that it will work:

	On platforms without ACPI;

	On platforms with ACPI where we do a non-ACPI type of shutdown
	to whatever extent it is possible (or perhaps an ACPI-aware
	shutdown rather than change to S4);

	On platforms with ACPI where we do an ACPI-aware transition
	to S4.
Quoted 5 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

Sure.

In the third case (ie. transition to S4) we are supposed to do the following:

(1) Upon entering the sleep state, which IMO can be done _after_ the image has been saved:
* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in the Dx states compatible with the wake capability, the others are powered off)
* execute the _PTS global control method
* switch off the nonlocal CPUs (eg. nonboot CPUs on x86)
* execute the _GTS global control method
* set the GPE enable registers corresponding to the wake-up devices)
* make the platform enter S4 (there's a well defined procedure for that) I think that this should be done by the image-saving kernel.

(2) Upon start-up (by which I mean what happens after the user has pressed the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI (we don't do that now, but I see no reason for not doing it in the new framework)
* if the image is present (and valid), load it
* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading kernel, but the remaining operations have to be carried out by the restored kernel.

In the remaining two cases we generally don't need to bother with the global ACPI handling.

Quoted 4 lines

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel?

No, I think the image-saving kernel should suspend. Then, on resume the platform will go back to it and it will jump back to the hibernated kernel.

Quoted 3 lines

After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

That's correct, but ...

Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

... we can't return to the hibernated kernel unless we are going to cancel the hibernation.

That's why I think that for the suspend-to-both the image-saving kernel will need to support the same set of devices as the hibernated kernel.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#167 lore raw
In reply to Alan Stern
Quoted 22 lines · Alan Stern
Quoted 8 lines · Rafael J. Wysocki

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

Absolutely. This needs to be done in such a way that it will work:

	On platforms without ACPI;

	On platforms with ACPI where we do a non-ACPI type of shutdown
	to whatever extent it is possible (or perhaps an ACPI-aware
	shutdown rather than change to S4);

	On platforms with ACPI where we do an ACPI-aware transition
	to S4.
Quoted 6 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

there was just a link on slashdot toa primer on the subject of power management

http://www.techarp.com/showarticle.aspx?artno=420

Quoted 7 lines

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel? After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

this is what I'm thinking, but the issue here is that the original kernel needs to go into suspend-to-ram mode instead of resuming operation. per the e-mail I got from Ying last night this should not be hard to implement.

Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

no, user tasks just don't get scheduled during shutdown.

the big problem with the freezer isn't stopping anything from happening, it's _selectivly_ stopping things.

with kexec you don't need to let any portion of the origional kernel or userspace operate so you don't have a problem.

David Lang

#168 lore raw
Quoted 55 lines · On Tuesday, 17 July 2007 22:27, [email protected] wrote:
Quoted 22 lines · Alan Stern
Quoted 8 lines · Rafael J. Wysocki

I'm afraid of one thing, though.

If we create a framework without ACPI (well, ACPI needs to be enabled in the kernel anyway for other reasons, like the ability to suspend to RAM) and then it turns out that we have to add some ACPI hooks to it, that might be difficult to do cleanly.

Thus, it seems reasonable to think of the ACPI handling in advance.

Absolutely. This needs to be done in such a way that it will work:

	On platforms without ACPI;

	On platforms with ACPI where we do a non-ACPI type of shutdown
	to whatever extent it is possible (or perhaps an ACPI-aware
	shutdown rather than change to S4);

	On platforms with ACPI where we do an ACPI-aware transition
	to S4.
Quoted 6 lines

Rafael, for those of us who aren't thoroughly familiar with all the ins and outs of the ACPI spec, could you please summarize a list of the ACPI calls needed in the second and third cases above? Indicate which ones need to be done from within the original kernel and which should be done from within a kexec'd hibernation kernel.

there was just a link on slashdot toa primer on the subject of power management

http://www.techarp.com/showarticle.aspx?artno=420

Quoted 7 lines

I'm still not entirely clear on how "suspend-to-both" ought to be handled. Presumably it will start off as a normal hibernation. But instead of shutting down, wouldn't the kexec'd kernel return to the original kernel? After all, the original kernel knows about all the devices and can put them into a low-power state, while the kexec'd kernel might not have sufficient information.

this is what I'm thinking, but the issue here is that the original kernel needs to go into suspend-to-ram mode instead of resuming operation. per the e-mail I got from Ying last night this should not be hard to implement.

Quoted 5 lines

But what about the freezer? The original reason for using kexec was to avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with the on-disk data structures.

Quoted 4 lines

no, user tasks just don't get scheduled during shutdown.

the big problem with the freezer isn't stopping anything from happening, it's _selectivly_ stopping things.

It's selectively stopping kernel threads, which is just about right. If you that _this_ is a main problem with the freezer, then think again.

Quoted 2 lines

with kexec you don't need to let any portion of the origional kernel or userspace operate so you don't have a problem.

In fact, the main problem with the freezer is that it is a coarse-grained solution. Therefore, what I believe we should do is to evolve in the directoin of more fine-grained solutions and gradually phase out the freezer.

The kexec-based approach is an attempt to replace one coarse-grained solution (the freezer) with even more coarse-grained solution (stopping the entire kernel with everything), which IMO doesn't address the main problem.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth

A message that is not in the archive (sent off-list or not yet received): [email protected]

#170 lore raw
Quoted 15 lines · Milton Miller
Quoted 6 lines

(2) Upon start-up (by which I mean what happens after the user has pressed the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI (we
don't
do that now, but I see no reason for not doing it in the new
framework)

Quoted 8 lines

* if the image is present (and valid), load it
* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored kernel.

Quoted 7 lines

Here I agree.

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image. After that its done. The platform can be powered off if we are going to S5. However, to support suspend to ram and suspend to disk, we return to the first kernel.

This means that the first kernel will need to know why it got resumed. Was the system powered off, and this is the resume from the user? Or was it restarted because the image has been saved, and its now time to actually suspend until woken up? If you look at it, this is the same interface we have with the magic arch_suspend hook -- did we just suspend and its time to write the image, or did we just resume and its time to wake everything up.

I think this can be easily solved by giving the image saving kernel two resume points: one for the image has been written, and one for we rebooted and have restored the image. I'm not familiar with ACPI. Perhaps we need a third to differentiate we read the image from S4 instead of from S5, but that information must be available to the OS because it needs that to know if it should resume from hibernate.

are we sure that there are only 2-3 possible actions? or should this be made into a simple jump table so that it's extendable?

Quoted 14 lines

As noted in the thread

Message-ID: <[email protected]>
Subject: [linux-pm] Re: hibernation/snapshot design

Quoted 1 line · Jeremy Maitin-Shepard

(3) how to communicate where to save the memory

This is an intresting topic. The suspended kernel has most IO and disk space. It also knows how much space is to be occupied by the kernel. So communicating a block map to the second kernel would be the obvious choice. But the second kernel must be able to find the image to restore it, and it must have drivers for the media. Also, this is not feasible for storing to nfs.

I think we will end up with several methods.

One would be supply a list of blocks, and implement a file system that reads the file by reading the scatter list from media. The restore kernel then only needs to read an anchor, and can build upon that until the image is read into memory. Or do this in userspace.

Quoted 7 lines

I don't know how this compares to the current restore path. I wasn't able to identify the code that creates the on disk structure in my 10 minute perusal of kernel/power/.

A second method will be to supply a device and file that will be mounted by the save kernel, then unmounted and restored. This would require a partition that is not mounted or open by the suspended kernel (or use nfs or a similar protocol that is designed for multiple client concurrent access).

A third method would be to allocate a file with the first kernel, and make sure the blocks are flushed to disk. The save and restore kernels map the file system using a snapshot device. Writing would map the blocks and use the block offset to write to the real device using the method from the first option; reading could be done directly from the snapshot device.

The first and third option are dead on log based file systems (where the data is stored in the log).

remember that the save and restore kernel can access the memory of the suspending kernel, so as long as the data is in a known format and there is a pointer to the data in a known location, the save and restore kernel can retreive the data from memory, there's no need to involve media.

Quoted 3 lines

Simplifying kjump: the proposal for v3.

The current code is trying to use crash dump area as a safe, reserved area to run the second kernel. However, that means that the kernel has to be linked specially to run in the reserved area. I think we need to finish separating kexec_jump from the other code paths.

on x86 at least it's possible to compile a relocateable kernel, so it doesn't need to be compiled specificly for a particular reserved area. This would allow you to use the same kernel build as the suspending kernel if you wanted to (I think that the config of the save and restore kernel is going to be trivial enough to consider auto-configuring and building a specific kernel for each box a real possibility)

Quoted 1 line

As a first stage of suspend and resume, we can save to dedicated partitions all memory (as supplied to crash_dump) that is not marked nosave and not part of the save kernel's image. The fancy block lists and memory lists can be added later.

if the suspending kernel needs to tell the save and restore kernel what memory is not marked nosave have it do so useing a memory list of some kind. you need to setup a mechanism for communicating the data anyway, setup a mechansim that's useable in the long term.

Quoted 1 line

If we want to keep the second kernel booted, then we need to add a save area for the booted jump target. Note that the save and restore lists to relocate_new_kernel can be computed once and saved. Longer term we could implement sys_kexec_load(UNLOAD) that would retrieve the saved list back to application space to save to disk in a file. This means you could save the booted save kernel, it just couldn't have any shared storage open.

since the kexec to the second kernel needs to handle the device intialization, do you really save much by doing this? from a reliability point of view it would seem simpler (and therefor more reliable) to initialize the save and restore kernel each time it's used, so that it always does the same thing (as opposed to carrying state from one use to the next)

David Lang

#171 lore raw
Quoted 21 lines · On Jul 19, 2007, at 12:31 PM, [email protected] wrote:
Quoted 20 lines · Milton Miller
Quoted 9 lines

(2) Upon start-up (by which I mean what happens after the user has
pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling
ACPI (we
don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Here I agree.

Quoted 7 lines
Quoted 5 lines

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image. After that its done. The platform can be powered off if we are going to S5. However, to support suspend to ram and suspend to disk, we return to the first kernel.

This means that the first kernel will need to know why it got resumed. Was the system powered off, and this is the resume from the user? Or was it restarted because the image has been saved, and its now time to actually suspend until woken up? If you look at it, this is the same interface we have with the magic arch_suspend hook -- did we just suspend and its time to write the image, or did we just resume and its time to wake everything up.

I think this can be easily solved by giving the image saving kernel two resume points: one for the image has been written, and one for we rebooted and have restored the image. I'm not familiar with ACPI. Perhaps we need a third to differentiate we read the image from S4 instead of from S5, but that information must be available to the OS because it needs that to know if it should resume from hibernate.

are we sure that there are only 2-3 possible actions? or should this be made into a simple jump table so that it's extendable?

At 2 I don't think we need a jump table. Even if we had a table, we have to identify what each entry means. If we start getting more then we can change from command line to table.

Quoted 16 lines
Quoted 16 lines

As noted in the thread

Message-ID: <[email protected]>
Subject: [linux-pm] Re: hibernation/snapshot design

Quoted 1 line · Jeremy Maitin-Shepard

(3) how to communicate where to save the memory

This is an intresting topic. The suspended kernel has most IO and disk space. It also knows how much space is to be occupied by the kernel. So communicating a block map to the second kernel would be the obvious choice. But the second kernel must be able to find the image to restore it, and it must have drivers for the media. Also, this is not feasible for storing to nfs.

I think we will end up with several methods.

One would be supply a list of blocks, and implement a file system that reads the file by reading the scatter list from media. The restore kernel then only needs to read an anchor, and can build upon that until the image is read into memory. Or do this in userspace.

I don't know how this compares to the current restore path. I wasn't able to identify the code that creates the on disk structure in my 10 minute perusal of kernel/power/.

Quoted 7 lines
Quoted 5 lines

A second method will be to supply a device and file that will be mounted by the save kernel, then unmounted and restored. This would require a partition that is not mounted or open by the suspended kernel (or use nfs or a similar protocol that is designed for multiple client concurrent access).

A third method would be to allocate a file with the first kernel, and make sure the blocks are flushed to disk. The save and restore kernels map the file system using a snapshot device. Writing would map the blocks and use the block offset to write to the real device using the method from the first option; reading could be done directly from the snapshot device.

The first and third option are dead on log based file systems (where the data is stored in the log).

remember that the save and restore kernel can access the memory of the suspending kernel, so as long as the data is in a known format and there is a pointer to the data in a known location, the save and restore kernel can retreive the data from memory, there's no need to involve media.

I agree that the the save kernel can read the list from the being-saved kernel.

However, when restoring, the being-saved (being-restored) kernel is not accessable, so the save list has to be stored as part of the image.

Quoted 5 lines
Quoted 3 lines

Simplifying kjump: the proposal for v3.

The current code is trying to use crash dump area as a safe, reserved area to run the second kernel. However, that means that the kernel has to be linked specially to run in the reserved area. I think we need to finish separating kexec_jump from the other code paths.

on x86 at least it's possible to compile a relocateable kernel, so it doesn't need to be compiled specificly for a particular reserved area. This would allow you to use the same kernel build as the suspending kernel if you wanted to (I think that the config of the save and restore kernel is going to be trivial enough to consider auto-configuring and building a specific kernel for each box a real possibility)

Yes, one *can* build x86 relocatable. But there are funny restrictions like it has to be a bzImage or be loaded by kexec or something. And not all architectures have relocatable support. I think making the lists for the exsiting code to swap memory will not be that difficult and it will make the solution have less restrictions. Maybe I should shut up and write some code this weekend.

Actually, I think we can have the dedicated area as an option. If you suspend frequently keep a relocated kernel booted. If you need more ram or suspend infrequently allocate the pages on the fly.

Quoted 3 lines
Quoted 1 line

As a first stage of suspend and resume, we can save to dedicated partitions all memory (as supplied to crash_dump) that is not marked nosave and not part of the save kernel's image. The fancy block lists and memory lists can be added later.

if the suspending kernel needs to tell the save and restore kernel what memory is not marked nosave have it do so useing a memory list of some kind. you need to setup a mechanism for communicating the data anyway, setup a mechansim that's useable in the long term.

I'm saying we can have people start to test by the simple save all ram to dedicated while we figure out what the long term list looks like.

Quoted 5 lines
Quoted 3 lines

If we want to keep the second kernel booted, then we need to add a save area for the booted jump target. Note that the save and restore lists to relocate_new_kernel can be computed once and saved.
Longer term we could implement sys_kexec_load(UNLOAD) that would
retrieve the saved list back to application space to save to disk in a file. This means you could save the booted save kernel, it just couldn't have any shared storage open.

since the kexec to the second kernel needs to handle the device intialization, do you really save much by doing this? from a reliability point of view it would seem simpler (and therefor more reliable) to initialize the save and restore kernel each time it's used, so that it always does the same thing (as opposed to carrying state from one use to the next)

You can save a bit of run time initialization, at the cost of saving the whole image with the initialized pages instead of zeroing uninitialized pages. The code to restore the devices is the same code path as the code for the main kernel to restore the devices (as implemented in the current patch), so we get more testing of that path.

Quoted 1 line

David Lang

milton

#172 lore raw
Quoted 18 lines · Milton Miller
Quoted 17 lines · On Jul 19, 2007, at 12:31 PM, [email protected] wrote:
Quoted 15 lines · Milton Miller

This means that the first kernel will need to know why it got resumed.
Was the system powered off, and this is the resume from the user? Or
was it restarted because the image has been saved, and its now time to actually suspend until woken up? If you look at it, this is the same interface we have with the magic arch_suspend hook -- did we just suspend and its time to write the image, or did we just resume and its time to wake everything up.

I think this can be easily solved by giving the image saving kernel two resume points: one for the image has been written, and one for we rebooted and have restored the image. I'm not familiar with ACPI. Perhaps we need a third to differentiate we read the image from S4 instead of from S5, but that information must be available to the OS because it needs that to know if it should resume from hibernate.

Quoted 4 lines
Quoted 2 lines

are we sure that there are only 2-3 possible actions? or should this be made into a simple jump table so that it's extendable?

At 2 I don't think we need a jump table. Even if we had a table, we have to identify what each entry means. If we start getting more then we can change from command line to table.

Ok, I was just looking to future-proof things so that these features can work on older kernels (as opposed to having two interfaces and when we switch from one to the next kernels older then that can't be used)

Quoted 8 lines
Quoted 4 lines

remember that the save and restore kernel can access the memory of the suspending kernel, so as long as the data is in a known format and there is a pointer to the data in a known location, the save and restore kernel can retreive the data from memory, there's no need to involve media.

I agree that the the save kernel can read the list from the being-saved kernel.

However, when restoring, the being-saved (being-restored) kernel is not accessable, so the save list has to be stored as part of the image.

at that point it's less a save list then just the record of where the memory pages belong. you can use the same list, but you can store it along with the memory image. there's still no need for the suspending kernel to save it to permanent media.

Quoted 14 lines
Quoted 7 lines
Quoted 6 lines

Simplifying kjump: the proposal for v3.

The current code is trying to use crash dump area as a safe, reserved
area to run the second kernel. However, that means that the kernel has
to be linked specially to run in the reserved area. I think we need to
finish separating kexec_jump from the other code paths.

Quoted 6 lines

on x86 at least it's possible to compile a relocateable kernel, so it doesn't need to be compiled specificly for a particular reserved area. This would allow you to use the same kernel build as the suspending kernel if you wanted to (I think that the config of the save and restore kernel is going to be trivial enough to consider auto-configuring and building a specific kernel for each box a real possibility)

Quoted 3 lines

Yes, one *can* build x86 relocatable. But there are funny restrictions like it has to be a bzImage or be loaded by kexec or something. And not all architectures have relocatable support. I think making the lists for the exsiting code to swap memory will not be that difficult and it will make the solution have less restrictions. Maybe I should shut up and write some code this weekend.

Actually, I think we can have the dedicated area as an option. If you suspend frequently keep a relocated kernel booted. If you need more ram or suspend infrequently allocate the pages on the fly.

for the proof of concept that we are trying for now there's no need to implement the capability to free memory to make room for the kexec kernel. after we show that this can work that can be added.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

As a first stage of suspend and resume, we can save to dedicated partitions all memory (as supplied to crash_dump) that is not marked
nosave and not part of the save kernel's image. The fancy block lists
and memory lists can be added later.

Quoted 6 lines
Quoted 4 lines

if the suspending kernel needs to tell the save and restore kernel what memory is not marked nosave have it do so useing a memory list of some kind. you need to setup a mechanism for communicating the data anyway, setup a mechansim that's useable in the long term.

I'm saying we can have people start to test by the simple save all ram to dedicated while we figure out what the long term list looks like.

the only problem with this is that Rafael is saying that if you try to save all the ram you will fail (in some cases becouse you are trying to save ram that doesn't exist). so at the very least we need to get a list that tells us what _can_ be saved.

David Lang

#173 lore raw
In reply to a message not in the archive
Quoted 39 lines · Milton Miller

Hi. I've found this thread from the kjump thread on the kexec mailing
list. I'll respond to that one later, but I wanted to respond to
several messages in this thread. [Actually, there is a brief outline of a response near the bottom of this note]. I downloaded the archive to get message-ids and references, hopefully I don't break the threading badly.

First, my background is hardware and low level software. I wrote the initial ppc64 support for kexec. I try not to learn too much about x86 details, but have read this thread and the tutorial article mentioned in it. I've studied the suspend code at various times in the past but not in the last year. Several years I mused that kexec could be used restore the suspend image, but I was told that would not be swsupend.

Next: lets define what we are trying to solve with the kexec approach.

We can solve the case of getting the drivers to quiesce the hardware with requests from userspace suspended in queues. This is what the powermac suspend has been doing for years, and I think its agreed that it will be something similar when we remove the freezer. In the powermac code, there are two notifications to drivers; in the first stage they can allocate memory and interrupts are enabled, in the second its copy enough device state to memory to restart the device.

The problem with all the suspend methods is how do we select what needs to be re-enabled to write the image to stable storage (be it disk, network, or other medium).

The kjump kexec proposal says after we have the io quiesced, we can jump to a totally new kernel, let it initialize the io it needs, and write the image. This has the advantage that there is no confusion as far as which requests should be service or not serviced by the driver
and subsystem stacks. It also reuses all the drivers, which means we
don't get untested code paths. It also has the advantages that we can use any complicated user stack to access a file system and run any desired access methods (eg encryption, raid, etc).

Quoted 7 lines

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

Quoted 28 lines

I'll now start with quotes from several articles in this thread and my responses.

Message-ID: <[email protected]>

Quoted 7 lines · Rafael J. Wysocki

(1) Upon entering the sleep state, which IMO can be done _after_ the image
has been saved:
* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in
the Dx
states compatible with the wake capability, the others are powered

Quoted 8 lines

off)
* execute the _PTS global control method
* switch off the nonlocal CPUs (eg. nonboot CPUs on x86)
* execute the _GTS global control method
* set the GPE enable registers corresponding to the wake-up devices)
* make the platform enter S4 (there's a well defined procedure for
that)
I think that this should be done by the image-saving kernel.

Message-ID: <[email protected]>
On Tue Jul 17 13:35:52 2007, Jeremy Maitin-Shepard
expressed his agreement with this block but also confusion on the other blocks.

Quoted 8 lines

I strongly disagree.

(1) as has been pointed out, this requires the new kernel to understand all io devices in the first kernel.
(2) it requires both kernels to talk to ACPI. This is doomed to
failure. How can the second kernel initialize ACPI? The platform
thinks it has already been initialized. Do we plan to always undo all acpi initialization?

Good question. I don't know.

Quoted 17 lines
Quoted 8 lines

(2) Upon start-up (by which I mean what happens after the user has pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI
(we don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Quoted 8 lines

Here I agree.

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image.
After that its done. The platform can be powered off if we are going
to S5. However, to support suspend to ram and suspend to disk, we
return to the first kernel.

We can't do this unless we have frozen tasks (this way, or another) before carrying out the entire operation. In that case, however, the kexec-based approach would have only one advantage over the current one. Namely, it would allow us to create bigger images.

Quoted 34 lines

This means that the first kernel will need to know why it got resumed.
Was the system powered off, and this is the resume from the user? Or
was it restarted because the image has been saved, and its now time to actually suspend until woken up? If you look at it, this is the same interface we have with the magic arch_suspend hook -- did we just suspend and its time to write the image, or did we just resume and its time to wake everything up.

I think this can be easily solved by giving the image saving kernel two resume points: one for the image has been written, and one for we rebooted and have restored the image. I'm not familiar with ACPI. Perhaps we need a third to differentiate we read the image from S4 instead of from S5, but that information must be available to the OS because it needs that to know if it should resume from hibernate.

By making the split at image save and restore we have several advantages:

(1) the kernel always initializes with devices in the init or quiesced but active state.

(2) the kernel always resumes with devices in the init or quiesced but active state.

(3) the kjump save and restore kernel does not need to know how to suspend all devices in the platform.

(4) we have a merged path for suspend to disk, suspend to ram, and suspend to both.

(5) because of (4), we can implement sleep policys where we save the image to disk but try to stay in ram based on expected remaining battery life.

Quoted 5 lines

(6) we confine all platform (acpi) interaction to the main kernel

(7) we limit the knowledge needed in the second kernel. It needs to
know how to do its job and then put the hardware back how it found it. Nothing more.

This would have been nice if we had been able to do it.

Quoted 10 lines

For the suspend to ram and then woken up case, we simply need to invalidate the image before restarting normal kernel operation.

People have worried about how to boot and restore the kernel, and what
to do if reading the image fails. They worry about needing memory
hotplug or delayed acpi parsing. They are forgetting one thing. This kernel has support for kexec.

This is all easily solved by having the bootloader from the bios always boot the restore kernel.

Well, I think this is not generally acceptable, although I agree that it would be simpler.

Quoted 6 lines

It will boot with limited useable memory and
no acpi support. If the restore kernel userspace detects that there is no restore image, it simply loads the normal main kernel and initrd / initramfs and calls the normal kexec. The cost is the time to init the restore kernel, read the kernel with full drivers (vs reading it from the bootloader). If you want a boot menu, use kboot (on sourceforge).

Well, I'm afraid of adding more and more infrastructure to the mix.

Quoted 11 lines · Rafael J. Wysocki
Quoted 10 lines · On Tuesday, 17 July 2007 22:27, [email protected] wrote:
Quoted 9 lines · Alan Stern
Quoted 7 lines

But what about the freezer? The original reason for using kexec was to
avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with
the on-disk data structures.

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

no, user tasks just don't get scheduled during shutdown.

the big problem with the freezer isn't stopping anything from happening,
it's _selectivly_ stopping things.

Agreed. Or rather, selectively not stopping and resuming things.

I don't quite understant this statement. Can you please elaborate?

Quoted 32 lines
Quoted 14 lines

It's selectively stopping kernel threads, which is just about right. If you
that _this_ is a main problem with the freezer, then think again.

Quoted 3 lines

with kexec you don't need to let any portion of the origional kernel or
userspace operate so you don't have a problem.

In fact, the main problem with the freezer is that it is a coarse-grained
solution. Therefore, what I believe we should do is to evolve in the directoin
of more fine-grained solutions and gradually phase out the freezer.

Quoted 6 lines

The kexec-based approach is an attempt to replace one coarse-grained solution
(the freezer) with even more coarse-grained solution (stopping the entire
kernel with everything), which IMO doesn't address the main problem.

I think this addresses teh problem. Its probably a bit harder than
powermac because we have to fully quiesce devices; we can't cheat by
leaving interrupts off. But once the drivers save the state of their
devices and stop their queues, it should be easy to audit the paths to powerdown devices and call the platform suspend and ram wakeup paths.

Going back to the requirements document that started this thread:

Message-ID: <[email protected]> On Sun Jul 15 05:27:03 2007, Rafael J. Wysocki wrote:

Quoted 8 lines
Quoted 1 line

(1) Filesystems mounted before the hibernation are untouchable

This is because some file systems do a fsck or other activity even when mounted read only. For the kexec case, however, this should be "file
systems mounted by the hibernated system must not be written". As has
been mentioned in the past, we should be able to use something like dm snapshot to allow fsck and the file system to see the cleaned copy while not actually writing the media.

We can't _require_ users to use the dm snapshot in order for the hibernation to work, sorry.

And by _reading_ from a filesystem you generally update metadata.

Quoted 14 lines

The kjump kernel must not have any knowledge retained if we reuse it.

Quoted 1 line

(2) Swap space in use before the hibernation must be handled with care

Yes. Actually, even though they have been used by the write-in-the kernel users, they will be among the most difficult devices to use for snapshots by a userspace second kernel.

Quoted 1 line

(3) There are memory regions that must not be saved or restored

because they may not exist. This means that we must identify the
memory to be saved and restored in a format to be passed between the kernel.

Quoted 5 lines
Quoted 1 line

(4) The user should be able to limit the size of a hibernation image

This means the suspending kernel must arrange to reduce its active memory. The limited save can be done by providing a limited list in (3).

It seems to me that you don't understand the problem here.

Assume you have 90% of RAM allocated before the hibernation and the user has requested the image to be not greater than 50% of RAM. In that case you have to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

Quoted 7 lines
Quoted 2 lines

(5) Hibernation should be transparent from the applications' point of view

People have pointed out they may want userspace to be aware of the
suspend. I believed this can be done with /proc/apm emulation today
or by other means; it seems that should be hooked up to dbus in some fashion.

Not a solution, because there still will be programs not needing to know anything about hibernation. After all, we don't require all applications to know anything about SMP, even if they are executed on an SMP system.

Quoted 10 lines
Quoted 2 lines

(6) State of devices from before hibernation should be restored, if possible

related to suspend should be transparent ... yes.

Quoted 4 lines

(7) On ACPI systems special platform-related actions have to be carried out at
the right points, so that the platform works correctly after the
restore

Quoted 6 lines

I believe I have explained my suggestion.

Quoted 1 line

(8) Hibernation and restore should not be too slow

We control the added code. We are using full runtime drivers and will
run at hardware speeds.

That may not be enough. If you're going to save, say, 80% of RAM on a 2 GB machine, then you'll have to be using image compression.

Quoted 53 lines
Quoted 1 line

(9) Hibernation framework should not be too difficult to set up

Ok the current patch is presently too difficult. But I think it will be much simpler with a few small changes.

As noted in the thread

Message-ID: <[email protected]>
Subject: [linux-pm] Re: hibernation/snapshot design

Quoted 4 lines · Jeremy Maitin-Shepard
Quoted 1 line

Both would work. One would eat 8-64MB of your RAM, permanently;

As I have stated in other messages, the kdump approach would not waste any RAM permanently.

...

Quoted 8 lines

Immediately before jumping to the new kernel, the first X bytes (where X
is the amount of memory the new kernel will get, typically 16MB or 64MB)
of physical memory are backed up into the arbitrary discontiguous pages that are made available. This will not take very long, because copying even 64MB of memory is extremely fast. Then the new kernel is free to use the first X bytes of contiguous physical memory. Problem solved.

Ok, now let's look at my list again:

Quoted 1 line

(1) how to interact with acpi to enter into S4.

This was discussed.

Quoted 1 line

(2) how to identify which memory needs to be saved

We need to generate a list. We need it to fit in a compuatable size so that we can free and allocate the pages before suspending IO in the first kernel.

One possibility is to use something like the kexec copy list. If we are imaging a small fraction of ram this is appropriate, but if we are doing dense saves we need something extent based. We should be able to extend the list.

Quoted 1 line

(3) how to communicate where to save the memory

This is an intresting topic. The suspended kernel has most IO and disk space. It also knows how much space is to be occupied by the kernel. So communicating a block map to the second kernel would be the obvious
choice. But the second kernel must be able to find the image to
restore it, and it must have drivers for the media. Also, this is not feasible for storing to nfs.

I think we will end up with several methods.

Quoted 8 lines

One would be supply a list of blocks, and implement a file system that reads the file by reading the scatter list from media. The restore kernel then only needs to read an anchor, and can build upon that until the image is read into memory. Or do this in userspace.

I don't know how this compares to the current restore path. I wasn't
able to identify the code that creates the on disk structure in my 10 minute perusal of kernel/power/.

The structure is created at two levels.

First, the code in snapshot.c makes the image available to the code in swap.c as a stream of pages. The first page is the header, followed by some pages containing the PFNs of the page frames to which the image data pages are to be restored, followed by the image data pages themselves (the ordering of the PFNs must be the same as the ordering of data pages that correspond to them). Still, the low-level image format only needs to be known by the restore code in snapshot.c .

Second, the code in swap.c writes the image pages to a storage adding some metadata making it possible to reproduce their original ordering during the restore.

The fact that we use swap spaces as the storage is related to implementation simplicity rather than anything else.

Quoted 13 lines

A second method will be to supply a device and file that will be mounted by the save kernel, then unmounted and restored. This would require a partition that is not mounted or open by the suspended kernel (or use nfs or a similar protocol that is designed for multiple client concurrent access).

A third method would be to allocate a file with the first kernel, and make sure the blocks are flushed to disk. The save and restore kernels map the file system using a snapshot device. Writing would map the blocks and use the block offset to write to the real device using the method from the first option; reading could be done directly from the snapshot device.

Quoted 2 lines

The first and third option are dead on log based file systems (where the data is stored in the log).

All in all, we have three different and working implementation of the image-writing and image-reading code at our disposal. Why would you want to break the open doors?

Quoted 3 lines
Quoted 1 line

(4) what state should devices be in when switching kernels

My proposal is either initialized and untouched or quiesced.

This is reasonable, but in general we also need to save some information about the pre-hibernation state of devices, so that we can put them into the same state, if reasonably possible, during the restore.

Quoted 11 lines
Quoted 1 line

(5) the complicated setup required with the current patch

I think a few simple changes to kjump will make this much simpler. See below.

Quoted 1 line

(6) what code restores the image

The save kernel, loaded at boot. People have suggested booting the
first kernel, and using current restore code. However, I think that
ignores that (1) we saved from a different kernel, so the backed up region will be restored to its backed up random pages,

This problem has already been solved.

Quoted 1 line

(2) the code was written to restore the same kernel,

Not exactly. In fact, the current implementation only relies on the tiny portion of the restore code being in the same place in both kernels, but we can change the code not to make this assumption (it'll be more complicated, but that's perfectly doable).

Quoted 2 lines

so the text and data will be replaced by identical text. Its much simpler conceptually to use the same kernel to save and restore the image.

Here I agree. :-)

Quoted 26 lines

Simplifying kjump: the proposal for v3.

The current code is trying to use crash dump area as a safe, reserved
area to run the second kernel. However, that means that the kernel
has to be linked specially to run in the reserved area. I think we
need to finish separating kexec_jump from the other code paths.

(1) add a new command line argument that specifies the kexec_jump target area.

(2) add a kjump flag to the flags parameter, used by kexec_load. When
loading a jump kernel, it is loaded like a normal kernel, however, additional control pages are allocated to (a) save the kexec_jump target area (b) save the backed up region that is used by all kernels like crash dump, and (c) space for invoking relocate_new_kernel that will get its args from the execution entry point and will restore the kernel then call resume and suspend.

(3) replace jump_huf_pfn with two command line addresses that specify the (a) return point for after resume, and (b) the return point for
after image save. Actually these can be done in userspace; the second
restore kernel can just specify the null copy list and the entry points supplied by the suspended kernel. To do resume we also need (c) where to store resume address for the save kernel.

Quoted 3 lines

As a first stage of suspend and resume, we can save to dedicated partitions all memory (as supplied to crash_dump) that is not marked nosave and not part of the save kernel's image.

A little problem here: there are "nosave" areas that are not marked as nosave.

Quoted 1 line

The fancy block lists and memory lists can be added later.

On the majority of systems that will work. On some of them it won't.

Quoted 11 lines

mmaking these changes will allow us to use a normal kernel invoked with acpi=off apm=off mem=xxk as the save and restore kernel.

If we want to keep the second kernel booted, then we need to add a save
area for the booted jump target. Note that the save and restore lists
to relocate_new_kernel can be computed once and saved. Longer term we
could implement sys_kexec_load(UNLOAD) that would retrieve the saved
list back to application space to save to disk in a file. This means
you could save the booted save kernel, it just couldn't have any shared storage open.

Quoted 2 lines

I'll try to expand on this in the jump v2 thread, but it may be 36+ hours before I do so.

Well, I have no experience with kexec, so I really can't comment your kexec-related suggestions.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#174 lore raw
Quoted 11 lines · Rafael J. Wysocki
Quoted 8 lines · Milton Miller

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

Quoted 26 lines
Quoted 17 lines
Quoted 8 lines

(2) Upon start-up (by which I mean what happens after the user has pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI
(we don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Quoted 8 lines

Here I agree.

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image.
After that its done. The platform can be powered off if we are going
to S5. However, to support suspend to ram and suspend to disk, we
return to the first kernel.

Quoted 4 lines

We can't do this unless we have frozen tasks (this way, or another) before carrying out the entire operation. In that case, however, the kexec-based approach would have only one advantage over the current one. Namely, it would allow us to create bigger images.

we all agree that tasks cannot run during the suspend-to-ram state, but the disagreement is over what this means

at one extreme it could mean that you would need the full freezer as per the current suspend projects.

at the other extreme it could mean that all that's needed is to invoke the suspend-to-ram routine before anything else on the suspended kernel on the return from the save and restore kernel.

we just need to figure out which it is (or if it's somewhere in between).

Quoted 41 lines
Quoted 32 lines
Quoted 14 lines

It's selectively stopping kernel threads, which is just about right. If you
that _this_ is a main problem with the freezer, then think again.

Quoted 3 lines

with kexec you don't need to let any portion of the origional kernel or
userspace operate so you don't have a problem.

In fact, the main problem with the freezer is that it is a coarse-grained
solution. Therefore, what I believe we should do is to evolve in the directoin
of more fine-grained solutions and gradually phase out the freezer.

Quoted 6 lines

The kexec-based approach is an attempt to replace one coarse-grained solution
(the freezer) with even more coarse-grained solution (stopping the entire
kernel with everything), which IMO doesn't address the main problem.

I think this addresses teh problem. Its probably a bit harder than
powermac because we have to fully quiesce devices; we can't cheat by
leaving interrupts off. But once the drivers save the state of their
devices and stop their queues, it should be easy to audit the paths to powerdown devices and call the platform suspend and ram wakeup paths.

Going back to the requirements document that started this thread:

Message-ID: <[email protected]> On Sun Jul 15 05:27:03 2007, Rafael J. Wysocki wrote:

Quoted 8 lines
Quoted 1 line

(1) Filesystems mounted before the hibernation are untouchable

This is because some file systems do a fsck or other activity even when mounted read only. For the kexec case, however, this should be "file
systems mounted by the hibernated system must not be written". As has
been mentioned in the past, we should be able to use something like dm snapshot to allow fsck and the file system to see the cleaned copy while not actually writing the media.

Quoted 4 lines

We can't _require_ users to use the dm snapshot in order for the hibernation to work, sorry.

And by _reading_ from a filesystem you generally update metadata.

not if the filesystem is mounted read-only (except on ext3)

Quoted 20 lines
Quoted 14 lines

The kjump kernel must not have any knowledge retained if we reuse it.

Quoted 1 line

(2) Swap space in use before the hibernation must be handled with care

Yes. Actually, even though they have been used by the write-in-the kernel users, they will be among the most difficult devices to use for snapshots by a userspace second kernel.

Quoted 1 line

(3) There are memory regions that must not be saved or restored

because they may not exist. This means that we must identify the
memory to be saved and restored in a format to be passed between the kernel.

Quoted 5 lines
Quoted 1 line

(4) The user should be able to limit the size of a hibernation image

This means the suspending kernel must arrange to reduce its active memory. The limited save can be done by providing a limited list in (3).

Quoted 6 lines

It seems to me that you don't understand the problem here.

Assume you have 90% of RAM allocated before the hibernation and the user has requested the image to be not greater than 50% of RAM. In that case you have to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Quoted 12 lines
Quoted 12 lines
Quoted 2 lines

(6) State of devices from before hibernation should be restored, if possible

related to suspend should be transparent ... yes.

Quoted 4 lines

(7) On ACPI systems special platform-related actions have to be carried out at
the right points, so that the platform works correctly after the
restore

I believe I have explained my suggestion.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

(8) Hibernation and restore should not be too slow

We control the added code. We are using full runtime drivers and will
run at hardware speeds.

That may not be enough. If you're going to save, say, 80% of RAM on a 2 GB machine, then you'll have to be using image compression.

this doesn't make sense, 20% of 2G is 400M, if you can't make a kernel and userspace that can run in 400M you have a serious problem.

even if you wanted to save 99% of RAM on a 2G system, you have 20M of ram to play with, which should easily be enough.

remember, linux runs on really small systems as well, and while you do have to load some drivers for the big system, there are a lot of other things that aren't needed.

Quoted 3 lines

All in all, we have three different and working implementation of the image-writing and image-reading code at our disposal. Why would you want to break the open doors?

becouse you say that the current methods won't work without ACPI support.

David Lang

#175 lore raw
Quoted 12 lines · On Friday, 20 July 2007 01:07, [email protected] wrote:
Quoted 10 lines · Rafael J. Wysocki
Quoted 8 lines · Milton Miller

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

Quoted 6 lines
Quoted 1 line

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

That's correct. And since you cannot thouch ext3, you need either to assume that you won't touch filesystems at all, or to have a code to recognize the filesystem you're dealing with.

Quoted 34 lines
Quoted 26 lines
Quoted 17 lines
Quoted 8 lines

(2) Upon start-up (by which I mean what happens after the user has pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI
(we don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Quoted 8 lines

Here I agree.

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image.
After that its done. The platform can be powered off if we are going
to S5. However, to support suspend to ram and suspend to disk, we
return to the first kernel.

Quoted 4 lines

We can't do this unless we have frozen tasks (this way, or another) before carrying out the entire operation. In that case, however, the kexec-based approach would have only one advantage over the current one. Namely, it would allow us to create bigger images.

we all agree that tasks cannot run during the suspend-to-ram state, but the disagreement is over what this means

Quoted 8 lines

at one extreme it could mean that you would need the full freezer as per the current suspend projects.

at the other extreme it could mean that all that's needed is to invoke the suspend-to-ram routine before anything else on the suspended kernel on the return from the save and restore kernel.

we just need to figure out which it is (or if it's somewhere in between).

Well, I think that the "invoke the suspend-to-ram routine before anything else on the suspended kernel" thing won't be easy to implement in practice.

Quoted 41 lines
Quoted 41 lines
Quoted 40 lines
Quoted 14 lines

It's selectively stopping kernel threads, which is just about right. If you
that _this_ is a main problem with the freezer, then think again.

Quoted 3 lines

with kexec you don't need to let any portion of the origional kernel or
userspace operate so you don't have a problem.

In fact, the main problem with the freezer is that it is a coarse-grained
solution. Therefore, what I believe we should do is to evolve in the directoin
of more fine-grained solutions and gradually phase out the freezer.

Quoted 6 lines

The kexec-based approach is an attempt to replace one coarse-grained solution
(the freezer) with even more coarse-grained solution (stopping the entire
kernel with everything), which IMO doesn't address the main problem.

I think this addresses teh problem. Its probably a bit harder than
powermac because we have to fully quiesce devices; we can't cheat by
leaving interrupts off. But once the drivers save the state of their
devices and stop their queues, it should be easy to audit the paths to powerdown devices and call the platform suspend and ram wakeup paths.

Going back to the requirements document that started this thread:

Message-ID: <[email protected]>

Quoted 1 line · Rafael J. Wysocki

(1) Filesystems mounted before the hibernation are untouchable

This is because some file systems do a fsck or other activity even when mounted read only. For the kexec case, however, this should be "file
systems mounted by the hibernated system must not be written". As has
been mentioned in the past, we should be able to use something like dm snapshot to allow fsck and the file system to see the cleaned copy while not actually writing the media.

Quoted 6 lines
Quoted 4 lines

We can't _require_ users to use the dm snapshot in order for the hibernation to work, sorry.

And by _reading_ from a filesystem you generally update metadata.

not if the filesystem is mounted read-only (except on ext3)

Well, if the filesystem in question is a journaling one and the hibernated kernel has mounted this fs read-write, this seems to be tricky anyway.

Quoted 39 lines
Quoted 20 lines
Quoted 14 lines

The kjump kernel must not have any knowledge retained if we reuse it.

Quoted 1 line

(2) Swap space in use before the hibernation must be handled with care

Yes. Actually, even though they have been used by the write-in-the kernel users, they will be among the most difficult devices to use for snapshots by a userspace second kernel.

Quoted 1 line

(3) There are memory regions that must not be saved or restored

because they may not exist. This means that we must identify the
memory to be saved and restored in a format to be passed between the kernel.

Quoted 5 lines
Quoted 1 line

(4) The user should be able to limit the size of a hibernation image

This means the suspending kernel must arrange to reduce its active memory. The limited save can be done by providing a limited list in (3).

Quoted 6 lines

It seems to me that you don't understand the problem here.

Assume you have 90% of RAM allocated before the hibernation and the user has requested the image to be not greater than 50% of RAM. In that case you have to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

Quoted 8 lines

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

This means unreliable hibernation for some workloads. While I agree that shouldn't be a problem in a common case, there are users who will complain. ;-)

Quoted 4 lines

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Well, with the freezer that's much simpler (and more reliable, I'd say): you freeze tasks and _then_ you shrink memory.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines

(6) State of devices from before hibernation should be restored, if possible

related to suspend should be transparent ... yes.

Quoted 4 lines

(7) On ACPI systems special platform-related actions have to be carried out at
the right points, so that the platform works correctly after the
restore

I believe I have explained my suggestion.

Quoted 1 line

(8) Hibernation and restore should not be too slow

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

We control the added code. We are using full runtime drivers and will
run at hardware speeds.

That may not be enough. If you're going to save, say, 80% of RAM on a 2 GB machine, then you'll have to be using image compression.

this doesn't make sense, 20% of 2G is 400M, if you can't make a kernel and userspace that can run in 400M you have a serious problem.

I was talking about the _speed_ of writing and reading.

Quoted 7 lines

even if you wanted to save 99% of RAM on a 2G system, you have 20M of ram to play with, which should easily be enough.

remember, linux runs on really small systems as well, and while you do have to load some drivers for the big system, there are a lot of other things that aren't needed.

Quoted 5 lines
Quoted 3 lines

All in all, we have three different and working implementation of the image-writing and image-reading code at our disposal. Why would you want to break the open doors?

becouse you say that the current methods won't work without ACPI support.

I didn't say that. [Or if I did, please point me to this message.]

Anyway, this wouldn't be true even if I did.

What I've been trying to say from the very beginning is that the current frameworks _support_ hibernation a la ACPI S4 (although that's not exactly ACPI S4) and if we are going to introduce a new framework, then it should be designed to _support_ ACPI S4 fully _from_ _the_ _start_.

This DOESN'T mean that the non-ACPI hibernation should be unsupported and it DOESN"T mean that the non-ACPI hibernation is not supported currently. IT IS SUPPORTED.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#176 lore raw
Quoted 15 lines · Rafael J. Wysocki
Quoted 14 lines · On Friday, 20 July 2007 01:07, [email protected] wrote:
Quoted 11 lines · Rafael J. Wysocki
Quoted 8 lines · Milton Miller

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

Quoted 8 lines
Quoted 4 lines

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

That's correct. And since you cannot thouch ext3, you need either to assume that you won't touch filesystems at all, or to have a code to recognize the filesystem you're dealing with.

filesystem detection routines are already available

however, I'm the type to say that in a case like this where it matters you should explicitly give the filesystem type anyway.

or the userspace helper functions that setup the instructions for the hibernate warn you if you are telling it to mount a filesystem that it knows is ext3 and is in use by the system going to sleep.

in any case there needs to be a big warning about this issue, but that's different from saying "can't touch any filesystem that was mounted"

Quoted 7 lines
Quoted 4 lines

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Well, with the freezer that's much simpler (and more reliable, I'd say): you freeze tasks and _then_ you shrink memory.

this only works if you don't need tasks to do anything to free the memory.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 2 lines

(6) State of devices from before hibernation should be restored, if possible

related to suspend should be transparent ... yes.

Quoted 4 lines

(7) On ACPI systems special platform-related actions have to be carried out at
the right points, so that the platform works correctly after the
restore

I believe I have explained my suggestion.

Quoted 1 line

(8) Hibernation and restore should not be too slow

We control the added code. We are using full runtime drivers and will
run at hardware speeds.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

That may not be enough. If you're going to save, say, 80% of RAM on a 2 GB machine, then you'll have to be using image compression.

this doesn't make sense, 20% of 2G is 400M, if you can't make a kernel and userspace that can run in 400M you have a serious problem.

I was talking about the _speed_ of writing and reading.

if you are just talking about the I/O time for writing 2G of data, I wouldn't worry about it. suspend isn't supposed to change the capabilities of the system. if it takes a long time to do the I/O then that's how long it takes.

being able to do compression or send the data elsewhere is a good thing, but that's not something that is required to be supported in order to meet some performance goal or consider the approach a failure.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

All in all, we have three different and working implementation of the image-writing and image-reading code at our disposal. Why would you want to break the open doors?

becouse you say that the current methods won't work without ACPI support.

I didn't say that. [Or if I did, please point me to this message.]

I may have misunderstood you (I have deleted 90% of the messages in this thread so I won't try to go back and find where I thought you said this)

Quoted 6 lines

Anyway, this wouldn't be true even if I did.

What I've been trying to say from the very beginning is that the current frameworks _support_ hibernation a la ACPI S4 (although that's not exactly ACPI S4) and if we are going to introduce a new framework, then it should be designed to _support_ ACPI S4 fully _from_ _the_ _start_.

here is where there is some disagreement (although it may just be misunderstanding on the 'fully support' phrase)

it sounds like you are saying that the ACPI support requires a lot of work (the phrase I've seen some people use is a requirement to 'fix all the drivers'). we aren't wanting to have this work prevent the non-ACPI hibernation from progressing.

this isn't that we don't want the ACPI support eventually, it's in the spirit of 'perfection is the enemy of good enough'

David Lang

Quoted 3 lines

This DOESN'T mean that the non-ACPI hibernation should be unsupported and it DOESN"T mean that the non-ACPI hibernation is not supported currently. IT IS SUPPORTED.

#177 lore raw
Quoted 3 lines · On Fri, 20 Jul 2007 [email protected] wrote:

or the userspace helper functions that setup the instructions for the hibernate warn you if you are telling it to mount a filesystem that it knows is ext3 and is in use by the system going to sleep.

One can argue that the ext3 implementation is inadequate. We should be able to give it a mount option requiring it to fail rather than play back the journal and write to the disk.

Quoted 5 lines
Quoted 4 lines

What I've been trying to say from the very beginning is that the current frameworks _support_ hibernation a la ACPI S4 (although that's not exactly ACPI S4) and if we are going to introduce a new framework, then it should be designed to _support_ ACPI S4 fully _from_ _the_ _start_.

Quoted 7 lines

here is where there is some disagreement (although it may just be misunderstanding on the 'fully support' phrase)

it sounds like you are saying that the ACPI support requires a lot of work (the phrase I've seen some people use is a requirement to 'fix all the drivers'). we aren't wanting to have this work prevent the non-ACPI hibernation from progressing.

You have completely misunderstood. That phrase "fix all the drivers" has nothing whatsoever to do with ACPI. It is a prerequisite for removing the freezer.

And unless I'm mistaken, removing the freezer was the main reason for doing all this kexec-style work in the first place.

Alan Stern

#178 lore raw
Quoted 19 lines · Alan Stern
Quoted 3 lines · On Fri, 20 Jul 2007 [email protected] wrote:

or the userspace helper functions that setup the instructions for the hibernate warn you if you are telling it to mount a filesystem that it knows is ext3 and is in use by the system going to sleep.

One can argue that the ext3 implementation is inadequate. We should be able to give it a mount option requiring it to fail rather than play back the journal and write to the disk.

Quoted 8 lines
Quoted 4 lines

What I've been trying to say from the very beginning is that the current frameworks _support_ hibernation a la ACPI S4 (although that's not exactly ACPI S4) and if we are going to introduce a new framework, then it should be designed to _support_ ACPI S4 fully _from_ _the_ _start_.

here is where there is some disagreement (although it may just be misunderstanding on the 'fully support' phrase)

Quoted 8 lines
Quoted 4 lines

it sounds like you are saying that the ACPI support requires a lot of work (the phrase I've seen some people use is a requirement to 'fix all the drivers'). we aren't wanting to have this work prevent the non-ACPI hibernation from progressing.

You have completely misunderstood. That phrase "fix all the drivers" has nothing whatsoever to do with ACPI. It is a prerequisite for removing the freezer.

Yes.

Quoted 2 lines

And unless I'm mistaken, removing the freezer was the main reason for doing all this kexec-style work in the first place.

Yes, that also is my impression.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#179 lore raw
In reply to Rafael J. Wysocki
Quoted 13 lines · Rafael J. Wysocki
Quoted 12 lines · On Friday, 20 July 2007 01:07, [email protected] wrote:
Quoted 10 lines · Rafael J. Wysocki
Quoted 7 lines · Milton Miller

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

Quoted 8 lines
Quoted 4 lines

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

That's correct. And since you cannot thouch ext3, you need either to assume that you won't touch filesystems at all, or to have a code to recognize the filesystem you're dealing with.

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

The hibernate may fail, but you don't corrupt the media.

If you don't get the image out, resume back to the "this is resume" instead of the power-down path.

Quoted 38 lines
Quoted 38 lines
Quoted 27 lines
Quoted 18 lines
Quoted 9 lines

(2) Upon start-up (by which I mean what happens after the user has pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling
ACPI
(we don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Quoted 8 lines

Here I agree.

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image.
After that its done. The platform can be powered off if we are going
to S5. However, to support suspend to ram and suspend to disk, we
return to the first kernel.

Quoted 4 lines

We can't do this unless we have frozen tasks (this way, or another) before carrying out the entire operation. In that case, however, the kexec-based approach would have only one advantage over the current one. Namely, it would allow us to create bigger images.

we all agree that tasks cannot run during the suspend-to-ram state, but the disagreement is over what this means

at one extreme it could mean that you would need the full freezer as per the current suspend projects.

Quoted 8 lines
Quoted 5 lines

at the other extreme it could mean that all that's needed is to invoke the suspend-to-ram routine before anything else on the suspended kernel on the return from the save and restore kernel.

we just need to figure out which it is (or if it's somewhere in between).

Well, I think that the "invoke the suspend-to-ram routine before anything else on the suspended kernel" thing won't be easy to implement in practice.

Why? You don't expect suspend-to-ram in drivers to be implemented? We need more speperation of the quiesce drivers from power-down devices?

Note that we are just talking about "suspend devices and put their state in ram", not actually invoking the platform to suspend to ram.

And I'm actually saying we free memory and maybe allocate disk blocks for the save before we suspend (see below).

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

Message-ID: <[email protected]>

Quoted 1 line · Rafael J. Wysocki

(1) Filesystems mounted before the hibernation are untouchable

This is because some file systems do a fsck or other activity even when mounted read only. For the kexec case, however, this should be "file
systems mounted by the hibernated system must not be written". As has
been mentioned in the past, we should be able to use something like dm snapshot to allow fsck and the file system to see the cleaned copy while not actually writing the media.

We can't _require_ users to use the dm snapshot in order for the hibernation to work, sorry.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

And by _reading_ from a filesystem you generally update metadata.

not if the filesystem is mounted read-only (except on ext3)

Well, if the filesystem in question is a journaling one and the hibernated kernel has mounted this fs read-write, this seems to be tricky anyway.

Yes. I would argue writing to existing blocks of a file (not thorugh the filesystem, just getting their blocsk from the file system) should be safe, but it occurs to me that may not be the case if your fsck and bmap move data blocks from some update log to the file system.

But we know the (maximum) image size. So we could allocate the blocks in the first image before suspending the drivers and memory allocations, and supplying the list to the second kernel. We could even write to the first block with a signature "suspend to here", or even the whole block list to the beginning (it will have to be saved to disk for restore anyways).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

The kjump kernel must not have any knowledge retained if we reuse it.

Quoted 1 line

(2) Swap space in use before the hibernation must be handled with care

Yes. Actually, even though they have been used by the write-in-the kernel users, they will be among the most difficult devices to use for snapshots by a userspace second kernel.

If we use the "write to these blocks" then this is as easy as writing to a file in a mounted filesystem.

Quoted 31 lines
Quoted 31 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

(4) The user should be able to limit the size of a hibernation image

This means the suspending kernel must arrange to reduce its active memory. The limited save can be done by providing a limited list in (3).

Quoted 6 lines

It seems to me that you don't understand the problem here.

Assume you have 90% of RAM allocated before the hibernation and the user has requested the image to be not greater than 50% of RAM. In that case you have to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

Quoted 5 lines
Quoted 2 lines

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

This means unreliable hibernation for some workloads. While I agree that shouldn't be a problem in a common case, there are users who will complain. ;-)

With my allocate memory as a task and don't save that task's memory approach, we can get to this point while userspace is running. It could be controllled by userspace, or even be userspace (sys_do_not_save_me() waits for resume, and dies as the kernel resumes).

Quoted 7 lines
Quoted 4 lines

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Well, with the freezer that's much simpler (and more reliable, I'd say): you freeze tasks and _then_ you shrink memory.

It means you are committed to suspend before you try to shrink memory. What happens when the user requested a smaller image that memory in use?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

=(8) Hibernation and restore should not be too slow

We control the added code. We are using full runtime drivers and will
run at hardware speeds.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

That may not be enough. If you're going to save, say, 80% of RAM on a 2 GB machine, then you'll have to be using image compression.

this doesn't make sense, 20% of 2G is 400M, if you can't make a kernel and userspace that can run in 400M you have a serious problem.

I was talking about the _speed_ of writing and reading.

Yes. As I said, adding a compress as we copy the pages into the saving kernel for writeout should be easy.

Quoted 17 lines
Quoted 7 lines

even if you wanted to save 99% of RAM on a 2G system, you have 20M of ram to play with, which should easily be enough.

remember, linux runs on really small systems as well, and while you do have to load some drivers for the big system, there are a lot of other things that aren't needed.

Quoted 5 lines
Quoted 3 lines

All in all, we have three different and working implementation of the image-writing and image-reading code at our disposal. Why would you want to break the open doors?

becouse you say that the current methods won't work without ACPI support.

I didn't say that. [Or if I did, please point me to this message.]

Anyway, this wouldn't be true even if I did.

Quoted 9 lines

What I've been trying to say from the very beginning is that the current frameworks _support_ hibernation a la ACPI S4 (although that's not exactly ACPI S4) and if we are going to introduce a new framework, then it should be designed to _support_ ACPI S4 fully _from_ _the_ _start_.

This DOESN'T mean that the non-ACPI hibernation should be unsupported and it DOESN"T mean that the non-ACPI hibernation is not supported currently. IT IS SUPPORTED.

As I said, I see kjump as a way to solve the "ok i am at a save point, now how do I write this image to media without allowing any other io". As you know by now, my solution for ACPI support is after the image is written we go back to the kernel that started the suspend and it puts the machine in S4.

If this works, we get down to 1 hibernate implementation in the kernel :-).

milton

#180 lore raw
In reply to Rafael J. Wysocki
Quoted 13 lines · Rafael J. Wysocki
Quoted 12 lines · On Friday, 20 July 2007 01:07, [email protected] wrote:
Quoted 10 lines · Rafael J. Wysocki
Quoted 7 lines · Milton Miller

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

Quoted 8 lines
Quoted 4 lines

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

That's correct. And since you cannot thouch ext3, you need either to assume that you won't touch filesystems at all, or to have a code to recognize the filesystem you're dealing with.

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

The hibernate may fail, but you don't corrupt the media.

If you don't get the image out, resume back to the "this is resume" instead of the power-down path.

Quoted 38 lines
Quoted 38 lines
Quoted 27 lines
Quoted 18 lines
Quoted 9 lines

(2) Upon start-up (by which I mean what happens after the user has pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling
ACPI
(we don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Quoted 8 lines

Here I agree.

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image.
After that its done. The platform can be powered off if we are going
to S5. However, to support suspend to ram and suspend to disk, we
return to the first kernel.

Quoted 4 lines

We can't do this unless we have frozen tasks (this way, or another) before carrying out the entire operation. In that case, however, the kexec-based approach would have only one advantage over the current one. Namely, it would allow us to create bigger images.

we all agree that tasks cannot run during the suspend-to-ram state, but the disagreement is over what this means

at one extreme it could mean that you would need the full freezer as per the current suspend projects.

Quoted 8 lines
Quoted 5 lines

at the other extreme it could mean that all that's needed is to invoke the suspend-to-ram routine before anything else on the suspended kernel on the return from the save and restore kernel.

we just need to figure out which it is (or if it's somewhere in between).

Well, I think that the "invoke the suspend-to-ram routine before anything else on the suspended kernel" thing won't be easy to implement in practice.

Why? You don't expect suspend-to-ram in drivers to be implemented? We need more speperation of the quiesce drivers from power-down devices?

Note that we are just talking about "suspend devices and put their state in ram", not actually invoking the platform to suspend to ram.

And I'm actually saying we free memory and maybe allocate disk blocks for the save before we suspend (see below).

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

Message-ID: <[email protected]>

Quoted 1 line · Rafael J. Wysocki

(1) Filesystems mounted before the hibernation are untouchable

This is because some file systems do a fsck or other activity even when mounted read only. For the kexec case, however, this should be "file
systems mounted by the hibernated system must not be written". As has
been mentioned in the past, we should be able to use something like dm snapshot to allow fsck and the file system to see the cleaned copy while not actually writing the media.

We can't _require_ users to use the dm snapshot in order for the hibernation to work, sorry.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

And by _reading_ from a filesystem you generally update metadata.

not if the filesystem is mounted read-only (except on ext3)

Well, if the filesystem in question is a journaling one and the hibernated kernel has mounted this fs read-write, this seems to be tricky anyway.

Yes. I would argue writing to existing blocks of a file (not thorugh the filesystem, just getting their blocsk from the file system) should be safe, but it occurs to me that may not be the case if your fsck and bmap move data blocks from some update log to the file system.

But we know the (maximum) image size. So we could allocate the blocks in the first image before suspending the drivers and memory allocations, and supplying the list to the second kernel. We could even write to the first block with a signature "suspend to here", or even the whole block list to the beginning (it will have to be saved to disk for restore anyways).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

The kjump kernel must not have any knowledge retained if we reuse it.

Quoted 1 line

(2) Swap space in use before the hibernation must be handled with care

Yes. Actually, even though they have been used by the write-in-the kernel users, they will be among the most difficult devices to use for snapshots by a userspace second kernel.

If we use the "write to these blocks" then this is as easy as writing to a file in a mounted filesystem.

Quoted 31 lines
Quoted 31 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

(4) The user should be able to limit the size of a hibernation image

This means the suspending kernel must arrange to reduce its active memory. The limited save can be done by providing a limited list in (3).

Quoted 6 lines

It seems to me that you don't understand the problem here.

Assume you have 90% of RAM allocated before the hibernation and the user has requested the image to be not greater than 50% of RAM. In that case you have to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

Quoted 5 lines
Quoted 2 lines

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

This means unreliable hibernation for some workloads. While I agree that shouldn't be a problem in a common case, there are users who will complain. ;-)

With my allocate memory as a task and don't save that task's memory approach, we can get to this point while userspace is running. It could be controllled by userspace, or even be userspace (sys_do_not_save_me() waits for resume, and dies as the kernel resumes).

Quoted 7 lines
Quoted 4 lines

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Well, with the freezer that's much simpler (and more reliable, I'd say): you freeze tasks and _then_ you shrink memory.

It means you are committed to suspend before you try to shrink memory. What happens when the user requested a smaller image that memory in use?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

=(8) Hibernation and restore should not be too slow

We control the added code. We are using full runtime drivers and will
run at hardware speeds.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

That may not be enough. If you're going to save, say, 80% of RAM on a 2 GB machine, then you'll have to be using image compression.

this doesn't make sense, 20% of 2G is 400M, if you can't make a kernel and userspace that can run in 400M you have a serious problem.

I was talking about the _speed_ of writing and reading.

Yes. As I said, adding a compress as we copy the pages into the saving kernel for writeout should be easy.

Quoted 17 lines
Quoted 7 lines

even if you wanted to save 99% of RAM on a 2G system, you have 20M of ram to play with, which should easily be enough.

remember, linux runs on really small systems as well, and while you do have to load some drivers for the big system, there are a lot of other things that aren't needed.

Quoted 5 lines
Quoted 3 lines

All in all, we have three different and working implementation of the image-writing and image-reading code at our disposal. Why would you want to break the open doors?

becouse you say that the current methods won't work without ACPI support.

I didn't say that. [Or if I did, please point me to this message.]

Anyway, this wouldn't be true even if I did.

Quoted 9 lines

What I've been trying to say from the very beginning is that the current frameworks _support_ hibernation a la ACPI S4 (although that's not exactly ACPI S4) and if we are going to introduce a new framework, then it should be designed to _support_ ACPI S4 fully _from_ _the_ _start_.

This DOESN'T mean that the non-ACPI hibernation should be unsupported and it DOESN"T mean that the non-ACPI hibernation is not supported currently. IT IS SUPPORTED.

As I said, I see kjump as a way to solve the "ok i am at a save point, now how do I write this image to media without allowing any other io". As you know by now, my solution for ACPI support is after the image is written we go back to the kernel that started the suspend and it puts the machine in S4.

If this works, we get down to 1 hibernate implementation in the kernel :-).

milton

#181 lore raw

Milton Miller <[email protected]> writes:

[snip]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

Quoted 7 lines
Quoted 3 lines

That's correct. And since you cannot thouch ext3, you need either to assume that you won't touch filesystems at all, or to have a code to recognize the filesystem you're dealing with.

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

I still don't understand why there is this fixation on accessing dirty filesystems in use by the hibernated system. Even if you avoid corrupting the filesystem by avoiding writing to the block device, there isn't any real guarantee about the state of the data, except for a filesystem that specifically makes guarantees about such data (and I don't believe any of the existing ones do).

It isn't necessary to be able to access such filesystems: everything can be done from an initramfs/initrd.

[snip]

Signature · 1 line
Jeremy Maitin-Shepard
#182 lore raw
Quoted 26 lines · Jeremy Maitin-Shepard

Milton Miller <[email protected]> writes:

[snip]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

Quoted 7 lines
Quoted 3 lines

That's correct. And since you cannot thouch ext3, you need either to assume that you won't touch filesystems at all, or to have a code to recognize the filesystem you're dealing with.

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

I still don't understand why there is this fixation on accessing dirty filesystems in use by the hibernated system. Even if you avoid corrupting the filesystem by avoiding writing to the block device, there isn't any real guarantee about the state of the data, except for a filesystem that specifically makes guarantees about such data (and I don't believe any of the existing ones do).

Quoted 2 lines

It isn't necessary to be able to access such filesystems: everything can be done from an initramfs/initrd.

That's correct, but you need an additional ramdisk for that (yet another complication).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#183 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 26 lines · Jeremy Maitin-Shepard

Milton Miller <[email protected]> writes:

[snip]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

Quoted 7 lines
Quoted 3 lines

That's correct. And since you cannot thouch ext3, you need either to assume that you won't touch filesystems at all, or to have a code to recognize the filesystem you're dealing with.

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

I still don't understand why there is this fixation on accessing dirty filesystems in use by the hibernated system. Even if you avoid corrupting the filesystem by avoiding writing to the block device, there isn't any real guarantee about the state of the data, except for a filesystem that specifically makes guarantees about such data (and I don't believe any of the existing ones do).

Quoted 2 lines

It isn't necessary to be able to access such filesystems: everything can be done from an initramfs/initrd.

That's correct, but you need an additional ramdisk for that (yet another complication).

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#184 lore raw
In reply to Milton Miller
Quoted 20 lines · Milton Miller
Quoted 19 lines · Rafael J. Wysocki
Quoted 17 lines · On Friday, 20 July 2007 01:07, [email protected] wrote:
Quoted 11 lines · Rafael J. Wysocki
Quoted 7 lines · Milton Miller

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

I didn't realize this was a discussion item. I thought the options were clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

Quoted 7 lines
Quoted 5 lines

That's correct. And since you cannot thouch ext3, you need either to assume
that you won't touch filesystems at all, or to have a code to recognize the
filesystem you're dealing with.

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

the problem is that the filesystem code will replay the journal when you mount the partition, even if you mount it read-only (I seem to remember that you could avoid this if you put the entire block device into read-only mode, but that doesn't help in this case)

Quoted 55 lines

The hibernate may fail, but you don't corrupt the media.

If you don't get the image out, resume back to the "this is resume" instead of the power-down path.

Quoted 51 lines
Quoted 50 lines
Quoted 28 lines
Quoted 20 lines
Quoted 9 lines

(2) Upon start-up (by which I mean what happens after the user has pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling
ACPI
(we don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Here I agree.

Quoted 7 lines

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image.
After that its done. The platform can be powered off if we are
going
to S5. However, to support suspend to ram and suspend to disk, we
return to the first kernel.

Quoted 7 lines

We can't do this unless we have frozen tasks (this way, or another) before
carrying out the entire operation. In that case, however, the kexec-based
approach would have only one advantage over the current one. Namely, it
would allow us to create bigger images.

we all agree that tasks cannot run during the suspend-to-ram state, but the disagreement is over what this means

at one extreme it could mean that you would need the full freezer as per the current suspend projects.

at the other extreme it could mean that all that's needed is to invoke the
suspend-to-ram routine before anything else on the suspended kernel on the
return from the save and restore kernel.

we just need to figure out which it is (or if it's somewhere in between).

Quoted 7 lines
Quoted 3 lines

Well, I think that the "invoke the suspend-to-ram routine before anything else
on the suspended kernel" thing won't be easy to implement in practice.

Why? You don't expect suspend-to-ram in drivers to be implemented? We need more speperation of the quiesce drivers from power-down devices?

Note that we are just talking about "suspend devices and put their state in ram", not actually invoking the platform to suspend to ram.

I thought we were talking about actually invoking the suspend-to-ram

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 4 lines

Message-ID: <[email protected]>

Quoted 1 line · Rafael J. Wysocki

(1) Filesystems mounted before the hibernation are untouchable

Quoted 10 lines

This is because some file systems do a fsck or other activity even when
mounted read only. For the kexec case, however, this should be "file
systems mounted by the hibernated system must not be written". As
has
been mentioned in the past, we should be able to use something like dm
snapshot to allow fsck and the file system to see the cleaned copy while not actually writing the media.

We can't _require_ users to use the dm snapshot in order for the hibernation
to work, sorry.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

And by _reading_ from a filesystem you generally update metadata.

not if the filesystem is mounted read-only (except on ext3)

Well, if the filesystem in question is a journaling one and the hibernated kernel has mounted this fs read-write, this seems to be tricky anyway.

Yes. I would argue writing to existing blocks of a file (not thorugh the filesystem, just getting their blocsk from the file system) should be safe, but it occurs to me that may not be the case if your fsck and bmap move data blocks from some update log to the file system.

right, and the answer is that the filesystem blocks allocated for the suspend image are not allowed to be accessed in any way from the main system.

this is a good argument for saving the data somewhere else ;-)

Quoted 1 line

But we know the (maximum) image size. So we could allocate the blocks in the first image before suspending the drivers and memory allocations, and supplying the list to the second kernel. We could even write to the first block with a signature "suspend to here", or even the whole block list to the beginning (it will have to be saved to disk for restore anyways).

no, you want to make the blocks that are allocated for the suspend image be like the blocks allocated to the journal, alloate them once and never touch them again

you especially do not want to try and write something to them from the main system just before suspending, you don't know enough about what it takes to get the data to the media to be absolutly sure that it's there when the save-and-restore kernel goes to look.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

The kjump kernel must not have any knowledge retained if we reuse it.

Quoted 2 lines

(2) Swap space in use before the hibernation must be handled with care

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Yes. Actually, even though they have been used by the write-in-the kernel users, they will be among the most difficult devices to use for
snapshots by a userspace second kernel.

If we use the "write to these blocks" then this is as easy as writing to a file in a mounted filesystem.

and keep in mind that "write to these blocks" can be done in userspace, it doesn't require the kernel to do this.

David Lang

#185 lore raw
In reply to Milton Miller
Quoted 27 lines · Milton Miller
Quoted 20 lines · Rafael J. Wysocki
Quoted 10 lines · On Friday, 20 July 2007 01:07, [email protected] wrote:
Quoted 9 lines · Rafael J. Wysocki
Quoted 7 lines · Milton Miller

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

Quoted 8 lines
Quoted 2 lines

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

I didn't realize this was a discussion item. I thought the options were
clear, for some filesystem types you can mount them read-only, but for ext3 (and possilby other less common ones) you just plain cannot touch them.

Quoted 5 lines

That's correct. And since you cannot thouch ext3, you need either to assume
that you won't touch filesystems at all, or to have a code to recognize the
filesystem you're dealing with.

Quoted 8 lines

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

The hibernate may fail, but you don't corrupt the media.

If you don't get the image out, resume back to the "this is resume" instead of the power-down path.

Well, I don't think that is much prettier than the freezer ...

Quoted 53 lines
Quoted 53 lines
Quoted 52 lines
Quoted 28 lines
Quoted 20 lines
Quoted 9 lines

(2) Upon start-up (by which I mean what happens after the user has pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling
ACPI
(we don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Here I agree.

Quoted 7 lines

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image.
After that its done. The platform can be powered off if we are
going
to S5. However, to support suspend to ram and suspend to disk, we
return to the first kernel.

Quoted 7 lines

We can't do this unless we have frozen tasks (this way, or another) before
carrying out the entire operation. In that case, however, the kexec-based
approach would have only one advantage over the current one. Namely, it
would allow us to create bigger images.

we all agree that tasks cannot run during the suspend-to-ram state, but
the disagreement is over what this means

at one extreme it could mean that you would need the full freezer as per
the current suspend projects.

at the other extreme it could mean that all that's needed is to invoke the
suspend-to-ram routine before anything else on the suspended kernel on the
return from the save and restore kernel.

we just need to figure out which it is (or if it's somewhere in between).

Quoted 6 lines
Quoted 3 lines

Well, I think that the "invoke the suspend-to-ram routine before anything else
on the suspended kernel" thing won't be easy to implement in practice.

Why? You don't expect suspend-to-ram in drivers to be implemented? We need more speperation of the quiesce drivers from power-down devices?

No. I'm saying that when you go back from the image-saving kernel to the hibernated kernel, you need to make sure that no task will cause any filesystem's on-disk state to be actually updated. If you can't make such a guarantee, you just can't do that.

With the current state of the drivers, it's not doable without the freezer.

Quoted 5 lines

Note that we are just talking about "suspend devices and put their state in ram", not actually invoking the platform to suspend to ram.

And I'm actually saying we free memory and maybe allocate disk blocks for the save before we suspend (see below).

Well, I've already written about the OOM killer ...

Quoted 32 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 4 lines

Message-ID: <[email protected]>

Quoted 1 line · Rafael J. Wysocki

(1) Filesystems mounted before the hibernation are untouchable

Quoted 10 lines

This is because some file systems do a fsck or other activity even when
mounted read only. For the kexec case, however, this should be "file
systems mounted by the hibernated system must not be written". As
has
been mentioned in the past, we should be able to use something like dm
snapshot to allow fsck and the file system to see the cleaned copy while not actually writing the media.

We can't _require_ users to use the dm snapshot in order for the hibernation
to work, sorry.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

And by _reading_ from a filesystem you generally update metadata.

not if the filesystem is mounted read-only (except on ext3)

Well, if the filesystem in question is a journaling one and the hibernated
kernel has mounted this fs read-write, this seems to be tricky anyway.

Yes. I would argue writing to existing blocks of a file (not thorugh the filesystem, just getting their blocsk from the file system) should be safe, but it occurs to me that may not be the case if your fsck and bmap move data blocks from some update log to the file system.

Quoted 6 lines

But we know the (maximum) image size. So we could allocate the blocks
in the first image before suspending the drivers and memory allocations, and supplying the list to the second kernel. We could even write to the first block with a signature "suspend to here", or even the whole block list to the beginning (it will have to be saved to disk for restore anyways).

The writing is easy (we're doing that already, just fine).

The tricky part would be if the image-saving kernel tried to mount a journaling filesystem in use by the hibernated kernel.

Quoted 76 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

The kjump kernel must not have any knowledge retained if we reuse it.

Quoted 2 lines

(2) Swap space in use before the hibernation must be handled with care

Yes. Actually, even though they have been used by the write-in-the kernel users, they will be among the most difficult devices to use for
snapshots by a userspace second kernel.

If we use the "write to these blocks" then this is as easy as writing to a file in a mounted filesystem.

Quoted 41 lines
Quoted 41 lines
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

(4) The user should be able to limit the size of a hibernation image

This means the suspending kernel must arrange to reduce its active memory. The limited save can be done by providing a limited list in (3).

It seems to me that you don't understand the problem here.

Quoted 8 lines

Assume you have 90% of RAM allocated before the hibernation and the user has
requested the image to be not greater than 50% of RAM. In that case you have
to free some memory _before_ identifying memory to save and you must not
race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what
is needed to do so (remember this is kernel internals, it can change from
patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away
caches to do so, you don't know what is going to be involved in freeing
the memory, it's very possilbe that it is going to involve userspace, so
you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

Quoted 8 lines
Quoted 3 lines

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

This means unreliable hibernation for some workloads. While I agree that
shouldn't be a problem in a common case, there are users who will complain. ;-)

With my allocate memory as a task and don't save that task's memory
approach, we can get to this point while userspace is running. It
could be controllled by userspace, or even be userspace (sys_do_not_save_me() waits for resume, and dies as the kernel resumes).

Quoted 6 lines
Quoted 5 lines

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Quoted 7 lines
Quoted 3 lines

Well, with the freezer that's much simpler (and more reliable, I'd say): you
freeze tasks and _then_ you shrink memory.

It means you are committed to suspend before you try to shrink memory. What happens when the user requested a smaller image that memory in use?

You mean the user wanted the image to be so small that we can't create it? Well, we don't. :-)

In fact, we cheat a little. Namely, we check if there's enough storage space and if so, we create an image that's bigger than requested by the user.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Quoted 1 line

=(8) Hibernation and restore should not be too slow

We control the added code. We are using full runtime drivers and
will
run at hardware speeds.

That may not be enough. If you're going to save, say, 80% of RAM on a 2 GB
machine, then you'll have to be using image compression.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

this doesn't make sense, 20% of 2G is 400M, if you can't make a kernel and
userspace that can run in 400M you have a serious problem.

I was talking about the _speed_ of writing and reading.

Yes. As I said, adding a compress as we copy the pages into the saving kernel for writeout should be easy.

Easy or not, that's one more thing you should remember about.

Quoted 35 lines
Quoted 28 lines
Quoted 8 lines

even if you wanted to save 99% of RAM on a 2G system, you have 20M of ram
to play with, which should easily be enough.

remember, linux runs on really small systems as well, and while you do have to load some drivers for the big system, there are a lot of other things that aren't needed.

Quoted 7 lines
Quoted 4 lines

All in all, we have three different and working implementation of the image-writing and image-reading code at our disposal. Why would you want to
break the open doors?

becouse you say that the current methods won't work without ACPI support.

I didn't say that. [Or if I did, please point me to this message.]

Anyway, this wouldn't be true even if I did.

What I've been trying to say from the very beginning is that the current
frameworks _support_ hibernation a la ACPI S4 (although that's not exactly
ACPI S4) and if we are going to introduce a new framework, then it should
be designed to _support_ ACPI S4 fully _from_ _the_ _start_.

Quoted 6 lines

This DOESN'T mean that the non-ACPI hibernation should be unsupported and
it DOESN"T mean that the non-ACPI hibernation is not supported currently.
IT IS SUPPORTED.

Quoted 8 lines

As I said, I see kjump as a way to solve the "ok i am at a save point, now how do I write this image to media without allowing any other io". As you know by now, my solution for ACPI support is after the image is written we go back to the kernel that started the suspend and it puts the machine in S4.

If this works, we get down to 1 hibernate implementation in the kernel :-).

For now, we have one implementation in the kernel (swsusp) that may be used with some external (user space) tools (and is called uswsusp in that case, quite confusingly), the other complete one that's waiting for merging with the first one, at least in part (tuxonice, formerly known as suspend2), and your proposed _third_ one (in a number of variants, perhaps).

I _think_ we can get down to one, but not by creating something entirely new from the scratch. If you can think of introducing the kexec-based approach in such a way that it uses _as_ _much_ _of_ _existing_ _code_ _as_ _reasonably_ _possible_, then the result might be a candidate for the one common implementation, as far as I'm concerned.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#186 lore raw

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 10 lines
Quoted 8 lines

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

The hibernate may fail, but you don't corrupt the media.

If you don't get the image out, resume back to the "this is resume" instead of the power-down path.

Well, I don't think that is much prettier than the freezer ...

It seems that a better solution to the "how do we write to a file on an in-use partition" has been suggested, which also handles swap partitions and swap files, and does not require mounting filesystems, so it seems that the filesystem issue need not be considered.

[snip]

Quoted 7 lines

No. I'm saying that when you go back from the image-saving kernel to the hibernated kernel, you need to make sure that no task will cause any filesystem's on-disk state to be actually updated. If you can't make such a guarantee, you just can't do that.

With the current state of the drivers, it's not doable without the freezer.

It seems that it should be feasible to fix the drivers so that

1. they can be taken from normal state to quiesced state without requiring the freezer;

2. they can be taken from normal state to low power state without requiring the freezer;

3. they can be taken from quiesced state to low power state without requiring the freezer.

In the particular, it seems that it should be possible to do (3) without needing to schedule tasks.

It seems likely that (2) may in fact be almost exactly the same as, or at least similar to, (1) followed by (3), at least for many drivers.
(1) is required by the kexec hibernate approach even ignoring suspend to both or S4. (2) is required for suspend to ram without the freezer, which seems to be desired anyway.

[snip]

Signature · 1 line
Jeremy Maitin-Shepard
#187 lore raw
In reply to Rafael J. Wysocki

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 10 lines
Quoted 8 lines

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

The hibernate may fail, but you don't corrupt the media.

If you don't get the image out, resume back to the "this is resume" instead of the power-down path.

Well, I don't think that is much prettier than the freezer ...

It seems that a better solution to the "how do we write to a file on an in-use partition" has been suggested, which also handles swap partitions and swap files, and does not require mounting filesystems, so it seems that the filesystem issue need not be considered.

[snip]

Quoted 7 lines

No. I'm saying that when you go back from the image-saving kernel to the hibernated kernel, you need to make sure that no task will cause any filesystem's on-disk state to be actually updated. If you can't make such a guarantee, you just can't do that.

With the current state of the drivers, it's not doable without the freezer.

It seems that it should be feasible to fix the drivers so that

1. they can be taken from normal state to quiesced state without requiring the freezer;

2. they can be taken from normal state to low power state without requiring the freezer;

3. they can be taken from quiesced state to low power state without requiring the freezer.

In the particular, it seems that it should be possible to do (3) without needing to schedule tasks.

It seems likely that (2) may in fact be almost exactly the same as, or at least similar to, (1) followed by (3), at least for many drivers.
(1) is required by the kexec hibernate approach even ignoring suspend to both or S4. (2) is required for suspend to ram without the freezer, which seems to be desired anyway.

[snip]

Signature · 1 line
Jeremy Maitin-Shepard
#188 lore raw
Quoted 30 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 10 lines
Quoted 8 lines

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

The hibernate may fail, but you don't corrupt the media.

If you don't get the image out, resume back to the "this is resume" instead of the power-down path.

Well, I don't think that is much prettier than the freezer ...

It seems that a better solution to the "how do we write to a file on an in-use partition" has been suggested, which also handles swap partitions and swap files, and does not require mounting filesystems, so it seems that the filesystem issue need not be considered.

[snip]

Quoted 7 lines

No. I'm saying that when you go back from the image-saving kernel to the hibernated kernel, you need to make sure that no task will cause any filesystem's on-disk state to be actually updated. If you can't make such a guarantee, you just can't do that.

With the current state of the drivers, it's not doable without the freezer.

Quoted 7 lines

It seems that it should be feasible to fix the drivers so that

1. they can be taken from normal state to quiesced state without requiring the freezer;

2. they can be taken from normal state to low power state without requiring the freezer;

Yes, that's correct.

Quoted 5 lines

3. they can be taken from quiesced state to low power state without requiring the freezer.

In the particular, it seems that it should be possible to do (3) without needing to schedule tasks.

For that, you'd have to forbid the drivers to call schedule() from the relevant callbacks, which means, eg. no timeouts in there.

Quoted 5 lines

It seems likely that (2) may in fact be almost exactly the same as, or at least similar to, (1) followed by (3), at least for many drivers.
(1) is required by the kexec hibernate approach even ignoring suspend to both or S4. (2) is required for suspend to ram without the freezer, which seems to be desired anyway.

Yes, (2) is needed anyway.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#189 lore raw
In reply to Jeremy Maitin-Shepard
Quoted 30 lines · Jeremy Maitin-Shepard

"Rafael J. Wysocki" <[email protected]> writes:

[snip]

Quoted 10 lines
Quoted 8 lines

Or add a small bit of infrastructure that errors writes at make_request if you don't have a magic "i am a direct block device write from userspace" flag on the bio.

The hibernate may fail, but you don't corrupt the media.

If you don't get the image out, resume back to the "this is resume" instead of the power-down path.

Well, I don't think that is much prettier than the freezer ...

It seems that a better solution to the "how do we write to a file on an in-use partition" has been suggested, which also handles swap partitions and swap files, and does not require mounting filesystems, so it seems that the filesystem issue need not be considered.

[snip]

Quoted 7 lines

No. I'm saying that when you go back from the image-saving kernel to the hibernated kernel, you need to make sure that no task will cause any filesystem's on-disk state to be actually updated. If you can't make such a guarantee, you just can't do that.

With the current state of the drivers, it's not doable without the freezer.

Quoted 7 lines

It seems that it should be feasible to fix the drivers so that

1. they can be taken from normal state to quiesced state without requiring the freezer;

2. they can be taken from normal state to low power state without requiring the freezer;

Yes, that's correct.

Quoted 5 lines

3. they can be taken from quiesced state to low power state without requiring the freezer.

In the particular, it seems that it should be possible to do (3) without needing to schedule tasks.

For that, you'd have to forbid the drivers to call schedule() from the relevant callbacks, which means, eg. no timeouts in there.

Quoted 5 lines

It seems likely that (2) may in fact be almost exactly the same as, or at least similar to, (1) followed by (3), at least for many drivers.
(1) is required by the kexec hibernate approach even ignoring suspend to both or S4. (2) is required for suspend to ram without the freezer, which seems to be desired anyway.

Yes, (2) is needed anyway.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth

A message that is not in the archive (sent off-list or not yet received): [email protected]

#191 lore raw
Quoted 28 lines · Jim Crilly
Quoted 28 lines
Quoted 6 lines

has
requested the image to be not greater than 50% of RAM. In that case you have
to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

Quoted 8 lines
Quoted 4 lines

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Which would be a pretty big regression from what we have now. With the current implementation I can hibernate under virtually any workload because the freezer stops everything and there's no competition for resources.

as long as what you are trying to save is <=50% of ram (at least with some implementations). if you are trying to save more then 50% of ram with some current implmenetations you just can't

David Lang

#192 lore raw
Quoted 35 lines · On Friday, 20 July 2007 17:36, [email protected] wrote:
Quoted 33 lines · Jim Crilly
Quoted 32 lines
Quoted 6 lines

has
requested the image to be not greater than 50% of RAM. In that case you have
to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Quoted 7 lines
Quoted 3 lines

Which would be a pretty big regression from what we have now. With the current implementation I can hibernate under virtually any workload because the freezer stops everything and there's no competition for resources.

as long as what you are trying to save is <=50% of ram (at least with some implementations). if you are trying to save more then 50% of ram with some current implmenetations you just can't

With some, you can't, with the others, you can. :-)

The argument given was about the freezer and IMO it was valid.

Why didn't you address it directly?

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#193 lore raw
Quoted 44 lines · Rafael J. Wysocki
Quoted 35 lines · On Friday, 20 July 2007 17:36, [email protected] wrote:
Quoted 33 lines · Jim Crilly
Quoted 32 lines
Quoted 6 lines

has
requested the image to be not greater than 50% of RAM. In that case you have
to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Quoted 7 lines
Quoted 3 lines

Which would be a pretty big regression from what we have now. With the current implementation I can hibernate under virtually any workload because the freezer stops everything and there's no competition for resources.

as long as what you are trying to save is <=50% of ram (at least with some implementations). if you are trying to save more then 50% of ram with some current implmenetations you just can't

Quoted 5 lines

With some, you can't, with the others, you can. :-)

The argument given was about the freezer and IMO it was valid.

Why didn't you address it directly?

I thought it had been covered in other messages (with as big as this thread is I'm trying to avoid repeating the same thing more then a couple times a day :-)

there was another message talking about ways that you could reduce the image size without it being racy (allocate pinned memory until the remainder is small enough, then don't backup the pinned memory)

that's a much cleaner answer then what I was thinking, so I'll go with it instead ;-)

David Lang

#194 lore raw
Quoted 56 lines · On Friday, 20 July 2007 23:39, [email protected] wrote:
Quoted 44 lines · Rafael J. Wysocki
Quoted 35 lines · On Friday, 20 July 2007 17:36, [email protected] wrote:
Quoted 33 lines · Jim Crilly
Quoted 32 lines
Quoted 6 lines

has
requested the image to be not greater than 50% of RAM. In that case you have
to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Quoted 7 lines
Quoted 3 lines

Which would be a pretty big regression from what we have now. With the current implementation I can hibernate under virtually any workload because the freezer stops everything and there's no competition for resources.

as long as what you are trying to save is <=50% of ram (at least with some implementations). if you are trying to save more then 50% of ram with some current implmenetations you just can't

Quoted 5 lines

With some, you can't, with the others, you can. :-)

The argument given was about the freezer and IMO it was valid.

Why didn't you address it directly?

I thought it had been covered in other messages (with as big as this thread is I'm trying to avoid repeating the same thing more then a couple times a day :-)

Quoted 6 lines

there was another message talking about ways that you could reduce the image size without it being racy (allocate pinned memory until the remainder is small enough, then don't backup the pinned memory)

that's a much cleaner answer then what I was thinking, so I'll go with it instead ;-)

Wouldn't that cause the OOM killer to act, in some cases?

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#195 lore raw
Quoted 57 lines · Rafael J. Wysocki
Quoted 56 lines · On Friday, 20 July 2007 23:39, [email protected] wrote:
Quoted 44 lines · Rafael J. Wysocki
Quoted 35 lines · On Friday, 20 July 2007 17:36, [email protected] wrote:
Quoted 33 lines · Jim Crilly
Quoted 32 lines
Quoted 6 lines

has
requested the image to be not greater than 50% of RAM. In that case you have
to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

I disagree a little bit.

first off, only the suspending kernel can know what can be freed and what is needed to do so (remember this is kernel internals, it can change from patch to patch, let alone version to version)

second, if you have a lot of memory to free, and you can't just throw away caches to do so, you don't know what is going to be involved in freeing the memory, it's very possilbe that it is going to involve userspace, so you can't freeze any significant portion of the system, so you can't eliminate all chance of races

what you can do is

1. try to free stuff
2. stop the system and account for memory, is enough free if not goto 1

if userspace is dirtying memory fast enough, or is just useing enough memory that you can't meet your limit you just won't be able to suspend.

but under any other conditions you will eventually get enough memory free.

so try several times and if you still fail tell the user they have too much stuff running and they need to kill something.

Quoted 7 lines
Quoted 3 lines

Which would be a pretty big regression from what we have now. With the current implementation I can hibernate under virtually any workload because the freezer stops everything and there's no competition for resources.

as long as what you are trying to save is <=50% of ram (at least with some implementations). if you are trying to save more then 50% of ram with some current implmenetations you just can't

Quoted 5 lines

With some, you can't, with the others, you can. :-)

The argument given was about the freezer and IMO it was valid.

Why didn't you address it directly?

I thought it had been covered in other messages (with as big as this thread is I'm trying to avoid repeating the same thing more then a couple times a day :-)

Quoted 8 lines
Quoted 6 lines

there was another message talking about ways that you could reduce the image size without it being racy (allocate pinned memory until the remainder is small enough, then don't backup the pinned memory)

that's a much cleaner answer then what I was thinking, so I'll go with it instead ;-)

Wouldn't that cause the OOM killer to act, in some cases?

only in the case where the image absolutly cannot be made small enough.

and this should be detectable by the process that's pinning memory (this can be a kernel process) so that it stops before the OOM killer is triggered, even if that means that it returns 'unable to fit'

David Lang

#196 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 7 lines · Milton Miller

The currently identified problems under discussion include:
(1) how to interact with acpi to enter into S4.
(2) how to identify which memory needs to be saved
(3) how to communicate where to save the memory
(4) what state should devices be in when switching kernels
(5) the complicated setup required with the current patch
(6) what code restores the image

(7) how to avoid corrupting filesystems mounted by the hibernated kernel

Ok I talked on this too.

Quoted 67 lines
Quoted 29 lines

I'll now start with quotes from several articles in this thread and my responses.

Message-ID: <[email protected]>

Quoted 9 lines · Rafael J. Wysocki

(1) Upon entering the sleep state, which IMO can be done _after_ the image
has been saved:
* figure out which devices can wake up
* put devices into low power states (wake-up devices are placed in
the Dx
states compatible with the wake capability, the others are
powered
off)

Quoted 8 lines

* execute the _PTS global control method
* switch off the nonlocal CPUs (eg. nonboot CPUs on x86)
* execute the _GTS global control method
* set the GPE enable registers corresponding to the wake-up
devices)
* make the platform enter S4 (there's a well defined procedure for
that)
I think that this should be done by the image-saving kernel.

Message-ID: <[email protected]>
On Tue Jul 17 13:35:52 2007, Jeremy Maitin-Shepard
expressed his agreement with this block but also confusion on the other blocks.

Quoted 8 lines

I strongly disagree.

(1) as has been pointed out, this requires the new kernel to understand all io devices in the first kernel.
(2) it requires both kernels to talk to ACPI. This is doomed to
failure. How can the second kernel initialize ACPI? The platform
thinks it has already been initialized. Do we plan to always undo all acpi initialization?

Good question. I don't know.

Quoted 17 lines
Quoted 8 lines

(2) Upon start-up (by which I mean what happens after the user has pressed
the power button or something like that):
* check if the image is present (and valid) _without_ enabling ACPI
(we don't
do that now, but I see no reason for not doing it in the new
framework)
* if the image is present (and valid), load it

Quoted 8 lines

* turn on ACPI (unless already turned on by the BIOS, that is)
* execute the _BFS global control method
* execute the _WAK global control method
* continue
Here, the first two things should be done by the image-loading
kernel, but
the remaining operations have to be carried out by the restored
kernel.

Quoted 8 lines

Here I agree.

Here is my proposal. Instead of trying to both write the image and suspend, I think this all becomes much simpler if we limit the scope the work of the second kernel. Its purpose is to write the image.
After that its done. The platform can be powered off if we are going
to S5. However, to support suspend to ram and suspend to disk, we
return to the first kernel.

Quoted 2 lines

We can't do this unless we have frozen tasks (this way, or another) before carrying out the entire operation.

What can't we do? We've already worked with the drivers to quesce the hardware and put any information to resume the device in ram. Now we ask them to put their device in low power mode so we can go to sleep. Even if we schedule, the only thing userspace could touch is memory. If we resume, they just run those computations again.

Quoted 3 lines

In that case, however, the kexec-based
approach would have only one advantage over the current one. Namely, it would allow us to create bigger images.

The advantage is we don't have to come up with a way to teach drivers "wake up to run these requests, but no other requests". We don't have to figure out what we need to resume to allow them to process a request.

Quoted 34 lines
Quoted 34 lines

This means that the first kernel will need to know why it got resumed.
Was the system powered off, and this is the resume from the user? Or
was it restarted because the image has been saved, and its now time to actually suspend until woken up? If you look at it, this is the same interface we have with the magic arch_suspend hook -- did we just suspend and its time to write the image, or did we just resume and its time to wake everything up.

I think this can be easily solved by giving the image saving kernel two resume points: one for the image has been written, and one for we rebooted and have restored the image. I'm not familiar with ACPI. Perhaps we need a third to differentiate we read the image from S4 instead of from S5, but that information must be available to the OS because it needs that to know if it should resume from hibernate.

By making the split at image save and restore we have several advantages:

(1) the kernel always initializes with devices in the init or quiesced but active state.

(2) the kernel always resumes with devices in the init or quiesced but active state.

(3) the kjump save and restore kernel does not need to know how to suspend all devices in the platform.

(4) we have a merged path for suspend to disk, suspend to ram, and suspend to both.

(5) because of (4), we can implement sleep policys where we save the image to disk but try to stay in ram based on expected remaining battery life.

Quoted 7 lines
Quoted 5 lines

(6) we confine all platform (acpi) interaction to the main kernel

(7) we limit the knowledge needed in the second kernel. It needs to
know how to do its job and then put the hardware back how it found it. Nothing more.

This would have been nice if we had been able to do it.

I don't understand this comment. "if we had been able"? I don't think we have tried yet.

Quoted 9 lines
Quoted 9 lines

For the suspend to ram and then woken up case, we simply need to invalidate the image before restarting normal kernel operation.

People have worried about how to boot and restore the kernel, and what
to do if reading the image fails. They worry about needing memory
hotplug or delayed acpi parsing. They are forgetting one thing. This kernel has support for kexec.

Quoted 5 lines
Quoted 2 lines

This is all easily solved by having the bootloader from the bios always boot the restore kernel.

Well, I think this is not generally acceptable, although I agree that it would be simpler.

For those that don't find it acceptable they can teach their bootloader when they may have a image to resume.

Quoted 8 lines
Quoted 6 lines

It will boot with limited useable memory and
no acpi support. If the restore kernel userspace detects that there is no restore image, it simply loads the normal main kernel and initrd / initramfs and calls the normal kexec. The cost is the time to init the restore kernel, read the kernel with full drivers (vs reading it from the bootloader). If you want a boot menu, use kboot (on sourceforge).

Well, I'm afraid of adding more and more infrastructure to the mix.

Requiring the hibernated kernel to be able to start from kexec should not be bad. If you were referring to adding kboot, that is just an option.

One can still use bootloaders menus to select alternate kernels. However, as you said, you want to boot differently for resume (no acpi until after image loaded) from full boot.

Quoted 13 lines
Quoted 13 lines · Rafael J. Wysocki
Quoted 12 lines · On Tuesday, 17 July 2007 22:27, [email protected] wrote:
Quoted 11 lines · Alan Stern
Quoted 7 lines

But what about the freezer? The original reason for using kexec was to
avoid the need for the freezer. With no freezer, while the original kernel is busy powering down its devices, user tasks will be free to carry out I/O -- which will make the memory snapshot inconsistent with
the on-disk data structures.

no, user tasks just don't get scheduled during shutdown.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

the big problem with the freezer isn't stopping anything from happening,
it's _selectivly_ stopping things.

Agreed. Or rather, selectively not stopping and resuming things.

I don't quite understant this statement. Can you please elaborate?

Feel free to list other problems with the freezer, but I'm saying that the problems are stemming from trying to freeze most of userspace and some selection of kernel threads so that new requests to the outside are not made, but then turning around and saying "ok now do some io, but only what this thread of execution originates". Its originates not generates so we are trying to teach the whole stack these limits, including going back to userspace for FUSE.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines

It's selectively stopping kernel threads, which is just about right. If you
that _this_ is a main problem with the freezer, then think again.

Quoted 2 lines

with kexec you don't need to let any portion of the origional kernel or userspace operate so you don't have a problem.

In fact, the main problem with the freezer is that it is a coarse-grained
solution. Therefore, what I believe we should do is to evolve in the directoin
of more fine-grained solutions and gradually phase out the freezer.

The kexec-based approach is an attempt to replace one coarse-grained solution
(the freezer) with even more coarse-grained solution (stopping the entire
kernel with everything), which IMO doesn't address the main problem.

Quoted 5 lines
Quoted 5 lines

I think this addresses teh problem. Its probably a bit harder than
powermac because we have to fully quiesce devices; we can't cheat by
leaving interrupts off. But once the drivers save the state of their
devices and stop their queues, it should be easy to audit the paths to powerdown devices and call the platform suspend and ram wakeup paths.

In other words, I'm replacing a course-grained solution with an absolute solution. "From this point on you can only write to ram."

Quoted 13 lines
Quoted 4 lines

Going back to the requirements document that started this thread:

Message-ID: <[email protected]> On Sun Jul 15 05:27:03 2007, Rafael J. Wysocki wrote:

Quoted 8 lines
Quoted 1 line

(1) Filesystems mounted before the hibernation are untouchable

This is because some file systems do a fsck or other activity even when mounted read only. For the kexec case, however, this should be "file
systems mounted by the hibernated system must not be written". As has
been mentioned in the past, we should be able to use something like dm snapshot to allow fsck and the file system to see the cleaned copy while not actually writing the media.

Quoted 2 lines

We can't _require_ users to use the dm snapshot in order for the hibernation to work, sorry.

I actually listed three ways to start. Not all of them required dm-snapshot. I was proposing "if you need to read ext3, then use dm-snapshot".

Quoted 1 line

And by _reading_ from a filesystem you generally update metadata.

not on ones mounted read-only. I'll reply more later in the thread.

Quoted 20 lines
Quoted 14 lines

The kjump kernel must not have any knowledge retained if we reuse it.

Quoted 1 line

(2) Swap space in use before the hibernation must be handled with care

Yes. Actually, even though they have been used by the write-in-the kernel users, they will be among the most difficult devices to use for snapshots by a userspace second kernel.

Quoted 1 line

(3) There are memory regions that must not be saved or restored

because they may not exist. This means that we must identify the
memory to be saved and restored in a format to be passed between the kernel.

Quoted 5 lines
Quoted 1 line

(4) The user should be able to limit the size of a hibernation image

This means the suspending kernel must arrange to reduce its active memory. The limited save can be done by providing a limited list in (3).

Quoted 6 lines

It seems to me that you don't understand the problem here.

Assume you have 90% of RAM allocated before the hibernation and the user has requested the image to be not greater than 50% of RAM. In that case you have to free some memory _before_ identifying memory to save and you must not race with applications that attempt to allocate memory while you're doing it.

Hmm... I didn't say how to reduce the memory or identify it, did I?

Ok fine. I'll allocate a bunch of memory and put it on a list. Normal memory pressure will swap things out or drop filesystem pages. When I build the list of memory to backup, I filter out this list. After resume, I'll free it back.

We can arrange for this "task" to be preferred by the oom killer, if case the user is trying to suspend into less than memory than can be freed.

Quoted 11 lines
Quoted 7 lines
Quoted 2 lines

(5) Hibernation should be transparent from the applications' point of view

People have pointed out they may want userspace to be aware of the
suspend. I believed this can be done with /proc/apm emulation today
or by other means; it seems that should be hooked up to dbus in some fashion.

Not a solution, because there still will be programs not needing to know anything about hibernation. After all, we don't require all applications to know anything about SMP, even if they are executed on an SMP system.

How do any of those methods require userpsace to know anything about hibernation? I was talking about a general framework consistent with todays kernel to user communication for those parts of userspace that *want* to know about suspend and hibernation.

Quoted 12 lines
Quoted 12 lines
Quoted 2 lines

(6) State of devices from before hibernation should be restored, if possible

related to suspend should be transparent ... yes.

Quoted 4 lines

(7) On ACPI systems special platform-related actions have to be carried out at
the right points, so that the platform works correctly after the
restore

I believe I have explained my suggestion.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

(8) Hibernation and restore should not be too slow

We control the added code. We are using full runtime drivers and will
run at hardware speeds.

That may not be enough. If you're going to save, say, 80% of RAM on a 2 GB machine, then you'll have to be using image compression.

Yea, so? We have a full kernel and userspace, adding compression before writing should be easy. The is no struct page for memory in the old kernel, so we likely need to be copying them in userspace anyways. Adding compression should be easy.

Quoted 64 lines
Quoted 53 lines
Quoted 1 line

(9) Hibernation framework should not be too difficult to set up

Ok the current patch is presently too difficult. But I think it will be much simpler with a few small changes.

As noted in the thread

Message-ID: <[email protected]>
Subject: [linux-pm] Re: hibernation/snapshot design

Quoted 4 lines · Jeremy Maitin-Shepard
Quoted 1 line

Both would work. One would eat 8-64MB of your RAM, permanently;

As I have stated in other messages, the kdump approach would not waste any RAM permanently.

...

Quoted 8 lines

Immediately before jumping to the new kernel, the first X bytes (where X
is the amount of memory the new kernel will get, typically 16MB or 64MB)
of physical memory are backed up into the arbitrary discontiguous pages that are made available. This will not take very long, because copying even 64MB of memory is extremely fast. Then the new kernel is free to use the first X bytes of contiguous physical memory. Problem solved.

Ok, now let's look at my list again:

Quoted 1 line

(1) how to interact with acpi to enter into S4.

This was discussed.

Quoted 1 line

(2) how to identify which memory needs to be saved

We need to generate a list. We need it to fit in a compuatable size so that we can free and allocate the pages before suspending IO in the first kernel.

One possibility is to use something like the kexec copy list. If we are imaging a small fraction of ram this is appropriate, but if we are doing dense saves we need something extent based. We should be able to extend the list.

Quoted 1 line

(3) how to communicate where to save the memory

This is an intresting topic. The suspended kernel has most IO and disk space. It also knows how much space is to be occupied by the kernel. So communicating a block map to the second kernel would be the obvious
choice. But the second kernel must be able to find the image to
restore it, and it must have drivers for the media. Also, this is not feasible for storing to nfs.

I think we will end up with several methods.

Quoted 8 lines

One would be supply a list of blocks, and implement a file system that reads the file by reading the scatter list from media. The restore kernel then only needs to read an anchor, and can build upon that until the image is read into memory. Or do this in userspace.

I don't know how this compares to the current restore path. I wasn't
able to identify the code that creates the on disk structure in my 10 minute perusal of kernel/power/.

The structure is created at two levels.

Quoted 7 lines

First, the code in snapshot.c makes the image available to the code in swap.c as a stream of pages. The first page is the header, followed by some pages containing the PFNs of the page frames to which the image data pages are to be restored, followed by the image data pages themselves (the ordering of the PFNs must be the same as the ordering of data pages that correspond to them). Still, the low-level image format only needs to be known by the restore code in snapshot.c .

Ok sounds like this code could be reused. I'll look into it.

Quoted 3 lines

Second, the code in swap.c writes the image pages to a storage adding some metadata making it possible to reproduce their original ordering during the restore.

So you are allocating the blocks as you go ... and adding meta data along the way?

Quoted 2 lines

The fact that we use swap spaces as the storage is related to implementation simplicity rather than anything else.

Ok ... this only supports uncompressed hibernation?

The first kernel is going to specify (1) what to backup. It can specify (2) where to backup, although we have to be careful identify the device in a persistent way.

Quoted 13 lines
Quoted 13 lines

A second method will be to supply a device and file that will be mounted by the save kernel, then unmounted and restored. This would require a partition that is not mounted or open by the suspended kernel (or use nfs or a similar protocol that is designed for multiple client concurrent access).

A third method would be to allocate a file with the first kernel, and make sure the blocks are flushed to disk. The save and restore kernels map the file system using a snapshot device. Writing would map the blocks and use the block offset to write to the real device using the method from the first option; reading could be done directly from the snapshot device.

Quoted 6 lines
Quoted 2 lines

The first and third option are dead on log based file systems (where the data is stored in the log).

All in all, we have three different and working implementation of the image-writing and image-reading code at our disposal. Why would you want to break the open doors?

The problem I'm saying kexec solves is how to get the data to the device while most of the kernel is trying not do anything permanent.

If we can reuse existing code, great.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

(4) what state should devices be in when switching kernels

My proposal is either initialized and untouched or quiesced.

This is reasonable, but in general we also need to save some information about the pre-hibernation state of devices, so that we can put them into the same state, if reasonably possible, during the restore.

What state are you referring to?

Yes, there is state that the drivers have to store to ram, but this the same state they need to store when suspending to ram if the device can be powered off.

Maybe we need to teach drivers to store more state, like remember that a hard drive was spun down.

So we may need a flag saying "we powered off", "we resumed from suspend".

Quoted 12 lines
Quoted 11 lines
Quoted 1 line

(5) the complicated setup required with the current patch

I think a few simple changes to kjump will make this much simpler. See below.

Quoted 1 line

(6) what code restores the image

The save kernel, loaded at boot. People have suggested booting the
first kernel, and using current restore code. However, I think that
ignores that (1) we saved from a different kernel, so the backed up region will be restored to its backed up random pages,

Quoted 8 lines

This problem has already been solved.

Quoted 1 line

(2) the code was written to restore the same kernel,

Not exactly. In fact, the current implementation only relies on the tiny portion of the restore code being in the same place in both kernels, but we can change the code not to make this assumption (it'll be more complicated, but that's perfectly doable).

If the save kernel is different from the run kernel (to make it smaller), its likely the image saving code will move. I view restoring from a different kernel than saving as an advanced feature.

Lets get resuming from the save kernel working first.

Quoted 31 lines
Quoted 2 lines

so the text and data will be replaced by identical text. Its much simpler conceptually to use the same kernel to save and restore the image.

Here I agree. :-)

Quoted 26 lines

Simplifying kjump: the proposal for v3.

The current code is trying to use crash dump area as a safe, reserved
area to run the second kernel. However, that means that the kernel
has to be linked specially to run in the reserved area. I think we
need to finish separating kexec_jump from the other code paths.

(1) add a new command line argument that specifies the kexec_jump target area.

(2) add a kjump flag to the flags parameter, used by kexec_load. When
loading a jump kernel, it is loaded like a normal kernel, however, additional control pages are allocated to (a) save the kexec_jump target area (b) save the backed up region that is used by all kernels like crash dump, and (c) space for invoking relocate_new_kernel that will get its args from the execution entry point and will restore the kernel then call resume and suspend.

(3) replace jump_huf_pfn with two command line addresses that specify the (a) return point for after resume, and (b) the return point for
after image save. Actually these can be done in userspace; the second
restore kernel can just specify the null copy list and the entry points supplied by the suspended kernel. To do resume we also need (c) where to store resume address for the save kernel.

Quoted 5 lines
Quoted 3 lines

As a first stage of suspend and resume, we can save to dedicated partitions all memory (as supplied to crash_dump) that is not marked nosave and not part of the save kernel's image.

A little problem here: there are "nosave" areas that are not marked as nosave.

If crash_dump is going work the memory must exist.

Quoted 3 lines
Quoted 1 line

The fancy block lists and memory lists can be added later.

On the majority of systems that will work. On some of them it won't.

Ok .... well, my point is we can get started while we workout what the list format is. If we decide to reuse the pfn lists above that may come quickly.

Quoted 11 lines
Quoted 11 lines

mmaking these changes will allow us to use a normal kernel invoked with acpi=off apm=off mem=xxk as the save and restore kernel.

If we want to keep the second kernel booted, then we need to add a save
area for the booted jump target. Note that the save and restore lists
to relocate_new_kernel can be computed once and saved. Longer term we
could implement sys_kexec_load(UNLOAD) that would retrieve the saved
list back to application space to save to disk in a file. This means
you could save the booted save kernel, it just couldn't have any shared storage open.

Quoted 8 lines
Quoted 2 lines

I'll try to expand on this in the jump v2 thread, but it may be 36+ hours before I do so.

Well, I have no experience with kexec, so I really can't comment your kexec-related suggestions.

Greetings,
Rafael

Thanks,
milton

#197 lore raw
Quoted 8 lines · Milton Miller
Quoted 3 lines

We can't do this unless we have frozen tasks (this way, or another) before
carrying out the entire operation.

What can't we do? We've already worked with the drivers to quesce the
hardware and put any information to resume the device in ram. Now we ask them to put their device in low power mode so we can go to sleep. Even if we schedule, the only thing userspace could touch is memory.

Userspace can submit I/O requests. Someone will have to audit every driver to make sure that such I/O requests don't cause a quiesced device to become active. If the device is active, it will make the memory snapshot inconsistent with the on-device data.

Alan Stern