From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 5/7] [Suspend2] Serialise pageflags.
Date: Tue, 27 Jun 2006 08:31:46 +1000 [thread overview]
Message-ID: <20060626223145.3725.93463.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060626223128.3725.55605.stgit@nigel.suspend2.net>
Routines for serialising pageflags in an image header.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/pageflags.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 74 insertions(+), 0 deletions(-)
diff --git a/kernel/power/pageflags.c b/kernel/power/pageflags.c
index 7c00257..0b019de 100644
--- a/kernel/power/pageflags.c
+++ b/kernel/power/pageflags.c
@@ -56,3 +56,77 @@ int suspend_pageflags_space_needed(void)
return total;
}
+/* save_dyn_pageflags
+ *
+ * Description: Save a set of pageflags.
+ * Arguments: dyn_pageflags_t *: Pointer to the bitmap being saved.
+ */
+
+void save_dyn_pageflags(dyn_pageflags_t pagemap)
+{
+ int i, zone_num = 0;
+ struct zone *zone;
+
+ if (!*pagemap)
+ return;
+
+ for_each_zone(zone) {
+ int size = pages_for_zone(zone);
+
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ (char *) &zone_num, sizeof(int));
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ (char *) &size, sizeof(int));
+
+ for (i = 0; i < size; i++)
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ (char *) pagemap[zone_num][i], PAGE_SIZE);
+ zone_num++;
+ }
+ zone_num = -1;
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ (char *) &zone_num, sizeof(int));
+}
+
+/* load_dyn_pageflags
+ *
+ * Description: Load a set of pageflags.
+ * Arguments: dyn_pageflags_t *: Pointer to the bitmap being loaded.
+ * (It must be allocated before calling this routine).
+ */
+
+void load_dyn_pageflags(dyn_pageflags_t pagemap)
+{
+ int i, zone_num = 0, zone_check = 0;
+ struct zone *zone;
+
+ if (!pagemap)
+ return;
+
+ for_each_zone(zone) {
+ int size = 0;
+ suspend_active_writer->rw_header_chunk(READ, NULL,
+ (char *) &zone_check, sizeof(int));
+ if (zone_check != zone_num) {
+ printk("Zone check (%d) != zone_num (%d).\n",
+ zone_check, zone_num);
+ BUG();
+ }
+ suspend_active_writer->rw_header_chunk(READ, NULL,
+ (char *) &size, sizeof(int));
+
+ for (i = 0; i < size; i++)
+ suspend_active_writer->rw_header_chunk(READ, NULL,
+ (char *) pagemap[zone_num][i],
+ PAGE_SIZE);
+ zone_num++;
+ }
+ suspend_active_writer->rw_header_chunk(READ, NULL, (char *) &zone_check,
+ sizeof(int));
+ if (zone_check != -1) {
+ printk("Didn't read end of dyn pageflag data marker.(%x)\n",
+ zone_check);
+ BUG();
+ }
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
next prev parent reply other threads:[~2006-06-26 22:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 22:31 [Suspend2][ 0/7] Pageflags support Nigel Cunningham
2006-06-26 22:31 ` [Suspend2][ 1/7] [Suspend2] Pagedir.h Nigel Cunningham
2006-06-26 22:31 ` [Suspend2][ 2/7] [Suspend2] Return number of zones used Nigel Cunningham
2006-06-26 22:31 ` [Suspend2][ 3/7] [Suspend2] Pages for zone Nigel Cunningham
2006-06-26 22:31 ` [Suspend2][ 4/7] [Suspend2] Space needed to store one set of pageflags Nigel Cunningham
2006-06-26 22:31 ` Nigel Cunningham [this message]
2006-06-26 22:31 ` [Suspend2][ 6/7] [Suspend2] Relocate pageflags Nigel Cunningham
2006-06-26 22:31 ` [Suspend2][ 7/7] [Suspend2] Pageflags.h Nigel Cunningham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060626223145.3725.93463.stgit@nigel.suspend2.net \
--to=nigel@suspend2.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®