Skip to content

Commit 96dad67

Browse files
sashalevintorvalds
authored andcommitted
mm: use VM_BUG_ON_MM where possible
Dump the contents of the relevant struct_mm when we hit the bug condition. Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 31c9afa commit 96dad67

6 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎kernel/fork.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,8 @@ static void check_mm(struct mm_struct *mm)
601601
printk(KERN_ALERT "BUG: Bad rss-counter state "
602602
"mm:%p idx:%d val:%ld\n", mm, i, x);
603603
}
604-
605604
#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
606-
VM_BUG_ON(mm->pmd_huge_pte);
605+
VM_BUG_ON_MM(mm->pmd_huge_pte, mm);
607606
#endif
608607
}
609608

‎kernel/sys.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ static int prctl_set_mm_exe_file_locked(struct mm_struct *mm, unsigned int fd)
16341634
struct inode *inode;
16351635
int err;
16361636

1637-
VM_BUG_ON(!rwsem_is_locked(&mm->mmap_sem));
1637+
VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_sem), mm);
16381638

16391639
exe = fdget(fd);
16401640
if (!exe.file)

‎mm/huge_memory.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ int __khugepaged_enter(struct mm_struct *mm)
20482048
return -ENOMEM;
20492049

20502050
/* __khugepaged_exit() must not run from under us */
2051-
VM_BUG_ON(khugepaged_test_exit(mm));
2051+
VM_BUG_ON_MM(khugepaged_test_exit(mm), mm);
20522052
if (unlikely(test_and_set_bit(MMF_VM_HUGEPAGE, &mm->flags))) {
20532053
free_mm_slot(mm_slot);
20542054
return 0;

‎mm/mlock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ long __mlock_vma_pages_range(struct vm_area_struct *vma,
235235
VM_BUG_ON(end & ~PAGE_MASK);
236236
VM_BUG_ON_VMA(start < vma->vm_start, vma);
237237
VM_BUG_ON_VMA(end > vma->vm_end, vma);
238-
VM_BUG_ON(!rwsem_is_locked(&mm->mmap_sem));
238+
VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_sem), mm);
239239

240240
gup_flags = FOLL_TOUCH | FOLL_MLOCK;
241241
/*

‎mm/mmap.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,9 @@ static void validate_mm_rb(struct rb_root *root, struct vm_area_struct *ignore)
410410
for (nd = rb_first(root); nd; nd = rb_next(nd)) {
411411
struct vm_area_struct *vma;
412412
vma = rb_entry(nd, struct vm_area_struct, vm_rb);
413-
BUG_ON(vma != ignore &&
414-
vma->rb_subtree_gap != vma_compute_subtree_gap(vma));
413+
VM_BUG_ON_VMA(vma != ignore &&
414+
vma->rb_subtree_gap != vma_compute_subtree_gap(vma),
415+
vma);
415416
}
416417
}
417418

@@ -448,7 +449,7 @@ static void validate_mm(struct mm_struct *mm)
448449
pr_emerg("map_count %d rb %d\n", mm->map_count, i);
449450
bug = 1;
450451
}
451-
BUG_ON(bug);
452+
VM_BUG_ON_MM(bug, mm);
452453
}
453454
#else
454455
#define validate_mm_rb(root, ignore) do { } while (0)

‎mm/pagewalk.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ int walk_page_range(unsigned long addr, unsigned long end,
177177
if (!walk->mm)
178178
return -EINVAL;
179179

180-
VM_BUG_ON(!rwsem_is_locked(&walk->mm->mmap_sem));
180+
VM_BUG_ON_MM(!rwsem_is_locked(&walk->mm->mmap_sem), walk->mm);
181181

182182
pgd = pgd_offset(walk->mm, addr);
183183
do {

0 commit comments

Comments
 (0)