Merge tag 'block-6.6-2023-09-08' of git://git.kernel.dk/linux
[linux-2.6-microblaze.git] / mm / mlock.c
index 479e09d..06bdfab 100644 (file)
@@ -387,6 +387,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
         */
        if (newflags & VM_LOCKED)
                newflags |= VM_IO;
+       vma_start_write(vma);
        vm_flags_reset_once(vma, newflags);
 
        lru_add_drain();
@@ -461,9 +462,9 @@ success:
         * It's okay if try_to_unmap_one unmaps a page just after we
         * set VM_LOCKED, populate_vma_page_range will bring it back.
         */
-
        if ((newflags & VM_LOCKED) && (oldflags & VM_LOCKED)) {
                /* No work to do, and mlocking twice would be wrong */
+               vma_start_write(vma);
                vm_flags_reset(vma, newflags);
        } else {
                mlock_vma_pages_range(vma, start, end, newflags);