[Suspend2][ 05/10] [Suspend2] Highmem copyback routine.

From: Nigel Cunningham
Date: Tue Jun 27 2006 - 01:05:11 EST


A routine to restore highmem pages which were atomically copied. We use
data allocated prior to the atomic restore of lowmem, so also have to do
this before other processes are allowed to run.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

kernel/power/atomic_copy.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/kernel/power/atomic_copy.c b/kernel/power/atomic_copy.c
index 556e481..e565bf3 100644
--- a/kernel/power/atomic_copy.c
+++ b/kernel/power/atomic_copy.c
@@ -136,6 +136,38 @@ static unsigned long __suspend_get_next_
}

/*
+ * copyback_high: Restore highmem pages.
+ *
+ * Iterate through the source and destination bitmaps, restoring
+ * highmem pages that were atomically copied.
+ */
+void copyback_high(void)
+{
+ unsigned long *origpage;
+ unsigned long *copypage;
+
+ origoffset = __suspend_get_next_bit_on(origmap, &o_zone_num, -1);
+ copyoffset = __suspend_get_next_bit_on(copymap, &c_zone_num, -1);
+
+ while (o_zone_num < num_zones) {
+ if (zone_nosave[o_zone_num].is_highmem) {
+ origpage = (unsigned long *) kmap_atomic(pfn_to_page(origoffset), KM_USER1);
+ copypage = (unsigned long *) __va(copyoffset << PAGE_SHIFT);
+
+ memcpy(origpage, copypage, PAGE_SIZE);
+
+ kunmap_atomic(origpage, KM_USER1);
+ }
+
+ origoffset = __suspend_get_next_bit_on(origmap, &o_zone_num, origoffset);
+ copyoffset = __suspend_get_next_bit_on(copymap, &c_zone_num, copyoffset);
+ }
+}
+#else
+void copyback_high(void) { }
+#endif
+
+/*
* prepare_suspend2_pbe_list
*
* Prepare pageset2 pages for doing the atomic copy. If necessary,

--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/