]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - mm/mlock.c
ARM: dts: imx6ul-tx6ul: disable DS1339 which is not normally equipped on the TXUL...
[karo-tx-linux.git] / mm / mlock.c
index a18d4aea7685534142425d224acc38c19a44d5f1..0147b57f9704398f8f75dbb6d9c24ca5efedc6ce 100644 (file)
@@ -82,6 +82,9 @@ void mlock_vma_page(struct page *page)
        /* Serialize with page migration */
        BUG_ON(!PageLocked(page));
 
+       VM_BUG_ON_PAGE(PageTail(page), page);
+       VM_BUG_ON_PAGE(PageCompound(page) && PageDoubleMap(page), page);
+
        if (!TestSetPageMlocked(page)) {
                mod_zone_page_state(page_zone(page), NR_MLOCK,
                                    hpage_nr_pages(page));
@@ -178,6 +181,8 @@ unsigned int munlock_vma_page(struct page *page)
        /* For try_to_munlock() and to serialize with page migration */
        BUG_ON(!PageLocked(page));
 
+       VM_BUG_ON_PAGE(PageTail(page), page);
+
        /*
         * Serialize with any parallel __split_huge_page_refcount() which
         * might otherwise copy PageMlocked to part of the tail pages before
@@ -444,7 +449,10 @@ void munlock_vma_pages_range(struct vm_area_struct *vma,
                                &page_mask);
 
                if (page && !IS_ERR(page)) {
-                       if (PageTransHuge(page)) {
+                       if (PageTransTail(page)) {
+                               VM_BUG_ON_PAGE(PageMlocked(page), page);
+                               put_page(page); /* follow_page_mask() */
+                       } else if (PageTransHuge(page)) {
                                lock_page(page);
                                /*
                                 * Any THP page found by follow_page_mask() may
@@ -477,8 +485,6 @@ void munlock_vma_pages_range(struct vm_area_struct *vma,
                                goto next;
                        }
                }
-               /* It's a bug to munlock in the middle of a THP page */
-               VM_BUG_ON((start >> PAGE_SHIFT) & page_mask);
                page_increm = 1 + page_mask;
                start += page_increm * PAGE_SIZE;
 next:
@@ -578,8 +584,7 @@ static int apply_vma_lock_flags(unsigned long start, size_t len,
                prev = vma;
 
        for (nstart = start ; ; ) {
-               vm_flags_t newflags =
-                       vma->vm_flags & ~(VM_LOCKED | VM_LOCKONFAULT);
+               vm_flags_t newflags = vma->vm_flags & VM_LOCKED_CLEAR_MASK;
 
                newflags |= flags;
 
@@ -688,7 +693,7 @@ static int apply_mlockall_flags(int flags)
        struct vm_area_struct * vma, * prev = NULL;
        vm_flags_t to_add = 0;
 
-       current->mm->def_flags &= ~(VM_LOCKED | VM_LOCKONFAULT);
+       current->mm->def_flags &= VM_LOCKED_CLEAR_MASK;
        if (flags & MCL_FUTURE) {
                current->mm->def_flags |= VM_LOCKED;
 
@@ -708,7 +713,7 @@ static int apply_mlockall_flags(int flags)
        for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
                vm_flags_t newflags;
 
-               newflags = vma->vm_flags & ~(VM_LOCKED | VM_LOCKONFAULT);
+               newflags = vma->vm_flags & VM_LOCKED_CLEAR_MASK;
                newflags |= to_add;
 
                /* Ignore errors */