Skip to contentSkip to conversation

Remove page flags for software suspend

RFC PATCH In review Christoph Lameter 8 participants 55 messages Feb 16, 2007 – Mar 14, 2007

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

I think we can just move the flags completely into the kernel/power directory? This centralizes all your handling of pageflags into snapshot.c so that you need no external definitions anymore.

include/linux/mmzone.h +1 -0
Index: linux-2.6.20-mm1/include/linux/mmzone.h
===================================================================
@@ -295,6 +295,7 @@ struct zone {
 	unsigned long		spanned_pages;	/* total size, including holes */
 	unsigned long		present_pages;	/* amount of memory (excluding holes) */
 
+	unsigned long		*suspend_flags;
 	/*
 	 * rarely used fields:
 	 */
include/linux/page-flags.h +0 -12
Index: linux-2.6.20-mm1/include/linux/page-flags.h
===================================================================
@@ -82,13 +82,11 @@
 #define PG_private		11	/* If pagecache, has fs-private data */
 
 #define PG_writeback		12	/* Page is under writeback */
-#define PG_nosave		13	/* Used for system suspend/resume */
 #define PG_compound		14	/* Part of a compound page */
 #define PG_swapcache		15	/* Swap page: swp_entry_t in private */
 
 #define PG_mappedtodisk		16	/* Has blocks allocated on-disk */
 #define PG_reclaim		17	/* To be reclaimed asap */
-#define PG_nosave_free		18	/* Used for system suspend/resume */
 #define PG_buddy		19	/* Page is free, on buddy lists */
 
 #define PG_mlocked		20	/* Page is mlocked */
@@ -192,16 +190,6 @@ static inline void SetPageUptodate(struc
 #define TestClearPageWriteback(page) test_and_clear_bit(PG_writeback,	\
 							&(page)->flags)
 
-#define PageNosave(page)	test_bit(PG_nosave, &(page)->flags)
-#define SetPageNosave(page)	set_bit(PG_nosave, &(page)->flags)
-#define TestSetPageNosave(page)	test_and_set_bit(PG_nosave, &(page)->flags)
-#define ClearPageNosave(page)		clear_bit(PG_nosave, &(page)->flags)
-#define TestClearPageNosave(page)	test_and_clear_bit(PG_nosave, &(page)->flags)
-
-#define PageNosaveFree(page)	test_bit(PG_nosave_free, &(page)->flags)
-#define SetPageNosaveFree(page)	set_bit(PG_nosave_free, &(page)->flags)
-#define ClearPageNosaveFree(page)		clear_bit(PG_nosave_free, &(page)->flags)
-
 #define PageBuddy(page)		test_bit(PG_buddy, &(page)->flags)
 #define __SetPageBuddy(page)	__set_bit(PG_buddy, &(page)->flags)
 #define __ClearPageBuddy(page)	__clear_bit(PG_buddy, &(page)->flags)
include/linux/suspend.h +12 -1
Index: linux-2.6.20-mm1/include/linux/suspend.h
===================================================================
@@ -21,7 +22,6 @@ struct pbe {
 
 /* mm/page_alloc.c */
 extern void drain_local_pages(void);
-extern void mark_free_pages(struct zone *zone);
 
 #ifdef CONFIG_PM
 /* kernel/power/swsusp.c */
@@ -42,6 +42,18 @@ static inline int software_suspend(void)
 }
 #endif /* CONFIG_PM */
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+int suspend_flags_init(struct zone *zone, unsigned long zone_size_pages);
+void mark_free_pages(struct zone *zone);
+#else
+static inline int suspend_flags_init(struct zone *zone, unsigned long zone_size_pages)
+{
+	return 0;
+}
+
+static inline void mark_free_pages(struct zone *zone) {}
+#endif
+
 void save_processor_state(void);
 void restore_processor_state(void);
 struct saved_context;
mm/page_alloc.c +3 -34
Index: linux-2.6.20-mm1/mm/page_alloc.c
===================================================================
@@ -767,40 +767,6 @@ static void __drain_pages(unsigned int c
 }
 
 #ifdef CONFIG_PM
-
-void mark_free_pages(struct zone *zone)
-{
-	unsigned long pfn, max_zone_pfn;
-	unsigned long flags;
-	int order;
-	struct list_head *curr;
-
-	if (!zone->spanned_pages)
-		return;
-
-	spin_lock_irqsave(&zone->lock, flags);
-
-	max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
-	for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
-		if (pfn_valid(pfn)) {
-			struct page *page = pfn_to_page(pfn);
-
-			if (!PageNosave(page))
-				ClearPageNosaveFree(page);
-		}
-
-	for (order = MAX_ORDER - 1; order >= 0; --order)
-		list_for_each(curr, &zone->free_area[order].free_list) {
-			unsigned long i;
-
-			pfn = page_to_pfn(list_entry(curr, struct page, lru));
-			for (i = 0; i < (1UL << order); i++)
-				SetPageNosaveFree(pfn_to_page(pfn + i));
-		}
-
-	spin_unlock_irqrestore(&zone->lock, flags);
-}
-
 /*
  * Spill all of this CPU's per-cpu pages back into the buddy allocator.
  */
@@ -2354,6 +2320,9 @@ __meminit int init_currently_empty_zone(
 	ret = zone_wait_table_init(zone, size);
 	if (ret)
 		return ret;
+	ret = suspend_flags_init(zone, size);
+	if (ret)
+		return ret;
 	pgdat->nr_zones = zone_idx(zone) + 1;
 
 	zone->zone_start_pfn = zone_start_pfn;
kernel/power/snapshot.c +120 -0

126 lines not on this page · raw message

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 3 lines · Christoph Lameter

I think we can just move the flags completely into the kernel/power directory? This centralizes all your handling of pageflags into snapshot.c so that you need no external definitions anymore.

Yes, I think we can do it this way, but can we generally assume that the offset for eg. test_bit() won't be taken modulo 32 (or 64)?

And ...

Quoted 153 lines

Index: linux-2.6.20-mm1/include/linux/mmzone.h
===================================================================

include/linux/mmzone.h +1 -0
@@ -295,6 +295,7 @@ struct zone {
 	unsigned long		spanned_pages;	/* total size, including holes */
 	unsigned long		present_pages;	/* amount of memory (excluding holes) */
 
+	unsigned long		*suspend_flags;
 	/*
 	 * rarely used fields:
 	 */

Index: linux-2.6.20-mm1/include/linux/page-flags.h
===================================================================

include/linux/page-flags.h +0 -12
@@ -82,13 +82,11 @@
 #define PG_private		11	/* If pagecache, has fs-private data */
 
 #define PG_writeback		12	/* Page is under writeback */
-#define PG_nosave		13	/* Used for system suspend/resume */
 #define PG_compound		14	/* Part of a compound page */
 #define PG_swapcache		15	/* Swap page: swp_entry_t in private */
 
 #define PG_mappedtodisk		16	/* Has blocks allocated on-disk */
 #define PG_reclaim		17	/* To be reclaimed asap */
-#define PG_nosave_free		18	/* Used for system suspend/resume */
 #define PG_buddy		19	/* Page is free, on buddy lists */
 
 #define PG_mlocked		20	/* Page is mlocked */
@@ -192,16 +190,6 @@ static inline void SetPageUptodate(struc
 #define TestClearPageWriteback(page) test_and_clear_bit(PG_writeback,	\
 							&(page)->flags)
 
-#define PageNosave(page)	test_bit(PG_nosave, &(page)->flags)
-#define SetPageNosave(page)	set_bit(PG_nosave, &(page)->flags)
-#define TestSetPageNosave(page)	test_and_set_bit(PG_nosave, &(page)->flags)
-#define ClearPageNosave(page)		clear_bit(PG_nosave, &(page)->flags)
-#define TestClearPageNosave(page)	test_and_clear_bit(PG_nosave, &(page)->flags)
-
-#define PageNosaveFree(page)	test_bit(PG_nosave_free, &(page)->flags)
-#define SetPageNosaveFree(page)	set_bit(PG_nosave_free, &(page)->flags)
-#define ClearPageNosaveFree(page)		clear_bit(PG_nosave_free, &(page)->flags)
-
 #define PageBuddy(page)		test_bit(PG_buddy, &(page)->flags)
 #define __SetPageBuddy(page)	__set_bit(PG_buddy, &(page)->flags)
 #define __ClearPageBuddy(page)	__clear_bit(PG_buddy, &(page)->flags)

Index: linux-2.6.20-mm1/include/linux/suspend.h
===================================================================

include/linux/suspend.h +12 -1
@@ -21,7 +22,6 @@ struct pbe {
 
 /* mm/page_alloc.c */
 extern void drain_local_pages(void);
-extern void mark_free_pages(struct zone *zone);
 
 #ifdef CONFIG_PM
 /* kernel/power/swsusp.c */
@@ -42,6 +42,18 @@ static inline int software_suspend(void)
 }
 #endif /* CONFIG_PM */
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+int suspend_flags_init(struct zone *zone, unsigned long zone_size_pages);
+void mark_free_pages(struct zone *zone);
+#else
+static inline int suspend_flags_init(struct zone *zone, unsigned long zone_size_pages)
+{
+	return 0;
+}
+
+static inline void mark_free_pages(struct zone *zone) {}
+#endif
+
 void save_processor_state(void);
 void restore_processor_state(void);
 struct saved_context;

Index: linux-2.6.20-mm1/mm/page_alloc.c
===================================================================

mm/page_alloc.c +3 -34
@@ -767,40 +767,6 @@ static void __drain_pages(unsigned int c
 }
 
 #ifdef CONFIG_PM
-
-void mark_free_pages(struct zone *zone)
-{
-	unsigned long pfn, max_zone_pfn;
-	unsigned long flags;
-	int order;
-	struct list_head *curr;
-
-	if (!zone->spanned_pages)
-		return;
-
-	spin_lock_irqsave(&zone->lock, flags);
-
-	max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
-	for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
-		if (pfn_valid(pfn)) {
-			struct page *page = pfn_to_page(pfn);
-
-			if (!PageNosave(page))
-				ClearPageNosaveFree(page);
-		}
-
-	for (order = MAX_ORDER - 1; order >= 0; --order)
-		list_for_each(curr, &zone->free_area[order].free_list) {
-			unsigned long i;
-
-			pfn = page_to_pfn(list_entry(curr, struct page, lru));
-			for (i = 0; i < (1UL << order); i++)
-				SetPageNosaveFree(pfn_to_page(pfn + i));
-		}
-
-	spin_unlock_irqrestore(&zone->lock, flags);
-}
-
 /*
  * Spill all of this CPU's per-cpu pages back into the buddy allocator.
  */
@@ -2354,6 +2320,9 @@ __meminit int init_currently_empty_zone(
 	ret = zone_wait_table_init(zone, size);
 	if (ret)
 		return ret;
+	ret = suspend_flags_init(zone, size);
+	if (ret)
+		return ret;
 	pgdat->nr_zones = zone_idx(zone) + 1;
 
 	zone->zone_start_pfn = zone_start_pfn;

Index: linux-2.6.20-mm1/kernel/power/snapshot.c
===================================================================

kernel/power/snapshot.c +12 -0
@@ -34,6 +34,126 @@
 
 #include "power.h"
 
+static inline int PageNosave(struct page *page)
+{
+	struct zone *zone = page_zone(page);
+	unsigned long offset = page_to_pfn(page) - zone->zone_start_pfn;
+
+	return test_bit(offset * 2, zone->suspend_flags);
+}
+
+static inline void SetPageNosave(struct page *page)
+{
+	struct zone *zone = page_zone(page);
+	unsigned long offset = page_to_pfn(page) - zone->zone_start_pfn;

kernel/power/snapshot.c line 58

Quoted 10 lines
kernel/power/snapshot.c +10 -0
+
+	set_bit(offset * 2, zone->suspend_flags);
+}
+
+static inline int TestSetPageNosave(struct page *page)
+{
+	struct zone *zone = page_zone(page);
+	unsigned long offset = page_to_pfn(page) - zone->zone_start_pfn;
+
+	return test_and_set_bit(offset * 2, zone->suspend_flags);

... I'd prefer

	unsigned long offset = (page_to_pfn(page) - zone->zone_start_pfn) << 1;

	return test_and_set_bit(offset, zone->suspend_flags);
Quoted 91 lines
kernel/power/snapshot.c +91 -0
+}
+
+static inline void ClearPageNosave(struct page *page)
+{
+	struct zone *zone = page_zone(page);
+	unsigned long offset = page_to_pfn(page) - zone->zone_start_pfn;
+
+	clear_bit(offset * 2, zone->suspend_flags);
+}
+
+static inline int TestClearPageNosave(struct page *page)
+{
+	struct zone *zone = page_zone(page);
+	unsigned long offset = page_to_pfn(page) - zone->zone_start_pfn;
+
+	return test_and_clear_bit(offset * 2, zone->suspend_flags);
+}
+
+
+static inline int PageNosaveFree(struct page *page)
+{
+	struct zone *zone = page_zone(page);
+	unsigned long offset = page_to_pfn(page) - zone->zone_start_pfn;
+
+	return test_bit(offset * 2 + 1, zone->suspend_flags);
+}
+
+static inline void SetPageNosaveFree(struct page *page)
+{
+	struct zone *zone = page_zone(page);
+	unsigned long offset = page_to_pfn(page) - zone->zone_start_pfn;
+
+	set_bit(offset * 2 + 1, zone->suspend_flags);
+}
+
+static inline void ClearPageNosaveFree(struct page *page)
+{
+	struct zone *zone = page_zone(page);
+	unsigned long offset = page_to_pfn(page) - zone->zone_start_pfn;
+
+	clear_bit(offset * 2 + 1, zone->suspend_flags);
+}
+
+int suspend_flags_init(struct zone *zone, unsigned long zone_size_pages)
+{
+	struct pglist_data *pgdat = zone->zone_pgdat;
+	size_t alloc_size;
+
+	/*
+	 * We need two bits per page in the zone. One for PageNosave and the other
+	 * for PageNosaveFree.
+	 */
+	alloc_size = BITS_TO_LONGS(zone_size_pages * 2);
+ 	if (system_state == SYSTEM_BOOTING) {
+		zone->suspend_flags = (unsigned long *)
+			alloc_bootmem_node(pgdat, alloc_size);
+	} else
+		zone->suspend_flags = (unsigned long *)vmalloc(alloc_size);
+	if (!zone->suspend_flags)
+		return -ENOMEM;
+
+	bitmap_zero(zone->suspend_flags, 2 * zone_size_pages);
+	return 0;
+}
+
+void mark_free_pages(struct zone *zone)
+{
+	unsigned long pfn, max_zone_pfn;
+	unsigned long flags;
+	int order;
+	struct list_head *curr;
+
+	if (!zone->spanned_pages)
+		return;
+
+	spin_lock_irqsave(&zone->lock, flags);
+
+	max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
+	for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
+		if (pfn_valid(pfn)) {
+			struct page *page = pfn_to_page(pfn);
+
+			if (!PageNosave(page))
+				ClearPageNosaveFree(page);
+		}
+
+	for (order = MAX_ORDER - 1; order >= 0; --order)
+		list_for_each(curr, &zone->free_area[order].free_list) {
+			unsigned long i;
+
+			pfn = page_to_pfn(list_entry(curr, struct page, lru));

kernel/power/snapshot.c line 159

Quoted 10 lines
kernel/power/snapshot.c +7 -0
+			for (i = 0; i < (1UL << order); i++)
+				SetPageNosaveFree(pfn_to_page(pfn + i));
+		}
+
+	spin_unlock_irqrestore(&zone->lock, flags);
+}
+
 /* List of PBEs needed for restoring the pages that were allocated before
  * the suspend and included in the suspend image, but have also been
  * allocated by the "resume" kernel, so their contents cannot be written

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw

Hi!

Quoted 6 lines
Quoted 3 lines

I think we can just move the flags completely into the kernel/power directory? This centralizes all your handling of pageflags into snapshot.c so that you need no external definitions anymore.

Yes, I think we can do it this way, but can we generally assume that the offset for eg. test_bit() won't be taken modulo 32 (or 64)?

I... actually do not like that patch. It adds code... at little or no benefit.

(And Nigel, please cc me when changing kernel/power/*).
Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 2 lines · Pavel Machek

I... actually do not like that patch. It adds code... at little or no benefit.

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
Quoted 8 lines · Christoph Lameter
Quoted 2 lines · Pavel Machek

I... actually do not like that patch. It adds code... at little or no benefit.

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
Quoted 3 lines · Rafael J. Wysocki

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

Ummm.. There are other parties who would like to use these flags!

I think my patch localizes the suspend material properly. In fact there is *no* reason for the page flags to be visible outside of snapshot.c. What is the problem with the patch?

How long will it take you to remove the flags on your own?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
Quoted 7 lines · Christoph Lameter
Quoted 3 lines · Rafael J. Wysocki

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

Ummm.. There are other parties who would like to use these flags!

Yes, I know that. On the other hand, we have terminally broken CPU hotplug code in the kernel that I'd like to get fixed _first_.

Quoted 2 lines

I think my patch localizes the suspend material properly. In fact there is *no* reason for the page flags to be visible outside of snapshot.c.

Yes, there is. PageNosave should be visible to the architectures so that they can mark nosave pages for the suspend.

Quoted 1 line

What is the problem with the patch?

PageNosaveFree is only needed at the suspend time, so we need not allocate it in advance.

Quoted 1 line

How long will it take you to remove the flags on your own?

I can't promise anything, because that also depends on people who work on the CPU hotplug, workqueues etc. and these things are hard. I'll do that as soon as I can.

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw
Quoted 2 lines · Rafael J. Wysocki

Yes, I know that. On the other hand, we have terminally broken CPU hotplug code in the kernel that I'd like to get fixed _first_.

The cpu hotplug code has been terminal for years.

Quoted 2 lines

PageNosaveFree is only needed at the suspend time, so we need not allocate it in advance.

Well it should be simple to change the patch to allocate the bitmaps later.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
Quoted 6 lines · Christoph Lameter
Quoted 2 lines · Rafael J. Wysocki

Yes, I know that. On the other hand, we have terminally broken CPU hotplug code in the kernel that I'd like to get fixed _first_.

The cpu hotplug code has been terminal for years.

But recently it's been becoming a real pain.

Quoted 5 lines
Quoted 2 lines

PageNosaveFree is only needed at the suspend time, so we need not allocate it in advance.

Well it should be simple to change the patch to allocate the bitmaps later.

Well, yes, I think so. Still, there may be another way of doing it and I need some time to have a look.

BTW, have you tested the patch?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw

Hi!

Quoted 6 lines
Quoted 4 lines

Well, yes, I think so. Still, there may be another way of doing it and I need some time to have a look.

BTW, have you tested the patch?

Nope. Sorry, have no use for software suspend.

It is a matter of adding resume=/dev/hda9 to kernel cmdline and then echo disk

Quoted 1 line

/sys/power/state... I guess that is not too much to ask?

Anyway, if you want to submit patch to swsusp, please test it, and cc me on that mail.
Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#11 lore raw
In reply to Christoph Lameter
Quoted 9 lines · Christoph Lameter
Quoted 3 lines · Rafael J. Wysocki

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

Ummm.. There are other parties who would like to use these flags!

Lots of other parties. Let's make sure that no more backdoor page flags get allocated without going through the linux-mm list to work out whether we really need it or can live without it...

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#12 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Christoph Lameter
Quoted 2 lines · Pavel Machek

I... actually do not like that patch. It adds code... at little or no benefit.

Quoted 6 lines
Quoted 1 line

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

I need one bit for lockless pagecache ;)

Anyway, I guess if you want something done you have to do it yourself.

This patch still needs work (and I don't know if it even works, because I can't make swsusp resume even on a vanilla kernel). But this is my WIP for removing swsusp page flags.

This patch adds a simple extent based nosave region tracker, and rearranges some of the snapshot code to be a bit simpler and more amenable to having dynamically allocated flags (they aren't actually dynamically allocated in this patch, however).

Signature · 1 line
SUSE Labs, Novell Inc.
---
 arch/x86_64/kernel/e820.c  |    8 --
 include/linux/page-flags.h |   33 ++++----
 include/linux/suspend.h    |   12 ++-
 kernel/power/Makefile      |    2 
 kernel/power/main.c        |    4 +
 kernel/power/nosave.c      |  103 +++++++++++++++++++++++++++
 kernel/power/power.h       |    1 
 kernel/power/snapshot.c    |  167 ++++++++++++++++++++++-----------------------
 mm/page_alloc.c            |   34 ---------
 9 files changed, 222 insertions(+), 142 deletions(-)
include/linux/suspend.h +11 -1
Index: linux-2.6/include/linux/suspend.h
===================================================================
@@ -21,7 +21,6 @@ struct pbe {
 
 /* mm/page_alloc.c */
 extern void drain_local_pages(void);
-extern void mark_free_pages(struct zone *zone);
 
 #ifdef CONFIG_PM
 /* kernel/power/swsusp.c */
@@ -42,6 +41,17 @@ static inline int software_suspend(void)
 }
 #endif /* CONFIG_PM */
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+/* kernel/power/nosave.c */
+extern int __init register_nosave_region(unsigned long start_pfn, unsigned long end_pfn);
+#else
+static inline int register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
+{
+	return 0;
+}
+#endif
+
+
 void save_processor_state(void);
 void restore_processor_state(void);
 struct saved_context;
kernel/power/Makefile +1 -1
Index: linux-2.6/kernel/power/Makefile
===================================================================
@@ -5,6 +5,6 @@ endif
 
 obj-y				:= main.o process.o console.o
 obj-$(CONFIG_PM_LEGACY)		+= pm.o
-obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o disk.o snapshot.o swap.o user.o
+obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o disk.o snapshot.o swap.o user.o nosave.o
 
 obj-$(CONFIG_MAGIC_SYSRQ)	+= poweroff.o
kernel/power/nosave.c new file +103 -0

103 lines not on this page · raw message

kernel/power/power.h +1 -0
Index: linux-2.6/kernel/power/power.h
===================================================================
@@ -15,6 +15,7 @@ struct swsusp_info {
 
 #ifdef CONFIG_SOFTWARE_SUSPEND
 extern int pm_suspend_disk(void);
+extern int is_nosave_pfn(unsigned long pfn);
 
 #else
 static inline int pm_suspend_disk(void)
kernel/power/snapshot.c +84 -83

418 lines not on this page · raw message

arch/x86_64/kernel/e820.c +2 -6
Index: linux-2.6/arch/x86_64/kernel/e820.c
===================================================================
@@ -259,16 +259,12 @@ void __init e820_reserve_resources(void)
 static void __init
 e820_mark_nosave_range(unsigned long start, unsigned long end)
 {
-	unsigned long pfn, max_pfn;
-
 	if (start >= end)
 		return;
 
 	printk("Nosave address range: %016lx - %016lx\n", start, end);
-	max_pfn = end >> PAGE_SHIFT;
-	for (pfn = start >> PAGE_SHIFT; pfn < max_pfn; pfn++)
-		if (pfn_valid(pfn))
-			SetPageNosave(pfn_to_page(pfn));
+	if (register_nosave_region(start >> PAGE_SHIFT, end >> PAGE_SHIFT))
+		panic("Could not register nosave region\n");
 }
 
 /*
include/linux/page-flags.h +16 -17
Index: linux-2.6/include/linux/page-flags.h
===================================================================
@@ -82,14 +82,15 @@
 #define PG_private		11	/* If pagecache, has fs-private data */
 
 #define PG_writeback		12	/* Page is under writeback */
-#define PG_nosave		13	/* Used for system suspend/resume */
-#define PG_compound		14	/* Part of a compound page */
-#define PG_swapcache		15	/* Swap page: swp_entry_t in private */
-
-#define PG_mappedtodisk		16	/* Has blocks allocated on-disk */
-#define PG_reclaim		17	/* To be reclaimed asap */
-#define PG_nosave_free		18	/* Used for system suspend/resume */
-#define PG_buddy		19	/* Page is free, on buddy lists */
+#define PG_compound		13	/* Part of a compound page */
+#define PG_swapcache		14	/* Swap page: swp_entry_t in private */
+#define PG_mappedtodisk		15	/* Has blocks allocated on-disk */
+
+#define PG_reclaim		16	/* To be reclaimed asap */
+#define PG_buddy		17	/* Page is free, on buddy lists */
+
+#define PG_swsusp_image		18
+#define PG_swsusp_saved		19
 
 /* PG_owner_priv_1 users should have descriptive aliases */
 #define PG_checked		PG_owner_priv_1 /* Used by some filesystems */
@@ -214,15 +215,13 @@ static inline void SetPageUptodate(struc
 		ret;							\
 	})
 
-#define PageNosave(page)	test_bit(PG_nosave, &(page)->flags)
-#define SetPageNosave(page)	set_bit(PG_nosave, &(page)->flags)
-#define TestSetPageNosave(page)	test_and_set_bit(PG_nosave, &(page)->flags)
-#define ClearPageNosave(page)		clear_bit(PG_nosave, &(page)->flags)
-#define TestClearPageNosave(page)	test_and_clear_bit(PG_nosave, &(page)->flags)
-
-#define PageNosaveFree(page)	test_bit(PG_nosave_free, &(page)->flags)
-#define SetPageNosaveFree(page)	set_bit(PG_nosave_free, &(page)->flags)
-#define ClearPageNosaveFree(page)		clear_bit(PG_nosave_free, &(page)->flags)
+#define PageSwsuspImage(page)	test_bit(PG_swsusp_image, &(page)->flags)
+#define SetPageSwsuspImage(page) set_bit(PG_swsusp_image, &(page)->flags)
+#define ClearPageSwsuspImage(page) clear_bit(PG_swsusp_image, &(page)->flags)
+
+#define PageSwsuspSaved(page)	test_bit(PG_swsusp_saved, &(page)->flags)
+#define SetPageSwsuspSaved(page) set_bit(PG_swsusp_saved, &(page)->flags)
+#define ClearPageSwsuspSaved(page) clear_bit(PG_swsusp_saved, &(page)->flags)
 
 #define PageBuddy(page)		test_bit(PG_buddy, &(page)->flags)
 #define __SetPageBuddy(page)	__set_bit(PG_buddy, &(page)->flags)
kernel/power/main.c +4 -0
Index: linux-2.6/kernel/power/main.c
===================================================================
@@ -334,6 +334,10 @@ static int __init pm_init(void)
 	int error = subsystem_register(&power_subsys);
 	if (!error)
 		error = sysfs_create_group(&power_subsys.kset.kobj,&attr_group);
+	if (!error)
+		error = register_nosave_region(
+				__pa(&__nosave_begin) >> PAGE_SHIFT,
+				PAGE_ALIGN(__pa(&__nosave_end)) >> PAGE_SHIFT);
 	return error;
 }
 
mm/page_alloc.c +0 -34
Index: linux-2.6/mm/page_alloc.c
===================================================================
@@ -752,40 +752,6 @@ static void __drain_pages(unsigned int c
 }
 
 #ifdef CONFIG_PM
-
-void mark_free_pages(struct zone *zone)
-{
-	unsigned long pfn, max_zone_pfn;
-	unsigned long flags;
-	int order;
-	struct list_head *curr;
-
-	if (!zone->spanned_pages)
-		return;
-
-	spin_lock_irqsave(&zone->lock, flags);
-
-	max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
-	for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
-		if (pfn_valid(pfn)) {
-			struct page *page = pfn_to_page(pfn);
-
-			if (!PageNosave(page))
-				ClearPageNosaveFree(page);
-		}
-
-	for (order = MAX_ORDER - 1; order >= 0; --order)
-		list_for_each(curr, &zone->free_area[order].free_list) {
-			unsigned long i;
-
-			pfn = page_to_pfn(list_entry(curr, struct page, lru));
-			for (i = 0; i < (1UL << order); i++)
-				SetPageNosaveFree(pfn_to_page(pfn + i));
-		}
-
-	spin_unlock_irqrestore(&zone->lock, flags);
-}
-
 /*
  * Spill all of this CPU's per-cpu pages back into the buddy allocator.
  */
#13 lore raw
Quoted 22 lines · Nick Piggin
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Christoph Lameter
Quoted 2 lines · Pavel Machek

I... actually do not like that patch. It adds code... at little or no benefit.

Quoted 8 lines
Quoted 3 lines

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

I need one bit for lockless pagecache ;)

Anyway, I guess if you want something done you have to do it yourself.

Quoted 8 lines

This patch still needs work (and I don't know if it even works, because I can't make swsusp resume even on a vanilla kernel). But this is my WIP for removing swsusp page flags.

This patch adds a simple extent based nosave region tracker, and rearranges some of the snapshot code to be a bit simpler and more amenable to having dynamically allocated flags (they aren't actually dynamically allocated in this patch, however).

Thanks for the patch.

Probably I'd like to do some things in a different way, I'll think about that later today.

I hope I'll have a working patch that removes the "offending" page flags after the weekend.

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#14 lore raw
Quoted 32 lines · Rafael J. Wysocki
Quoted 22 lines · Nick Piggin
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Christoph Lameter
Quoted 2 lines · Pavel Machek

I... actually do not like that patch. It adds code... at little or no benefit.

Quoted 8 lines
Quoted 3 lines

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

I need one bit for lockless pagecache ;)

Anyway, I guess if you want something done you have to do it yourself.

Quoted 8 lines

This patch still needs work (and I don't know if it even works, because I can't make swsusp resume even on a vanilla kernel). But this is my WIP for removing swsusp page flags.

This patch adds a simple extent based nosave region tracker, and rearranges some of the snapshot code to be a bit simpler and more amenable to having dynamically allocated flags (they aren't actually dynamically allocated in this patch, however).

Quoted 7 lines

Thanks for the patch.

Probably I'd like to do some things in a different way, I'll think about that later today.

I hope I'll have a working patch that removes the "offending" page flags after the weekend.

Well, there is one problem that I think you can help me solve. Namely, the arch code that marks the nosave pages runs very early, before the buddy allocator is set up. Thus the question is how I can allocate a list of nosave regions at this stage of initialization, so that it survives to the point at which swsusp can be activated.

Please advise.

Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw

cover swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

In reply to Rafael J. Wysocki
Quoted 32 lines · Rafael J. Wysocki
Quoted 22 lines · Nick Piggin
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Christoph Lameter
Quoted 2 lines · Pavel Machek

I... actually do not like that patch. It adds code... at little or no benefit.

Quoted 8 lines
Quoted 3 lines

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

I need one bit for lockless pagecache ;)

Anyway, I guess if you want something done you have to do it yourself.

Quoted 8 lines

This patch still needs work (and I don't know if it even works, because I can't make swsusp resume even on a vanilla kernel). But this is my WIP for removing swsusp page flags.

This patch adds a simple extent based nosave region tracker, and rearranges some of the snapshot code to be a bit simpler and more amenable to having dynamically allocated flags (they aren't actually dynamically allocated in this patch, however).

Quoted 7 lines

Thanks for the patch.

Probably I'd like to do some things in a different way, I'll think about that later today.

I hope I'll have a working patch that removes the "offending" page flags after the weekend.

Okay, the next three messages contain patches that should do the trick.

They have been tested on x86_64, but not very thoroughly.

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#16 lore raw

RFC PATCH 1/3 swsusp: Do not use page flags directly

Make swsusp stop using SetPageNosave(), SetPageNosaveFree() and friends directly.

This way the amount of changes made in the next patch is smaller.

---
 include/linux/suspend.h |   33 +++++++++++++++++++++++++++++++++
 kernel/power/snapshot.c |   48 +++++++++++++++++++++++++-----------------------
 mm/page_alloc.c         |    6 +++---
 3 files changed, 61 insertions(+), 26 deletions(-)
include/linux/suspend.h +33 -0
Index: linux-2.6.21-rc2/include/linux/suspend.h
===================================================================
@@ -8,6 +8,7 @@
 #include <linux/notifier.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/mm.h>
 
 /* struct pbe is used for creating lists of pages that should be restored
  * atomically during the resume from disk, because the page frames they have
@@ -49,6 +50,38 @@ void __save_processor_state(struct saved
 void __restore_processor_state(struct saved_context *ctxt);
 unsigned long get_safe_page(gfp_t gfp_mask);
 
+/* Page management functions for the software suspend (swsusp) */
+
+static inline void swsusp_set_page_forbidden(struct page *page)
+{
+	SetPageNosave(page);
+}
+
+static inline int swsusp_page_is_forbidden(struct page *page)
+{
+	return PageNosave(page);
+}
+
+static inline void swsusp_unset_page_forbidden(struct page *page)
+{
+	ClearPageNosave(page);
+}
+
+static inline void swsusp_set_page_free(struct page *page)
+{
+	SetPageNosaveFree(page);
+}
+
+static inline int swsusp_page_is_free(struct page *page)
+{
+	return PageNosaveFree(page);
+}
+
+static inline void swsusp_unset_page_free(struct page *page)
+{
+	ClearPageNosaveFree(page);
+}
+
 /*
  * XXX: We try to keep some more pages free so that I/O operations succeed
  * without paging. Might this be more?
kernel/power/snapshot.c +25 -23

136 lines not on this page · raw message

mm/page_alloc.c +3 -3
Index: linux-2.6.21-rc2/mm/page_alloc.c
===================================================================
@@ -770,8 +770,8 @@ void mark_free_pages(struct zone *zone)
 		if (pfn_valid(pfn)) {
 			struct page *page = pfn_to_page(pfn);
 
-			if (!PageNosave(page))
-				ClearPageNosaveFree(page);
+			if (!swsusp_page_is_forbidden(page))
+				swsusp_unset_page_free(page);
 		}
 
 	for (order = MAX_ORDER - 1; order >= 0; --order)
@@ -780,7 +780,7 @@ void mark_free_pages(struct zone *zone)
 
 			pfn = page_to_pfn(list_entry(curr, struct page, lru));
 			for (i = 0; i < (1UL << order); i++)
-				SetPageNosaveFree(pfn_to_page(pfn + i));
+				swsusp_set_page_free(pfn_to_page(pfn + i));
 		}
 
 	spin_unlock_irqrestore(&zone->lock, flags);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#17 lore raw

Re: [RFC][PATCH 1/3] swsusp: Do not use page flags directly

Quoted 48 lines · Rafael J. Wysocki

Make swsusp stop using SetPageNosave(), SetPageNosaveFree() and friends directly.

This way the amount of changes made in the next patch is smaller.

---
 include/linux/suspend.h |   33 +++++++++++++++++++++++++++++++++
 kernel/power/snapshot.c |   48 +++++++++++++++++++++++++-----------------------
 mm/page_alloc.c         |    6 +++---
 3 files changed, 61 insertions(+), 26 deletions(-)

Index: linux-2.6.21-rc2/include/linux/suspend.h
===================================================================

include/linux/suspend.h +22 -0
@@ -8,6 +8,7 @@
 #include <linux/notifier.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/mm.h>
 
 /* struct pbe is used for creating lists of pages that should be restored
  * atomically during the resume from disk, because the page frames they have
@@ -49,6 +50,38 @@ void __save_processor_state(struct saved
 void __restore_processor_state(struct saved_context *ctxt);
 unsigned long get_safe_page(gfp_t gfp_mask);
 
+/* Page management functions for the software suspend (swsusp) */
+
+static inline void swsusp_set_page_forbidden(struct page *page)
+{
+	SetPageNosave(page);
+}
+
+static inline int swsusp_page_is_forbidden(struct page *page)
+{
+	return PageNosave(page);
+}
+
+static inline void swsusp_unset_page_forbidden(struct page *page)
+{
+	ClearPageNosave(page);
+}
+
+static inline void swsusp_set_page_free(struct page *page)
+{
+	SetPageNosaveFree(page);
+}

include/linux/suspend.h void __save_processor_state(struct saved · line 83

Quoted 10 lines
include/linux/suspend.h +10 -0
+
+static inline int swsusp_page_is_free(struct page *page)
+{
+	return PageNosaveFree(page);
+}
+
+static inline void swsusp_unset_page_free(struct page *page)
+{
+	ClearPageNosaveFree(page);
+}

Hi,

I don't have much to do with swsusp, but I really prefer that a page flag name should tell you what the property of the page is, rather than what this subsystem should or shouldn't do with it.

I thought the page flag names I used were pretty nice, and a big improvement overthe current page flag names.

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#18 lore raw

RFC PATCH 2/3 swsusp: Do not use page flags

In reply to Rafael J. Wysocki

Make swsusp use memory bitmaps instead of page flags for marking 'nosave' and free pages. This allows us to 'recycle' two page flags that can be used for other purposes. Also, the memory needed to store the bitmaps is allocated when necessary (ie. before the suspend) and freed after the resume which is more reasonable.

The patch is designed to minimize the amount of changes and there are some nice simplifications and optimizations possible on top of it. I am going to post them as separate patches in the future.

---
 arch/x86_64/kernel/e820.c |   26 +---
 include/linux/suspend.h   |   58 +++-------
 kernel/power/disk.c       |   23 +++-
 kernel/power/power.h      |    2 
 kernel/power/snapshot.c   |  250 +++++++++++++++++++++++++++++++++++++++++++---
 kernel/power/user.c       |    4 
 6 files changed, 281 insertions(+), 82 deletions(-)
include/linux/suspend.h +18 -40
Index: linux-2.6.21-rc2/include/linux/suspend.h
===================================================================
@@ -24,63 +24,41 @@ struct pbe {
 extern void drain_local_pages(void);
 extern void mark_free_pages(struct zone *zone);
 
-#ifdef CONFIG_PM
-/* kernel/power/swsusp.c */
-extern int software_suspend(void);
-
-#if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
+#if defined(CONFIG_PM) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
 extern int pm_prepare_console(void);
 extern void pm_restore_console(void);
 #else
 static inline int pm_prepare_console(void) { return 0; }
 static inline void pm_restore_console(void) {}
-#endif /* defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE) */
+#endif
+
+#if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND)
+/* kernel/power/swsusp.c */
+extern int software_suspend(void);
+/* kernel/power/snapshot.c */
+extern void __init register_nosave_region(unsigned long, unsigned long);
+extern int swsusp_page_is_forbidden(struct page *);
+extern void swsusp_set_page_free(struct page *);
+extern void swsusp_unset_page_free(struct page *);
+extern unsigned long get_safe_page(gfp_t gfp_mask);
 #else
 static inline int software_suspend(void)
 {
 	printk("Warning: fake suspend called\n");
 	return -ENOSYS;
 }
-#endif /* CONFIG_PM */
+
+static inline void register_nosave_region(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) {}
+#endif /* defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) */
 
 void save_processor_state(void);
 void restore_processor_state(void);
 struct saved_context;
 void __save_processor_state(struct saved_context *ctxt);
 void __restore_processor_state(struct saved_context *ctxt);
-unsigned long get_safe_page(gfp_t gfp_mask);
-
-/* Page management functions for the software suspend (swsusp) */
-
-static inline void swsusp_set_page_forbidden(struct page *page)
-{
-	SetPageNosave(page);
-}
-
-static inline int swsusp_page_is_forbidden(struct page *page)
-{
-	return PageNosave(page);
-}
-
-static inline void swsusp_unset_page_forbidden(struct page *page)
-{
-	ClearPageNosave(page);
-}
-
-static inline void swsusp_set_page_free(struct page *page)
-{
-	SetPageNosaveFree(page);
-}
-
-static inline int swsusp_page_is_free(struct page *page)
-{
-	return PageNosaveFree(page);
-}
-
-static inline void swsusp_unset_page_free(struct page *page)
-{
-	ClearPageNosaveFree(page);
-}
 
 /*
  * XXX: We try to keep some more pages free so that I/O operations succeed
kernel/power/snapshot.c +234 -16

299 lines not on this page · raw message

arch/x86_64/kernel/e820.c +6 -20
Index: linux-2.6.21-rc2/arch/x86_64/kernel/e820.c
===================================================================
@@ -17,6 +17,8 @@
 #include <linux/kexec.h>
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/suspend.h>
+#include <linux/pfn.h>
 
 #include <asm/pgtable.h>
 #include <asm/page.h>
@@ -255,22 +257,6 @@ void __init e820_reserve_resources(void)
 	}
 }
 
-/* Mark pages corresponding to given address range as nosave */
-static void __init
-e820_mark_nosave_range(unsigned long start, unsigned long end)
-{
-	unsigned long pfn, max_pfn;
-
-	if (start >= end)
-		return;
-
-	printk("Nosave address range: %016lx - %016lx\n", start, end);
-	max_pfn = end >> PAGE_SHIFT;
-	for (pfn = start >> PAGE_SHIFT; pfn < max_pfn; pfn++)
-		if (pfn_valid(pfn))
-			SetPageNosave(pfn_to_page(pfn));
-}
-
 /*
  * Find the ranges of physical addresses that do not correspond to
  * e820 RAM areas and mark the corresponding pages as nosave for software
@@ -289,13 +275,13 @@ void __init e820_mark_nosave_regions(voi
 		struct e820entry *ei = &e820.map[i];
 
 		if (paddr < ei->addr)
-			e820_mark_nosave_range(paddr,
-					round_up(ei->addr, PAGE_SIZE));
+			register_nosave_region(PFN_DOWN(paddr),
+						PFN_UP(ei->addr));
 
 		paddr = round_down(ei->addr + ei->size, PAGE_SIZE);
 		if (ei->type != E820_RAM)
-			e820_mark_nosave_range(round_up(ei->addr, PAGE_SIZE),
-					paddr);
+			register_nosave_region(PFN_UP(ei->addr),
+						PFN_DOWN(paddr));
 
 		if (paddr >= (end_pfn << PAGE_SHIFT))
 			break;
kernel/power/power.h +2 -0
Index: linux-2.6.21-rc2/kernel/power/power.h
===================================================================
@@ -49,6 +49,8 @@ extern sector_t swsusp_resume_block;
 extern asmlinkage int swsusp_arch_suspend(void);
 extern asmlinkage int swsusp_arch_resume(void);
 
+extern int create_basic_memory_bitmaps(void);
+extern void free_basic_memory_bitmaps(void);
 extern unsigned int count_data_pages(void);
 
 /**
kernel/power/user.c +4 -0
Index: linux-2.6.21-rc2/kernel/power/user.c
===================================================================
@@ -52,6 +52,9 @@ static int snapshot_open(struct inode *i
 	if ((filp->f_flags & O_ACCMODE) == O_RDWR)
 		return -ENOSYS;
 
+	if(create_basic_memory_bitmaps())
+		return -ENOMEM;
+
 	nonseekable_open(inode, filp);
 	data = &snapshot_state;
 	filp->private_data = data;
@@ -77,6 +80,7 @@ static int snapshot_release(struct inode
 	struct snapshot_data *data;
 
 	swsusp_free();
+	free_basic_memory_bitmaps();
 	data = filp->private_data;
 	free_all_swap_pages(data->swap, data->bitmap);
 	free_bitmap(data->bitmap);
kernel/power/disk.c +17 -6
Index: linux-2.6.21-rc2/kernel/power/disk.c
===================================================================
@@ -127,14 +127,19 @@ int pm_suspend_disk(void)
 		mdelay(5000);
 		goto Thaw;
 	}
+	/* Allocate memory management structures */
+	error = create_basic_memory_bitmaps();
+	if (error)
+		goto Thaw;
+
 	/* Free memory before shutting down devices. */
 	error = swsusp_shrink_memory();
 	if (error)
-		goto Thaw;
+		goto Finish;
 
 	error = platform_prepare();
 	if (error)
-		goto Thaw;
+		goto Finish;
 
 	suspend_console();
 	error = device_suspend(PMSG_FREEZE);
@@ -169,7 +174,7 @@ int pm_suspend_disk(void)
 			power_down(pm_disk_mode);
 		else {
 			swsusp_free();
-			goto Thaw;
+			goto Finish;
 		}
 	} else {
 		pr_debug("PM: Image restored successfully.\n");
@@ -182,6 +187,8 @@ int pm_suspend_disk(void)
 	platform_finish();
 	device_resume();
 	resume_console();
+ Finish:
+	free_basic_memory_bitmaps();
  Thaw:
 	unprepare_processes();
 	return error;
@@ -227,13 +234,15 @@ static int software_resume(void)
 	}
 
 	pr_debug("PM: Checking swsusp image.\n");
-
 	error = swsusp_check();
 	if (error)
-		goto Done;
+		goto Unlock;
 
-	pr_debug("PM: Preparing processes for restore.\n");
+	error = create_basic_memory_bitmaps();
+	if (error)
+		goto Unlock;
 
+	pr_debug("PM: Preparing processes for restore.\n");
 	error = prepare_processes();
 	if (error) {
 		swsusp_close();
@@ -275,7 +284,9 @@ static int software_resume(void)
 	printk(KERN_ERR "PM: Restore failed, recovering.\n");
 	unprepare_processes();
  Done:
+	free_basic_memory_bitmaps();
 	/* For success case, the suspend path will release the lock */
+ Unlock:
 	mutex_unlock(&pm_mutex);
 	pr_debug("PM: Resume from disk failed.\n");
 	return 0;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#19 lore raw

Re: [RFC][PATCH 2/3] swsusp: Do not use page flags

Quoted 37 lines · Rafael J. Wysocki

}

/**
+ * This structure represents a range of page frames the contents of which
+ * should not be saved during the suspend.
+ */

kernel/power/snapshot.c +31 -0
+
+struct nosave_region {
+	struct list_head list;
+	unsigned long start_pfn;
+	unsigned long end_pfn;
+};
+
+static LIST_HEAD(nosave_regions);
+
+/**
+ *	register_nosave_region - register a range of page frames the contents
+ *	of which should not be saved during the suspend (to be used in the early
+ *	initializatoion code)
+ */
+
+void __init
+register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
+{
+	struct nosave_region *region;
+
+	if (start_pfn >= end_pfn)
+		return;
+
+	if (!list_empty(&nosave_regions)) {
+		/* Try to extend the previous region (they should be sorted) */
+		region = list_entry(nosave_regions.prev,
+					struct nosave_region, list);
+		if (region->end_pfn == start_pfn) {
+			region->end_pfn = end_pfn;
+			goto Report;
+		}

kernel/power/snapshot.c static unsigned long memory_bm_next_pfn( · line 635

Quoted 10 lines
kernel/power/snapshot.c +10 -0
+	}
+	/* 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(&region->list, &nosave_regions);
+ Report:
+	printk("swsusp: Registered nosave memory region: %016lx - %016lx\n",
+		start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
+}

I wonder why you reimplemented this and put it in snapshot.c, rather than use my version which was nicely in its own file, had appropriate locking, etc.?

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#20 lore raw

Re: [RFC][PATCH 2/3] swsusp: Do not use page flags

Quoted 46 lines · Nick Piggin
Quoted 44 lines · Rafael J. Wysocki

}

/**
+ * This structure represents a range of page frames the contents of which
+ * should not be saved during the suspend.
+ */

kernel/power/snapshot.c +38 -0
+
+struct nosave_region {
+	struct list_head list;
+	unsigned long start_pfn;
+	unsigned long end_pfn;
+};
+
+static LIST_HEAD(nosave_regions);
+
+/**
+ *	register_nosave_region - register a range of page frames the contents
+ *	of which should not be saved during the suspend (to be used in the early
+ *	initializatoion code)
+ */
+
+void __init
+register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
+{
+	struct nosave_region *region;
+
+	if (start_pfn >= end_pfn)
+		return;
+
+	if (!list_empty(&nosave_regions)) {
+		/* Try to extend the previous region (they should be sorted) */
+		region = list_entry(nosave_regions.prev,
+					struct nosave_region, list);
+		if (region->end_pfn == start_pfn) {
+			region->end_pfn = end_pfn;
+			goto Report;
+		}
+	}
+	/* 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(&region->list, &nosave_regions);
+ Report:
Quoted 8 lines

kernel/power/snapshot.c static unsigned long memory_bm_next_pfn( · line 635

Quoted 3 lines
kernel/power/snapshot.c +3 -0
+	printk("swsusp: Registered nosave memory region: %016lx - %016lx\n",
+		start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
+}

I wonder why you reimplemented this and put it in snapshot.c, rather than use my version which was nicely in its own file, had appropriate locking, etc.?

Well, the locking is not necessary and we only need a list for that. Also, mark_nosave_pages() refers to a function that's invisible outside snapshot.c and I didn't think it was a good idea to separate mark_nosave_pages() from register_nosave_region().

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#21 lore raw

Re: [RFC][PATCH 2/3] swsusp: Do not use page flags

Quoted 59 lines · Rafael J. Wysocki
Quoted 47 lines · Nick Piggin
Quoted 44 lines · Rafael J. Wysocki

}

/**
+ * This structure represents a range of page frames the contents of which
+ * should not be saved during the suspend.
+ */

kernel/power/snapshot.c +38 -0
+
+struct nosave_region {
+	struct list_head list;
+	unsigned long start_pfn;
+	unsigned long end_pfn;
+};
+
+static LIST_HEAD(nosave_regions);
+
+/**
+ *	register_nosave_region - register a range of page frames the contents
+ *	of which should not be saved during the suspend (to be used in the early
+ *	initializatoion code)
+ */
+
+void __init
+register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
+{
+	struct nosave_region *region;
+
+	if (start_pfn >= end_pfn)
+		return;
+
+	if (!list_empty(&nosave_regions)) {
+		/* Try to extend the previous region (they should be sorted) */
+		region = list_entry(nosave_regions.prev,
+					struct nosave_region, list);
+		if (region->end_pfn == start_pfn) {
+			region->end_pfn = end_pfn;
+			goto Report;
+		}
+	}
+	/* 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(&region->list, &nosave_regions);
+ Report:
Quoted 8 lines

kernel/power/snapshot.c static unsigned long memory_bm_next_pfn( · line 635

Quoted 3 lines
kernel/power/snapshot.c +3 -0
+	printk("swsusp: Registered nosave memory region: %016lx - %016lx\n",
+		start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
+}

I wonder why you reimplemented this and put it in snapshot.c, rather than use my version which was nicely in its own file, had appropriate locking, etc.?

Quoted 1 line

Well, the locking is not necessary and we only need a list for that. Also,

I wouldn't say that. You're creating an interface here that is going to be used outside swsusp. Users of that interface may not need locking now, but that could cause problems down the line.

Sure you don't _need_ an rbtree, but our implementation makes it so simple that there isn't much downside.

Quoted 3 lines

mark_nosave_pages() refers to a function that's invisible outside snapshot.c and I didn't think it was a good idea to separate mark_nosave_pages() from register_nosave_region().

But that's because you even use mark_nosave_pages in your implementation. Mine uses the nosave regions directly.

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#22 lore raw

Re: [RFC][PATCH 2/3] swsusp: Do not use page flags

Quoted 60 lines · Nick Piggin
Quoted 59 lines · Rafael J. Wysocki
Quoted 55 lines · Nick Piggin
Quoted 37 lines · Rafael J. Wysocki

}

/**
+ * This structure represents a range of page frames the contents of which
+ * should not be saved during the suspend.
+ */

kernel/power/snapshot.c +31 -0
+
+struct nosave_region {
+	struct list_head list;
+	unsigned long start_pfn;
+	unsigned long end_pfn;
+};
+
+static LIST_HEAD(nosave_regions);
+
+/**
+ *	register_nosave_region - register a range of page frames the contents
+ *	of which should not be saved during the suspend (to be used in the early
+ *	initializatoion code)
+ */
+
+void __init
+register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
+{
+	struct nosave_region *region;
+
+	if (start_pfn >= end_pfn)
+		return;
+
+	if (!list_empty(&nosave_regions)) {
+		/* Try to extend the previous region (they should be sorted) */
+		region = list_entry(nosave_regions.prev,
+					struct nosave_region, list);
+		if (region->end_pfn == start_pfn) {
+			region->end_pfn = end_pfn;
+			goto Report;
+		}

kernel/power/snapshot.c static unsigned long memory_bm_next_pfn( · line 635

Quoted 10 lines
kernel/power/snapshot.c +10 -0
+	}
+	/* 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(&region->list, &nosave_regions);
+ Report:
+	printk("swsusp: Registered nosave memory region: %016lx - %016lx\n",
+		start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
+}

I wonder why you reimplemented this and put it in snapshot.c, rather than use my version which was nicely in its own file, had appropriate locking, etc.?

Quoted 5 lines
Quoted 1 line

Well, the locking is not necessary and we only need a list for that. Also,

I wouldn't say that. You're creating an interface here that is going to be used outside swsusp. Users of that interface may not need locking now, but that could cause problems down the line.

I think we can add the locking when it's necessary. For now, IMHO, it could be confusing to someone who doesn't know the locking is not needed.

Quoted 2 lines

Sure you don't _need_ an rbtree, but our implementation makes it so simple that there isn't much downside.

Not much, but the code is more complicated.

Quoted 6 lines
Quoted 3 lines

mark_nosave_pages() refers to a function that's invisible outside snapshot.c and I didn't think it was a good idea to separate mark_nosave_pages() from register_nosave_region().

But that's because you even use mark_nosave_pages in your implementation. Mine uses the nosave regions directly.

Well, I think we need two bits per page anyway, to mark free pages and pages allocated by swsusp, so using the nosave regions directly won't save us much.

Still, for now the bits are not optimally used, but I'm going to change that. I just wanted to avoid making too many changes at a time in this particular patch series.

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#23 lore raw

Re: [RFC][PATCH 2/3] swsusp: Do not use page flags

Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Nick Piggin

I wouldn't say that. You're creating an interface here that is going to be used outside swsusp. Users of that interface may not need locking now, but that could cause problems down the line.

I think we can add the locking when it's necessary. For now, IMHO, it could be confusing to someone who doesn't know the locking is not needed.

I don't know why it would confuse them. We just define the API to guarantee the correct locking, and that means the locking _is_ needed.

You don't have to care what the callers are doing. That's the beauty of a sane API.

Quoted 5 lines
Quoted 2 lines

Sure you don't _need_ an rbtree, but our implementation makes it so simple that there isn't much downside.

Not much, but the code is more complicated.

But it's in its own file and has a contained API, so it is very easy to review, test and verify.

Quoted 11 lines
Quoted 6 lines
Quoted 3 lines

mark_nosave_pages() refers to a function that's invisible outside snapshot.c and I didn't think it was a good idea to separate mark_nosave_pages() from register_nosave_region().

But that's because you even use mark_nosave_pages in your implementation. Mine uses the nosave regions directly.

Well, I think we need two bits per page anyway, to mark free pages and pages allocated by swsusp, so using the nosave regions directly won't save us much.

Well I think it is a cleaner though.

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#24 lore raw

Re: [RFC][PATCH 2/3] swsusp: Do not use page flags

Quoted 9 lines · Nick Piggin
Quoted 8 lines · Rafael J. Wysocki
Quoted 3 lines · Nick Piggin

I wouldn't say that. You're creating an interface here that is going to be used outside swsusp. Users of that interface may not need locking now, but that could cause problems down the line.

Quoted 5 lines
Quoted 2 lines

I think we can add the locking when it's necessary. For now, IMHO, it could be confusing to someone who doesn't know the locking is not needed.

I don't know why it would confuse them. We just define the API to guarantee the correct locking, and that means the locking _is_ needed.

Even if there are no users that actually need the locking and probably never will be?

For now, register_nosave_region() is to be called by architecture initialization code _only_ and there's no reason whatsoever why any architecture would need to call it concurrently from many places.

Quoted 2 lines

You don't have to care what the callers are doing. That's the beauty of a sane API.

Well, I don't think adding unneded infrastructure is a good thing.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Sure you don't _need_ an rbtree, but our implementation makes it so simple that there isn't much downside.

Not much, but the code is more complicated.

But it's in its own file and has a contained API, so it is very easy to review, test and verify.

I'm still thinking that register_nosave_region() in its current form is simpler and easier to review than the code using rbtrees. Still, of course this only is my personal opinion. :-)

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

mark_nosave_pages() refers to a function that's invisible outside snapshot.c and I didn't think it was a good idea to separate mark_nosave_pages() from register_nosave_region().

But that's because you even use mark_nosave_pages in your implementation. Mine uses the nosave regions directly.

Quoted 5 lines
Quoted 3 lines

Well, I think we need two bits per page anyway, to mark free pages and pages allocated by swsusp, so using the nosave regions directly won't save us much.

Well I think it is a cleaner though.

This is a matter of opinion, too ...

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#25 lore raw

Re: [RFC][PATCH 2/3] swsusp: Do not use page flags

Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Nick Piggin
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Nick Piggin

I wouldn't say that. You're creating an interface here that is going to be used outside swsusp. Users of that interface may not need locking now, but that could cause problems down the line.

I think we can add the locking when it's necessary. For now, IMHO, it could be confusing to someone who doesn't know the locking is not needed.

Quoted 6 lines
Quoted 2 lines

I don't know why it would confuse them. We just define the API to guarantee the correct locking, and that means the locking _is_ needed.

Even if there are no users that actually need the locking and probably never will be?

Probably is the keyword.

Why would you *not* make this a sane API? Surely performance isn't the reason? Nor complexity.

Quoted 10 lines

For now, register_nosave_region() is to be called by architecture initialization code _only_ and there's no reason whatsoever why any architecture would need to call it concurrently from many places.

Quoted 2 lines

You don't have to care what the callers are doing. That's the beauty of a sane API.

Well, I don't think adding unneded infrastructure is a good thing.

But defining good APIs is a very good thing. And with my good API, the lock is not unneeded.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

But that's because you even use mark_nosave_pages in your implementation. Mine uses the nosave regions directly.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Well, I think we need two bits per page anyway, to mark free pages and pages allocated by swsusp, so using the nosave regions directly won't save us much.

Well I think it is a cleaner though.

This is a matter of opinion, too ...

Well, as I'm not volunteering to maintain swsusp, if your opinion is that your way is cleaner, I can't argue ;) So long as it stops wasting those page flags then I'm happy.

However the register_nosave API really should use locking, I think. There is absolutely no downside, AFAIKS.

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#26 lore raw

Re: [RFC][PATCH 2/3] swsusp: Do not use page flags

Quoted 57 lines · Nick Piggin
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Nick Piggin
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Nick Piggin

I wouldn't say that. You're creating an interface here that is going to be used outside swsusp. Users of that interface may not need locking now, but that could cause problems down the line.

I think we can add the locking when it's necessary. For now, IMHO, it could be confusing to someone who doesn't know the locking is not needed.

Quoted 6 lines
Quoted 2 lines

I don't know why it would confuse them. We just define the API to guarantee the correct locking, and that means the locking _is_ needed.

Even if there are no users that actually need the locking and probably never will be?

Probably is the keyword.

Why would you *not* make this a sane API? Surely performance isn't the reason? Nor complexity.

Quoted 10 lines

For now, register_nosave_region() is to be called by architecture initialization code _only_ and there's no reason whatsoever why any architecture would need to call it concurrently from many places.

Quoted 2 lines

You don't have to care what the callers are doing. That's the beauty of a sane API.

Well, I don't think adding unneded infrastructure is a good thing.

But defining good APIs is a very good thing. And with my good API, the lock is not unneeded.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

But that's because you even use mark_nosave_pages in your implementation. Mine uses the nosave regions directly.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Well, I think we need two bits per page anyway, to mark free pages and pages allocated by swsusp, so using the nosave regions directly won't save us much.

Well I think it is a cleaner though.

This is a matter of opinion, too ...

Quoted 6 lines

Well, as I'm not volunteering to maintain swsusp, if your opinion is that your way is cleaner, I can't argue ;) So long as it stops wasting those page flags then I'm happy.

However the register_nosave API really should use locking, I think. There is absolutely no downside, AFAIKS.

Hm, I can add the lock, but currently register_nosave_region() calls alloc_bootmem_low() directly, which means it won't even work outside the early initialization code which is single-threaded. For this reason I think that the locking can be added later, when register_nosave_region() is extended so that it can be called from other contexts too.

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#27 lore raw

RFC PATCH 3/3 mm: Remove nosave and nosave_free page flags

In reply to Rafael J. Wysocki

Remove two page flags that are no longer needed.

---
 include/linux/page-flags.h |   12 ------------
 1 file changed, 12 deletions(-)
include/linux/page-flags.h +0 -12
Index: linux-2.6.21-rc2/include/linux/page-flags.h
===================================================================
@@ -82,13 +82,11 @@
 #define PG_private		11	/* If pagecache, has fs-private data */
 
 #define PG_writeback		12	/* Page is under writeback */
-#define PG_nosave		13	/* Used for system suspend/resume */
 #define PG_compound		14	/* Part of a compound page */
 #define PG_swapcache		15	/* Swap page: swp_entry_t in private */
 
 #define PG_mappedtodisk		16	/* Has blocks allocated on-disk */
 #define PG_reclaim		17	/* To be reclaimed asap */
-#define PG_nosave_free		18	/* Used for system suspend/resume */
 #define PG_buddy		19	/* Page is free, on buddy lists */
 
 
@@ -212,16 +210,6 @@ static inline void SetPageUptodate(struc
 		ret;							\
 	})
 
-#define PageNosave(page)	test_bit(PG_nosave, &(page)->flags)
-#define SetPageNosave(page)	set_bit(PG_nosave, &(page)->flags)
-#define TestSetPageNosave(page)	test_and_set_bit(PG_nosave, &(page)->flags)
-#define ClearPageNosave(page)		clear_bit(PG_nosave, &(page)->flags)
-#define TestClearPageNosave(page)	test_and_clear_bit(PG_nosave, &(page)->flags)
-
-#define PageNosaveFree(page)	test_bit(PG_nosave_free, &(page)->flags)
-#define SetPageNosaveFree(page)	set_bit(PG_nosave_free, &(page)->flags)
-#define ClearPageNosaveFree(page)		clear_bit(PG_nosave_free, &(page)->flags)
-
 #define PageBuddy(page)		test_bit(PG_buddy, &(page)->flags)
 #define __SetPageBuddy(page)	__set_bit(PG_buddy, &(page)->flags)
 #define __ClearPageBuddy(page)	__clear_bit(PG_buddy, &(page)->flags)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#28 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

In reply to Rafael J. Wysocki
Quoted 3 lines · Rafael J. Wysocki

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 <[email protected]>

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.

---
 include/linux/suspend.h |   11 ++++++++++-
 kernel/power/snapshot.c |   12 +++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)
include/linux/suspend.h +10 -1
@@ -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) {}
kernel/power/snapshot.c +9 -3
@@ -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(&region->list, &nosave_regions);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#29 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 15 lines · Johannes Berg
Quoted 3 lines · Rafael J. Wysocki

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.

Quoted 4 lines

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.

Well, it may be needed for other things too.

Quoted 3 lines

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.

You're right, there's nothing like that.

Quoted 2 lines

Also, maybe passing in a gfp mask would be better (and we could use 0 to mean bootmem too, I'd think)

I think we should pass a mask. BTW, can you please check if the appended patch is sufficient?

Quoted 7 lines

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!

It only merges regions passed in the right order (ie. sorted).

Quoted 1 line

With this patch and appropriate changes to my suspend code, it works.

OK, thanks for testing!

Greetings,
Rafael

---
 kernel/power/snapshot.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
kernel/power/snapshot.c +12 -2
Index: linux-2.6.21-rc3/kernel/power/snapshot.c
===================================================================
@@ -624,8 +624,18 @@ register_nosave_region(unsigned long sta
 			goto Report;
 		}
 	}
-	/* This allocation cannot fail */
-	region = alloc_bootmem_low(sizeof(struct nosave_region));
+	if (system_state == SYSTEM_BOOTING) {
+		/* This allocation cannot fail */
+		region = alloc_bootmem_low(sizeof(struct nosave_region));
+	} else {
+		region = kzalloc(sizeof(struct nosave_region), GFP_ATOMIC);
+		if (!region) {
+			printk(KERN_WARNING "swsusp: Not enough memory "
+				"to register a nosave region!\n");
+			WARN_ON(1);
+			return;
+		}
+	}
 	region->start_pfn = start_pfn;
 	region->end_pfn = end_pfn;
 	list_add_tail(&region->list, &nosave_regions);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#30 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines

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.

Well, it may be needed for other things too.

Yeah, but it's probably better to wait for them :)

Quoted 2 lines

I think we should pass a mask. BTW, can you please check if the appended patch is sufficient?

Unfortunately I won't be able to actually try this on hardware until the 20th or so.

Quoted 3 lines
Quoted 1 line

With this patch and appropriate changes to my suspend code, it works.

OK, thanks for testing!

Forgot to mention, patches are at
http://johannes.sipsolutions.net/patches/ look for the latest powerpc-suspend-* patchset.

kernel/power/snapshot.c register_nosave_region(unsigned long sta · line 638

Quoted 12 lines
kernel/power/snapshot.c +12 -0
+	if (system_state == SYSTEM_BOOTING) {
+		/* This allocation cannot fail */
+		region = alloc_bootmem_low(sizeof(struct nosave_region));
+	} else {
+		region = kzalloc(sizeof(struct nosave_region), GFP_ATOMIC);
+		if (!region) {
+			printk(KERN_WARNING "swsusp: Not enough memory "
+				"to register a nosave region!\n");
+			WARN_ON(1);
+			return;
+		}
+	}

I don't think that'll be sufficient, system_state = SYSTEM_BOOTING is done only in init/main.c:init_post which is done after after calling the initcalls (they are called in do_basic_setup)

johannes

#31 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 10 lines · Johannes Berg
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines

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.

Well, it may be needed for other things too.

Yeah, but it's probably better to wait for them :)

Agreed.

Quoted 5 lines
Quoted 2 lines

I think we should pass a mask. BTW, can you please check if the appended patch is sufficient?

Unfortunately I won't be able to actually try this on hardware until the 20th or so.

OK, it's not an urgent thing. ;-)

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

With this patch and appropriate changes to my suspend code, it works.

OK, thanks for testing!

Forgot to mention, patches are at
http://johannes.sipsolutions.net/patches/ look for the latest powerpc-suspend-* patchset.

Thanks for the link.

Quoted 8 lines
Quoted 8 lines
kernel/power/snapshot.c +8 -0
+	if (system_state == SYSTEM_BOOTING) {
+		/* This allocation cannot fail */
+		region = alloc_bootmem_low(sizeof(struct nosave_region));
+	} else {
+		region = kzalloc(sizeof(struct nosave_region), GFP_ATOMIC);
+		if (!region) {
+			printk(KERN_WARNING "swsusp: Not enough memory "
+				"to register a nosave region!\n");
Quoted 8 lines

kernel/power/snapshot.c register_nosave_region(unsigned long sta · line 638

Quoted 4 lines
kernel/power/snapshot.c +4 -0
+			WARN_ON(1);
+			return;
+		}
+	}

I don't think that'll be sufficient, system_state = SYSTEM_BOOTING is done only in init/main.c:init_post which is done after after calling the initcalls (they are called in do_basic_setup)

Well, I don't think so. If I understand the definition of system_state correctly, it is initially equal to SYSTEM_BOOTING. Then, it's changed to SYSTEM_RUNNING in init/main.c after the bootmem has been freed.

Anyway, the patch works on x86_64. :-)

Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#32 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines

Unfortunately I won't be able to actually try this on hardware until the 20th or so.

OK, it's not an urgent thing. ;-)

True :)

Quoted 3 lines

Well, I don't think so. If I understand the definition of system_state correctly, it is initially equal to SYSTEM_BOOTING. Then, it's changed to SYSTEM_RUNNING in init/main.c after the bootmem has been freed.

No, I think you're confusing bootmem with initmem right now. If you actually look at the code then free_all_bootmem is called as part of mem_init() on powerpc, which is called from start_kernel() a long time before initcalls are done and system state is set.

Put it this way. By the time initcalls are done, I can no longer use bootmem. I tested this and it panics. But if you look at the code in init/main.c, system_state is only changed after initcalls are done.

Quoted 1 line

Anyway, the patch works on x86_64. :-)

Yeah but it worked before too ;)

johannes

#33 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 7 lines · Johannes Berg
Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines

Unfortunately I won't be able to actually try this on hardware until the 20th or so.

OK, it's not an urgent thing. ;-)

Quoted 7 lines

True :)

Quoted 3 lines

Well, I don't think so. If I understand the definition of system_state correctly, it is initially equal to SYSTEM_BOOTING. Then, it's changed to SYSTEM_RUNNING in init/main.c after the bootmem has been freed.

No, I think you're confusing bootmem with initmem right now.

Yes, you're right, sorry.

Quoted 7 lines

If you actually look at the code then free_all_bootmem is called as part of mem_init() on powerpc, which is called from start_kernel() a long time before initcalls are done and system state is set.

Put it this way. By the time initcalls are done, I can no longer use bootmem. I tested this and it panics. But if you look at the code in init/main.c, system_state is only changed after initcalls are done.

That's true.

In that case your patch seems to be the simplest one and I think it should go along with some code that will actually use it.

Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#34 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 2 lines · Rafael J. Wysocki

In that case your patch seems to be the simplest one and I think it should go along with some code that will actually use it.

Right. So if anyone else needs it feel free to pick up my patch, if not I'll submit it again as part of my "suspend on powermac G5" patchset when that is properly reviewed by the appropriate people. Assuming, of course, that this (yours) patchset is picked up.

johannes

#35 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

In reply to Rafael J. Wysocki

Hi!

kernel/power/snapshot.c register_nosave_region(unsigned long sta · line 637

Quoted 7 lines
kernel/power/snapshot.c +7 -0
+		region = kzalloc(sizeof(struct nosave_region), GFP_ATOMIC);
+		if (!region) {
+			printk(KERN_WARNING "swsusp: Not enough memory "
+				"to register a nosave region!\n");
+			WARN_ON(1);
+			return;
+		}

That's a no-no. ATOMIC alocations can fail, and no, WARN_ON is not enough. It is not a bug, they just fail.
Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#36 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 2 lines · Pavel Machek

That's a no-no. ATOMIC alocations can fail, and no, WARN_ON is not enough. It is not a bug, they just fail.

But like I said in my post, there's no way we can disable suspend to disk when they do, right now anyway. Also, this can't be called any later than a late initcall or such since it's __init, and thus there shouldn't be memory pressure yet that would cause this to fail.

In any case, I'd be much happier with having a "disable suspend" variable so we could print a big warning and set that flag.

johannes

#37 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Hi!

Quoted 10 lines
Quoted 2 lines

That's a no-no. ATOMIC alocations can fail, and no, WARN_ON is not enough. It is not a bug, they just fail.

But like I said in my post, there's no way we can disable suspend to disk when they do, right now anyway. Also, this can't be called any later than a late initcall or such since it's __init, and thus there shouldn't be memory pressure yet that would cause this to fail.

In any case, I'd be much happier with having a "disable suspend" variable so we could print a big warning and set that flag.

Patch would probably be accepted ;-).
Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#38 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

In reply to Johannes Berg
Quoted 9 lines · Johannes Berg
Quoted 2 lines · Pavel Machek

That's a no-no. ATOMIC alocations can fail, and no, WARN_ON is not enough. It is not a bug, they just fail.

But like I said in my post, there's no way we can disable suspend to disk when they do, right now anyway. Also, this can't be called any later than a late initcall or such since it's __init, and thus there shouldn't be memory pressure yet that would cause this to fail.

Exactly. If an atomic allocation fails at this stage, there is a bug IMHO (although not necessarily in our code).

Still, the patch is not sufficient, so that's just a theoretical thing.

Quoted 2 lines

In any case, I'd be much happier with having a "disable suspend" variable so we could print a big warning and set that flag.

Well, I think that if we can't get so little memory at this early stage, the kernel will have much more trouble anyway. ;-)

Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#39 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Hi!

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

That's a no-no. ATOMIC alocations can fail, and no, WARN_ON is not enough. It is not a bug, they just fail.

But like I said in my post, there's no way we can disable suspend to disk when they do, right now anyway. Also, this can't be called any later than a late initcall or such since it's __init, and thus there shouldn't be memory pressure yet that would cause this to fail.

Exactly. If an atomic allocation fails at this stage, there is a bug IMHO (although not necessarily in our code).

Ok, so just do a BUG(). WARN_ON(), then do something subtly wrong
during suspend is evil.
Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#40 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

In reply to Rafael J. Wysocki
Quoted 4 lines

Okay, the next three messages contain patches that should do the trick.

They have been tested on x86_64, but not very thoroughly.

Works on my powerbook as well. Never mind that usb is broken again with suspend to disk. And my own patches break both str and std right now.

But these (on top of wireless-dev which is currently about 2.6.21-rc2) work fine as long as I assume they don't break usb ;)

johannes

#41 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 7 lines · Johannes Berg
Quoted 4 lines

Okay, the next three messages contain patches that should do the trick.

They have been tested on x86_64, but not very thoroughly.

Works on my powerbook as well. Never mind that usb is broken again with suspend to disk. And my own patches break both str and std right now.

Ouch.

Quoted 2 lines

But these (on top of wireless-dev which is currently about 2.6.21-rc2) work fine as long as I assume they don't break usb ;)

Well, on my boxes they don't. ;-)

Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#42 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines

Works on my powerbook as well. Never mind that usb is broken again with suspend to disk. And my own patches break both str and std right now.

Ouch.

Actually. Some fluke or mismanagement of patches, my own patches are fine (the suspend set I just gave you the link to). Probably screwed something up during testing earlier.

Quoted 4 lines
Quoted 2 lines

But these (on top of wireless-dev which is currently about 2.6.21-rc2) work fine as long as I assume they don't break usb ;)

Well, on my boxes they don't. ;-)

Good :)
I think usb suspend is broken on my machine with and without these patches but I haven't tested it. I may debug it more some time, or just leave it since it works with str and I hardly ever std. Then again, maybe it's fine in -rc3, I'm still at -rc2 (due to wireless-dev not being up to date)

johannes

#43 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

In reply to Rafael J. Wysocki
Quoted 3 lines · Rafael J. Wysocki

Okay, the next three messages contain patches that should do the trick.

They have been tested on x86_64, but not very thoroughly.

They look good to me, but what do I know about swsusp :-) I'll stick them in my laptop's kernel (boring i386-UP) and see what happens.

I did notice you don't stick KERN_ prio markers in your printk()s not sure what to think of that (or if its common practise and I'm just not aware of it).

