]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - mm/hugetlb.c
mm, hugetlbfs: introduce ->split() to vm_operations_struct
[mirror_ubuntu-bionic-kernel.git] / mm / hugetlb.c
index 2d2ff5e8bf2bc035eb300ee16dbdaadcdb0279dd..698e8fb340318664c591f7ba787b15b58add64cb 100644 (file)
@@ -3125,6 +3125,13 @@ static void hugetlb_vm_op_close(struct vm_area_struct *vma)
        }
 }
 
+static int hugetlb_vm_op_split(struct vm_area_struct *vma, unsigned long addr)
+{
+       if (addr & ~(huge_page_mask(hstate_vma(vma))))
+               return -EINVAL;
+       return 0;
+}
+
 /*
  * We cannot handle pagefaults against hugetlb pages at all.  They cause
  * handle_mm_fault() to try to instantiate regular-sized pages in the
@@ -3141,6 +3148,7 @@ const struct vm_operations_struct hugetlb_vm_ops = {
        .fault = hugetlb_vm_op_fault,
        .open = hugetlb_vm_op_open,
        .close = hugetlb_vm_op_close,
+       .split = hugetlb_vm_op_split,
 };
 
 static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page,
@@ -3256,9 +3264,14 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                        set_huge_swap_pte_at(dst, addr, dst_pte, entry, sz);
                } else {
                        if (cow) {
+                               /*
+                                * No need to notify as we are downgrading page
+                                * table protection not changing it to point
+                                * to a new page.
+                                *
+                                * See Documentation/vm/mmu_notifier.txt
+                                */
                                huge_ptep_set_wrprotect(src, addr, src_pte);
-                               mmu_notifier_invalidate_range(src, mmun_start,
-                                                                  mmun_end);
                        }
                        entry = huge_ptep_get(src_pte);
                        ptepage = pte_page(entry);
@@ -4318,7 +4331,12 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
         * and that page table be reused and filled with junk.
         */
        flush_hugetlb_tlb_range(vma, start, end);
-       mmu_notifier_invalidate_range(mm, start, end);
+       /*
+        * No need to call mmu_notifier_invalidate_range() we are downgrading
+        * page table protection not changing it to point to a new page.
+        *
+        * See Documentation/vm/mmu_notifier.txt
+        */
        i_mmap_unlock_write(vma->vm_file->f_mapping);
        mmu_notifier_invalidate_range_end(mm, start, end);