Jiri Slaby | 59ea746 | 2008-06-12 13:56:40 +0200 | [diff] [blame] | 1 | #ifndef LINUX_MM_DEBUG_H |
| 2 | #define LINUX_MM_DEBUG_H 1 |
| 3 | |
James Morse | 1d5cda4 | 2015-12-18 14:22:07 -0800 | [diff] [blame] | 4 | #include <linux/bug.h> |
Dave Hansen | e4f6742 | 2014-06-04 16:07:02 -0700 | [diff] [blame] | 5 | #include <linux/stringify.h> |
| 6 | |
Sasha Levin | 309381fea | 2014-01-23 15:52:54 -0800 | [diff] [blame] | 7 | struct page; |
Sasha Levin | 0bf5513 | 2014-10-09 15:28:06 -0700 | [diff] [blame] | 8 | struct vm_area_struct; |
Sasha Levin | 31c9afa | 2014-10-09 15:28:37 -0700 | [diff] [blame] | 9 | struct mm_struct; |
Sasha Levin | 309381fea | 2014-01-23 15:52:54 -0800 | [diff] [blame] | 10 | |
Kirill A. Shutemov | d230dec | 2014-04-07 15:37:38 -0700 | [diff] [blame] | 11 | extern void dump_page(struct page *page, const char *reason); |
| 12 | extern void dump_page_badflags(struct page *page, const char *reason, |
Sasha Levin | 309381fea | 2014-01-23 15:52:54 -0800 | [diff] [blame] | 13 | unsigned long badflags); |
Sasha Levin | 0bf5513 | 2014-10-09 15:28:06 -0700 | [diff] [blame] | 14 | void dump_vma(const struct vm_area_struct *vma); |
Sasha Levin | 31c9afa | 2014-10-09 15:28:37 -0700 | [diff] [blame] | 15 | void dump_mm(const struct mm_struct *mm); |
Sasha Levin | 309381fea | 2014-01-23 15:52:54 -0800 | [diff] [blame] | 16 | |
Jiri Slaby | 59ea746 | 2008-06-12 13:56:40 +0200 | [diff] [blame] | 17 | #ifdef CONFIG_DEBUG_VM |
| 18 | #define VM_BUG_ON(cond) BUG_ON(cond) |
Dave Hansen | e4f6742 | 2014-06-04 16:07:02 -0700 | [diff] [blame] | 19 | #define VM_BUG_ON_PAGE(cond, page) \ |
| 20 | do { \ |
| 21 | if (unlikely(cond)) { \ |
| 22 | dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ |
| 23 | BUG(); \ |
| 24 | } \ |
| 25 | } while (0) |
Sasha Levin | fa3759c | 2014-10-09 15:28:08 -0700 | [diff] [blame] | 26 | #define VM_BUG_ON_VMA(cond, vma) \ |
| 27 | do { \ |
| 28 | if (unlikely(cond)) { \ |
| 29 | dump_vma(vma); \ |
| 30 | BUG(); \ |
| 31 | } \ |
| 32 | } while (0) |
Sasha Levin | 31c9afa | 2014-10-09 15:28:37 -0700 | [diff] [blame] | 33 | #define VM_BUG_ON_MM(cond, mm) \ |
| 34 | do { \ |
| 35 | if (unlikely(cond)) { \ |
| 36 | dump_mm(mm); \ |
| 37 | BUG(); \ |
| 38 | } \ |
| 39 | } while (0) |
Andrew Morton | 02a8efe | 2014-06-04 16:06:59 -0700 | [diff] [blame] | 40 | #define VM_WARN_ON(cond) WARN_ON(cond) |
| 41 | #define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond) |
Andrew Morton | ef6b571 | 2014-08-06 16:06:30 -0700 | [diff] [blame] | 42 | #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format) |
Jiri Slaby | 59ea746 | 2008-06-12 13:56:40 +0200 | [diff] [blame] | 43 | #else |
Konstantin Khlebnikov | 02602a1 | 2012-05-29 15:06:28 -0700 | [diff] [blame] | 44 | #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) |
Sasha Levin | 309381fea | 2014-01-23 15:52:54 -0800 | [diff] [blame] | 45 | #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond) |
Sasha Levin | fa3759c | 2014-10-09 15:28:08 -0700 | [diff] [blame] | 46 | #define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond) |
Sasha Levin | 31c9afa | 2014-10-09 15:28:37 -0700 | [diff] [blame] | 47 | #define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond) |
Andrew Morton | 02a8efe | 2014-06-04 16:06:59 -0700 | [diff] [blame] | 48 | #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) |
| 49 | #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond) |
Andrew Morton | ef6b571 | 2014-08-06 16:06:30 -0700 | [diff] [blame] | 50 | #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond) |
Jiri Slaby | 59ea746 | 2008-06-12 13:56:40 +0200 | [diff] [blame] | 51 | #endif |
| 52 | |
| 53 | #ifdef CONFIG_DEBUG_VIRTUAL |
| 54 | #define VIRTUAL_BUG_ON(cond) BUG_ON(cond) |
| 55 | #else |
Ingo Molnar | 7aa413d | 2008-06-19 13:28:11 +0200 | [diff] [blame] | 56 | #define VIRTUAL_BUG_ON(cond) do { } while (0) |
Jiri Slaby | 59ea746 | 2008-06-12 13:56:40 +0200 | [diff] [blame] | 57 | #endif |
| 58 | |
Kirill A. Shutemov | 95ad975 | 2016-01-15 16:51:21 -0800 | [diff] [blame] | 59 | #ifdef CONFIG_DEBUG_VM_PGFLAGS |
| 60 | #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) |
| 61 | #else |
| 62 | #define VM_BUG_ON_PGFLAGS(cond, page) BUILD_BUG_ON_INVALID(cond) |
| 63 | #endif |
| 64 | |
Jiri Slaby | 59ea746 | 2008-06-12 13:56:40 +0200 | [diff] [blame] | 65 | #endif |