Thanks for doing this.

Peter

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#44 lore raw

Re: [RFC][PATCH 0/3] swsusp: Do not use page flags (was: Re: Remove page flags for software suspend)

Quoted 9 lines · Peter Zijlstra
Quoted 3 lines · Rafael J. Wysocki

Okay, the next three messages contain patches that should do the trick.

They have been tested on x86_64, but not very thoroughly.

They look good to me, but what do I know about swsusp :-) I'll stick them in my laptop's kernel (boring i386-UP) and see what happens.

Thanks!

Quoted 3 lines

I did notice you don't stick KERN_ prio markers in your printk()s not sure what to think of that (or if its common practise and I'm just not aware of it).

This means use the default (which initially is KERN_WARNING, AFAICT).

Quoted 1 line

Thanks for doing this.

You're welcome. :-)

Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#45 lore raw
In reply to Nick Piggin
Quoted 4 lines · Nick Piggin

Let's make sure that no more backdoor page flags get allocated without going through the linux-mm list to work out whether we really need it or can live without it...

Quoted 2 lines · Nick Piggin

I need one bit for lockless pagecache ;)

Is that still your PageNoNewRefs thing?
What was wrong with my atomic_cmpxchg suggestion?

Hugh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#46 lore raw

Sorry to take so long to reply. I was having issues with this account.

