Re: Memory corruption during hibernation since 2.6.31

From: KAMEZAWA Hiroyuki
Date: Thu Jul 29 2010 - 23:41:27 EST

On Fri, 30 Jul 2010 01:29:33 +0200
"Rafael J. Wysocki" <rjw@xxxxxxx> wrote:

> Well, the rule of thumb (if it can be called this way) is that the contents of
> the image has to be consistent with whatever is stored in permanent storage.
> So, for example, filesystems that were mounted before creating the image
> cannot be modified until the image is restored. Consequently, if there are
> any kernel threads that might cause that to happen, they need to be frozen.
> Now, if I understand it correctly, the failure mode is that certain page had
> been swapped out before the image was created and then it was swapped in
> while we were writing the image out and the slot occupied by it was re-used.
> In that case the image would contain wrong information on the state of the
> swap and that would result in wrong data being loaded into memory on an attempt
> to swap that page in after resume.
> So, generally, we have to avoid doing things that would result in swapping
> memory pages out after we have created a hibernation image. If that can be
> achieved by freezing certain kernel threads, that probably is the simplest
> approach.

BTW, I can't understand what happens in following situation.

1. start saving image.
2. at saving image, swap entry is used and swap_map[off] += 1.
3. At some point, swap_map[] itself is saved.

At restore, IIUC, hibernation don't call any swap_free().
Where does the +1 goes ?
I'm sorry if I misunderstand.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at