]>
Commit | Line | Data |
---|---|---|
59ea7463 JS |
1 | #ifndef LINUX_MM_DEBUG_H |
2 | #define LINUX_MM_DEBUG_H 1 | |
3 | ||
e4f67422 DH |
4 | #include <linux/stringify.h> |
5 | ||
309381fe | 6 | struct page; |
0bf55139 | 7 | struct vm_area_struct; |
31c9afa6 | 8 | struct mm_struct; |
309381fe | 9 | |
d230dec1 KS |
10 | extern void dump_page(struct page *page, const char *reason); |
11 | extern void dump_page_badflags(struct page *page, const char *reason, | |
309381fe | 12 | unsigned long badflags); |
0bf55139 | 13 | void dump_vma(const struct vm_area_struct *vma); |
31c9afa6 | 14 | void dump_mm(const struct mm_struct *mm); |
309381fe | 15 | |
59ea7463 JS |
16 | #ifdef CONFIG_DEBUG_VM |
17 | #define VM_BUG_ON(cond) BUG_ON(cond) | |
e4f67422 DH |
18 | #define VM_BUG_ON_PAGE(cond, page) \ |
19 | do { \ | |
20 | if (unlikely(cond)) { \ | |
21 | dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ | |
22 | BUG(); \ | |
23 | } \ | |
24 | } while (0) | |
fa3759cc SL |
25 | #define VM_BUG_ON_VMA(cond, vma) \ |
26 | do { \ | |
27 | if (unlikely(cond)) { \ | |
28 | dump_vma(vma); \ | |
29 | BUG(); \ | |
30 | } \ | |
31 | } while (0) | |
31c9afa6 SL |
32 | #define VM_BUG_ON_MM(cond, mm) \ |
33 | do { \ | |
34 | if (unlikely(cond)) { \ | |
35 | dump_mm(mm); \ | |
36 | BUG(); \ | |
37 | } \ | |
38 | } while (0) | |
02a8efed AM |
39 | #define VM_WARN_ON(cond) WARN_ON(cond) |
40 | #define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond) | |
ef6b571f | 41 | #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format) |
59ea7463 | 42 | #else |
02602a18 | 43 | #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) |
309381fe | 44 | #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond) |
fa3759cc | 45 | #define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond) |
31c9afa6 | 46 | #define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond) |
02a8efed AM |
47 | #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) |
48 | #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond) | |
ef6b571f | 49 | #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond) |
59ea7463 JS |
50 | #endif |
51 | ||
52 | #ifdef CONFIG_DEBUG_VIRTUAL | |
53 | #define VIRTUAL_BUG_ON(cond) BUG_ON(cond) | |
54 | #else | |
7aa413de | 55 | #define VIRTUAL_BUG_ON(cond) do { } while (0) |
59ea7463 JS |
56 | #endif |
57 | ||
58 | #endif |