xfs: introduce xfs_for_each_perag_wrap()
[platform/kernel/linux-starfive.git] / mm / mmap.c
index 54abd46..425a934 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1524,6 +1524,10 @@ int vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot)
        if (vma_soft_dirty_enabled(vma) && !is_vm_hugetlb_page(vma))
                return 1;
 
+       /* Do we need write faults for uffd-wp tracking? */
+       if (userfaultfd_wp(vma))
+               return 1;
+
        /* Specialty mapping? */
        if (vm_flags & VM_PFNMAP)
                return 0;
@@ -2290,7 +2294,7 @@ static inline int munmap_sidetree(struct vm_area_struct *vma,
  * @start: The aligned start address to munmap.
  * @end: The aligned end address to munmap.
  * @uf: The userfaultfd list_head
- * @downgrade: Set to true to attempt a write downgrade of the mmap_sem
+ * @downgrade: Set to true to attempt a write downgrade of the mmap_lock
  *
  * If @downgrade is true, check return code for potential release of the lock.
  */
@@ -2465,7 +2469,7 @@ map_count_exceeded:
  * @len: The length of the range to munmap
  * @uf: The userfaultfd list_head
  * @downgrade: set to true if the user wants to attempt to write_downgrade the
- * mmap_sem
+ * mmap_lock
  *
  * This function takes a @mas that is either pointing to the previous VMA or set
  * to MA_START and sets it up to remove the mapping(s).  The @len will be
@@ -2950,7 +2954,7 @@ static int do_brk_flags(struct ma_state *mas, struct vm_area_struct *vma,
                                addr >> PAGE_SHIFT, NULL_VM_UFFD_CTX, NULL)) {
                mas_set_range(mas, vma->vm_start, addr + len - 1);
                if (mas_preallocate(mas, vma, GFP_KERNEL))
-                       return -ENOMEM;
+                       goto unacct_fail;
 
                vma_adjust_trans_huge(vma, vma->vm_start, addr + len, 0);
                if (vma->anon_vma) {
@@ -2972,7 +2976,7 @@ static int do_brk_flags(struct ma_state *mas, struct vm_area_struct *vma,
        /* create a vma struct for an anonymous mapping */
        vma = vm_area_alloc(mm);
        if (!vma)
-               goto vma_alloc_fail;
+               goto unacct_fail;
 
        vma_set_anonymous(vma);
        vma->vm_start = addr;
@@ -2997,7 +3001,7 @@ out:
 
 mas_store_fail:
        vm_area_free(vma);
-vma_alloc_fail:
+unacct_fail:
        vm_unacct_memory(len >> PAGE_SHIFT);
        return -ENOMEM;
 }
@@ -3744,13 +3748,9 @@ static int reserve_mem_notifier(struct notifier_block *nb,
        return NOTIFY_OK;
 }
 
-static struct notifier_block reserve_mem_nb = {
-       .notifier_call = reserve_mem_notifier,
-};
-
 static int __meminit init_reserve_notifier(void)
 {
-       if (register_hotmemory_notifier(&reserve_mem_nb))
+       if (hotplug_memory_notifier(reserve_mem_notifier, DEFAULT_CALLBACK_PRI))
                pr_err("Failed registering memory add/remove notifier for admin reserve\n");
 
        return 0;