diff options
-rw-r--r-- | include/linux/mm.h | 1 | ||||
-rw-r--r-- | mm/huge_memory.c | 3 | ||||
-rw-r--r-- | mm/ksm.c | 2 | ||||
-rw-r--r-- | mm/memory.c | 14 | ||||
-rw-r--r-- | mm/mmap.c | 2 |
5 files changed, 15 insertions, 7 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 9c039f84b63..fb0685b1791 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -103,7 +103,6 @@ extern unsigned int kobjsize(const void *objp); | |||
103 | #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */ | 103 | #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */ |
104 | #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */ | 104 | #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */ |
105 | #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */ | 105 | #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */ |
106 | #define VM_INSERTPAGE 0x02000000 /* The vma has had "vm_insert_page()" done on it */ | ||
107 | #define VM_NODUMP 0x04000000 /* Do not include in the core dump */ | 106 | #define VM_NODUMP 0x04000000 /* Do not include in the core dump */ |
108 | 107 | ||
109 | #define VM_CAN_NONLINEAR 0x08000000 /* Has ->fault & does nonlinear pages */ | 108 | #define VM_CAN_NONLINEAR 0x08000000 /* Has ->fault & does nonlinear pages */ |
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 47206692cf8..9b72d127051 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -1491,8 +1491,7 @@ out: | |||
1491 | return ret; | 1491 | return ret; |
1492 | } | 1492 | } |
1493 | 1493 | ||
1494 | #define VM_NO_THP (VM_SPECIAL|VM_INSERTPAGE|VM_MIXEDMAP| \ | 1494 | #define VM_NO_THP (VM_SPECIAL|VM_MIXEDMAP|VM_HUGETLB|VM_SHARED|VM_MAYSHARE) |
1495 | VM_HUGETLB|VM_SHARED|VM_MAYSHARE) | ||
1496 | 1495 | ||
1497 | int hugepage_madvise(struct vm_area_struct *vma, | 1496 | int hugepage_madvise(struct vm_area_struct *vma, |
1498 | unsigned long *vm_flags, int advice) | 1497 | unsigned long *vm_flags, int advice) |
@@ -1469,7 +1469,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, | |||
1469 | */ | 1469 | */ |
1470 | if (*vm_flags & (VM_MERGEABLE | VM_SHARED | VM_MAYSHARE | | 1470 | if (*vm_flags & (VM_MERGEABLE | VM_SHARED | VM_MAYSHARE | |
1471 | VM_PFNMAP | VM_IO | VM_DONTEXPAND | | 1471 | VM_PFNMAP | VM_IO | VM_DONTEXPAND | |
1472 | VM_RESERVED | VM_HUGETLB | VM_INSERTPAGE | | 1472 | VM_RESERVED | VM_HUGETLB | |
1473 | VM_NONLINEAR | VM_MIXEDMAP)) | 1473 | VM_NONLINEAR | VM_MIXEDMAP)) |
1474 | return 0; /* just ignore the advice */ | 1474 | return 0; /* just ignore the advice */ |
1475 | 1475 | ||
diff --git a/mm/memory.c b/mm/memory.c index 655e1429388..7b1e4feaec0 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -1047,7 +1047,8 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, | |||
1047 | * readonly mappings. The tradeoff is that copy_page_range is more | 1047 | * readonly mappings. The tradeoff is that copy_page_range is more |
1048 | * efficient than faulting. | 1048 | * efficient than faulting. |
1049 | */ | 1049 | */ |
1050 | if (!(vma->vm_flags & (VM_HUGETLB|VM_NONLINEAR|VM_PFNMAP|VM_INSERTPAGE))) { | 1050 | if (!(vma->vm_flags & (VM_HUGETLB | VM_NONLINEAR | |
1051 | VM_PFNMAP | VM_MIXEDMAP))) { | ||
1051 | if (!vma->anon_vma) | 1052 | if (!vma->anon_vma) |
1052 | return 0; | 1053 | return 0; |
1053 | } | 1054 | } |
@@ -2085,6 +2086,11 @@ out: | |||
2085 | * ask for a shared writable mapping! | 2086 | * ask for a shared writable mapping! |
2086 | * | 2087 | * |
2087 | * The page does not need to be reserved. | 2088 | * The page does not need to be reserved. |
2089 | * | ||
2090 | * Usually this function is called from f_op->mmap() handler | ||
2091 | * under mm->mmap_sem write-lock, so it can change vma->vm_flags. | ||
2092 | * Caller must set VM_MIXEDMAP on vma if it wants to call this | ||
2093 | * function from other places, for example from page-fault handler. | ||
2088 | */ | 2094 | */ |
2089 | int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, | 2095 | int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, |
2090 | struct page *page) | 2096 | struct page *page) |
@@ -2093,7 +2099,11 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, | |||
2093 | return -EFAULT; | 2099 | return -EFAULT; |
2094 | if (!page_count(page)) | 2100 | if (!page_count(page)) |
2095 | return -EINVAL; | 2101 | return -EINVAL; |
2096 | vma->vm_flags |= VM_INSERTPAGE; | 2102 | if (!(vma->vm_flags & VM_MIXEDMAP)) { |
2103 | BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem)); | ||
2104 | BUG_ON(vma->vm_flags & VM_PFNMAP); | ||
2105 | vma->vm_flags |= VM_MIXEDMAP; | ||
2106 | } | ||
2097 | return insert_page(vma, addr, page, vma->vm_page_prot); | 2107 | return insert_page(vma, addr, page, vma->vm_page_prot); |
2098 | } | 2108 | } |
2099 | EXPORT_SYMBOL(vm_insert_page); | 2109 | EXPORT_SYMBOL(vm_insert_page); |
@@ -1190,7 +1190,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma) | |||
1190 | return 0; | 1190 | return 0; |
1191 | 1191 | ||
1192 | /* Specialty mapping? */ | 1192 | /* Specialty mapping? */ |
1193 | if (vm_flags & (VM_PFNMAP|VM_INSERTPAGE)) | 1193 | if (vm_flags & VM_PFNMAP) |
1194 | return 0; | 1194 | return 0; |
1195 | 1195 | ||
1196 | /* Can the mapping track the dirty pages? */ | 1196 | /* Can the mapping track the dirty pages? */ |