All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] PM / hibernate: Image restore code improvements
@ 2016-06-29  0:58 Rafael J. Wysocki
  2016-06-29  1:00 ` [PATCH v2 1/3] PM / hibernate: Do not free preallocated safe pages during image restore Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-06-29  0:58 UTC (permalink / raw)
  To: Linux PM list; +Cc: Linux Kernel Mailing List

Hi,

This series basically is a resent of the following patches:

https://patchwork.kernel.org/patch/9186389/
https://patchwork.kernel.org/patch/9194255/
https://patchwork.kernel.org/patch/9194259/

with some changes moved from the first patch to the last one and
with the ordering changed.

The net result of applying the series should be the same as after applying
the above patches.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] PM / hibernate: Do not free preallocated safe pages during image restore
  2016-06-29  0:58 [PATCH 0/3] PM / hibernate: Image restore code improvements Rafael J. Wysocki
@ 2016-06-29  1:00 ` Rafael J. Wysocki
  2016-06-29  1:02 ` [PATCH v2 RESEND 2/3] PM / hibernate: Simplify mark_unsafe_pages() Rafael J. Wysocki
  2016-06-29  1:05 ` [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration Rafael J. Wysocki
  2 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-06-29  1:00 UTC (permalink / raw)
  To: Linux PM list; +Cc: Linux Kernel Mailing List

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The core image restoration code preallocates some safe pages
(ie. pages that weren't used by the image kernel before hibernation)
for future use before allocating the bulk of memory for loading the
image data.  Those safe pages are then freed so they can be allocated
again (with the memory management subsystem's help).  That's done to
ensure that there will be enough safe pages for temporary data
structures needed during image restoration.

However, it is not really necessary to free those pages after they
have been allocated.  They can be added to the (global) list of
safe pages right away and then picked up from there when needed
without freeing.

That reduces the overhead related to using safe pages, especially
in the arch-specific code, so modify the code accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 kernel/power/snapshot.c |   66 +++++++++++++++++++++++++++---------------------
 1 file changed, 38 insertions(+), 28 deletions(-)

Index: linux-pm/kernel/power/snapshot.c
===================================================================
--- linux-pm.orig/kernel/power/snapshot.c
+++ linux-pm/kernel/power/snapshot.c
@@ -74,6 +74,22 @@ void __init hibernate_image_size_init(vo
  */
 struct pbe *restore_pblist;
 
+/* struct linked_page is used to build chains of pages */
+
+#define LINKED_PAGE_DATA_SIZE	(PAGE_SIZE - sizeof(void *))
+
+struct linked_page {
+	struct linked_page *next;
+	char data[LINKED_PAGE_DATA_SIZE];
+} __packed;
+
+/*
+ * List of "safe" pages (ie. pages that were not used by the image kernel
+ * before hibernation) that may be used as temporary storage for image kernel
+ * memory contents.
+ */
+static struct linked_page *safe_pages_list;
+
 /* Pointer to an auxiliary buffer (1 page) */
 static void *buffer;
 
@@ -113,9 +129,21 @@ static void *get_image_page(gfp_t gfp_ma
 	return res;
 }
 
+static void *__get_safe_page(gfp_t gfp_mask)
+{
+	if (safe_pages_list) {
+		void *ret = safe_pages_list;
+
+		safe_pages_list = safe_pages_list->next;
+		memset(ret, 0, PAGE_SIZE);
+		return ret;
+	}
+	return get_image_page(gfp_mask, PG_SAFE);
+}
+
 unsigned long get_safe_page(gfp_t gfp_mask)
 {
-	return (unsigned long)get_image_page(gfp_mask, PG_SAFE);
+	return (unsigned long)__get_safe_page(gfp_mask);
 }
 
 static struct page *alloc_image_page(gfp_t gfp_mask)
@@ -150,15 +178,6 @@ static inline void free_image_page(void
 	__free_page(page);
 }
 
-/* struct linked_page is used to build chains of pages */
-
-#define LINKED_PAGE_DATA_SIZE	(PAGE_SIZE - sizeof(void *))
-
-struct linked_page {
-	struct linked_page *next;
-	char data[LINKED_PAGE_DATA_SIZE];
-} __packed;
-
 static inline void
 free_list_of_pages(struct linked_page *list, int clear_page_nosave)
 {
@@ -208,7 +227,8 @@ static void *chain_alloc(struct chain_al
 	if (LINKED_PAGE_DATA_SIZE - ca->used_space < size) {
 		struct linked_page *lp;
 
-		lp = get_image_page(ca->gfp_mask, ca->safe_needed);
+		lp = ca->safe_needed ? __get_safe_page(ca->gfp_mask) :
+					get_image_page(ca->gfp_mask, PG_ANY);
 		if (!lp)
 			return NULL;
 
@@ -2104,11 +2124,6 @@ static int unpack_orig_pfns(unsigned lon
 	return 0;
 }
 
-/* List of "safe" pages that may be used to store data loaded from the suspend
- * image
- */
-static struct linked_page *safe_pages_list;
-
 #ifdef CONFIG_HIGHMEM
 /* struct highmem_pbe is used for creating the list of highmem pages that
  * should be restored atomically during the resume from disk, because the page
@@ -2334,7 +2349,7 @@ static int
 prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
 {
 	unsigned int nr_pages, nr_highmem;
-	struct linked_page *sp_list, *lp;
+	struct linked_page *lp;
 	int error;
 
 	/* If there is no highmem, the buffer will not be necessary */
@@ -2362,9 +2377,9 @@ prepare_image(struct memory_bitmap *new_
 	 * NOTE: This way we make sure there will be enough safe pages for the
 	 * chain_alloc() in get_buffer().  It is a bit wasteful, but
 	 * nr_copy_pages cannot be greater than 50% of the memory anyway.
+	 *
+	 * nr_copy_pages cannot be less than allocated_unsafe_pages too.
 	 */
-	sp_list = NULL;
-	/* nr_copy_pages cannot be lesser than allocated_unsafe_pages */
 	nr_pages = nr_copy_pages - nr_highmem - allocated_unsafe_pages;
 	nr_pages = DIV_ROUND_UP(nr_pages, PBES_PER_LINKED_PAGE);
 	while (nr_pages > 0) {
@@ -2373,12 +2388,11 @@ prepare_image(struct memory_bitmap *new_
 			error = -ENOMEM;
 			goto Free;
 		}
-		lp->next = sp_list;
-		sp_list = lp;
+		lp->next = safe_pages_list;
+		safe_pages_list = lp;
 		nr_pages--;
 	}
 	/* Preallocate memory for the image */
-	safe_pages_list = NULL;
 	nr_pages = nr_copy_pages - nr_highmem - allocated_unsafe_pages;
 	while (nr_pages > 0) {
 		lp = (struct linked_page *)get_zeroed_page(GFP_ATOMIC);
@@ -2396,12 +2410,6 @@ prepare_image(struct memory_bitmap *new_
 		swsusp_set_page_free(virt_to_page(lp));
 		nr_pages--;
 	}
-	/* Free the reserved safe pages so that chain_alloc() can use them */
-	while (sp_list) {
-		lp = sp_list->next;
-		free_image_page(sp_list, PG_UNSAFE_CLEAR);
-		sp_list = lp;
-	}
 	return 0;
 
  Free:
@@ -2491,6 +2499,8 @@ int snapshot_write_next(struct snapshot_
 		if (error)
 			return error;
 
+		safe_pages_list = NULL;
+
 		error = memory_bm_create(&copy_bm, GFP_ATOMIC, PG_ANY);
 		if (error)
 			return error;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 RESEND 2/3] PM / hibernate: Simplify mark_unsafe_pages()
  2016-06-29  0:58 [PATCH 0/3] PM / hibernate: Image restore code improvements Rafael J. Wysocki
  2016-06-29  1:00 ` [PATCH v2 1/3] PM / hibernate: Do not free preallocated safe pages during image restore Rafael J. Wysocki
@ 2016-06-29  1:02 ` Rafael J. Wysocki
  2016-06-29  1:05 ` [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration Rafael J. Wysocki
  2 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-06-29  1:02 UTC (permalink / raw)
  To: Linux PM list; +Cc: Linux Kernel Mailing List

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Rework mark_unsafe_pages() to use a simpler method of clearing
all bits in free_pages_map and to set the bits for the "unsafe"
pages (ie. pages that were used by the image kernel before
hibernation) with the help of duplicate_memory_bitmap().

For this purpose, move the pfn_valid() check from mark_unsafe_pages()
to unpack_orig_pfns() where the "unsafe" pages are discovered.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 kernel/power/snapshot.c |   64 ++++++++++++++++++------------------------------
 1 file changed, 25 insertions(+), 39 deletions(-)

Index: linux-pm/kernel/power/snapshot.c
===================================================================
--- linux-pm.orig/kernel/power/snapshot.c
+++ linux-pm/kernel/power/snapshot.c
@@ -2019,53 +2019,41 @@ int snapshot_read_next(struct snapshot_h
 	return PAGE_SIZE;
 }
 
+static void duplicate_memory_bitmap(struct memory_bitmap *dst,
+				    struct memory_bitmap *src)
+{
+	unsigned long pfn;
+
+	memory_bm_position_reset(src);
+	pfn = memory_bm_next_pfn(src);
+	while (pfn != BM_END_OF_MAP) {
+		memory_bm_set_bit(dst, pfn);
+		pfn = memory_bm_next_pfn(src);
+	}
+}
+
 /**
  *	mark_unsafe_pages - mark the pages that cannot be used for storing
  *	the image during resume, because they conflict with the pages that
  *	had been used before suspend
  */
 
-static int mark_unsafe_pages(struct memory_bitmap *bm)
+static void mark_unsafe_pages(struct memory_bitmap *bm)
 {
-	struct zone *zone;
-	unsigned long pfn, max_zone_pfn;
+	unsigned long pfn;
 
-	/* Clear page flags */
-	for_each_populated_zone(zone) {
-		max_zone_pfn = zone_end_pfn(zone);
-		for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
-			if (pfn_valid(pfn))
-				swsusp_unset_page_free(pfn_to_page(pfn));
+	/* Clear the "free"/"unsafe" bit for all PFNs */
+	memory_bm_position_reset(free_pages_map);
+	pfn = memory_bm_next_pfn(free_pages_map);
+	while (pfn != BM_END_OF_MAP) {
+		memory_bm_clear_current(free_pages_map);
+		pfn = memory_bm_next_pfn(free_pages_map);
 	}
 
-	/* Mark pages that correspond to the "original" pfns as "unsafe" */
-	memory_bm_position_reset(bm);
-	do {
-		pfn = memory_bm_next_pfn(bm);
-		if (likely(pfn != BM_END_OF_MAP)) {
-			if (likely(pfn_valid(pfn)))
-				swsusp_set_page_free(pfn_to_page(pfn));
-			else
-				return -EFAULT;
-		}
-	} while (pfn != BM_END_OF_MAP);
+	/* Mark pages that correspond to the "original" PFNs as "unsafe" */
+	duplicate_memory_bitmap(free_pages_map, bm);
 
 	allocated_unsafe_pages = 0;
-
-	return 0;
-}
-
-static void
-duplicate_memory_bitmap(struct memory_bitmap *dst, struct memory_bitmap *src)
-{
-	unsigned long pfn;
-
-	memory_bm_position_reset(src);
-	pfn = memory_bm_next_pfn(src);
-	while (pfn != BM_END_OF_MAP) {
-		memory_bm_set_bit(dst, pfn);
-		pfn = memory_bm_next_pfn(src);
-	}
 }
 
 static int check_header(struct swsusp_info *info)
@@ -2115,7 +2103,7 @@ static int unpack_orig_pfns(unsigned lon
 		/* Extract and buffer page key for data page (s390 only). */
 		page_key_memorize(buf + j);
 
-		if (memory_bm_pfn_present(bm, buf[j]))
+		if (pfn_valid(buf[j]) && memory_bm_pfn_present(bm, buf[j]))
 			memory_bm_set_bit(bm, buf[j]);
 		else
 			return -EFAULT;
@@ -2357,9 +2345,7 @@ prepare_image(struct memory_bitmap *new_
 	buffer = NULL;
 
 	nr_highmem = count_highmem_image_pages(bm);
-	error = mark_unsafe_pages(bm);
-	if (error)
-		goto Free;
+	mark_unsafe_pages(bm);
 
 	error = memory_bm_create(new_bm, GFP_ATOMIC, PG_SAFE);
 	if (error)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration
  2016-06-29  0:58 [PATCH 0/3] PM / hibernate: Image restore code improvements Rafael J. Wysocki
  2016-06-29  1:00 ` [PATCH v2 1/3] PM / hibernate: Do not free preallocated safe pages during image restore Rafael J. Wysocki
  2016-06-29  1:02 ` [PATCH v2 RESEND 2/3] PM / hibernate: Simplify mark_unsafe_pages() Rafael J. Wysocki
@ 2016-06-29  1:05 ` Rafael J. Wysocki
  2016-08-11 21:06   ` Pavel Machek
  2 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-06-29  1:05 UTC (permalink / raw)
  To: Linux PM list; +Cc: Linux Kernel Mailing List

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

One of the memory bitmaps used by the hibernation image restoration
code is freed after the image has been loaded.

That is not quite efficient, though, because the memory pages used
for building that bitmap are known to be safe (ie. they were not
used by the image kernel before hibernation) and the arch-specific
code finalizing the image restoration may need them.  In that case
it needs to allocate those pages again via the memory management
subsystem, check if they are really safe again by consulting the
other bitmaps and so on.

To avoid that, recycle those pages by putting them into the global
list of known safe pages so that they can be given to the arch code
right away when necessary.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 kernel/power/snapshot.c |   40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Index: linux-pm/kernel/power/snapshot.c
===================================================================
--- linux-pm.orig/kernel/power/snapshot.c
+++ linux-pm/kernel/power/snapshot.c
@@ -158,6 +158,14 @@ static struct page *alloc_image_page(gfp
 	return page;
 }
 
+static void recycle_safe_page(void *page_address)
+{
+	struct linked_page *lp = page_address;
+
+	lp->next = safe_pages_list;
+	safe_pages_list = lp;
+}
+
 /**
  *	free_image_page - free page represented by @addr, allocated with
  *	get_image_page (page flags set by it must be cleared)
@@ -852,6 +860,34 @@ struct nosave_region {
 
 static LIST_HEAD(nosave_regions);
 
+static void recycle_zone_bm_rtree(struct mem_zone_bm_rtree *zone)
+{
+	struct rtree_node *node;
+
+	list_for_each_entry(node, &zone->nodes, list)
+		recycle_safe_page(node->data);
+
+	list_for_each_entry(node, &zone->leaves, list)
+		recycle_safe_page(node->data);
+}
+
+static void memory_bm_recycle(struct memory_bitmap *bm)
+{
+	struct mem_zone_bm_rtree *zone;
+	struct linked_page *p_list;
+
+	list_for_each_entry(zone, &bm->zones, list)
+		recycle_zone_bm_rtree(zone);
+
+	p_list = bm->p_list;
+	while (p_list) {
+		struct linked_page *lp = p_list;
+
+		p_list = lp->next;
+		recycle_safe_page(lp);
+	}
+}
+
 /**
  *	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
@@ -2542,9 +2578,9 @@ void snapshot_write_finalize(struct snap
 	/* Restore page key for data page (s390 only). */
 	page_key_write(handle->buffer);
 	page_key_free();
-	/* Free only if we have loaded the image entirely */
+	/* Do that only if we have loaded the image entirely */
 	if (handle->cur > 1 && handle->cur > nr_meta_pages + nr_copy_pages) {
-		memory_bm_free(&orig_bm, PG_UNSAFE_CLEAR);
+		memory_bm_recycle(&orig_bm);
 		free_highmem_data();
 	}
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration
  2016-06-29  1:05 ` [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration Rafael J. Wysocki
@ 2016-08-11 21:06   ` Pavel Machek
  2016-08-11 21:23     ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: Pavel Machek @ 2016-08-11 21:06 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux PM list, Linux Kernel Mailing List

Hi!

> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> One of the memory bitmaps used by the hibernation image restoration
> code is freed after the image has been loaded.
> 
> That is not quite efficient, though, because the memory pages used
> for building that bitmap are known to be safe (ie. they were not
> used by the image kernel before hibernation) and the arch-specific
> code finalizing the image restoration may need them.  In that case
> it needs to allocate those pages again via the memory management
> subsystem, check if they are really safe again by consulting the
> other bitmaps and so on.
> 
> To avoid that, recycle those pages by putting them into the global
> list of known safe pages so that they can be given to the arch code
> right away when necessary.

Ok, so you are trying to gain speed here? How much is the speedup?

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration
  2016-08-11 21:06   ` Pavel Machek
@ 2016-08-11 21:23     ` Rafael J. Wysocki
  2016-08-15 14:33       ` Pavel Machek
  0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-08-11 21:23 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Linux PM list, Linux Kernel Mailing List

On Thursday, August 11, 2016 11:06:15 PM Pavel Machek wrote:
> Hi!
> 
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > One of the memory bitmaps used by the hibernation image restoration
> > code is freed after the image has been loaded.
> > 
> > That is not quite efficient, though, because the memory pages used
> > for building that bitmap are known to be safe (ie. they were not
> > used by the image kernel before hibernation) and the arch-specific
> > code finalizing the image restoration may need them.  In that case
> > it needs to allocate those pages again via the memory management
> > subsystem, check if they are really safe again by consulting the
> > other bitmaps and so on.
> > 
> > To avoid that, recycle those pages by putting them into the global
> > list of known safe pages so that they can be given to the arch code
> > right away when necessary.
> 
> Ok, so you are trying to gain speed here? How much is the speedup?

This is more about making it easier to debug than about speed, TBH.

Avoiding bitmap operations and the mm subsystem involvement reduces
complexity and the number of places to look into in case something goes
wrong.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration
  2016-08-11 21:23     ` Rafael J. Wysocki
@ 2016-08-15 14:33       ` Pavel Machek
  2016-08-15 23:16         ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: Pavel Machek @ 2016-08-15 14:33 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux PM list, Linux Kernel Mailing List

On Thu 2016-08-11 23:23:20, Rafael J. Wysocki wrote:
> On Thursday, August 11, 2016 11:06:15 PM Pavel Machek wrote:
> > Hi!
> > 
> > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > 
> > > One of the memory bitmaps used by the hibernation image restoration
> > > code is freed after the image has been loaded.
> > > 
> > > That is not quite efficient, though, because the memory pages used
> > > for building that bitmap are known to be safe (ie. they were not
> > > used by the image kernel before hibernation) and the arch-specific
> > > code finalizing the image restoration may need them.  In that case
> > > it needs to allocate those pages again via the memory management
> > > subsystem, check if they are really safe again by consulting the
> > > other bitmaps and so on.
> > > 
> > > To avoid that, recycle those pages by putting them into the global
> > > list of known safe pages so that they can be given to the arch code
> > > right away when necessary.
> > 
> > Ok, so you are trying to gain speed here? How much is the speedup?
> 
> This is more about making it easier to debug than about speed, TBH.
> 
> Avoiding bitmap operations and the mm subsystem involvement reduces
> complexity and the number of places to look into in case something goes
> wrong.

Well, it looked like 3/3 just added code and did not remove anything,
so I fail to see how it makes code easier to follow...

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration
  2016-08-15 14:33       ` Pavel Machek
@ 2016-08-15 23:16         ` Rafael J. Wysocki
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-08-15 23:16 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Linux PM list, Linux Kernel Mailing List

On Monday, August 15, 2016 04:33:49 PM Pavel Machek wrote:
> On Thu 2016-08-11 23:23:20, Rafael J. Wysocki wrote:
> > On Thursday, August 11, 2016 11:06:15 PM Pavel Machek wrote:
> > > Hi!
> > > 
> > > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > > 
> > > > One of the memory bitmaps used by the hibernation image restoration
> > > > code is freed after the image has been loaded.
> > > > 
> > > > That is not quite efficient, though, because the memory pages used
> > > > for building that bitmap are known to be safe (ie. they were not
> > > > used by the image kernel before hibernation) and the arch-specific
> > > > code finalizing the image restoration may need them.  In that case
> > > > it needs to allocate those pages again via the memory management
> > > > subsystem, check if they are really safe again by consulting the
> > > > other bitmaps and so on.
> > > > 
> > > > To avoid that, recycle those pages by putting them into the global
> > > > list of known safe pages so that they can be given to the arch code
> > > > right away when necessary.
> > > 
> > > Ok, so you are trying to gain speed here? How much is the speedup?
> > 
> > This is more about making it easier to debug than about speed, TBH.
> > 
> > Avoiding bitmap operations and the mm subsystem involvement reduces
> > complexity and the number of places to look into in case something goes
> > wrong.
> 
> Well, it looked like 3/3 just added code and did not remove anything,
> so I fail to see how it makes code easier to follow...

With the patch what it takes to release a safe page and re-use it is to
(a) put it into the list of safe pages and (b) take it back from that list
when needed.

Without it what that takes is to (a) clear bitmap bits corresponding to the
page in two bitmaps, (b) free it, (c) allocate it again (which may involve
allocating a number of other pages that aren't "safe") and (d) set bits
corresponding to it in the bitmaps.  Clearly, more complicated.

And now if there's a memory corruption bug that looks like it might be
related to that code, in the "with the patch" case we know that the bitmaps
were not involved, for example.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-08-15 23:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29  0:58 [PATCH 0/3] PM / hibernate: Image restore code improvements Rafael J. Wysocki
2016-06-29  1:00 ` [PATCH v2 1/3] PM / hibernate: Do not free preallocated safe pages during image restore Rafael J. Wysocki
2016-06-29  1:02 ` [PATCH v2 RESEND 2/3] PM / hibernate: Simplify mark_unsafe_pages() Rafael J. Wysocki
2016-06-29  1:05 ` [PATCH v2 3/3] PM / hibernate: Recycle safe pages after image restoration Rafael J. Wysocki
2016-08-11 21:06   ` Pavel Machek
2016-08-11 21:23     ` Rafael J. Wysocki
2016-08-15 14:33       ` Pavel Machek
2016-08-15 23:16         ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.