public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Oren Laadan <orenl@cs.columbia.edu>
Cc: containers@lists.linux-foundation.org, jeremy@goop.org,
	arnd@arndb.de, linux-kernel@vger.kernel.org
Subject: Cleanups for: [PATCH 5/9] Memory managemnet (restore)
Date: Wed, 10 Sep 2008 15:00:14 -0700	[thread overview]
Message-ID: <1221084015.6781.66.camel@nimitz> (raw)
In-Reply-To: <1221082922.6781.62.camel@nimitz>

Here's the restore side of my cleanups on top of the v4 patches and the
one against 4/9 I just sent.

This purely makes it compile again.

---

 linux-2.6.git-dave/checkpoint/ckpt_mem.c |    2 --
 linux-2.6.git-dave/checkpoint/ckpt_mem.h |    4 ++++
 linux-2.6.git-dave/checkpoint/rstr_mem.c |   30 +++++++++++++++++++-----------
 3 files changed, 23 insertions(+), 13 deletions(-)

diff -puN checkpoint/rstr_mem.c~p5-dave checkpoint/rstr_mem.c
--- linux-2.6.git/checkpoint/rstr_mem.c~p5-dave	2008-09-10 14:51:26.000000000 -0700
+++ linux-2.6.git-dave/checkpoint/rstr_mem.c	2008-09-10 14:58:53.000000000 -0700
@@ -31,27 +31,35 @@
  * read in directly to the address space of the current process
  */
 
+static int pgarr_nr_free(struct cr_pgarr *pgarr)
+{
+	return CR_PGARR_TOTAL - pgarr->nr_used;
+}
+
 /**
- * cr_vma_read_pages_vaddrs - read addresses of pages to page-array chain
+ * cr_vma_restore_contents - read addresses of pages to page-array chain
  * @ctx - restart context
  * @npages - number of pages
  */
-static int cr_vma_read_pages_vaddrs(struct cr_ctx *ctx, int npages)
+static int cr_vma_restore_contents(struct cr_ctx *ctx, int pages_to_read)
 {
 	struct cr_pgarr *pgarr;
 	int nr, ret;
 
-	while (npages) {
-		pgarr = cr_pgarr_prep(ctx);
+	while (pages_to_read) {
+		unsigned long *vaddr_position;
+		pgarr = cr_get_empty_pgarr(ctx);
 		if (!pgarr)
 			return -ENOMEM;
-		nr = min(npages, (int) pgarr->nr_free);
-		ret = cr_kread(ctx, pgarr->vaddrs, nr * sizeof(unsigned long));
+		nr = pages_to_read;
+	       	if (nr > pgarr_nr_free(pgarr))
+			nr = pgarr_nr_free(pgarr);
+		vaddr_position = &pgarr->vaddrs[pgarr->nr_used];
+		ret = cr_kread(ctx, vaddr_position, nr * sizeof(unsigned long));
 		if (ret < 0)
 			return ret;
-		pgarr->nr_free -= nr;
 		pgarr->nr_used += nr;
-		npages -= nr;
+		pages_to_read -= nr;
 	}
 	return 0;
 }
@@ -67,7 +75,7 @@ static int cr_vma_read_pages_contents(st
 	unsigned long *vaddrs;
 	int i, ret;
 
-	list_for_each_entry(pgarr, &ctx->pgarr, list) {
+	list_for_each_entry(pgarr, &ctx->pgarr_list, list) {
 		vaddrs = pgarr->vaddrs;
 		for (i = 0; i < pgarr->nr_used; i++) {
 			void *ptr = (void *) vaddrs[i];
@@ -126,14 +134,14 @@ static int cr_vma_read_pages(struct cr_c
 		ret = cr_vma_set_writable(mm, hh->vm_start, hh->vm_end, 1);
 	if (ret < 0)
 		goto out;
-	ret = cr_vma_read_pages_vaddrs(ctx, hh->nr_pages);
+	ret = cr_vma_restore_contents(ctx, hh->nr_pages);
 	if (ret < 0)
 		goto out;
 	ret = cr_vma_read_pages_contents(ctx, hh->nr_pages);
 	if (ret < 0)
 		goto out;
 
-	cr_pgarr_reset(ctx);	/* reset page-array chain */
+	cr_reset_all_pgarrs(ctx);	/* reset page-array chain */
 
 	/* restore original protection for this vma */
 	if (!(hh->vm_flags & VM_WRITE))
diff -puN checkpoint/ckpt_mem.c~p5-dave checkpoint/ckpt_mem.c
--- linux-2.6.git/checkpoint/ckpt_mem.c~p5-dave	2008-09-10 14:51:33.000000000 -0700
+++ linux-2.6.git-dave/checkpoint/ckpt_mem.c	2008-09-10 14:51:54.000000000 -0700
@@ -35,8 +35,6 @@
  * freed (that is, dereference page pointers).
  */
 
-#define CR_PGARR_TOTAL  (PAGE_SIZE / sizeof(void *))
-
 /* release pages referenced by a page-array */
 void cr_pgarr_release_pages(struct cr_pgarr *pgarr)
 {
diff -puN checkpoint/ckpt_mem.h~p5-dave checkpoint/ckpt_mem.h
--- linux-2.6.git/checkpoint/ckpt_mem.h~p5-dave	2008-09-10 14:52:17.000000000 -0700
+++ linux-2.6.git-dave/checkpoint/ckpt_mem.h	2008-09-10 14:57:09.000000000 -0700
@@ -26,7 +26,11 @@ struct cr_pgarr {
 	struct list_head list;
 };
 
+#define CR_PGARR_TOTAL  (PAGE_SIZE / sizeof(void *))
+
 void cr_pgarr_free(struct cr_ctx *ctx);
+void cr_reset_all_pgarrs(struct cr_ctx *ctx);
 struct cr_pgarr *cr_pgarr_prep(struct cr_ctx *ctx);
+struct cr_pgarr *cr_get_empty_pgarr(struct cr_ctx *ctx);
 
 #endif /* _CHECKPOINT_CKPT_MEM_H_ */
_


-- Dave


  reply	other threads:[~2008-09-10 22:00 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-04  7:57 [RFC v3][PATCH 0/9] Kernel based checkpoint/restart Oren Laadan
2008-09-04  8:02 ` [RFC v3][PATCH 1/9] Create syscalls: sys_checkpoint, sys_restart Oren Laadan
2008-09-04  8:37   ` Cedric Le Goater
2008-09-04 14:42   ` Serge E. Hallyn
2008-09-04 17:32     ` Oren Laadan
2008-09-04 20:37       ` Serge E. Hallyn
2008-09-04 21:05         ` Oren Laadan
2008-09-04 22:03           ` Serge E. Hallyn
2008-09-08 15:02     ` [Devel] " Andrey Mirkin
2008-09-08 16:07       ` Cedric Le Goater
2008-09-04  8:02 ` [RFC v3][PATCH 2/9] General infrastructure for checkpoint restart Oren Laadan
2008-09-04  9:12   ` Louis Rilling
2008-09-04 16:00     ` Serge E. Hallyn
2008-09-04 16:03   ` Serge E. Hallyn
2008-09-04 16:09     ` Dave Hansen
2008-09-04  8:03 ` [RFC v3][PATCH 3/9] x86 support for checkpoint/restart Oren Laadan
2008-09-04  8:03 ` [RFC v3][PATCH 4/9] Memory management (dump) Oren Laadan
2008-09-04 18:25   ` Dave Hansen
2008-09-07  1:54     ` Oren Laadan
2008-09-08 15:55       ` Dave Hansen
2008-09-04  8:04 ` [RFC v3][PATCH 5/9] Memory managemnet (restore) Oren Laadan
2008-09-04 18:08   ` Dave Hansen
2008-09-07  3:09     ` Oren Laadan
2008-09-08 16:49       ` Dave Hansen
2008-09-09  6:01         ` Oren Laadan
2008-09-10 21:42           ` Dave Hansen
2008-09-10 22:00             ` Dave Hansen [this message]
2008-09-11  7:37             ` Oren Laadan
2008-09-11 15:38               ` Serge E. Hallyn
2008-09-12 16:34               ` Dave Hansen
2008-09-04  8:04 ` [RFC v3][PATCH 6/9] Checkpoint/restart: initial documentation Oren Laadan
2008-09-04  8:05 ` [RFC v3][PATCH 7/9] Infrastructure for shared objects Oren Laadan
2008-09-04  9:38   ` Louis Rilling
2008-09-04 14:23     ` Oren Laadan
2008-09-04 18:14   ` Dave Hansen
2008-09-04  8:05 ` [RFC v3][PATCH 8/9] File descriprtors (dump) Oren Laadan
2008-09-04  9:47   ` Louis Rilling
2008-09-04 14:43     ` Oren Laadan
2008-09-04 15:01   ` Dave Hansen
2008-09-04 18:41   ` Dave Hansen
2008-09-07  4:52     ` Oren Laadan
2008-09-08 16:57       ` Dave Hansen
2008-09-04  8:06 ` [RFC v3][PATCH 9/9] File descriprtors (restore) Oren Laadan

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=1221084015.6781.66.camel@nimitz \
    --to=dave@linux.vnet.ibm.com \
    --cc=arnd@arndb.de \
    --cc=containers@lists.linux-foundation.org \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=orenl@cs.columbia.edu \
    /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