mm, thp: fix locking inconsistency in collapse_huge_page
authorEbru Akagunduz <[email protected]>
Tue, 26 Jul 2016 22:25:09 +0000 (15:25 -0700)
committerLinus Torvalds <[email protected]>
Tue, 26 Jul 2016 23:19:19 +0000 (16:19 -0700)
After creating revalidate vma function, locking inconsistency occured
due to directing the code path to wrong label.  This patch directs to
correct label and fix the inconsistency.

Related commit that caused inconsistency:
 http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=da4360877094368f6dfe75bbe804b0f0a5d575b0

Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/1466021202-61880-4-git-send-email-kirill.shutemov@linux.intel.com
Signed-off-by: Ebru Akagunduz <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Sergey Senozhatsky <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/huge_memory.c

index b54559058d30683ade94518497ae5ac71d7ed34f..1841e0ceac235108ec40d3a24a4600102b230024 100644 (file)
@@ -2483,13 +2483,18 @@ static void collapse_huge_page(struct mm_struct *mm,
 
        down_read(&mm->mmap_sem);
        result = hugepage_vma_revalidate(mm, address);
-       if (result)
-               goto out;
+       if (result) {
+               mem_cgroup_cancel_charge(new_page, memcg, true);
+               up_read(&mm->mmap_sem);
+               goto out_nolock;
+       }
 
        pmd = mm_find_pmd(mm, address);
        if (!pmd) {
                result = SCAN_PMD_NULL;
-               goto out;
+               mem_cgroup_cancel_charge(new_page, memcg, true);
+               up_read(&mm->mmap_sem);
+               goto out_nolock;
        }
 
        /*
@@ -2498,8 +2503,9 @@ static void collapse_huge_page(struct mm_struct *mm,
         * Continuing to collapse causes inconsistency.
         */
        if (!__collapse_huge_page_swapin(mm, vma, address, pmd)) {
+               mem_cgroup_cancel_charge(new_page, memcg, true);
                up_read(&mm->mmap_sem);
-               goto out;
+               goto out_nolock;
        }
 
        up_read(&mm->mmap_sem);