Quoted 7 lines · Hugh Dickins
Quoted 3 lines · Nick Piggin

Let's make sure that no more backdoor page flags get allocated without going through the linux-mm list to work out whether we really need it or can live without it...

Quoted 6 lines
Quoted 1 line · Nick Piggin

I need one bit for lockless pagecache ;)

Is that still your PageNoNewRefs thing?

Yes.

Quoted 1 line

What was wrong with my atomic_cmpxchg suggestion?

It is a very good suggestion. I think I ran into an issue where I had wanted to set PG_nonewrefs for a page with an elevated refcount or some other issue like that. Can't remember exactly -- I think it is fixable by reworking some code, but I had wanted to do taht as a subsequent patch.

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#47 lore raw
In reply to Nick Piggin

Hi,

Quoted 18 lines · Nick Piggin
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Christoph Lameter
Quoted 2 lines · Pavel Machek

I... actually do not like that patch. It adds code... at little or no benefit.

Quoted 8 lines
Quoted 3 lines

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

As I have already said for a couple of times, I think we can and I'm going to do it, but right now I'm a bit busy with other things that I consider as more urgent.

Quoted 6 lines

I need one bit for lockless pagecache ;)

Anyway, I guess if you want something done you have to do it yourself.

This patch still needs work (and I don't know if it even works, because I can't make swsusp resume even on a vanilla kernel).

