[CRIU] [PATCH 2/3] mm: enable customization of specail mapping operations

Alexander Kartashov alekskartashov at parallels.com
Mon Mar 10 03:00:47 PDT 2014


Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
 include/linux/mm.h |    4 ++++
 mm/mmap.c          |   35 ++++++++++++++++++++++-------------
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6999a78..c7cf7a1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1743,6 +1743,10 @@ extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
 extern int install_special_mapping(struct mm_struct *mm,
 				   unsigned long addr, unsigned long len,
 				   unsigned long flags, struct page **pages);
+extern int _install_special_mapping(struct mm_struct *mm,
+				    unsigned long addr, unsigned long len,
+				    unsigned long vm_flags, struct page **pages,
+				    const struct vm_operations_struct *vm_ops);
 
 extern int special_mapping_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 extern void special_mapping_close(struct vm_area_struct *vma);
diff --git a/mm/mmap.c b/mm/mmap.c
index 99a9ad8..882d6a1 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2909,18 +2909,10 @@ static const struct vm_operations_struct special_mapping_vmops = {
 	.fault = special_mapping_fault,
 };
 
-/*
- * Called with mm->mmap_sem held for writing.
- * Insert a new vma covering the given region, with the given flags.
- * Its pages are supplied by the given array of struct page *.
- * The array can be shorter than len >> PAGE_SHIFT if it's null-terminated.
- * The region past the last page supplied will always produce SIGBUS.
- * The array pointer and the pages it points to are assumed to stay alive
- * for as long as this mapping might exist.
- */
-int install_special_mapping(struct mm_struct *mm,
-			    unsigned long addr, unsigned long len,
-			    unsigned long vm_flags, struct page **pages)
+int _install_special_mapping(struct mm_struct *mm,
+			     unsigned long addr, unsigned long len,
+			     unsigned long vm_flags, struct page **pages,
+			     const struct vm_operations_struct *vm_ops)
 {
 	int ret;
 	struct vm_area_struct *vma;
@@ -2937,7 +2929,7 @@ int install_special_mapping(struct mm_struct *mm,
 	vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
 	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
 
-	vma->vm_ops = &special_mapping_vmops;
+	vma->vm_ops = vm_ops;
 	vma->vm_private_data = pages;
 
 	ret = insert_vm_struct(mm, vma);
@@ -2953,6 +2945,23 @@ int install_special_mapping(struct mm_struct *mm,
 out:
 	kmem_cache_free(vm_area_cachep, vma);
 	return ret;
+
+}
+
+/*
+ * Called with mm->mmap_sem held for writing.
+ * Insert a new vma covering the given region, with the given flags.
+ * Its pages are supplied by the given array of struct page *.
+ * The array can be shorter than len >> PAGE_SHIFT if it's null-terminated.
+ * The region past the last page supplied will always produce SIGBUS.
+ * The array pointer and the pages it points to are assumed to stay alive
+ * for as long as this mapping might exist.
+ */
+int install_special_mapping(struct mm_struct *mm,
+			    unsigned long addr, unsigned long len,
+			    unsigned long vm_flags, struct page **pages)
+{
+	return _install_special_mapping(mm, addr, len, vm_flags, pages, &special_mapping_vmops);
 }
 
 static DEFINE_MUTEX(mm_all_locks_mutex);
-- 
1.7.9.5



More information about the CRIU mailing list