]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/linux/mmdebug.h
Merge tag 'for-linus-4.11b-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / include / linux / mmdebug.h
1 #ifndef LINUX_MM_DEBUG_H
2 #define LINUX_MM_DEBUG_H 1
3
4 #include <linux/bug.h>
5 #include <linux/stringify.h>
6
7 struct page;
8 struct vm_area_struct;
9 struct mm_struct;
10
11 extern void dump_page(struct page *page, const char *reason);
12 extern void __dump_page(struct page *page, const char *reason);
13 void dump_vma(const struct vm_area_struct *vma);
14 void dump_mm(const struct mm_struct *mm);
15
16 #ifdef CONFIG_DEBUG_VM
17 #define VM_BUG_ON(cond) BUG_ON(cond)
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)
25 #define VM_BUG_ON_VMA(cond, vma)                                        \
26         do {                                                            \
27                 if (unlikely(cond)) {                                   \
28                         dump_vma(vma);                                  \
29                         BUG();                                          \
30                 }                                                       \
31         } while (0)
32 #define VM_BUG_ON_MM(cond, mm)                                          \
33         do {                                                            \
34                 if (unlikely(cond)) {                                   \
35                         dump_mm(mm);                                    \
36                         BUG();                                          \
37                 }                                                       \
38         } while (0)
39 #define VM_WARN_ON(cond) WARN_ON(cond)
40 #define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond)
41 #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format)
42 #define VM_WARN(cond, format...) WARN(cond, format)
43 #else
44 #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond)
45 #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
46 #define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond)
47 #define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond)
48 #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond)
49 #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
50 #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
51 #define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond)
52 #endif
53
54 #ifdef CONFIG_DEBUG_VIRTUAL
55 #define VIRTUAL_BUG_ON(cond) BUG_ON(cond)
56 #else
57 #define VIRTUAL_BUG_ON(cond) do { } while (0)
58 #endif
59
60 #ifdef CONFIG_DEBUG_VM_PGFLAGS
61 #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page)
62 #else
63 #define VM_BUG_ON_PGFLAGS(cond, page) BUILD_BUG_ON_INVALID(cond)
64 #endif
65
66 #endif