Merge tag 'pm+acpi-3.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[sfrench/cifs-2.6.git] / mm / mprotect.c
index c43d557941f807471a3c39963f77a8ba3d32dd8a..ace93454ce8ebe10f0b3cf5278aafd0a0d5fe4df 100644 (file)
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
-#ifndef pgprot_modify
-static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
-{
-       return newprot;
-}
-#endif
-
 /*
  * For a prot_numa update we only hold mmap_sem for read so there is a
  * potential race with faulting where a pmd was temporarily none. This
@@ -93,7 +86,9 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
                                 * Avoid taking write faults for pages we
                                 * know to be dirty.
                                 */
-                               if (dirty_accountable && pte_dirty(ptent))
+                               if (dirty_accountable && pte_dirty(ptent) &&
+                                   (pte_soft_dirty(ptent) ||
+                                    !(vma->vm_flags & VM_SOFTDIRTY)))
                                        ptent = pte_mkwrite(ptent);
                                ptep_modify_prot_commit(mm, addr, pte, ptent);
                                updated = true;
@@ -320,13 +315,8 @@ success:
         * held in write mode.
         */
        vma->vm_flags = newflags;
-       vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
-                                         vm_get_page_prot(newflags));
-
-       if (vma_wants_writenotify(vma)) {
-               vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
-               dirty_accountable = 1;
-       }
+       dirty_accountable = vma_wants_writenotify(vma);
+       vma_set_page_prot(vma);
 
        change_protection(vma, start, end, vma->vm_page_prot,
                          dirty_accountable, 0);