That's interesting, BTW, because recently I've been having problems with finding a machine on which it doesn't work. ;-) If you could tell me (in private) what the problems are, I'd try to help.

Quoted 6 lines

But this is my WIP for removing swsusp page flags.

This patch adds a simple extent based nosave region tracker, and rearranges some of the snapshot code to be a bit simpler and more amenable to having dynamically allocated flags (they aren't actually dynamically allocated in this patch, however).

I like the idea of using just one bit for marking the allocated pages and the simplifications it allows us to make, but is it really true that all of the free pages and only the free pages will have page_count(page) == 0?

Also, the extents-related part is not exactly nice IMHO ...

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#48 lore raw

Hi!

Quoted 8 lines
Quoted 4 lines

Anyway, I guess if you want something done you have to do it yourself.

This patch still needs work (and I don't know if it even works, because I can't make swsusp resume even on a vanilla kernel).

That's interesting, BTW, because recently I've been having problems with finding a machine on which it doesn't work. ;-) If you could tell me (in private) what the problems are, I'd try to help.

Feel free to cc me.

(Actually, rafael, something is very wrong in 2.6.21-rc1+. I got broken swsusp, s2ram, bluetooth and MMC.)
Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#49 lore raw
In reply to Christoph Lameter

Hi!

Quoted 6 lines
Quoted 2 lines

I... actually do not like that patch. It adds code... at little or no benefit.

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

Hmm, can't we just add another word to struct page?

Plus we really need PageNosave from boot on...

Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#50 lore raw
Quoted 3 lines · Pavel Machek

Hmm, can't we just add another word to struct page?

Plus we really need PageNosave from boot on...

Well it would be great to get the story straight. First I was told that the bitmaps can be allocated later. Now we dont. The current patch should do what you want.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#51 lore raw
Quoted 3 lines · Christoph Lameter
Quoted 1 line · Pavel Machek

Hmm, can't we just add another word to struct page?

?

Quoted 5 lines
Quoted 1 line

Plus we really need PageNosave from boot on...

Well it would be great to get the story straight. First I was told that the bitmaps can be allocated later. Now we dont. The current patch should do what you want.

PageNosave is set by boot code in some cases, as Rafael told you.

It may be possible to redo boot processing at suspend time, but it would be ugly can of worms, I'm not sure if BIOS data are still available, and neccessary functions are probably __init.

Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#52 lore raw
Quoted 6 lines · Pavel Machek
Quoted 3 lines · Christoph Lameter
Quoted 1 line · Pavel Machek

Hmm, can't we just add another word to struct page?

?

That would be wasteful, I think, and PageNosaveFree isn't really needed outside the swsusp code.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Plus we really need PageNosave from boot on...

Yes.

Quoted 4 lines
Quoted 4 lines

Well it would be great to get the story straight. First I was told that the bitmaps can be allocated later. Now we dont. The current patch should do what you want.

Nope. There are two flags and one of them (PageNosaveFree) can and really should be allocated later, while the other (PageNosave) is needed from the start.

Quoted 5 lines

PageNosave is set by boot code in some cases, as Rafael told you.

It may be possible to redo boot processing at suspend time, but it would be ugly can of worms, I'm not sure if BIOS data are still available, and neccessary functions are probably __init.

Exactly.

Greetings,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#53 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek

Hi!

Quoted 4 lines
Quoted 2 lines

I... actually do not like that patch. It adds code... at little or no benefit.

We are looking into saving page flags since we are running out. The two page flags used by software suspend are rarely needed and should be taken out of the flags. If you can do it a different way then please do.

Hmm, can't we just add another word to struct page?

That's what we want to avoid. As soon as we add another word, then everbody goes crazy using it up and we can never remove it again.

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#54 lore raw
In reply to Rafael J. Wysocki

Hi!

Quoted 8 lines
Quoted 3 lines

I think we can just move the flags completely into the kernel/power directory? This centralizes all your handling of pageflags into snapshot.c so that you need no external definitions anymore.

Yes, I think we can do it this way, but can we generally assume that the offset for eg. test_bit() won't be taken modulo 32 (or 64)?

And ...

Ouch... I somehow assumed it was Nigel doing this patch, and noticed too late. Sorry.

I still wish to be cc-ed on swsusp changes.
Pavel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>