memory.c (b3b9c2932c32e0692018ed5f12f3fd8c70eea8ce) | memory.c (4b6e1e37026ec7dae9b23d78ffcebdd5ddb1bfa1) |
---|---|
1/* 2 * linux/mm/memory.c 3 * 4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 5 */ 6 7/* 8 * demand-loading started 01.12.91 - seems it is high on the list of --- 1033 unchanged lines hidden (view full) --- 1042 int ret; 1043 1044 /* 1045 * Don't copy ptes where a page fault will fill them correctly. 1046 * Fork becomes much lighter when there are big shared or private 1047 * readonly mappings. The tradeoff is that copy_page_range is more 1048 * efficient than faulting. 1049 */ | 1/* 2 * linux/mm/memory.c 3 * 4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 5 */ 6 7/* 8 * demand-loading started 01.12.91 - seems it is high on the list of --- 1033 unchanged lines hidden (view full) --- 1042 int ret; 1043 1044 /* 1045 * Don't copy ptes where a page fault will fill them correctly. 1046 * Fork becomes much lighter when there are big shared or private 1047 * readonly mappings. The tradeoff is that copy_page_range is more 1048 * efficient than faulting. 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 return 0; 1053 } 1054 1055 if (is_vm_hugetlb_page(vma)) 1056 return copy_hugetlb_page_range(dst_mm, src_mm, vma); 1057 1058 if (unlikely(vma->vm_flags & VM_PFNMAP)) { --- 1021 unchanged lines hidden (view full) --- 2080 * 2081 * NOTE! Traditionally this was done with "remap_pfn_range()" which 2082 * took an arbitrary page protection parameter. This doesn't allow 2083 * that. Your vma protection will have to be set up correctly, which 2084 * means that if you want a shared writable mapping, you'd better 2085 * ask for a shared writable mapping! 2086 * 2087 * The page does not need to be reserved. | 1052 if (!vma->anon_vma) 1053 return 0; 1054 } 1055 1056 if (is_vm_hugetlb_page(vma)) 1057 return copy_hugetlb_page_range(dst_mm, src_mm, vma); 1058 1059 if (unlikely(vma->vm_flags & VM_PFNMAP)) { --- 1021 unchanged lines hidden (view full) --- 2081 * 2082 * NOTE! Traditionally this was done with "remap_pfn_range()" which 2083 * took an arbitrary page protection parameter. This doesn't allow 2084 * that. Your vma protection will have to be set up correctly, which 2085 * means that if you want a shared writable mapping, you'd better 2086 * ask for a shared writable mapping! 2087 * 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 */ 2089int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, 2090 struct page *page) 2091{ 2092 if (addr < vma->vm_start || addr >= vma->vm_end) 2093 return -EFAULT; 2094 if (!page_count(page)) 2095 return -EINVAL; | 2094 */ 2095int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, 2096 struct page *page) 2097{ 2098 if (addr < vma->vm_start || addr >= vma->vm_end) 2099 return -EFAULT; 2100 if (!page_count(page)) 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); 2098} 2099EXPORT_SYMBOL(vm_insert_page); 2100 2101static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, 2102 unsigned long pfn, pgprot_t prot) 2103{ 2104 struct mm_struct *mm = vma->vm_mm; --- 1927 unchanged lines hidden --- | 2107 return insert_page(vma, addr, page, vma->vm_page_prot); 2108} 2109EXPORT_SYMBOL(vm_insert_page); 2110 2111static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, 2112 unsigned long pfn, pgprot_t prot) 2113{ 2114 struct mm_struct *mm = vma->vm_mm; --- 1927 unchanged lines hidden --- |