From: Johannes Berg <johannes@sipsolutions.net>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
Pavel Machek <pavel@ucw.cz>,
Christoph Lameter <clameter@engr.sgi.com>,
linux-mm@kvack.org, pm list <linux-pm@lists.osdl.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)
Date: Thu, 08 Mar 2007 02:00:25 +0100 [thread overview]
Message-ID: <1173315625.3546.32.camel@johannes.berg> (raw)
In-Reply-To: <200703041450.02178.rjw@sisk.pl>
On Sun, 2007-03-04 at 14:50 +0100, Rafael J. Wysocki wrote:
> Okay, the next three messages contain patches that should do the trick.
>
> They have been tested on x86_64, but not very thoroughly.
Looks nice, but I'm having some trouble with it. Solved too though :)
Thing is that I need to call register_nosave_region for a region
reserved for the IOMMU. Because the region is reserved so early during
boot I cannot call register_nosave_region at that time. However, I also
can't call register_nosave_region during a late initcall because at that
point bootmem can no longer be allocated. I could of course put a hook
somewhere into the arch code to do the marking, but I'd prefer not to.
The easiest solution I came up with is below. Of course, the suspend
patches for powerpc64 are still very much work in progress and I might
end up changing the whole reservation scheme after some feedback... If
nobody else needs this then don't think about it now.
However, would that patch be acceptable to you? What about error
handling? Printing a message and setting a "suspend not permitted"
variable would be great but I don't think such a variable exists. Also,
maybe passing in a gfp mask would be better (and we could use 0 to mean
bootmem too, I'd think)
Actually... I'd never have noticed this if register_nosave_region merged
regions. I have these two regions:
[ 0.000000] swsusp: Registered nosave memory region: 0000000080000000 - 0000000100000000
[...]
[ 19.406116] swsusp: Registered nosave memory region: 000000007f000000 - 0000000080000000
But they aren't merged, if they were the latter call wouldn't need to do
any allocations. Not that I'd want to rely on these positions!
With this patch and appropriate changes to my suspend code, it works.
johannes
---
Subject: [PATCH] swsusp: introduce register_nosave_region_late
From: Johannes Berg <johannes@sipsolutions.net>
This patch introduces a new register_nosave_region_late function that
can be called from initcalls when register_nosave_region can no longer
be used because it uses bootmem.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
include/linux/suspend.h | 11 ++++++++++-
kernel/power/snapshot.c | 12 +++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
--- linux-2.6-git.orig/include/linux/suspend.h 2007-03-08 01:25:37.248701500 +0100
+++ linux-2.6-git/include/linux/suspend.h 2007-03-08 01:41:49.967826495 +0100
@@ -36,7 +36,15 @@ static inline void pm_restore_console(vo
/* kernel/power/swsusp.c */
extern int software_suspend(void);
/* kernel/power/snapshot.c */
-extern void __init register_nosave_region(unsigned long, unsigned long);
+extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
+static inline void register_nosave_region(unsigned long b, unsigned long e)
+{
+ __register_nosave_region(b, e, 0);
+}
+static inline void register_nosave_region_late(unsigned long b, unsigned long e)
+{
+ __register_nosave_region(b, e, 1);
+}
extern int swsusp_page_is_forbidden(struct page *);
extern void swsusp_set_page_free(struct page *);
extern void swsusp_unset_page_free(struct page *);
@@ -49,6 +57,7 @@ static inline int software_suspend(void)
}
static inline void register_nosave_region(unsigned long b, unsigned long e) {}
+static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
static inline void swsusp_set_page_free(struct page *p) {}
static inline void swsusp_unset_page_free(struct page *p) {}
--- linux-2.6-git.orig/kernel/power/snapshot.c 2007-03-08 01:26:17.680701500 +0100
+++ linux-2.6-git/kernel/power/snapshot.c 2007-03-08 01:42:35.385826495 +0100
@@ -608,7 +608,8 @@ static LIST_HEAD(nosave_regions);
*/
void __init
-register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
+__register_nosave_region(unsigned long start_pfn, unsigned long end_pfn,
+ int use_kmalloc)
{
struct nosave_region *region;
@@ -624,8 +625,13 @@ register_nosave_region(unsigned long sta
goto Report;
}
}
- /* This allocation cannot fail */
- region = alloc_bootmem_low(sizeof(struct nosave_region));
+ if (use_kmalloc) {
+ /* during init, this shouldn't fail */
+ region = kmalloc(sizeof(struct nosave_region), GFP_KERNEL);
+ BUG_ON(!region);
+ } else
+ /* This allocation cannot fail */
+ region = alloc_bootmem_low(sizeof(struct nosave_region));
region->start_pfn = start_pfn;
region->end_pfn = end_pfn;
list_add_tail(®ion->list, &nosave_regions);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-03-08 1:00 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-16 10:13 Remove page flags for software suspend Christoph Lameter
2007-02-16 10:56 ` Rafael J. Wysocki
2007-02-28 10:14 ` Pavel Machek
2007-02-28 15:25 ` Christoph Lameter
2007-02-28 17:13 ` Rafael J. Wysocki
2007-02-28 17:17 ` Christoph Lameter
2007-02-28 17:33 ` Rafael J. Wysocki
2007-02-28 17:35 ` Christoph Lameter
2007-02-28 17:51 ` Rafael J. Wysocki
2007-02-28 17:56 ` Christoph Lameter
2007-02-28 21:11 ` Pavel Machek
2007-03-01 2:35 ` Nick Piggin
2007-03-01 15:18 ` Nick Piggin
2007-03-01 15:33 ` Rafael J. Wysocki
2007-03-01 23:10 ` Rafael J. Wysocki
2007-03-04 13:50 ` [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend) Rafael J. Wysocki
2007-03-04 14:07 ` [RFC][PATCH 1/3] swsusp: Do not use page flags directly Rafael J. Wysocki
2007-03-13 4:45 ` Nick Piggin
2007-03-04 14:07 ` [RFC][PATCH 2/3] swsusp: Do not use page flags Rafael J. Wysocki
2007-03-13 4:47 ` Nick Piggin
2007-03-13 9:16 ` Rafael J. Wysocki
2007-03-13 9:23 ` Nick Piggin
2007-03-13 10:17 ` Rafael J. Wysocki
2007-03-13 10:31 ` Nick Piggin
2007-03-13 21:20 ` Rafael J. Wysocki
2007-03-14 3:17 ` Nick Piggin
2007-03-14 8:30 ` Rafael J. Wysocki
2007-03-04 14:08 ` [RFC][PATCH 3/3] mm: Remove nosave and nosave_free " Rafael J. Wysocki
2007-03-08 1:00 ` Johannes Berg [this message]
2007-03-08 22:05 ` [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend) Rafael J. Wysocki
2007-03-08 22:10 ` Johannes Berg
2007-03-08 22:33 ` Rafael J. Wysocki
2007-03-08 22:43 ` Johannes Berg
2007-03-08 22:54 ` Rafael J. Wysocki
2007-03-08 22:54 ` Johannes Berg
2007-03-08 23:15 ` Pavel Machek
2007-03-08 23:21 ` Johannes Berg
2007-03-08 23:23 ` Pavel Machek
2007-03-08 23:34 ` Rafael J. Wysocki
2007-03-08 23:36 ` Pavel Machek
2007-03-08 15:09 ` Johannes Berg
2007-03-08 22:10 ` Rafael J. Wysocki
2007-03-08 22:12 ` Johannes Berg
2007-03-08 15:53 ` Peter Zijlstra
2007-03-08 22:11 ` Rafael J. Wysocki
2007-03-01 17:48 ` Remove page flags for software suspend Hugh Dickins
2007-03-13 3:36 ` Nick Piggin
2007-03-01 20:46 ` Rafael J. Wysocki
2007-03-02 10:17 ` Pavel Machek
2007-02-28 21:08 ` Pavel Machek
2007-02-28 21:16 ` Christoph Lameter
2007-02-28 21:22 ` Pavel Machek
2007-02-28 22:23 ` Rafael J. Wysocki
2007-03-01 2:31 ` Nick Piggin
2007-02-28 10:14 ` 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=1173315625.3546.32.camel@johannes.berg \
--to=johannes@sipsolutions.net \
--cc=a.p.zijlstra@chello.nl \
--cc=clameter@engr.sgi.com \
--cc=linux-mm@kvack.org \
--cc=linux-pm@lists.osdl.org \
--cc=nickpiggin@yahoo.com.au \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox