All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] checkpoint: un-blacklist VM_NORESERVE
@ 2010-06-17 21:07 Nathan Lynch
  2010-06-18 15:33 ` Oren Laadan
  2010-06-18 21:49 ` [PATCH] c/r: Un-blacklist VM_NORESERVE and VM_LOCKED Oren Laadan
  0 siblings, 2 replies; 4+ messages in thread
From: Nathan Lynch @ 2010-06-17 21:07 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

While a region mapped with MAP_NORESERVE may segv on a write in
low-memory conditions, reading it (as we do during checkpoint) is
fine.  Remove the VM_NORESERVE flag from CKPT_VMA_NOT_SUPPORTED.

---

Oren, what do you think about this?  I've tested this lightly with no
apparent problems; is there some reason I'm missing to not support
MAP_NORESERVE regions?

 include/linux/checkpoint.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h
index 84bb7a9..f3e0d11 100644
--- a/include/linux/checkpoint.h
+++ b/include/linux/checkpoint.h
@@ -301,7 +301,7 @@ extern int restore_memory_contents(struct ckpt_ctx *ctx, struct inode *inode);
 
 #define CKPT_VMA_NOT_SUPPORTED						\
 	(VM_IO | VM_HUGETLB | VM_NONLINEAR | VM_PFNMAP |		\
-	 VM_RESERVED | VM_NORESERVE | VM_HUGETLB | VM_NONLINEAR |	\
+	 VM_RESERVED | VM_HUGETLB | VM_NONLINEAR |	\
 	 VM_MAPPED_COPY | VM_INSERTPAGE | VM_MIXEDMAP | VM_SAO)
 
 /* signals */
-- 
1.6.0.2

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

* Re: [RFC] checkpoint: un-blacklist VM_NORESERVE
  2010-06-17 21:07 [RFC] checkpoint: un-blacklist VM_NORESERVE Nathan Lynch
@ 2010-06-18 15:33 ` Oren Laadan
  2010-06-18 21:49 ` [PATCH] c/r: Un-blacklist VM_NORESERVE and VM_LOCKED Oren Laadan
  1 sibling, 0 replies; 4+ messages in thread
From: Oren Laadan @ 2010-06-18 15:33 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA


On 06/17/2010 05:07 PM, Nathan Lynch wrote:
> While a region mapped with MAP_NORESERVE may segv on a write in
> low-memory conditions, reading it (as we do during checkpoint) is
> fine.  Remove the VM_NORESERVE flag from CKPT_VMA_NOT_SUPPORTED.
> 
> ---
> 
> Oren, what do you think about this?  I've tested this lightly with no
> apparent problems; is there some reason I'm missing to not support
> MAP_NORESERVE regions?

Sounds reasonable. I originally left it out because I wasn't sure.
In particular, my concern was whether a user may cause troubles by
specifying this flag. Now I looked deeper, and I think it's safe.

Note, however, it isn't enough to allow the flag, we also need to
modify calc_map_flags_bits() to reintroduce MAP_NORESERVE for the
flags argument to do_mmap_pgoff(). Otherwise it won't be restored
at restart...

No need to repost the patch. I'll do it.

Oren.

> 
>  include/linux/checkpoint.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h
> index 84bb7a9..f3e0d11 100644
> --- a/include/linux/checkpoint.h
> +++ b/include/linux/checkpoint.h
> @@ -301,7 +301,7 @@ extern int restore_memory_contents(struct ckpt_ctx *ctx, struct inode *inode);
>  
>  #define CKPT_VMA_NOT_SUPPORTED						\
>  	(VM_IO | VM_HUGETLB | VM_NONLINEAR | VM_PFNMAP |		\
> -	 VM_RESERVED | VM_NORESERVE | VM_HUGETLB | VM_NONLINEAR |	\
> +	 VM_RESERVED | VM_HUGETLB | VM_NONLINEAR |	\
>  	 VM_MAPPED_COPY | VM_INSERTPAGE | VM_MIXEDMAP | VM_SAO)
>  
>  /* signals */

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

* [PATCH] c/r: Un-blacklist VM_NORESERVE and VM_LOCKED
  2010-06-17 21:07 [RFC] checkpoint: un-blacklist VM_NORESERVE Nathan Lynch
  2010-06-18 15:33 ` Oren Laadan
@ 2010-06-18 21:49 ` Oren Laadan
       [not found]   ` <1276897775-4911-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Oren Laadan @ 2010-06-18 21:49 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

Add support for VM_NORESERVE and VM_LOCKED and remove them from
the blacklist of vm flags.

VM_NORESERVE: a vma with VM_NORESERVE may segv on a write under
low-memory, but reading it (as we do during checkpoint) is fine.

VM_LOCKED: this flag is now explicitly restored for a vma that had
this flag, using sys_mlock()

Original patch and reports by Nathan Lynch and Dan Smith.

Signed-off-by: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
---
 include/linux/checkpoint.h |    2 +-
 mm/checkpoint.c            |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h
index c338149..a796308 100644
--- a/include/linux/checkpoint.h
+++ b/include/linux/checkpoint.h
@@ -306,7 +306,7 @@ extern int restore_memory_contents(struct ckpt_ctx *ctx, struct inode *inode);
 
 #define CKPT_VMA_NOT_SUPPORTED						\
 	(VM_IO | VM_HUGETLB | VM_NONLINEAR | VM_PFNMAP |		\
-	 VM_RESERVED | VM_NORESERVE | VM_HUGETLB | VM_NONLINEAR |	\
+	 VM_RESERVED | VM_HUGETLB | VM_NONLINEAR |	\
 	 VM_MAPPED_COPY | VM_INSERTPAGE | VM_MIXEDMAP | VM_SAO)
 
 /* signals */
diff --git a/mm/checkpoint.c b/mm/checkpoint.c
index d1d0bcb..70300e8 100644
--- a/mm/checkpoint.c
+++ b/mm/checkpoint.c
@@ -24,6 +24,7 @@
 #include <linux/shm.h>
 #include <linux/proc_fs.h>
 #include <linux/swap.h>
+#include <linux/syscalls.h>
 #include <linux/checkpoint.h>
 
 /*
@@ -1018,6 +1019,8 @@ static unsigned long calc_map_flags_bits(unsigned long orig_vm_flags)
 		vm_flags |= MAP_SHARED;
 	else
 		vm_flags |= MAP_PRIVATE;
+	if (orig_vm_flags & VM_NORESERVE)
+		vm_flags |= MAP_NORESERVE;
 
 	return vm_flags;
 }
@@ -1034,6 +1037,7 @@ unsigned long generic_vma_restore(struct mm_struct *mm,
 {
 	unsigned long vm_size, vm_start, vm_flags, vm_prot, vm_pgoff;
 	unsigned long addr;
+	int ret;
 
 	if (h->vm_end < h->vm_start)
 		return -EINVAL;
@@ -1053,6 +1057,12 @@ unsigned long generic_vma_restore(struct mm_struct *mm,
 	ckpt_debug("size %#lx prot %#lx flag %#lx pgoff %#lx => %#lx\n",
 		 vm_size, vm_prot, vm_flags, vm_pgoff, addr);
 
+	if (h->vm_flags & VM_LOCKED && !IS_ERR((void *) addr)) {
+		ret = sys_mlock(addr, vm_size);
+		if (ret < 0)
+			addr = (unsigned long) ret;
+	}
+
 	return addr;
 }
 
-- 
1.7.0.4

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

* Re: [PATCH] c/r: Un-blacklist VM_NORESERVE and VM_LOCKED
       [not found]   ` <1276897775-4911-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
@ 2010-06-19  2:49     ` Dan Smith
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Smith @ 2010-06-19  2:49 UTC (permalink / raw)
  To: Oren Laadan
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Nathan Lynch

OL> Add support for VM_NORESERVE and VM_LOCKED and remove them from
OL> the blacklist of vm flags.

OL> VM_NORESERVE: a vma with VM_NORESERVE may segv on a write under
OL> low-memory, but reading it (as we do during checkpoint) is fine.

OL> VM_LOCKED: this flag is now explicitly restored for a vma that had
OL> this flag, using sys_mlock()

OL> Original patch and reports by Nathan Lynch and Dan Smith.

OL> Signed-off-by: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>

Tested-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

Thanks :)

-- 
Dan Smith
IBM Linux Technology Center
email: danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org

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

end of thread, other threads:[~2010-06-19  2:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-17 21:07 [RFC] checkpoint: un-blacklist VM_NORESERVE Nathan Lynch
2010-06-18 15:33 ` Oren Laadan
2010-06-18 21:49 ` [PATCH] c/r: Un-blacklist VM_NORESERVE and VM_LOCKED Oren Laadan
     [not found]   ` <1276897775-4911-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-06-19  2:49     ` Dan Smith

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.