mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 08/10] [Suspend2] Atomic copy routine
Date: Tue, 27 Jun 2006 14:39:13 +1000	[thread overview]
Message-ID: <20060627043912.14546.41377.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060627043846.14546.75810.stgit@nigel.suspend2.net>

When suspending, this routine is used to make the atomic copy of memory.
Like swsusp, it is done in C.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

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

diff --git a/kernel/power/atomic_copy.c b/kernel/power/atomic_copy.c
index cb3663c..75e3beb 100644
--- a/kernel/power/atomic_copy.c
+++ b/kernel/power/atomic_copy.c
@@ -302,3 +302,50 @@ int suspend_post_context_save(void)
 	return 0;
 }
 
+/* suspend_copy_pageset1: Do the atomic copy of pageset1.
+ *
+ * Make the atomic copy of pageset1. We can't use copy_page (as we once did)
+ * because we can't be sure what side effects it has. On my old Duron, with
+ * 3DNOW, kernel_fpu_begin increments preempt count, making our preempt
+ * count at resume time 4 instead of 3.
+ * 
+ * We don't want to call kmap_atomic unconditionally because it has the side
+ * effect of incrementing the preempt count, which will leave it one too high
+ * post resume (the page containing the preempt count will be copied after
+ * its incremented. This is essentially the same problem.
+ */
+
+void suspend_copy_pageset1(void)
+{
+	int i, source_index, dest_index;
+
+	source_index = get_next_bit_on(pageset1_map, -1);
+	dest_index = get_next_bit_on(pageset1_copy_map, -1);
+
+	for (i = 0; i < pagedir1.pageset_size; i++) {
+		unsigned long *origvirt, *copyvirt;
+		struct page *origpage;
+		int loop = (PAGE_SIZE / sizeof(unsigned long)) - 1;
+
+		origpage = pfn_to_page(source_index);
+		
+	       	if (PageHighMem(origpage))
+			origvirt = kmap_atomic(origpage, KM_USER0);
+		else
+			origvirt = page_address(origpage);
+
+		copyvirt = (unsigned long *) page_address(pfn_to_page(dest_index));
+
+		while (loop >= 0) {
+			*(copyvirt + loop) = *(origvirt + loop);
+			loop--;
+		}
+		
+		if (PageHighMem(origpage))
+			kunmap_atomic(origvirt, KM_USER0);
+		
+		source_index = get_next_bit_on(pageset1_map, source_index);
+		dest_index = get_next_bit_on(pageset1_copy_map, dest_index);
+	}
+}
+

--
Nigel Cunningham		nigel at suspend2 dot net

  parent reply	other threads:[~2006-06-27  4:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-27  4:38 [Suspend2][ 00/10] Suspend2 Atomic Copy Patches Nigel Cunningham
2006-06-27  4:38 ` [Suspend2][ 01/10] [Suspend2] Atomic copy file header Nigel Cunningham
2006-06-27  4:38 ` [Suspend2][ 02/10] [Suspend2] Initialise nosave zone table Nigel Cunningham
2006-06-27  4:38 ` [Suspend2][ 03/10] [Suspend2] Atomic copy get_next_bit_on routine Nigel Cunningham
2006-06-27  4:39 ` [Suspend2][ 04/10] [Suspend2] Prepare pbe list for atomic restore Nigel Cunningham
2006-06-27  4:39 ` [Suspend2][ 05/10] [Suspend2] Highmem copyback routine Nigel Cunningham
2006-06-27  4:39 ` [Suspend2][ 06/10] [Suspend2] Post-atomic restore routine Nigel Cunningham
2006-06-27  4:39 ` [Suspend2][ 07/10] [Suspend2] Post suspend context-save routine Nigel Cunningham
2006-06-27  4:39 ` Nigel Cunningham [this message]
2006-06-27  4:39 ` [Suspend2][ 09/10] [Suspend2] Atomic copy highlevel routine Nigel Cunningham
2006-06-27  4:39 ` [Suspend2][ 10/10] [Suspend2] Atomic restore " 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=20060627043912.14546.41377.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®