From: Pavel Machek <pavel@ucw.cz>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Linux-pm mailing list <linux-pm@lists.osdl.org>,
Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Don't explode on swsusp failure to find swap
Date: Wed, 1 Jun 2005 11:27:42 +0200 [thread overview]
Message-ID: <20050601092742.GC6693@elf.ucw.cz> (raw)
In-Reply-To: <1117583403.5826.72.camel@gaston>
[-- Attachment #1: Type: text/plain, Size: 2082 bytes --]
Hi!
> > > > If we specify a swap device for swsusp using resume= kernel argument and
> > > > that device doesn't exist in the swap list, we end up calling
> > > > swsusp_free() before we have allocated pagedir_save. That causes us to
> > > > explode when trying to free it.
> > > >
> > > > Pavel, does that look right ?
> > >
> > > It looks like a workaround. We should not call swsusp_free in case
> > > device does not exists. Quick look did not reveal where the bug comes
> > > from, can you try to trace it?
> > > Pavel
> >
> > Well, the bug comes from arch code calling swsusp_save() which fails,
> > then we call swsusp_free()
>
> More specifically, arch suspend calls swsusp_save().
>
> It fails and returns the error to the arch asm code, which itself
> returns it to it's caller swsusp_suspend(), which does that:
>
> if ((error = swsusp_arch_suspend()))
> swsusp_free();
Ugh, swsusp_free should be totally unneccessary at this point; only
error returns are from the time before anything is allocated.
Does something like this help?
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -975,13 +975,6 @@ extern asmlinkage int swsusp_arch_resume
asmlinkage int swsusp_save(void)
{
- int error = 0;
-
- if ((error = swsusp_swap_check())) {
- printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try "
- "swapon -a!\n");
- return error;
- }
return suspend_prepare_image();
}
@@ -999,12 +992,19 @@ int swsusp_suspend(void)
*/
if ((error = device_power_down(PMSG_FREEZE))) {
local_irq_enable();
- swsusp_free();
return error;
}
+
+ if ((error = swsusp_swap_check())) {
+ printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try "
+ "swapon -a!\n");
+ local_irq_enable();
+ return error;
+ }
+
save_processor_state();
if ((error = swsusp_arch_suspend()))
- swsusp_free();
+ printk("Error %d suspending\n", error);
/* Restore control flow magically appears here */
restore_processor_state();
BUG_ON (nr_copy_pages_check != nr_copy_pages);
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Pavel Machek <pavel@ucw.cz>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Linux-pm mailing list <linux-pm@lists.osdl.org>,
Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Don't explode on swsusp failure to find swap
Date: Wed, 1 Jun 2005 11:27:42 +0200 [thread overview]
Message-ID: <20050601092742.GC6693@elf.ucw.cz> (raw)
In-Reply-To: <1117583403.5826.72.camel@gaston>
Hi!
> > > > If we specify a swap device for swsusp using resume= kernel argument and
> > > > that device doesn't exist in the swap list, we end up calling
> > > > swsusp_free() before we have allocated pagedir_save. That causes us to
> > > > explode when trying to free it.
> > > >
> > > > Pavel, does that look right ?
> > >
> > > It looks like a workaround. We should not call swsusp_free in case
> > > device does not exists. Quick look did not reveal where the bug comes
> > > from, can you try to trace it?
> > > Pavel
> >
> > Well, the bug comes from arch code calling swsusp_save() which fails,
> > then we call swsusp_free()
>
> More specifically, arch suspend calls swsusp_save().
>
> It fails and returns the error to the arch asm code, which itself
> returns it to it's caller swsusp_suspend(), which does that:
>
> if ((error = swsusp_arch_suspend()))
> swsusp_free();
Ugh, swsusp_free should be totally unneccessary at this point; only
error returns are from the time before anything is allocated.
Does something like this help?
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -975,13 +975,6 @@ extern asmlinkage int swsusp_arch_resume
asmlinkage int swsusp_save(void)
{
- int error = 0;
-
- if ((error = swsusp_swap_check())) {
- printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try "
- "swapon -a!\n");
- return error;
- }
return suspend_prepare_image();
}
@@ -999,12 +992,19 @@ int swsusp_suspend(void)
*/
if ((error = device_power_down(PMSG_FREEZE))) {
local_irq_enable();
- swsusp_free();
return error;
}
+
+ if ((error = swsusp_swap_check())) {
+ printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try "
+ "swapon -a!\n");
+ local_irq_enable();
+ return error;
+ }
+
save_processor_state();
if ((error = swsusp_arch_suspend()))
- swsusp_free();
+ printk("Error %d suspending\n", error);
/* Restore control flow magically appears here */
restore_processor_state();
BUG_ON (nr_copy_pages_check != nr_copy_pages);
next prev parent reply other threads:[~2005-06-01 9:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-31 7:13 [PATCH] Don't explode on swsusp failure to find swap Benjamin Herrenschmidt
2005-05-31 7:13 ` Benjamin Herrenschmidt
2005-05-31 10:36 ` Pavel Machek
2005-05-31 10:36 ` Pavel Machek
2005-05-31 14:45 ` Benjamin Herrenschmidt
2005-05-31 14:45 ` Benjamin Herrenschmidt
2005-05-31 23:50 ` Benjamin Herrenschmidt
2005-05-31 23:50 ` Benjamin Herrenschmidt
2005-06-01 6:52 ` Shaohua Li
2005-06-01 6:52 ` [linux-pm] " Shaohua Li
2005-06-01 9:29 ` Pavel Machek
2005-06-01 9:29 ` [linux-pm] " Pavel Machek
2005-06-01 9:27 ` Pavel Machek [this message]
2005-06-01 9:27 ` Pavel Machek
2005-06-01 19:20 ` [linux-pm] " Rafael J. Wysocki
2005-06-01 20:42 ` Pavel Machek
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=20050601092742.GC6693@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.osdl.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.