Commit 14d1a55cd26f1860f837f37ae42520c7c13b1347

Authored by Andrea Arcangeli
Committed by Linus Torvalds
1 parent 05b258e997

thp: add debug checks for mapcount related invariants

Add debug checks for invariants that if broken could lead to mapcount vs
page_mapcount debug checks to trigger later in split_huge_page.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff

... ... @@ -804,6 +804,7 @@
804 804 next = pmd_addr_end(addr, end);
805 805 if (pmd_trans_huge(*src_pmd)) {
806 806 int err;
  807 + VM_BUG_ON(next-addr != HPAGE_PMD_SIZE);
807 808 err = copy_huge_pmd(dst_mm, src_mm,
808 809 dst_pmd, src_pmd, addr, vma);
809 810 if (err == -ENOMEM)
810 811  
... ... @@ -1015,9 +1016,10 @@
1015 1016 do {
1016 1017 next = pmd_addr_end(addr, end);
1017 1018 if (pmd_trans_huge(*pmd)) {
1018   - if (next-addr != HPAGE_PMD_SIZE)
  1019 + if (next-addr != HPAGE_PMD_SIZE) {
  1020 + VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem));
1019 1021 split_huge_page_pmd(vma->vm_mm, pmd);
1020   - else if (zap_huge_pmd(tlb, vma, pmd)) {
  1022 + } else if (zap_huge_pmd(tlb, vma, pmd)) {
1021 1023 (*zap_work)--;
1022 1024 continue;
1023 1025 }