From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Ondrej Zary <linux@rainbow-software.org>,
Kernel development list <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Balbir Singh <balbir@in.ibm.com>,
Andrea Arcangeli <aarcange@redhat.com>
Subject: Re: [RFC][PATCH -mm] hibernation: freeze swap at hibernation (Was Re: Memory corruption during hibernation since 2.6.31
Date: Wed, 4 Aug 2010 01:09:15 +0200 [thread overview]
Message-ID: <201008040109.15818.rjw@sisk.pl> (raw)
In-Reply-To: <20100802150225.851b48fe.kamezawa.hiroyu@jp.fujitsu.com>
On Monday, August 02, 2010, KAMEZAWA Hiroyuki wrote:
> On Fri, 30 Jul 2010 13:14:32 +0900
> KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
>
> > On Thu, 29 Jul 2010 21:10:10 -0700
> > Hugh Dickins <hughd@google.com> wrote:
> >
> > > On Thu, Jul 29, 2010 at 5:01 PM, KAMEZAWA Hiroyuki
> > > <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> > >
> > > > I think the best way is kexec(). But maybe rollback from hibernation failure
> > > > will be difficult. Considering how crash-dump works well and under maintainance
> > > > by many enterprise guys, hibernation-by-kexec is a choice. I think. It can make
> > > > reuse of kdump code, ...or, hibernation-resume code can eat kdump image
> > > > directly. Maybe the problem will be the speed of dump.
> > >
> > > I've no appetite for a total rework of hibernation, and I don't see
> > > how that would
> > > address the issue: I'm just looking for some protection against swap
> > > reuse danger.
> > >
> > Okay ;) (And I forget that kexec has to prepare memory at boot time for 2nd kernel.
> > It will be harmful for small device guys.)
> >
> > I'll prepare a routine not-quick-fix.
>
> Ok, here. Passed easy tests as
> # echo disk > /sys/power/state
>
>
> Looks like a big hammer ? But I think following kind of patch is required.
> About swap-reuse, it's only possible when a page is added to swap cache
> but try_to_unmap() fails and the page remains in memory. IIUC, most of this
> kind of pages will be backed to swap by shrink_all_memory(). So, reuse-swap
> happens only when the user unlucky. This patch ignores reuse-swap but freeze
> swap_map[] for saving swap_map[] to the disk in consistent way.
>
> ==
> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> swap_map[] is a one of objects which can be update while hibernation. I.E,
> usage counter in swap_map[] is updated while hibernation is making a copy
> of memory image to the disk.
>
> At resume, hibenation code doesn't call swap_free() against the swaps they
> used...So, the swap_map[] will turns to be an initial state.
>
> With small consideration, the question is how swap_map[] updated before
> dumping to the disk is treated. In swap-system view, there are no guarantee
> that swap_map[] are properly reloaded and there is no leak in swap count.
>
> This patch tries to freeze swap_map[] during hibernation.
> By this, no updates will be happen to swap_map[] among save_image().
> At load_image(), the swap_map[] has no record for swap entries used by
> save_image(), we can simply forget it.
>
> Note: I'm not a specialist of hibernation...so, I'm not sure the hooks
> to kernel/power/user.c is appropriate or not.
> And this disables swap-out once hibernation starts saving.
> Should we afraid of OOM ?
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
I have only one comment (below).
> ---
...
> Index: mmotm-0727/kernel/power/user.c
> ===================================================================
> --- mmotm-0727.orig/kernel/power/user.c
> +++ mmotm-0727/kernel/power/user.c
> @@ -135,6 +135,7 @@ static int snapshot_release(struct inode
> free_basic_memory_bitmaps();
> data = filp->private_data;
> free_all_swap_pages(data->swap);
> + hibernation_thaw_swap();
free_all_swap_pages() calls hibernation_thaw_swap(), so it doesn't need to be
called again.
> if (data->frozen)
> thaw_processes();
> pm_notifier_call_chain(data->mode == O_WRONLY ?
>
>
> --
Rafael
next prev parent reply other threads:[~2010-08-03 23:11 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-28 21:20 Memory corruption during hibernation since 2.6.31 Ondrej Zary
2010-07-28 21:34 ` Rafael J. Wysocki
2010-07-28 21:38 ` Ondrej Zary
2010-07-29 1:06 ` KAMEZAWA Hiroyuki
2010-07-29 2:51 ` KAMEZAWA Hiroyuki
2010-07-29 4:23 ` KAMEZAWA Hiroyuki
2010-07-29 5:23 ` KOSAKI Motohiro
2010-07-29 5:24 ` KAMEZAWA Hiroyuki
2010-07-29 5:30 ` KOSAKI Motohiro
2010-07-29 17:33 ` Ondrej Zary
2010-07-29 18:44 ` Hugh Dickins
2010-07-29 18:55 ` Andrea Arcangeli
2010-07-29 23:40 ` Rafael J. Wysocki
2010-07-30 4:02 ` Hugh Dickins
2010-08-09 7:26 ` Pavel Machek
2010-07-29 23:29 ` Rafael J. Wysocki
2010-07-30 3:36 ` KAMEZAWA Hiroyuki
2010-07-30 3:54 ` Hugh Dickins
2010-07-30 0:01 ` KAMEZAWA Hiroyuki
2010-07-30 4:10 ` Hugh Dickins
2010-07-30 4:14 ` KAMEZAWA Hiroyuki
2010-07-30 4:46 ` Hugh Dickins
2010-07-30 10:43 ` KAMEZAWA Hiroyuki
2010-07-30 18:16 ` Hugh Dickins
2010-08-02 6:02 ` [RFC][PATCH -mm] hibernation: freeze swap at hibernation (Was " KAMEZAWA Hiroyuki
2010-08-02 14:27 ` Rafael J. Wysocki
2010-08-02 15:59 ` Balbir Singh
2010-08-03 0:19 ` KAMEZAWA Hiroyuki
2010-08-03 23:09 ` Rafael J. Wysocki [this message]
2010-08-03 23:31 ` KAMEZAWA Hiroyuki
2010-08-04 2:26 ` KAMEZAWA Hiroyuki
2010-08-04 4:57 ` [PATCH -mm] hibernation: freeze swap at hibernation v2 KAMEZAWA Hiroyuki
2010-08-04 22:18 ` Andrew Morton
2010-08-05 0:32 ` KAMEZAWA Hiroyuki
2010-07-30 4:18 ` Memory corruption during hibernation since 2.6.31 Balbir Singh
2010-07-30 4:32 ` Hugh Dickins
2010-07-30 6:37 ` Balbir Singh
2010-08-05 12:44 ` Ondrej Zary
2010-08-03 10:50 ` Andrea Gelmini
2010-08-03 23:36 ` KAMEZAWA Hiroyuki
2010-08-04 1:50 ` [BUGFIX][PATCH] fix corruption of hibernation caused by reusing swap at saving image KAMEZAWA Hiroyuki
2010-08-04 2:31 ` KAMEZAWA Hiroyuki
2010-08-04 2:46 ` KAMEZAWA Hiroyuki
2010-08-05 19:12 ` Hugh Dickins
2010-08-05 11:41 ` Memory corruption during hibernation since 2.6.31 Andrea Gelmini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201008040109.15818.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@in.ibm.com \
--cc=hughd@google.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rainbow-software.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.